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() {