From 0af95842a940c7732fb97b728a1e6d5f3ff59924 Mon Sep 17 00:00:00 2001 From: patrick-werner Date: Thu, 22 Feb 2018 12:23:42 +0100 Subject: [PATCH] fixes #853 performer validation implementation is now list based added Test --- .../fhir/r4/validation/InstanceValidator.java | 4 +++- .../validation/FhirInstanceValidatorR4Test.java | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java index 985d77a87b6..1b6517746d6 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java @@ -3538,7 +3538,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat // all observations should have a subject, a performer, and a time bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("subject") != null, "All observations should have a subject"); - bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("performer") != null, "All observations should have a performer"); + List performer = new ArrayList(); + element.getNamedChildren("performer", performer); + bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), !performer.isEmpty(), "All observations should have a performer"); bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("effectiveDateTime") != null || element.getNamedChild("effectivePeriod") != null, "All observations should have an effectiveDateTime or an effectivePeriod"); } diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java index 9bb949c1381..a9c9080e035 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java @@ -208,6 +208,23 @@ public class FhirInstanceValidatorR4Test { } + /** + * See #853 + */ + @Test + public void testObservationsWithMultiplePerformers() { + Observation observation = new Observation(); + observation.setStatus(ObservationStatus.FINAL); + observation.setCode(new CodeableConcept().addCoding(new Coding().setSystem("http://system").setCode("code"))); + Practitioner p1 = new Practitioner(); + Practitioner p2 = new Practitioner(); + observation.addPerformer(new Reference(p1)); + observation.addPerformer(new Reference(p2)); + + ValidationResult output = myVal.validateWithResult(observation); + List errors = logResultsAndReturnNonInformationalOnes(output); + assertThat(errors, empty()); + } @Test public void testBase64Invalid() {