Fix an NPE in validation
This commit is contained in:
parent
92bd2c7173
commit
444730373b
|
@ -401,11 +401,11 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.sun.activation</groupId>-->
|
||||
<!-- <artifactId>javax.activation</artifactId>-->
|
||||
<!-- <version>1.2.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.sun.activation</groupId>
|
||||
<artifactId>javax.activation</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>javax.transaction</groupId>-->
|
||||
<!--<artifactId>javax.transaction-api</artifactId>-->
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package ca.uhn.fhir.jpa.provider.dstu3;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoDstu3TerminologyTest;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
|
@ -12,11 +17,14 @@ import org.junit.Test;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDstu3Test {
|
||||
|
||||
public static FhirContext ourCtx = FhirContext.forDstu3();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu3CodeSystemTest.class);
|
||||
private IIdType myExtensionalVsId;
|
||||
|
||||
|
@ -254,6 +262,42 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst
|
|||
assertEquals(false, ((BooleanType) respParam.getParameter().get(2).getValue()).booleanValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidationOfUploadedCodeSystems() throws IOException {
|
||||
CodeSystem csYesNo = loadResource("/dstu3/fmc01-cs-yesnounk.json", CodeSystem.class);
|
||||
ourClient.update().resource(csYesNo).execute();
|
||||
|
||||
CodeSystem csBinderRecommended = loadResource("/dstu3/fmc03-cs-binderrecommend.json", CodeSystem.class);
|
||||
ourClient.update().resource(csBinderRecommended).execute();
|
||||
|
||||
ValueSet vsBinderRequired = loadResource("/dstu3/fmc03-vs-binderrecommend.json", ValueSet.class);
|
||||
ourClient.update().resource(vsBinderRequired);
|
||||
|
||||
ValueSet vsYesNo = loadResource("/dstu3/fmc03-vs-fmcyesno.json", ValueSet.class);
|
||||
ourClient.update().resource(vsYesNo).execute();
|
||||
|
||||
Questionnaire q = loadResource("/dstu3/fmc03-questionnaire.json", Questionnaire.class);
|
||||
ourClient.update().resource(q).execute();
|
||||
|
||||
QuestionnaireResponse qr = loadResource("/dstu3/fmc03-questionnaireresponse.json", QuestionnaireResponse.class);
|
||||
IBaseOperationOutcome oo = ourClient.validate().resource(qr).execute().getOperationOutcome();
|
||||
|
||||
String encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo);
|
||||
ourLog.info("Encoded:\n{}", encoded);
|
||||
}
|
||||
|
||||
private String loadResource(String theFileName) throws IOException {
|
||||
InputStream resourceAsStream = ResourceProviderDstu3CodeSystemTest.class.getResourceAsStream(theFileName);
|
||||
if (resourceAsStream == null) {
|
||||
resourceAsStream = ResourceProviderDstu3CodeSystemTest.class.getResourceAsStream(theFileName.substring(1));
|
||||
}
|
||||
return IOUtils.toString(resourceAsStream, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
private <T extends IBaseResource> T loadResource(String theFilename, Class<T> theType) throws IOException {
|
||||
return ourCtx.newJsonParser().parseResource(theType, loadResource(theFilename));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
|
|
|
@ -15,7 +15,7 @@ import static org.junit.Assert.*;
|
|||
|
||||
public class JsonPatchUtilsTest extends BaseJpaTest {
|
||||
|
||||
public static final FhirContext ourCtx = FhirContext.forR4();
|
||||
private static final FhirContext ourCtx = FhirContext.forR4();
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(JsonPatchUtilsTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"resourceType": "CodeSystem",
|
||||
"id": "FMCYesNoUnk",
|
||||
"meta": {
|
||||
"versionId": "1",
|
||||
"lastUpdated": "2019-04-17T12:50:19.996+00:00"
|
||||
},
|
||||
"url": "http://fkcfhir.org/fhir/cs/FMCYesNoUnk",
|
||||
"identifier": {
|
||||
"value": "FMCYesNoUnk"
|
||||
},
|
||||
"name": "FMCYesNoUnk",
|
||||
"status": "active",
|
||||
"publisher": "FMCNA",
|
||||
"description": "CodeSystem for Yes or No or Unknown",
|
||||
"hierarchyMeaning": "grouped-by",
|
||||
"content": "complete",
|
||||
"concept": [
|
||||
{
|
||||
"code": "Yes",
|
||||
"display": "Yes"
|
||||
},
|
||||
{
|
||||
"code": "No",
|
||||
"display": "No"
|
||||
},
|
||||
{
|
||||
"code": "UnKnown",
|
||||
"display": "UnKnown"
|
||||
},
|
||||
{
|
||||
"code": "Pending",
|
||||
"display": "Pending"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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,146 @@
|
|||
{
|
||||
"resourceType": "QuestionnaireResponse",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -155,8 +155,10 @@ public class ValidationSupportChain implements IValidationSupport {
|
|||
for (IValidationSupport next : myChain) {
|
||||
if (next.isCodeSystemSupported(theCtx, theCodeSystem)) {
|
||||
CodeValidationResult result = next.validateCode(theCtx, theCodeSystem, theCode, theDisplay);
|
||||
ourLog.debug("Chain item {} returned outcome {}", next, result.isOk());
|
||||
return result;
|
||||
if (result != null) {
|
||||
ourLog.debug("Chain item {} returned outcome {}", next, result.isOk());
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
ourLog.debug("Chain item {} does not support code system {}", next, theCodeSystem);
|
||||
}
|
||||
|
|
|
@ -134,8 +134,10 @@ public class ValidationSupportChain implements IValidationSupport {
|
|||
for (IValidationSupport next : myChain) {
|
||||
if (next.isCodeSystemSupported(theCtx, theCodeSystem)) {
|
||||
CodeValidationResult result = next.validateCode(theCtx, theCodeSystem, theCode, theDisplay);
|
||||
ourLog.debug("Chain item {} returned outcome {}", next, result.isOk());
|
||||
return result;
|
||||
if (result != null) {
|
||||
ourLog.debug("Chain item {} returned outcome {}", next, result.isOk());
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
ourLog.debug("Chain item {} does not support code system {}", next, theCodeSystem);
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
}
|
||||
}
|
||||
if (retVal == null) {
|
||||
ourLog.info("fetchResource({}, {}) : {}", new Object[] {type, id, retVal});
|
||||
ourLog.info("fetchResource({}, {}) : {}", type, id, retVal);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue