From 328080e87bdaf694fa6ee38ba00b98f47f2f394e Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 27 Sep 2017 21:36:40 -0400 Subject: [PATCH] Add test for #739 --- .../FhirInstanceValidatorDstu3Test.java | 13 ++++++ .../src/test/resources/dstu3/bug739.json | 45 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 hapi-fhir-validation/src/test/resources/dstu3/bug739.json 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" + } + } + } + ] +}