Open iordachemc opened 6 years ago
I noticed the same problem while validating custom resources. Wrote a small unit test to reproduce the problem with the default HAPI FHIR resources and the default validator.
To Reproduce
@Test
public void validateFHIRResource() {
final org.hl7.fhir.dstu3.model.CareTeam careTeam = new org.hl7.fhir.dstu3.model.CareTeam();
careTeam.addParticipant(new org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent() //
.setMember(new Reference(new Practitioner())) //
.setOnBehalfOf(new Reference(new Organization().setName("Organizer"))));
final FhirContext ctx = FhirContext.forDstu3();
final FhirValidator validator = ctx.newValidator();
final FhirInstanceValidator instanceValidator = new FhirInstanceValidator();
ValidationSupportChain support = new ValidationSupportChain(new DefaultProfileValidationSupport());
instanceValidator.setValidationSupport(support);
validator.registerValidatorModule(instanceValidator);
final ValidationResult result = validator.validateWithResult(careTeam);
result.getMessages().forEach(v -> logger.info("validateResource - " + v.toString()));
MatcherAssert.assertThat(result.isSuccessful(), equalTo(true));
MatcherAssert.assertThat(result.getMessages().size(), equalTo(0));
}
Environment:
Describe the bug Constraints applies to all values ctm-1: On CareTeam.participant: CareTeam.participant.onBehalfOf can only be populated when CareTeam.participant.member is a Practitioner (expression on CareTeam.participant: onBehalfOf.exists() implies (member.resolve() is Practitioner))
To Reproduce Steps to reproduce the behavior:
Expected behavior Should return a Successful created message
Environment (please complete the following information):