From ac3b1e3e17adb53600637fea8e40f3dbeb8cf1c0 Mon Sep 17 00:00:00 2001 From: Nick Goupinets Date: Mon, 9 Nov 2020 11:46:56 -0500 Subject: [PATCH] Fixed code for use case #3 test case --- .../fhir/jpa/empi/svc/EmpiResourceDaoSvc.java | 6 +++- .../jpa/empi/svc/EmpiMatchLinkSvcTest.java | 34 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiResourceDaoSvc.java b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiResourceDaoSvc.java index 035261fa853e..a1cf801ff0e9 100644 --- a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiResourceDaoSvc.java +++ b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiResourceDaoSvc.java @@ -22,11 +22,13 @@ import ca.uhn.fhir.empi.api.EmpiConstants; import ca.uhn.fhir.empi.api.IEmpiSettings; +import ca.uhn.fhir.empi.util.EIDHelper; import ca.uhn.fhir.empi.util.EmpiUtil; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; +import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.param.TokenParam; @@ -70,7 +72,9 @@ public Optional searchSourceResourceByEID(String theEid, String th SearchParameterMap map = new SearchParameterMap(); map.setLoadSynchronous(true); map.add("identifier", new TokenParam(myEmpiConfig.getEmpiRules().getEnterpriseEIDSystem(), theEid)); - map.add("active", new TokenParam("true")); + // TODO NG - During person dedup do we set this to false? We might be setting a person to inactive... + // map.add("active", new TokenParam("true")); + map.add("_tag", new TokenParam(EmpiConstants.SYSTEM_EMPI_MANAGED, EmpiConstants.CODE_HAPI_EMPI_MANAGED)); IFhirResourceDao resourceDao = myDaoRegistry.getResourceDao(theResourceType); IBundleProvider search = resourceDao.search(map); diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/svc/EmpiMatchLinkSvcTest.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/svc/EmpiMatchLinkSvcTest.java index db18cdaae958..1762351429be 100644 --- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/svc/EmpiMatchLinkSvcTest.java +++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/svc/EmpiMatchLinkSvcTest.java @@ -225,24 +225,28 @@ public void testIncomingPatientWithEidMatchesAnotherPatientWithSameEIDAreLinked( Patient patient1 = addExternalEID(buildJanePatient(), "uniqueid"); createPatientAndUpdateLinks(patient1); - // state is now > Patient/ID.JANE.123[name=jane & EID = uniqueid] <-- EMPI Link -- Patient/[name=jane & EDI = uniqueid & EMPI_MANAGED = true] - IBundleProvider bundle = myPatientDao.search(new SearchParameterMap()); - List resources = bundle.getResources(0, bundle.size()); - resources.forEach(r -> { - print(r); - assertFalse(myEidHelper.getExternalEid(r).isEmpty()); - }); - assertEquals(2, resources.size()); - - IBaseResource testPatient1 = resources.get(0); - IBaseResource testPatient2 = resources.get(1); + { + // state is now > Patient/ID.JANE.123[name=jane & EID = uniqueid] <-- EMPI Link -- Patient/[name=jane & EDI = uniqueid & EMPI_MANAGED = true] + IBundleProvider bundle = myPatientDao.search(new SearchParameterMap()); + List resources = bundle.getResources(0, bundle.size()); + resources.forEach(r -> { + print(r); + assertFalse(myEidHelper.getExternalEid(r).isEmpty()); + }); + assertEquals(2, resources.size()); - assertThat((Patient) testPatient1, is(sameSourceResourceAs((Patient) testPatient2))); + IBaseResource testPatient1 = resources.get(0); + IBaseResource testPatient2 = resources.get(1); - Optional empiLinkByTarget = myEmpiLinkDaoSvc.findEmpiLinkByTarget(patient1); - assertTrue(empiLinkByTarget.isPresent()); + assertThat((Patient) testPatient1, is(sameSourceResourceAs((Patient) testPatient2))); - Patient patient2 = addExternalEID(buildPaulPatient(), "uniqueid"); + Optional empiLinkByTarget = myEmpiLinkDaoSvc.findEmpiLinkByTarget(patient1); + assertTrue(empiLinkByTarget.isPresent()); + System.out.println(empiLinkByTarget.get()); + } + Patient patient2 = buildPaulPatient(); + patient2.setActive(true); + patient2 = addExternalEID(patient2, "uniqueid"); createPatientAndUpdateLinks(patient2); // state should be > Patient/ID.JANE.123[name=jane & EID = uniqueid] <--> Patient/[name=jane & EDI = uniqueid] <--> Patient/[name=paul & EDI = uniqueid] IBundleProvider search = myPatientDao.search(new SearchParameterMap());