Merge pull request #951 from jamesagnew/bpCheckValFix

bpCheck observation.performer 0..1 fix
This commit is contained in:
Patrick Werner 2018-05-17 10:26:01 +02:00 committed by GitHub
commit 1613928ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 6 deletions

View File

@ -3,10 +3,7 @@ package ca.uhn.fhir.parser;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.TestUtil;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.*;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Reference;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;

View File

@ -3621,7 +3621,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
// all observations should have a subject, a performer, and a time // 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("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<Element> 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, 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"); "All observations should have an effectiveDateTime or an effectivePeriod");
} }

View File

@ -192,7 +192,6 @@ public class FhirInstanceValidatorR4Test {
retVal.add(next); retVal.add(next);
} }
return retVal; return retVal;
} }
@ -1041,6 +1040,24 @@ public class FhirInstanceValidatorR4Test {
} }
@Test
public void testMultiplePerformer() {
Observation o = new Observation();
Practitioner p1 = new Practitioner();
Practitioner p2 = new Practitioner();
o.addPerformer(new Reference(p1));
o.addPerformer(new Reference(p2));
ValidationResult output = myVal.validateWithResult(o);
List<SingleValidationMessage> valMessages = logResultsAndReturnAll(output);
List<String> messages = new ArrayList<>();
for (String msg : messages) {
messages.add(msg);
}
assertThat(messages, not(hasItem("All observations should have a performer")));
}
@Test @Test
public void testValidateResourceWithValuesetExpansionGood() { public void testValidateResourceWithValuesetExpansionGood() {
Patient patient = new Patient(); Patient patient = new Patient();