continue refactor of providers

This commit is contained in:
Tadgh 2020-11-09 21:44:11 -05:00
parent c55de80c6a
commit d7974a6f1d
11 changed files with 109 additions and 115 deletions

View File

@ -83,8 +83,6 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
@Autowired @Autowired
protected FhirContext myFhirContext; protected FhirContext myFhirContext;
@Autowired @Autowired
protected IFhirResourceDao<Person> myPersonDao;
@Autowired
protected IFhirResourceDao<Patient> myPatientDao; protected IFhirResourceDao<Patient> myPatientDao;
@Autowired @Autowired
protected IFhirResourceDao<Practitioner> myPractitionerDao; protected IFhirResourceDao<Practitioner> myPractitionerDao;
@ -362,10 +360,10 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
return IsMatchedToAPerson.matchedToAPerson(myIdHelperService, myEmpiLinkDaoSvc); return IsMatchedToAPerson.matchedToAPerson(myIdHelperService, myEmpiLinkDaoSvc);
} }
protected Person getOnlyActivePerson() { protected Patient getOnlyActiveSourcePatient() {
List<IBaseResource> resources = getAllActiveSourcePatients(); List<IBaseResource> resources = getAllActiveSourcePatients();
assertEquals(1, resources.size()); assertEquals(1, resources.size());
return (Person) resources.get(0); return (Patient) resources.get(0);
} }
@Nonnull @Nonnull

View File

@ -12,7 +12,6 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -34,7 +33,7 @@ public class EmpiExpungeTest extends BaseEmpiR4Test {
@Autowired @Autowired
IEmpiLinkDao myEmpiLinkDao; IEmpiLinkDao myEmpiLinkDao;
private ResourceTable myTargetEntity; private ResourceTable myTargetEntity;
private ResourceTable myPersonEntity; private ResourceTable mySourceEntity;
private IdDt myTargetId; private IdDt myTargetId;
@BeforeEach @BeforeEach
@ -43,12 +42,12 @@ public class EmpiExpungeTest extends BaseEmpiR4Test {
myTargetEntity = (ResourceTable) myPatientDao.create(new Patient()).getEntity(); myTargetEntity = (ResourceTable) myPatientDao.create(new Patient()).getEntity();
myTargetId = myTargetEntity.getIdDt().toVersionless(); myTargetId = myTargetEntity.getIdDt().toVersionless();
myPersonEntity = (ResourceTable) myPersonDao.create(new Person()).getEntity(); mySourceEntity = (ResourceTable) myPatientDao.create(new Patient()).getEntity();
EmpiLink empiLink = myEmpiLinkDaoSvc.newEmpiLink(); EmpiLink empiLink = myEmpiLinkDaoSvc.newEmpiLink();
empiLink.setLinkSource(EmpiLinkSourceEnum.MANUAL); empiLink.setLinkSource(EmpiLinkSourceEnum.MANUAL);
empiLink.setMatchResult(EmpiMatchResultEnum.MATCH); empiLink.setMatchResult(EmpiMatchResultEnum.MATCH);
empiLink.setSourceResourcePid(myPersonEntity.getId()); empiLink.setSourceResourcePid(mySourceEntity.getId());
empiLink.setTargetPid(myTargetEntity.getId()); empiLink.setTargetPid(myTargetEntity.getId());
saveLink(empiLink); saveLink(empiLink);
} }

View File

@ -68,18 +68,12 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
assertLinkCount(1); assertLinkCount(1);
} }
@Test
public void testCreatePerson() {
myPersonDao.create(new Person());
assertLinkCount(0);
}
@Test @Test
public void testDeletePersonDeletesLinks() throws InterruptedException { public void testDeletePersonDeletesLinks() throws InterruptedException {
myEmpiHelper.createWithLatch(buildPaulPatient()); myEmpiHelper.createWithLatch(buildPaulPatient());
assertLinkCount(1); assertLinkCount(1);
Person person = getOnlyActivePerson(); Patient sourcePatient = getOnlyActiveSourcePatient();
myPersonDao.delete(person.getIdElement()); myPatientDao.delete(sourcePatient.getIdElement());
assertLinkCount(0); assertLinkCount(0);
} }
@ -140,7 +134,8 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
myEmpiHelper.createWithLatch(buildJanePatient()); myEmpiHelper.createWithLatch(buildJanePatient());
myEmpiHelper.createWithLatch(buildPaulPatient()); myEmpiHelper.createWithLatch(buildPaulPatient());
IBundleProvider search = myPersonDao.search(new SearchParameterMap().setLoadSynchronous(true)); //TODO GGG MDM: this test is out of date, since we now are using golden record Patients
IBundleProvider search = myPatientDao.search(new SearchParameterMap().setLoadSynchronous(true));
List<IBaseResource> resources = search.getResources(0, search.size()); List<IBaseResource> resources = search.getResources(0, search.size());
for (IBaseResource person : resources) { for (IBaseResource person : resources) {
@ -175,11 +170,11 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
//Updating a Person who was created via EMPI should fail. //Updating a Person who was created via EMPI should fail.
EmpiLink empiLink = myEmpiLinkDaoSvc.getMatchedLinkForTargetPid(myIdHelperService.getPidOrNull(patient)).get(); EmpiLink empiLink = myEmpiLinkDaoSvc.getMatchedLinkForTargetPid(myIdHelperService.getPidOrNull(patient)).get();
Long personPid = empiLink.getSourceResourcePid(); Long sourcePatientPid = empiLink.getSourceResourcePid();
Person empiPerson = (Person) myPersonDao.readByPid(new ResourcePersistentId(personPid)); Patient empiSourcePatient = (Patient) myPatientDao.readByPid(new ResourcePersistentId(sourcePatientPid));
empiPerson.setGender(Enumerations.AdministrativeGender.MALE); empiSourcePatient.setGender(Enumerations.AdministrativeGender.MALE);
try { try {
myEmpiHelper.doUpdateResource(empiPerson, true); myEmpiHelper.doUpdateResource(empiSourcePatient, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertEquals("Cannot create or modify Resources that are managed by EMPI.", e.getMessage()); assertEquals("Cannot create or modify Resources that are managed by EMPI.", e.getMessage());

View File

@ -27,10 +27,10 @@ public abstract class BaseLinkR4Test extends BaseProviderR4Test {
DaoConfig myDaoConfig; DaoConfig myDaoConfig;
protected Patient myPatient; protected Patient myPatient;
protected IAnyResource myPerson; protected IAnyResource mySourcePatient;
protected EmpiLink myLink; protected EmpiLink myLink;
protected StringType myPatientId; protected StringType myPatientId;
protected StringType myPersonId; protected StringType mySourcePatientId;
protected StringType myVersionlessPersonId; protected StringType myVersionlessPersonId;
@Override @Override
@ -41,9 +41,9 @@ public abstract class BaseLinkR4Test extends BaseProviderR4Test {
myPatient = createPatientAndUpdateLinks(buildPaulPatient()); myPatient = createPatientAndUpdateLinks(buildPaulPatient());
myPatientId = new StringType(myPatient.getIdElement().getValue()); myPatientId = new StringType(myPatient.getIdElement().getValue());
myPerson = getSourceResourceFromTargetResource(myPatient); mySourcePatient = getSourceResourceFromTargetResource(myPatient);
myPersonId = new StringType(myPerson.getIdElement().getValue()); mySourcePatientId = new StringType(mySourcePatient.getIdElement().getValue());
myVersionlessPersonId = new StringType(myPerson.getIdElement().toVersionless().getValue()); myVersionlessPersonId = new StringType(mySourcePatient.getIdElement().toVersionless().getValue());
myLink = getOnlyPatientLink(); myLink = getOnlyPatientLink();
// Tests require our initial link to be a POSSIBLE_MATCH // Tests require our initial link to be a POSSIBLE_MATCH

View File

@ -1,15 +1,16 @@
package ca.uhn.fhir.jpa.empi.provider; package ca.uhn.fhir.jpa.empi.provider;
import ca.uhn.fhir.empi.api.EmpiConstants;
import ca.uhn.fhir.jpa.entity.EmpiLink; import ca.uhn.fhir.jpa.entity.EmpiLink;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person;
import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.Practitioner;
import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.StringType;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -29,16 +30,16 @@ import static org.junit.jupiter.api.Assertions.fail;
public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test { public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
protected Practitioner myPractitioner; protected Practitioner myPractitioner;
protected StringType myPractitionerId; protected StringType myPractitionerId;
protected IAnyResource myPractitionerPerson; protected IAnyResource myPractitionerSourceResource;
protected StringType myPractitionerPersonId; protected StringType myPractitionerSourceResourceId;
@BeforeEach @BeforeEach
public void before() { public void before() {
super.before(); super.before();
myPractitioner = createPractitionerAndUpdateLinks(new Practitioner()); myPractitioner = createPractitionerAndUpdateLinks(new Practitioner());
myPractitionerId = new StringType(myPractitioner.getIdElement().getValue()); myPractitionerId = new StringType(myPractitioner.getIdElement().getValue());
myPractitionerPerson = getSourceResourceFromTargetResource(myPractitioner); myPractitionerSourceResource = getSourceResourceFromTargetResource(myPractitioner);
myPractitionerPersonId = new StringType(myPractitionerPerson.getIdElement().getValue()); myPractitionerSourceResourceId = new StringType(myPractitionerSourceResource.getIdElement().getValue());
} }
@Test @Test
@ -64,12 +65,12 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testClearPatientLinks() { public void testClearPatientLinks() {
assertLinkCount(2); assertLinkCount(2);
Person read = myPersonDao.read(new IdDt(myPersonId.getValueAsString()).toVersionless()); Patient read = myPatientDao.read(new IdDt(mySourcePatientId.getValueAsString()).toVersionless());
assertThat(read, is(notNullValue())); assertThat(read, is(notNullValue()));
myEmpiProviderR4.clearEmpiLinks(new StringType("Patient"), myRequestDetails); myEmpiProviderR4.clearEmpiLinks(new StringType("Patient"), myRequestDetails);
assertNoPatientLinksExist(); assertNoPatientLinksExist();
try { try {
myPersonDao.read(new IdDt(myPersonId.getValueAsString()).toVersionless()); myPatientDao.read(new IdDt(mySourcePatientId.getValueAsString()).toVersionless());
fail(); fail();
} catch (ResourceNotFoundException e) {} } catch (ResourceNotFoundException e) {}
@ -103,10 +104,18 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails); myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
assertNoPatientLinksExist(); assertNoPatientLinksExist();
IBundleProvider search = myPersonDao.search(new SearchParameterMap().setLoadSynchronous(true)); IBundleProvider search = myPatientDao.search(buildSourceResourceParameterMap());
assertThat(search.size(), is(equalTo(0))); assertThat(search.size(), is(equalTo(0)));
} }
/**
* Build a SearchParameterMap which looks up Golden Records (Source resources).
* @return
*/
private SearchParameterMap buildSourceResourceParameterMap() {
return new SearchParameterMap().setLoadSynchronous(true).add("_tag", new TokenParam(EmpiConstants.SYSTEM_EMPI_MANAGED, EmpiConstants.CODE_HAPI_EMPI_MANAGED));
}
@Test @Test
public void testPersonsWithCircularReferenceCanBeCleared() { public void testPersonsWithCircularReferenceCanBeCleared() {
Patient patientAndUpdateLinks = createPatientAndUpdateLinks(buildPaulPatient()); Patient patientAndUpdateLinks = createPatientAndUpdateLinks(buildPaulPatient());
@ -125,12 +134,12 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
//SUT //SUT
Parameters parameters = myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails); Parameters parameters = myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
assertNoPatientLinksExist(); assertNoPatientLinksExist();
IBundleProvider search = myPersonDao.search(new SearchParameterMap().setLoadSynchronous(true)); IBundleProvider search = myPatientDao.search(buildSourceResourceParameterMap());
assertThat(search.size(), is(equalTo(0))); assertThat(search.size(), is(equalTo(0)));
} }
//TODO GGG //TODO GGG unclear if we actually need to reimplement this.
private void linkPersons(IAnyResource theSourcePerson, IAnyResource theTargetPerson) { private void linkPersons(IAnyResource theSourcePerson, IAnyResource theTargetPerson) {
throw new UnsupportedOperationException("We need to fix this!"); throw new UnsupportedOperationException("We need to fix this!");
} }
@ -138,12 +147,12 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testClearPractitionerLinks() { public void testClearPractitionerLinks() {
assertLinkCount(2); assertLinkCount(2);
Person read = myPersonDao.read(new IdDt(myPractitionerPersonId.getValueAsString()).toVersionless()); Practitioner read = myPractitionerDao.read(new IdDt(myPractitionerSourceResourceId.getValueAsString()).toVersionless());
assertThat(read, is(notNullValue())); assertThat(read, is(notNullValue()));
myEmpiProviderR4.clearEmpiLinks(new StringType("Practitioner"), myRequestDetails); myEmpiProviderR4.clearEmpiLinks(new StringType("Practitioner"), myRequestDetails);
assertNoPractitionerLinksExist(); assertNoPractitionerLinksExist();
try { try {
myPersonDao.read(new IdDt(myPractitionerPersonId.getValueAsString()).toVersionless()); myPractitionerDao.read(new IdDt(myPractitionerSourceResourceId.getValueAsString()).toVersionless());
fail(); fail();
} catch (ResourceNotFoundException e) {} } catch (ResourceNotFoundException e) {}
} }

View File

@ -1,21 +1,19 @@
package ca.uhn.fhir.jpa.empi.provider; package ca.uhn.fhir.jpa.empi.provider;
import ca.uhn.fhir.empi.api.EmpiLinkSourceEnum;
import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
import ca.uhn.fhir.empi.util.AssuranceLevelUtil;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person; import org.hl7.fhir.r4.model.Person;
import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.StringType;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.List; import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
@ -41,18 +39,22 @@ public class EmpiProviderMergePersonsR4Test extends BaseProviderR4Test {
@Test @Test
public void testMerge() { public void testMerge() {
Person mergedPerson = myEmpiProviderR4.mergePersons(myFromSourcePatientId, myToSourcePatientId, myRequestDetails); //TODO GGG RP fix
assertEquals(myToSourcePatient.getIdElement(), mergedPerson.getIdElement()); Person mergedSourcePatient = myEmpiProviderR4.mergePersons(myFromSourcePatientId, myToSourcePatientId, myRequestDetails);
assertThat(mergedPerson, is(sameSourceResourceAs(myToSourcePatient))); assertEquals(myToSourcePatient.getIdElement(), mergedSourcePatient.getIdElement());
assertThat(mergedSourcePatient, is(sameSourceResourceAs(myToSourcePatient)));
assertEquals(2, getAllSourcePatients().size()); assertEquals(2, getAllSourcePatients().size());
assertEquals(1, getAllActiveSourcePatients().size()); assertEquals(1, getAllActiveSourcePatients().size());
Person fromPerson = myPersonDao.read(myFromSourcePatient.getIdElement().toUnqualifiedVersionless()); Patient fromSourcePatient = myPatientDao.read(myFromSourcePatient.getIdElement().toUnqualifiedVersionless());
assertThat(fromPerson.getActive(), is(false)); assertThat(fromSourcePatient.getActive(), is(false));
List<Person.PersonLinkComponent> links = fromPerson.getLink(); //TODO GGG eventually this will need to check a redirect... this is a hack which doesnt work
assertThat(links, hasSize(1)); Optional<Identifier> redirect = fromSourcePatient.getIdentifier().stream().filter(theIdentifier -> theIdentifier.getSystem().equals("REDIRECT")).findFirst();
assertThat(links.get(0).getTarget().getReference(), is (myToSourcePatient.getIdElement().toUnqualifiedVersionless().getValue())); assertThat(redirect.get().getValue(), is(equalTo(myToSourcePatient.getIdElement().toUnqualified().getValue())));
assertThat(links.get(0).getAssurance(), is (AssuranceLevelUtil.getAssuranceLevel(EmpiMatchResultEnum.REDIRECT, EmpiLinkSourceEnum.MANUAL).toR4())); //List<Person.PersonLinkComponent> links = fromSourcePatient.getLink();
//assertThat(links, hasSize(1));
//assertThat(links.get(0).getTarget().getReference(), is (myToSourcePatient.getIdElement().toUnqualifiedVersionless().getValue()));
//assertThat(links.get(0).getAssurance(), is (AssuranceLevelUtil.getAssuranceLevel(EmpiMatchResultEnum.REDIRECT, EmpiLinkSourceEnum.MANUAL).toR4()));
} }
@Test @Test

View File

@ -56,12 +56,12 @@ public class EmpiProviderQueryLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testQueryLinkOneMatch() { public void testQueryLinkOneMatch() {
Parameters result = myEmpiProviderR4.queryLinks(myPersonId, myPatientId, null, null, myRequestDetails); Parameters result = myEmpiProviderR4.queryLinks(mySourcePatientId, myPatientId, null, null, myRequestDetails);
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(result)); ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(result));
List<Parameters.ParametersParameterComponent> list = result.getParameter(); List<Parameters.ParametersParameterComponent> list = result.getParameter();
assertThat(list, hasSize(1)); assertThat(list, hasSize(1));
List<Parameters.ParametersParameterComponent> part = list.get(0).getPart(); List<Parameters.ParametersParameterComponent> part = list.get(0).getPart();
assertEmpiLink(7, part, myPersonId.getValue(), myPatientId.getValue(), EmpiMatchResultEnum.POSSIBLE_MATCH, "false", "true", null); assertEmpiLink(7, part, mySourcePatientId.getValue(), myPatientId.getValue(), EmpiMatchResultEnum.POSSIBLE_MATCH, "false", "true", null);
} }
@Test @Test

View File

@ -25,7 +25,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testUpdateLinkNoMatch() { public void testUpdateLinkNoMatch() {
assertLinkCount(1); assertLinkCount(1);
myEmpiProviderR4.updateLink(myPersonId, myPatientId, NO_MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
assertLinkCount(2); assertLinkCount(2);
List<EmpiLink> links = getPatientLinks(); List<EmpiLink> links = getPatientLinks();
@ -39,7 +39,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testUpdateLinkMatch() { public void testUpdateLinkMatch() {
assertLinkCount(1); assertLinkCount(1);
myEmpiProviderR4.updateLink(myPersonId, myPatientId, MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
assertLinkCount(1); assertLinkCount(1);
List<EmpiLink> links = getPatientLinks(); List<EmpiLink> links = getPatientLinks();
@ -49,9 +49,9 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testUpdateLinkTwiceFailsDueToWrongVersion() { public void testUpdateLinkTwiceFailsDueToWrongVersion() {
myEmpiProviderR4.updateLink(myPersonId, myPatientId, MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
try { try {
myEmpiProviderR4.updateLink(myPersonId, myPatientId, NO_MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
fail(); fail();
} catch (ResourceVersionConflictException e) { } catch (ResourceVersionConflictException e) {
assertThat(e.getMessage(), matchesPattern("Requested resource Person/\\d+/_history/1 is not the latest version. Latest version is Person/\\d+/_history/2")); assertThat(e.getMessage(), matchesPattern("Requested resource Person/\\d+/_history/1 is not the latest version. Latest version is Person/\\d+/_history/2"));
@ -60,16 +60,16 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testUpdateLinkTwiceWorksWhenNoVersionProvided() { public void testUpdateLinkTwiceWorksWhenNoVersionProvided() {
myEmpiProviderR4.updateLink(myPersonId, myPatientId, MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
Person person = myEmpiProviderR4.updateLink(myVersionlessPersonId, myPatientId, NO_MATCH_RESULT, myRequestDetails); Person person = myEmpiProviderR4.updateLink(myVersionlessPersonId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
assertThat(person.getLink(), hasSize(0)); assertThat(person.getLink(), hasSize(0));
} }
@Test @Test
public void testUnlinkLink() { public void testUnlinkLink() {
myEmpiProviderR4.updateLink(myPersonId, myPatientId, NO_MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
try { try {
myEmpiProviderR4.updateLink(myPersonId, myPatientId, MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
fail(); fail();
} catch (ResourceVersionConflictException e) { } catch (ResourceVersionConflictException e) {
assertThat(e.getMessage(), matchesPattern("Requested resource Person/\\d+/_history/1 is not the latest version. Latest version is Person/\\d+/_history/2")); assertThat(e.getMessage(), matchesPattern("Requested resource Person/\\d+/_history/1 is not the latest version. Latest version is Person/\\d+/_history/2"));
@ -79,7 +79,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testUpdateIllegalResultPM() { public void testUpdateIllegalResultPM() {
try { try {
myEmpiProviderR4.updateLink(myPersonId, myPatientId, POSSIBLE_MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, POSSIBLE_MATCH_RESULT, myRequestDetails);
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("$empi-update-link illegal matchResult value 'POSSIBLE_MATCH'. Must be NO_MATCH or MATCH", e.getMessage()); assertEquals("$empi-update-link illegal matchResult value 'POSSIBLE_MATCH'. Must be NO_MATCH or MATCH", e.getMessage());
@ -89,7 +89,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testUpdateIllegalResultPD() { public void testUpdateIllegalResultPD() {
try { try {
myEmpiProviderR4.updateLink(myPersonId, myPatientId, POSSIBLE_DUPLICATE_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, POSSIBLE_DUPLICATE_RESULT, myRequestDetails);
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("$empi-update-link illegal matchResult value 'POSSIBLE_DUPLICATE'. Must be NO_MATCH or MATCH", e.getMessage()); assertEquals("$empi-update-link illegal matchResult value 'POSSIBLE_DUPLICATE'. Must be NO_MATCH or MATCH", e.getMessage());
@ -109,7 +109,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test @Test
public void testUpdateIllegalSecondArg() { public void testUpdateIllegalSecondArg() {
try { try {
myEmpiProviderR4.updateLink(myPersonId, myPersonId, NO_MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, mySourcePatientId, NO_MATCH_RESULT, myRequestDetails);
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertThat(e.getMessage(), endsWith("must have form Patient/<id> or Practitioner/<id> where <id> is the id of the resource")); assertThat(e.getMessage(), endsWith("must have form Patient/<id> or Practitioner/<id> where <id> is the id of the resource"));
@ -133,7 +133,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
patient.getMeta().addTag().setSystem(EmpiConstants.SYSTEM_EMPI_MANAGED).setCode(EmpiConstants.CODE_NO_EMPI_MANAGED); patient.getMeta().addTag().setSystem(EmpiConstants.SYSTEM_EMPI_MANAGED).setCode(EmpiConstants.CODE_NO_EMPI_MANAGED);
createPatient(patient); createPatient(patient);
try { try {
myEmpiProviderR4.updateLink(myPersonId, new StringType(patient.getIdElement().getValue()), NO_MATCH_RESULT, myRequestDetails); myEmpiProviderR4.updateLink(mySourcePatientId, new StringType(patient.getIdElement().getValue()), NO_MATCH_RESULT, myRequestDetails);
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("The target is marked with the " + EmpiConstants.CODE_NO_EMPI_MANAGED + " tag which means it may not be EMPI linked.", e.getMessage()); assertEquals("The target is marked with the " + EmpiConstants.CODE_NO_EMPI_MANAGED + " tag which means it may not be EMPI linked.", e.getMessage());

View File

@ -1,22 +1,10 @@
package ca.uhn.fhir.jpa.empi.searchparam; package ca.uhn.fhir.jpa.empi.searchparam;
import ca.uhn.fhir.jpa.empi.BaseEmpiR4Test; import ca.uhn.fhir.jpa.empi.BaseEmpiR4Test;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.param.TokenParam;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class SearchParameterTest extends BaseEmpiR4Test { public class SearchParameterTest extends BaseEmpiR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(SearchParameterTest.class); private static final Logger ourLog = LoggerFactory.getLogger(SearchParameterTest.class);
@ -25,6 +13,11 @@ public class SearchParameterTest extends BaseEmpiR4Test {
super.loadEmpiSearchParameters(); super.loadEmpiSearchParameters();
} }
/**
* TODO GGG MDM ask ken if we still need this search parameter.
* The implementation this test tests will instead need to rely on MPI_LINK table?
*/
/*
@Test @Test
public void testCanFindPossibleMatches() { public void testCanFindPossibleMatches() {
// Create a possible match // Create a possible match
@ -53,4 +46,5 @@ public class SearchParameterTest extends BaseEmpiR4Test {
assertEquals(Person.IdentityAssuranceLevel.LEVEL2, links.get(0).getAssurance()); assertEquals(Person.IdentityAssuranceLevel.LEVEL2, links.get(0).getAssurance());
assertEquals(Person.IdentityAssuranceLevel.LEVEL1, links.get(1).getAssurance()); assertEquals(Person.IdentityAssuranceLevel.LEVEL1, links.get(1).getAssurance());
} }
*/
} }

View File

@ -18,7 +18,6 @@ import org.hl7.fhir.r4.model.Enumerations;
import org.hl7.fhir.r4.model.HumanName; import org.hl7.fhir.r4.model.HumanName;
import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -94,16 +93,16 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
assertEquals(2, getAllSourcePatients().size()); assertEquals(2, getAllSourcePatients().size());
assertEquals(2, getAllActiveSourcePatients().size()); assertEquals(2, getAllActiveSourcePatients().size());
Person mergedPerson = mergePersons(); Patient mergedSourcePatients = mergeSourcePatients();
assertEquals(myToSourcePatient.getIdElement(), mergedPerson.getIdElement()); assertEquals(myToSourcePatient.getIdElement(), mergedSourcePatients.getIdElement());
assertThat(mergedPerson, is(sameSourceResourceAs(mergedPerson))); assertThat(mergedSourcePatients, is(sameSourceResourceAs(mergedSourcePatients)));
assertEquals(2, getAllSourcePatients().size()); assertEquals(2, getAllSourcePatients().size());
assertEquals(1, getAllActiveSourcePatients().size()); assertEquals(1, getAllActiveSourcePatients().size());
} }
private Person mergePersons() { private Patient mergeSourcePatients() {
assertEquals(0, redirectLinkCount()); assertEquals(0, redirectLinkCount());
Person retval = (Person) myEmpiPersonMergerSvc.mergePersons(myFromSourcePatient, myToSourcePatient, createEmpiContext()); Patient retval = (Patient) myEmpiPersonMergerSvc.mergePersons(myFromSourcePatient, myToSourcePatient, createEmpiContext());
assertEquals(1, redirectLinkCount()); assertEquals(1, redirectLinkCount());
return retval; return retval;
} }
@ -129,7 +128,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
assertEquals(EmpiMatchResultEnum.POSSIBLE_DUPLICATE, foundLinks.get(0).getMatchResult()); assertEquals(EmpiMatchResultEnum.POSSIBLE_DUPLICATE, foundLinks.get(0).getMatchResult());
} }
mergePersons(); mergeSourcePatients();
{ {
List<EmpiLink> foundLinks = myEmpiLinkDao.findAll(); List<EmpiLink> foundLinks = myEmpiLinkDao.findAll();
@ -142,11 +141,11 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
public void fullFromEmptyTo() { public void fullFromEmptyTo() {
populatePerson(myFromSourcePatient); populatePerson(myFromSourcePatient);
Person mergedPerson = mergePersons(); Patient mergedSourcePatient = mergeSourcePatients();
HumanName returnedName = mergedPerson.getNameFirstRep(); HumanName returnedName = mergedSourcePatient.getNameFirstRep();
assertEquals(GIVEN_NAME, returnedName.getGivenAsSingleString()); assertEquals(GIVEN_NAME, returnedName.getGivenAsSingleString());
assertEquals(FAMILY_NAME, returnedName.getFamily()); assertEquals(FAMILY_NAME, returnedName.getFamily());
assertEquals(POSTAL_CODE, mergedPerson.getAddressFirstRep().getPostalCode()); assertEquals(POSTAL_CODE, mergedSourcePatient.getAddressFirstRep().getPostalCode());
} }
@Test @Test
@ -154,21 +153,21 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
myFromSourcePatient.getName().add(new HumanName().addGiven(BAD_GIVEN_NAME)); myFromSourcePatient.getName().add(new HumanName().addGiven(BAD_GIVEN_NAME));
populatePerson(myToSourcePatient); populatePerson(myToSourcePatient);
Person mergedPerson = mergePersons(); Patient mergedSourcePatient = mergeSourcePatients();
HumanName returnedName = mergedPerson.getNameFirstRep(); HumanName returnedName = mergedSourcePatient.getNameFirstRep();
assertEquals(GIVEN_NAME, returnedName.getGivenAsSingleString()); assertEquals(GIVEN_NAME, returnedName.getGivenAsSingleString());
assertEquals(FAMILY_NAME, returnedName.getFamily()); assertEquals(FAMILY_NAME, returnedName.getFamily());
assertEquals(POSTAL_CODE, mergedPerson.getAddressFirstRep().getPostalCode()); assertEquals(POSTAL_CODE, mergedSourcePatient.getAddressFirstRep().getPostalCode());
} }
@Test @Test
public void fromLinkToNoLink() { public void fromLinkToNoLink() {
createEmpiLink(myFromSourcePatient, myTargetPatient1); createEmpiLink(myFromSourcePatient, myTargetPatient1);
Person mergedPerson = mergePersons(); Patient mergedSourcePatient = mergeSourcePatients();
List<EmpiLink> links = getNonRedirectLinksByPerson(mergedPerson); List<EmpiLink> links = getNonRedirectLinksByPerson(mergedSourcePatient);
assertEquals(1, links.size()); assertEquals(1, links.size());
assertThat(mergedPerson, is(possibleLinkedTo(myTargetPatient1))); assertThat(mergedSourcePatient, is(possibleLinkedTo(myTargetPatient1)));
assertEquals(1, myToSourcePatient.getLink().size()); assertEquals(1, myToSourcePatient.getLink().size());
} }
@ -176,10 +175,10 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
public void fromNoLinkToLink() { public void fromNoLinkToLink() {
createEmpiLink(myToSourcePatient, myTargetPatient1); createEmpiLink(myToSourcePatient, myTargetPatient1);
Person mergedPerson = mergePersons(); Patient mergedSourcePatient = mergeSourcePatients();
List<EmpiLink> links = getNonRedirectLinksByPerson(mergedPerson); List<EmpiLink> links = getNonRedirectLinksByPerson(mergedSourcePatient);
assertEquals(1, links.size()); assertEquals(1, links.size());
assertThat(mergedPerson, is(possibleLinkedTo(myTargetPatient1))); assertThat(mergedSourcePatient, is(possibleLinkedTo(myTargetPatient1)));
assertEquals(1, myToSourcePatient.getLink().size()); assertEquals(1, myToSourcePatient.getLink().size());
} }
@ -192,7 +191,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
createEmpiLink(myToSourcePatient, myTargetPatient1); createEmpiLink(myToSourcePatient, myTargetPatient1);
mergePersons(); mergeSourcePatients();
List<EmpiLink> links = getNonRedirectLinksByPerson(myToSourcePatient); List<EmpiLink> links = getNonRedirectLinksByPerson(myToSourcePatient);
assertEquals(1, links.size()); assertEquals(1, links.size());
assertEquals(EmpiLinkSourceEnum.MANUAL, links.get(0).getLinkSource()); assertEquals(EmpiLinkSourceEnum.MANUAL, links.get(0).getLinkSource());
@ -214,7 +213,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
createEmpiLink(myToSourcePatient, myTargetPatient1); createEmpiLink(myToSourcePatient, myTargetPatient1);
mergePersons(); mergeSourcePatients();
List<EmpiLink> links = getNonRedirectLinksByPerson(myToSourcePatient); List<EmpiLink> links = getNonRedirectLinksByPerson(myToSourcePatient);
assertEquals(1, links.size()); assertEquals(1, links.size());
assertEquals(EmpiLinkSourceEnum.MANUAL, links.get(0).getLinkSource()); assertEquals(EmpiLinkSourceEnum.MANUAL, links.get(0).getLinkSource());
@ -229,7 +228,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
toLink.setMatchResult(EmpiMatchResultEnum.NO_MATCH); toLink.setMatchResult(EmpiMatchResultEnum.NO_MATCH);
saveLink(toLink); saveLink(toLink);
mergePersons(); mergeSourcePatients();
List<EmpiLink> links = getNonRedirectLinksByPerson(myToSourcePatient); List<EmpiLink> links = getNonRedirectLinksByPerson(myToSourcePatient);
assertEquals(1, links.size()); assertEquals(1, links.size());
assertEquals(EmpiLinkSourceEnum.MANUAL, links.get(0).getLinkSource()); assertEquals(EmpiLinkSourceEnum.MANUAL, links.get(0).getLinkSource());
@ -248,7 +247,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
saveLink(toLink); saveLink(toLink);
try { try {
mergePersons(); mergeSourcePatients();
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("A MANUAL NO_MATCH link may not be merged into a MANUAL MATCH link for the same target", e.getMessage()); assertEquals("A MANUAL NO_MATCH link may not be merged into a MANUAL MATCH link for the same target", e.getMessage());
@ -268,7 +267,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
saveLink(toLink); saveLink(toLink);
try { try {
mergePersons(); mergeSourcePatients();
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("A MANUAL MATCH link may not be merged into a MANUAL NO_MATCH link for the same target", e.getMessage()); assertEquals("A MANUAL MATCH link may not be merged into a MANUAL NO_MATCH link for the same target", e.getMessage());
@ -287,7 +286,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
toLink.setMatchResult(EmpiMatchResultEnum.MATCH); toLink.setMatchResult(EmpiMatchResultEnum.MATCH);
saveLink(toLink); saveLink(toLink);
mergePersons(); mergeSourcePatients();
assertEquals(1, myToSourcePatient.getLink().size()); assertEquals(1, myToSourcePatient.getLink().size());
assertEquals(3, myEmpiLinkDao.count()); assertEquals(3, myEmpiLinkDao.count());
} }
@ -299,7 +298,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
createEmpiLink(myFromSourcePatient, myTargetPatient3); createEmpiLink(myFromSourcePatient, myTargetPatient3);
createEmpiLink(myToSourcePatient, myTargetPatient1); createEmpiLink(myToSourcePatient, myTargetPatient1);
mergePersons(); mergeSourcePatients();
myEmpiLinkHelper.logEmpiLinks(); myEmpiLinkHelper.logEmpiLinks();
assertThat(myToSourcePatient, is(possibleLinkedTo(myTargetPatient1, myTargetPatient2, myTargetPatient3))); assertThat(myToSourcePatient, is(possibleLinkedTo(myTargetPatient1, myTargetPatient2, myTargetPatient3)));
@ -313,7 +312,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
createEmpiLink(myToSourcePatient, myTargetPatient2); createEmpiLink(myToSourcePatient, myTargetPatient2);
createEmpiLink(myToSourcePatient, myTargetPatient3); createEmpiLink(myToSourcePatient, myTargetPatient3);
mergePersons(); mergeSourcePatients();
myEmpiLinkHelper.logEmpiLinks(); myEmpiLinkHelper.logEmpiLinks();
assertThat(myToSourcePatient, is(possibleLinkedTo(myTargetPatient1, myTargetPatient2, myTargetPatient3))); assertThat(myToSourcePatient, is(possibleLinkedTo(myTargetPatient1, myTargetPatient2, myTargetPatient3)));
@ -329,7 +328,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
createEmpiLink(myToSourcePatient, myTargetPatient2); createEmpiLink(myToSourcePatient, myTargetPatient2);
createEmpiLink(myToSourcePatient, myTargetPatient3); createEmpiLink(myToSourcePatient, myTargetPatient3);
mergePersons(); mergeSourcePatients();
myEmpiLinkHelper.logEmpiLinks(); myEmpiLinkHelper.logEmpiLinks();
assertThat(myToSourcePatient, is(possibleLinkedTo(myTargetPatient1, myTargetPatient2, myTargetPatient3))); assertThat(myToSourcePatient, is(possibleLinkedTo(myTargetPatient1, myTargetPatient2, myTargetPatient3)));
@ -343,7 +342,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
createEmpiLink(myToSourcePatient, myTargetPatient2); createEmpiLink(myToSourcePatient, myTargetPatient2);
createEmpiLink(myToSourcePatient, myTargetPatient3); createEmpiLink(myToSourcePatient, myTargetPatient3);
mergePersons(); mergeSourcePatients();
myEmpiLinkHelper.logEmpiLinks(); myEmpiLinkHelper.logEmpiLinks();
assertThat(myToSourcePatient, is(possibleLinkedTo(myTargetPatient1, myTargetPatient2, myTargetPatient3))); assertThat(myToSourcePatient, is(possibleLinkedTo(myTargetPatient1, myTargetPatient2, myTargetPatient3)));
@ -362,10 +361,10 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
assertThat(myToSourcePatient.getName(), hasSize(1)); assertThat(myToSourcePatient.getName(), hasSize(1));
assertThat(myToSourcePatient.getName().get(0).getGiven(), hasSize(2)); assertThat(myToSourcePatient.getName().get(0).getGiven(), hasSize(2));
Person mergedPerson = mergePersons(); Patient mergedSourcePatient = mergeSourcePatients();
assertThat(mergedPerson.getName(), hasSize(2)); assertThat(mergedSourcePatient.getName(), hasSize(2));
assertThat(mergedPerson.getName().get(0).getGiven(), hasSize(2)); assertThat(mergedSourcePatient.getName().get(0).getGiven(), hasSize(2));
assertThat(mergedPerson.getName().get(1).getGiven(), hasSize(2)); assertThat(mergedSourcePatient.getName().get(1).getGiven(), hasSize(2));
} }
@Test @Test
@ -380,7 +379,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
assertThat(myToSourcePatient.getName(), hasSize(1)); assertThat(myToSourcePatient.getName(), hasSize(1));
assertThat(myToSourcePatient.getName().get(0).getGiven(), hasSize(2)); assertThat(myToSourcePatient.getName().get(0).getGiven(), hasSize(2));
mergePersons(); mergeSourcePatients();
assertThat(myToSourcePatient.getName(), hasSize(1)); assertThat(myToSourcePatient.getName(), hasSize(1));
assertThat(myToSourcePatient.getName().get(0).getGiven(), hasSize(2)); assertThat(myToSourcePatient.getName().get(0).getGiven(), hasSize(2));
} }
@ -395,7 +394,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
myToSourcePatient.addIdentifier().setValue("ccc"); myToSourcePatient.addIdentifier().setValue("ccc");
assertThat(myToSourcePatient.getIdentifier(), hasSize(2)); assertThat(myToSourcePatient.getIdentifier(), hasSize(2));
mergePersons(); mergeSourcePatients();
assertThat(myToSourcePatient.getIdentifier(), hasSize(3)); assertThat(myToSourcePatient.getIdentifier(), hasSize(3));
} }

View File

@ -38,12 +38,10 @@ import ca.uhn.fhir.rest.server.provider.ProviderConstants;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.util.ParametersUtil; import ca.uhn.fhir.util.ParametersUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.CodeType; import org.hl7.fhir.r4.model.CodeType;
import org.hl7.fhir.r4.model.DecimalType; import org.hl7.fhir.r4.model.DecimalType;
import org.hl7.fhir.r4.model.Extension;
import org.hl7.fhir.r4.model.InstantType; import org.hl7.fhir.r4.model.InstantType;
import org.hl7.fhir.r4.model.IntegerType; import org.hl7.fhir.r4.model.IntegerType;
import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.Parameters;
@ -54,7 +52,6 @@ import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.codesystems.MatchGrade; import org.hl7.fhir.r4.model.codesystems.MatchGrade;
import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -126,6 +123,7 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
return searchComponent; return searchComponent;
} }
//TODO GGG ask ken, what is the best way to genericize this? Return Parameters??
@Operation(name = ProviderConstants.EMPI_MERGE_PERSONS, type = Person.class) @Operation(name = ProviderConstants.EMPI_MERGE_PERSONS, type = Person.class)
public Person mergePersons(@OperationParam(name=ProviderConstants.EMPI_MERGE_PERSONS_FROM_PERSON_ID, min = 1, max = 1) StringType theFromPersonId, public Person mergePersons(@OperationParam(name=ProviderConstants.EMPI_MERGE_PERSONS_FROM_PERSON_ID, min = 1, max = 1) StringType theFromPersonId,
@OperationParam(name=ProviderConstants.EMPI_MERGE_PERSONS_TO_PERSON_ID, min = 1, max = 1) StringType theToPersonId, @OperationParam(name=ProviderConstants.EMPI_MERGE_PERSONS_TO_PERSON_ID, min = 1, max = 1) StringType theToPersonId,