Ensure that source resource type of Provenance is also excluded from the $everything linkage. (#4692)
This commit is contained in:
parent
b2c0a48915
commit
479e412786
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: change
|
||||
issue: 4691
|
||||
title: "When calling $everything on a Patient instance, the jpa server no longer traverses into other patients.
|
||||
Previously it was possible to pull in data from another patient for example, via Provenance and Composition resources."
|
|
@ -1176,6 +1176,7 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
|
|||
// (e.g. via Provenance, List, or Group) when in an $everything operation
|
||||
if (myParams != null && myParams.getEverythingMode() == SearchParameterMap.EverythingModeEnum.PATIENT_INSTANCE) {
|
||||
sqlBuilder.append(" AND r.myTargetResourceType != 'Patient'");
|
||||
sqlBuilder.append(" AND r.mySourceResourceType != 'Provenance'");
|
||||
}
|
||||
|
||||
String sql = sqlBuilder.toString();
|
||||
|
|
|
@ -99,6 +99,7 @@ import org.hl7.fhir.r4.model.CodeSystem;
|
|||
import org.hl7.fhir.r4.model.CodeType;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.Composition;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.Condition;
|
||||
import org.hl7.fhir.r4.model.Coverage;
|
||||
|
@ -3799,6 +3800,55 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
assertThat(ids, containsInAnyOrder(goodPid, oid, provid));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEverythingDoesNotEnterSecondPatientLinkedByProvenanceAndComposition() {
|
||||
final Patient desiredPatient = new Patient();
|
||||
desiredPatient.setActive(true);
|
||||
final String desiredPid = myPatientDao.create(desiredPatient, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||
|
||||
final Patient notDesiredPatient = new Patient();
|
||||
desiredPatient.setActive(true);
|
||||
final String notDesiredPid = myPatientDao.create(notDesiredPatient, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||
|
||||
final Observation desiredObservation = new Observation();
|
||||
desiredObservation.getSubject().setReference(desiredPid);
|
||||
desiredObservation.addIdentifier().setSystem("foo").setValue("1");
|
||||
final String desiredObservationId = myObservationDao.create(desiredObservation, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||
|
||||
final Observation notDesiredObservation = new Observation();
|
||||
notDesiredObservation.getSubject().setReference(notDesiredPid);
|
||||
notDesiredObservation.addIdentifier().setSystem("foo").setValue("1");
|
||||
final String notDesiredObservationId = myObservationDao.create(notDesiredObservation, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||
|
||||
final Composition composition = new Composition();
|
||||
final Reference referenceToNotDesiredPatient = new Reference();
|
||||
referenceToNotDesiredPatient.setReference(notDesiredPid);
|
||||
composition.setSubject(referenceToNotDesiredPatient);
|
||||
final String compositionId = myCompositionDao.create(composition, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||
|
||||
final Provenance desiredProvenance = new Provenance();
|
||||
desiredProvenance.addTarget().setReference(desiredPid);
|
||||
desiredProvenance.addTarget().setReference(compositionId);
|
||||
final String desiredProvenanceId = myProvenanceDao.create(desiredProvenance, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||
|
||||
final Provenance notDesiredProvenance = new Provenance();
|
||||
notDesiredProvenance.addTarget().setReference(notDesiredPid);
|
||||
notDesiredProvenance.addTarget().setReference(compositionId);
|
||||
final String notDesiredProvenanceId = myProvenanceDao.create(notDesiredProvenance, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||
|
||||
final Bundle response = myClient
|
||||
.operation()
|
||||
.onInstance(new IdType(desiredPid))
|
||||
.named("everything")
|
||||
.withNoParameters(Parameters.class)
|
||||
.returnResourceType(Bundle.class)
|
||||
.execute();
|
||||
|
||||
final List<String> actualResourceIds = toUnqualifiedVersionlessIdValues(response);
|
||||
// We should not pick up other resources via the notDesiredProvenance
|
||||
assertThat(actualResourceIds, containsInAnyOrder(desiredPid, desiredObservationId, desiredProvenanceId));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncludeRecurseFromProvenanceDoesTraverse() {
|
||||
Patient goodPatient = new Patient();
|
||||
|
|
|
@ -125,6 +125,7 @@ import org.hl7.fhir.r4.model.CodeSystem;
|
|||
import org.hl7.fhir.r4.model.Communication;
|
||||
import org.hl7.fhir.r4.model.CommunicationRequest;
|
||||
import org.hl7.fhir.r4.model.CompartmentDefinition;
|
||||
import org.hl7.fhir.r4.model.Composition;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent;
|
||||
|
@ -380,6 +381,9 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil
|
|||
@Qualifier("myObservationDaoR4")
|
||||
protected IFhirResourceDao<Observation> myObservationDao;
|
||||
@Autowired
|
||||
@Qualifier("myCompositionDaoR4")
|
||||
protected IFhirResourceDao<Composition> myCompositionDao;
|
||||
@Autowired
|
||||
@Qualifier("myOperationDefinitionDaoR4")
|
||||
protected IFhirResourceDao<OperationDefinition> myOperationDefinitionDao;
|
||||
@Autowired
|
||||
|
|
Loading…
Reference in New Issue