diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java index 4fd43865736..32295577991 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java @@ -336,6 +336,19 @@ public class FhirInstanceValidatorDstu3Test { assertTrue(output.isSuccessful()); } + /** + * See #739 + */ + @Test + public void testValidateMedicationIngredient() throws IOException { + String input = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/dstu3/bug739.json"), Charsets.UTF_8); + + ValidationResult results = myVal.validateWithResult(input); + List outcome = logResultsAndReturnNonInformationalOnes(results); + assertThat(outcome.toString(), containsString("Element 'Medication.ingredient.item[x]': minimum required = 1")); + + } + @Test public void testValidateQuestionnaireResponse() throws IOException { String input = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/qr_jon.xml")); diff --git a/hapi-fhir-validation/src/test/resources/dstu3/bug739.json b/hapi-fhir-validation/src/test/resources/dstu3/bug739.json new file mode 100644 index 00000000000..b1b34196c57 --- /dev/null +++ b/hapi-fhir-validation/src/test/resources/dstu3/bug739.json @@ -0,0 +1,45 @@ +{ + "resourceType": "Medication", + "code": { + "coding": [ + { + "system": "urn:2.16.840.1.113883.6.88", + "code": "1191", + "display": "aspirin" + } + ], + "text": "ASPIRIN 325 MG TABLET" + }, + "form": { + "coding": [ + { + "system": "http://upmc.com/enterprises/rakia/rakida/cerner/h1/medication/form/code", + "code": "687545", + "display": "Tab" + } + ], + "text": "Tab" + }, + "ingredient": [ + { + "item": { + "reference": "medication/613168", + "display": "aspirin" + }, + "amount": { + "numerator": { + "value": "650", + "unit": "mg", + "system": "http://upmc.com/enterprises/rakia/rakida/cerner/h1/medication/strength/unit", + "code": "MG" + }, + "denominator": { + "value": "2", + "unit": "tab(s)", + "system": "http://upmc.com/enterprises/rakia/rakida/cerner/h1/medication/volume/unit", + "code": "TAB" + } + } + } + ] +}