Fix regression in validator when validating codesystems explicitly
defined in the JPA database
This commit is contained in:
parent
9b44b37df8
commit
92bd2c7173
|
@ -167,7 +167,7 @@ public class JpaValidationSupportDstu3 implements IJpaValidationSupportDstu3, Ap
|
|||
@Override
|
||||
@Transactional(value = TxType.SUPPORTS)
|
||||
public boolean isCodeSystemSupported(FhirContext theCtx, String theSystem) {
|
||||
return false;
|
||||
return fetchCodeSystem(theCtx, theSystem) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -161,7 +161,7 @@ public class JpaValidationSupportR4 implements IJpaValidationSupportR4, Applicat
|
|||
@Override
|
||||
@Transactional(value = TxType.SUPPORTS)
|
||||
public boolean isCodeSystemSupported(FhirContext theCtx, String theSystem) {
|
||||
return false;
|
||||
return fetchCodeSystem(theCtx, theSystem) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,13 +53,7 @@ import org.mockito.stubbing.Answer;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class FhirInstanceValidatorDstu3Test {
|
||||
|
@ -122,8 +116,12 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
when(myMockSupport.isCodeSystemSupported(nullable(FhirContext.class), nullable(String.class))).thenAnswer(new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(InvocationOnMock theInvocation) {
|
||||
boolean retVal = myValidSystems.contains(theInvocation.getArguments()[1]);
|
||||
ourLog.debug("isCodeSystemSupported({}) : {}", new Object[] {theInvocation.getArguments()[1], retVal});
|
||||
String url = (String) theInvocation.getArguments()[1];
|
||||
boolean retVal = myValidSystems.contains(url);
|
||||
ourLog.debug("isCodeSystemSupported({}) : {}", new Object[] {url, retVal});
|
||||
if (retVal == false) {
|
||||
retVal = myCodeSystems.containsKey(url);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
});
|
||||
|
@ -169,6 +167,10 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
CodeValidationResult retVal;
|
||||
if (myValidConcepts.contains(system + "___" + code)) {
|
||||
retVal = new CodeValidationResult(new ConceptDefinitionComponent(new CodeType(code)));
|
||||
} else if (myCodeSystems.containsKey(system)) {
|
||||
CodeSystem cs = myCodeSystems.get(system);
|
||||
Optional<ConceptDefinitionComponent> found = cs.getConcept().stream().filter(t -> t.getCode().equals(code)).findFirst();
|
||||
retVal = found.map(t->new CodeValidationResult(t)).orElse(null);
|
||||
} else {
|
||||
retVal = myDefaultValidationSupport.validateCode(ctx, system, code, (String) theInvocation.getArguments()[2]);
|
||||
}
|
||||
|
@ -342,6 +344,29 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateQuestionnaire03() throws IOException {
|
||||
CodeSystem csYesNo = loadResource("/dstu3/fmc01-cs-yesnounk.json", CodeSystem.class);
|
||||
myCodeSystems.put(csYesNo.getUrl(), csYesNo);
|
||||
CodeSystem csBinderRecommended = loadResource("/dstu3/fmc03-cs-binderrecommend.json", CodeSystem.class);
|
||||
myCodeSystems.put(csBinderRecommended.getUrl(), csBinderRecommended);
|
||||
|
||||
ValueSet vsBinderRequired = loadResource("/dstu3/fmc03-vs-binderrecommend.json", ValueSet.class);
|
||||
myValueSets.put(vsBinderRequired.getUrl(), vsBinderRequired);
|
||||
myValueSets.put("ValueSet/" +vsBinderRequired.getIdElement().getIdPart(), vsBinderRequired);
|
||||
ValueSet vsYesNo = loadResource("/dstu3/fmc03-vs-fmcyesno.json", ValueSet.class);
|
||||
myValueSets.put(vsYesNo.getUrl(), vsYesNo);
|
||||
myValueSets.put("ValueSet/" + vsYesNo.getIdElement().getIdPart(), vsYesNo);
|
||||
Questionnaire q = loadResource("/dstu3/fmc03-questionnaire.json", Questionnaire.class);
|
||||
myQuestionnaires.put("Questionnaire/" + q.getIdElement().getIdPart(), q);
|
||||
|
||||
QuestionnaireResponse qr = loadResource("/dstu3/fmc03-questionnaireresponse.json", QuestionnaireResponse.class);
|
||||
ValidationResult result = myVal.validateWithResult(qr);
|
||||
List<SingleValidationMessage> errors = logResultsAndReturnAll(result);
|
||||
assertThat(errors, empty());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateQuestionnaireWithEnableWhenAndSubItems_ShouldNotBeEnabled() throws IOException {
|
||||
CodeSystem csYesNo = loadResource("/dstu3/fmc01-cs-yesnounk.json", CodeSystem.class);
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"resourceType": "CodeSystem",
|
||||
"id": "FMCBinderRecommendation",
|
||||
"meta": {
|
||||
"versionId": "1",
|
||||
"lastUpdated": "2019-05-02T16:57:22.705+00:00"
|
||||
},
|
||||
"url": "http://fkcfhir.org/fhir/cs/FMCBinderRecommendation",
|
||||
"identifier": {
|
||||
"value": "FMCBinderRecommendation"
|
||||
},
|
||||
"name": "FMCBinderRecommendation",
|
||||
"title": "Binder recommendation",
|
||||
"status": "active",
|
||||
"publisher": "FMCNA",
|
||||
"description": "CodeSystem for Binder recommendation.",
|
||||
"hierarchyMeaning": "grouped-by",
|
||||
"content": "complete",
|
||||
"concept": [
|
||||
{
|
||||
"code": "Velphoro",
|
||||
"display": "Velphoro"
|
||||
},
|
||||
{
|
||||
"code": "Fosrenal",
|
||||
"display": "Fosrenal"
|
||||
},
|
||||
{
|
||||
"code": "Auryxia",
|
||||
"display": "Auryxia"
|
||||
},
|
||||
{
|
||||
"code": "Renvela",
|
||||
"display": "Renvela"
|
||||
},
|
||||
{
|
||||
"code": "Maintain current binder",
|
||||
"display": "Maintain current binder"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,188 @@
|
|||
{
|
||||
"resourceType": "Questionnaire",
|
||||
"id": "FMCBinderOptimizationAssessmentTest",
|
||||
"meta": {
|
||||
"versionId": "8",
|
||||
"lastUpdated": "2019-05-07T18:55:20.151+00:00"
|
||||
},
|
||||
"url": "http://fkcfhir.org/fhir/Questionnaire/FMCBinderOptimizationAssessmentTest",
|
||||
"status": "active",
|
||||
"item": [
|
||||
{
|
||||
"linkId": "Binder Optimization Assessment Test",
|
||||
"text": "Binder Optimization Assessment Test",
|
||||
"type": "group",
|
||||
"item": [
|
||||
{
|
||||
"linkId": "BINDER OPTIMIZATION ASSESSMENT TEST",
|
||||
"text": "BINDER OPTIMIZATION ASSESSMENT TEST",
|
||||
"type": "group",
|
||||
"item": [
|
||||
{
|
||||
"linkId": "CLINICID",
|
||||
"text": "CLINICID",
|
||||
"type": "reference"
|
||||
},
|
||||
{
|
||||
"linkId": "Home Medications",
|
||||
"text": "Home Medications",
|
||||
"type": "group",
|
||||
"item": [
|
||||
{
|
||||
"linkId": "BO_ConsPharm",
|
||||
"text": "Pharmacist consult",
|
||||
"type": "choice",
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCYesNo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"linkId": "BO_ConsTxt",
|
||||
"text": "Pharmacy consult notes",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"linkId": "BO_RecCons",
|
||||
"text": "Recommendation consistent with binder optimization guidelines",
|
||||
"type": "choice",
|
||||
"enableWhen": [
|
||||
{
|
||||
"question": "BO_RecNotCons",
|
||||
"hasAnswer": false
|
||||
}
|
||||
],
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCYesNo"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"linkId": "BO_ConsDrop",
|
||||
"text": "Binder recommended",
|
||||
"type": "choice",
|
||||
"enableWhen": [
|
||||
{
|
||||
"question": "BO_RecCons",
|
||||
"answerCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "Yes"
|
||||
}
|
||||
}
|
||||
],
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCBinderRecommended"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_RecNotCons",
|
||||
"text": "Recommendation not consistent with binder optimization guidelines",
|
||||
"type": "choice",
|
||||
"enableWhen": [
|
||||
{
|
||||
"question": "BO_RecCons",
|
||||
"hasAnswer": false
|
||||
}
|
||||
],
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCYesNo"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"linkId": "BO_NotConsDrop",
|
||||
"text": "Recommendation not consistent with binder optimization guidelines",
|
||||
"type": "text",
|
||||
"enableWhen": [
|
||||
{
|
||||
"question": "BO_RecNotCons",
|
||||
"answerCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "Yes"
|
||||
}
|
||||
}
|
||||
],
|
||||
"item": [
|
||||
{
|
||||
"linkId": "BO_OtherTxt",
|
||||
"text": "Other",
|
||||
"type": "text",
|
||||
"enableWhen": [
|
||||
{
|
||||
"question": "BO_NotConsDrop",
|
||||
"hasAnswer": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_Recommend",
|
||||
"text": "What is your recommendation",
|
||||
"type": "choice",
|
||||
"enableWhen": [
|
||||
{
|
||||
"question": "BO_RecNotCons",
|
||||
"answerCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "Yes"
|
||||
}
|
||||
}
|
||||
],
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCBinderRecommendation"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"linkId": "Plan",
|
||||
"text": "Plan",
|
||||
"type": "group",
|
||||
"item": [
|
||||
{
|
||||
"linkId": "BO_CommPres",
|
||||
"text": "Binder recommendation communicated to prescriber",
|
||||
"type": "choice",
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCYesNo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"linkId": "BO_ComAssmt",
|
||||
"text": "Referred to MSW for expressed co-pay concerns",
|
||||
"type": "choice",
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCYesNo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"linkId": "BO_RefMSW",
|
||||
"text": "Referred to MSW for potential medication adherence issues",
|
||||
"type": "choice",
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCYesNo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"linkId": "BO_AdjHyp",
|
||||
"text": "Continue adjustments per CMAB Hyperphosphatemia Algorithm",
|
||||
"type": "choice",
|
||||
"options": {
|
||||
"reference": "ValueSet/FMCYesNo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"linkId": "BO_AdjTxt",
|
||||
"text": "Adjustment Text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
{
|
||||
"resourceType": "QuestionnaireResponse",
|
||||
"id": "QRsfId",
|
||||
"identifier": {
|
||||
"system": "urn:oid:2.16.840.1.113883.3.7418.21.1",
|
||||
"value": "sfId"
|
||||
},
|
||||
"questionnaire": {
|
||||
"reference": "Questionnaire/FMCBinderOptimizationAssessmentTest"
|
||||
},
|
||||
"status": "completed",
|
||||
"subject": {
|
||||
"reference": "Patient/P123456"
|
||||
},
|
||||
"context": {
|
||||
"reference": "EpisodeOfCare/EC12345"
|
||||
},
|
||||
"authored": "2019-05-02T10:41:00-04:00",
|
||||
"author": {
|
||||
"reference": "Practitioner/PRLoginID"
|
||||
},
|
||||
"item": [{
|
||||
"linkId": "Binder Optimization Assessment Test",
|
||||
"text": "Binder Optimization Assessment Test",
|
||||
"item": [{
|
||||
"linkId": "BINDER OPTIMIZATION ASSESSMENT TEST",
|
||||
"text": "BINDER OPTIMIZATION ASSESSMENT TEST",
|
||||
"item": [{
|
||||
"linkId": "Home Medications",
|
||||
"text": "Home Medications",
|
||||
"item": [{
|
||||
"linkId": "BO_ConsPharm",
|
||||
"text": "Pharmacist consult",
|
||||
"answer": [{
|
||||
"valueCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "Yes",
|
||||
"display": "Yes"
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_ConsTxt",
|
||||
"text": "Pharmacy consult notes",
|
||||
"answer": [{
|
||||
"valueString": "Pharmacy consult notes comes here"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_RecNotCons",
|
||||
"text": "Recommendation not consistent with binder optimization guidelines",
|
||||
"answer": [{
|
||||
"valueCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "Yes",
|
||||
"display": "Yes"
|
||||
}
|
||||
}],
|
||||
"item": [{
|
||||
"linkId": "BO_NotConsDrop",
|
||||
"text": "Recommendation not consistent with binder optimization guidelines",
|
||||
"answer": [{
|
||||
"valueString": "Chewing difficulty,Other"
|
||||
}],
|
||||
"item": [{
|
||||
"linkId": "BO_OtherTxt",
|
||||
"text": "Other",
|
||||
"answer": [{
|
||||
"valueString": "Other difficulty"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_Recommend",
|
||||
"text": "What is your recommendation",
|
||||
"answer": [{
|
||||
"valueCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCBinderRecommendation",
|
||||
"code": "Renvela",
|
||||
"display": "Renvela"
|
||||
}
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"linkId": "Plan",
|
||||
"text": "Plan",
|
||||
"item": [{
|
||||
"linkId": "BO_CommPres",
|
||||
"text": "Binder recommendation communicated to prescriber",
|
||||
"answer": [{
|
||||
"valueCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "No",
|
||||
"display": "No"
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_ComAssmt",
|
||||
"text": "Referred to MSW for expressed co-pay concerns",
|
||||
"answer": [{
|
||||
"valueCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "No",
|
||||
"display": "No"
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_RefMSW",
|
||||
"text": "Referred to MSW for potential medication adherence issues",
|
||||
"answer": [{
|
||||
"valueCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "No",
|
||||
"display": "No"
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_AdjHyp",
|
||||
"text": "Continue adjustments per CMAB Hyperphosphatemia Algorithm",
|
||||
"answer": [{
|
||||
"valueCoding": {
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"code": "No",
|
||||
"display": "No"
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"linkId": "BO_AdjTxt",
|
||||
"text": "Adjustment Text",
|
||||
"answer": [{
|
||||
"valueString": "Adjustment Text comes here"
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}]
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"resourceType": "ValueSet",
|
||||
"id": "FMCBinderRecommendation",
|
||||
"meta": {
|
||||
"versionId": "1",
|
||||
"lastUpdated": "2019-05-02T16:58:46.423+00:00"
|
||||
},
|
||||
"url": "http://fkcfhir.org/fhir/vs/FMCBinderRecommendation",
|
||||
"identifier": [
|
||||
{
|
||||
"value": "FMCBinderRecommendation"
|
||||
}
|
||||
],
|
||||
"name": "FMCBinderRecommendation",
|
||||
"title": "Binder recommendation",
|
||||
"status": "active",
|
||||
"publisher": "FMCNA",
|
||||
"description": "ValueSet for Binder recommendation.",
|
||||
"compose": {
|
||||
"include": [
|
||||
{
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCBinderRecommendation"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"resourceType": "ValueSet",
|
||||
"id": "FMCYesNo",
|
||||
"meta": {
|
||||
"versionId": "3",
|
||||
"lastUpdated": "2019-05-03T16:50:45.195+00:00"
|
||||
},
|
||||
"url": "http://fkcfhir.org/fhir/vs/FMCYesNo",
|
||||
"identifier": [
|
||||
{
|
||||
"value": "FMCYesNo"
|
||||
}
|
||||
],
|
||||
"name": "FMCYesNo",
|
||||
"title": "Yes or No Choice",
|
||||
"status": "active",
|
||||
"publisher": "FMCNA",
|
||||
"description": "ValueSet for Yes or No Choice",
|
||||
"compose": {
|
||||
"include": [
|
||||
{
|
||||
"system": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"concept": [
|
||||
{
|
||||
"code": "Yes",
|
||||
"display": "Yes"
|
||||
},
|
||||
{
|
||||
"code": "No",
|
||||
"display": "No"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue