Renamed source to golden

This commit is contained in:
Nick Goupinets 2020-11-13 14:28:24 -05:00
parent dadd5f3caf
commit 1fc9689943
1 changed files with 35 additions and 34 deletions

View File

@ -53,13 +53,13 @@ public class EmpiLinkSvcTest extends BaseEmpiR4Test {
@Test @Test
public void testCreateRemoveLink() { public void testCreateRemoveLink() {
assertLinkCount(0); assertLinkCount(0);
Patient sourcePatient = createGoldenPatient(); Patient goldenPatient = createGoldenPatient();
IdType sourcePatientId = sourcePatient.getIdElement().toUnqualifiedVersionless(); IdType sourcePatientId = goldenPatient.getIdElement().toUnqualifiedVersionless();
// TODO NG should be ok to remove - assertEquals(0, sourcePatient.getLink().size()); // TODO NG should be ok to remove - assertEquals(0, goldenPatient.getLink().size());
Patient patient = createPatient(); Patient patient = createPatient();
{ {
myEmpiLinkSvc.updateLink(sourcePatient, patient, POSSIBLE_MATCH, EmpiLinkSourceEnum.AUTO, createContextForCreate("Patient")); myEmpiLinkSvc.updateLink(goldenPatient, patient, POSSIBLE_MATCH, EmpiLinkSourceEnum.AUTO, createContextForCreate("Patient"));
assertLinkCount(1); assertLinkCount(1);
// TODO NG should be ok to remove // TODO NG should be ok to remove
// Patient newSourcePatient = myPatientDao.read(sourcePatientId); // Patient newSourcePatient = myPatientDao.read(sourcePatientId);
@ -67,7 +67,7 @@ public class EmpiLinkSvcTest extends BaseEmpiR4Test {
} }
{ {
myEmpiLinkSvc.updateLink(sourcePatient, patient, EmpiMatchOutcome.NO_MATCH, EmpiLinkSourceEnum.MANUAL, createContextForCreate("Patient")); myEmpiLinkSvc.updateLink(goldenPatient, patient, EmpiMatchOutcome.NO_MATCH, EmpiLinkSourceEnum.MANUAL, createContextForCreate("Patient"));
assertLinkCount(1); assertLinkCount(1);
// TODO NG should be ok to remove // TODO NG should be ok to remove
// Patient newSourcePatient = myPatientDao.read(sourcePatientId); // Patient newSourcePatient = myPatientDao.read(sourcePatientId);
@ -79,52 +79,52 @@ public class EmpiLinkSvcTest extends BaseEmpiR4Test {
@Test @Test
public void testPossibleDuplicate() { public void testPossibleDuplicate() {
assertLinkCount(0); assertLinkCount(0);
Patient sourcePatient1 = createGoldenPatient(); Patient goldenPatient1 = createGoldenPatient();
Patient sourcePatient2 = createGoldenPatient(); Patient goldenPatient2 = createGoldenPatient();
// TODO GGG MDM NOT VALID // TODO GGG MDM NOT VALID
myEmpiLinkSvc.updateLink(sourcePatient1, sourcePatient2, EmpiMatchOutcome.POSSIBLE_DUPLICATE, EmpiLinkSourceEnum.AUTO, createContextForCreate("Patient")); myEmpiLinkSvc.updateLink(goldenPatient1, goldenPatient2, EmpiMatchOutcome.POSSIBLE_DUPLICATE, EmpiLinkSourceEnum.AUTO, createContextForCreate("Patient"));
assertLinkCount(1); assertLinkCount(1);
} }
@Test @Test
public void testNoMatchBlocksPossibleDuplicate() { public void testNoMatchBlocksPossibleDuplicate() {
assertLinkCount(0); assertLinkCount(0);
Patient sourcePatient1 = createGoldenPatient(); Patient goldenPatient1 = createGoldenPatient();
Patient sourcePatient2 = createGoldenPatient(); Patient goldenPatient2 = createGoldenPatient();
Long sourcePatient1Pid = myIdHelperService.getPidOrNull(sourcePatient1); Long goldenPatient1Pid = myIdHelperService.getPidOrNull(goldenPatient1);
Long sourcePatient2Pid = myIdHelperService.getPidOrNull(sourcePatient2); Long goldenPatient2Pid = myIdHelperService.getPidOrNull(goldenPatient2);
assertFalse(myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(sourcePatient1Pid, sourcePatient2Pid).isPresent()); assertFalse(myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(goldenPatient1Pid, goldenPatient2Pid).isPresent());
assertFalse(myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(sourcePatient2Pid, sourcePatient1Pid).isPresent()); assertFalse(myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(goldenPatient2Pid, goldenPatient1Pid).isPresent());
saveNoMatchLink(sourcePatient1Pid, sourcePatient2Pid); saveNoMatchLink(goldenPatient1Pid, goldenPatient2Pid);
myEmpiLinkSvc.updateLink(sourcePatient1, sourcePatient2, EmpiMatchOutcome.POSSIBLE_DUPLICATE, EmpiLinkSourceEnum.AUTO, createContextForCreate("Person")); myEmpiLinkSvc.updateLink(goldenPatient1, goldenPatient2, EmpiMatchOutcome.POSSIBLE_DUPLICATE, EmpiLinkSourceEnum.AUTO, createContextForCreate("Person"));
assertFalse(myEmpiLinkDaoSvc.getEmpiLinksByPersonPidTargetPidAndMatchResult(sourcePatient1Pid, sourcePatient2Pid, EmpiMatchResultEnum.POSSIBLE_DUPLICATE).isPresent()); assertFalse(myEmpiLinkDaoSvc.getEmpiLinksByPersonPidTargetPidAndMatchResult(goldenPatient1Pid, goldenPatient2Pid, EmpiMatchResultEnum.POSSIBLE_DUPLICATE).isPresent());
assertLinkCount(1); assertLinkCount(1);
} }
@Test @Test
public void testNoMatchBlocksPossibleDuplicateReversed() { public void testNoMatchBlocksPossibleDuplicateReversed() {
assertLinkCount(0); assertLinkCount(0);
Patient sourcePatient1 = createGoldenPatient(); Patient goldenPatient1 = createGoldenPatient();
Patient sourcePatient2 = createGoldenPatient(); Patient goldenPatient2 = createGoldenPatient();
Long sourcePatient1Pid = myIdHelperService.getPidOrNull(sourcePatient1); Long goldenPatient1Pid = myIdHelperService.getPidOrNull(goldenPatient1);
Long sourcePatient2Pid = myIdHelperService.getPidOrNull(sourcePatient2); Long goldenPatient2Pid = myIdHelperService.getPidOrNull(goldenPatient2);
assertFalse(myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(sourcePatient1Pid, sourcePatient2Pid).isPresent()); assertFalse(myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(goldenPatient1Pid, goldenPatient2Pid).isPresent());
assertFalse(myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(sourcePatient2Pid, sourcePatient1Pid).isPresent()); assertFalse(myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(goldenPatient2Pid, goldenPatient1Pid).isPresent());
saveNoMatchLink(sourcePatient2Pid, sourcePatient1Pid); saveNoMatchLink(goldenPatient2Pid, goldenPatient1Pid);
myEmpiLinkSvc.updateLink(sourcePatient1, sourcePatient2, EmpiMatchOutcome.POSSIBLE_DUPLICATE, EmpiLinkSourceEnum.AUTO, createContextForCreate("Person")); myEmpiLinkSvc.updateLink(goldenPatient1, goldenPatient2, EmpiMatchOutcome.POSSIBLE_DUPLICATE, EmpiLinkSourceEnum.AUTO, createContextForCreate("Person"));
assertFalse(myEmpiLinkDaoSvc.getEmpiLinksByPersonPidTargetPidAndMatchResult(sourcePatient1Pid, sourcePatient2Pid, EmpiMatchResultEnum.POSSIBLE_DUPLICATE).isPresent()); assertFalse(myEmpiLinkDaoSvc.getEmpiLinksByPersonPidTargetPidAndMatchResult(goldenPatient1Pid, goldenPatient2Pid, EmpiMatchResultEnum.POSSIBLE_DUPLICATE).isPresent());
assertLinkCount(1); assertLinkCount(1);
} }
private void saveNoMatchLink(Long thePersonPid, Long theTargetPid) { private void saveNoMatchLink(Long theGoldenResourcePid, Long theTargetPid) {
EmpiLink noMatchLink = myEmpiLinkDaoSvc.newEmpiLink() EmpiLink noMatchLink = myEmpiLinkDaoSvc.newEmpiLink()
.setGoldenResourcePid(thePersonPid) .setGoldenResourcePid(theGoldenResourcePid)
.setTargetPid(theTargetPid) .setTargetPid(theTargetPid)
.setLinkSource(EmpiLinkSourceEnum.MANUAL) .setLinkSource(EmpiLinkSourceEnum.MANUAL)
.setMatchResult(EmpiMatchResultEnum.NO_MATCH); .setMatchResult(EmpiMatchResultEnum.NO_MATCH);
@ -133,12 +133,13 @@ public class EmpiLinkSvcTest extends BaseEmpiR4Test {
@Test @Test
public void testManualEmpiLinksCannotBeModifiedBySystem() { public void testManualEmpiLinksCannotBeModifiedBySystem() {
Patient sourcePatient = createGoldenPatient(buildJaneSourcePatient()); // Patient goldenPatient = createGoldenPatient(buildJaneSourcePatient());
Patient goldenPatient = createGoldenPatient(buildJanePatient());
Patient patient = createPatient(buildJanePatient()); Patient patient = createPatient(buildJanePatient());
myEmpiLinkSvc.updateLink(sourcePatient, patient, EmpiMatchOutcome.NO_MATCH, EmpiLinkSourceEnum.MANUAL, createContextForCreate("Patient")); myEmpiLinkSvc.updateLink(goldenPatient, patient, EmpiMatchOutcome.NO_MATCH, EmpiLinkSourceEnum.MANUAL, createContextForCreate("Patient"));
try { try {
myEmpiLinkSvc.updateLink(sourcePatient, patient, EmpiMatchOutcome.NEW_PERSON_MATCH, EmpiLinkSourceEnum.AUTO, null); myEmpiLinkSvc.updateLink(goldenPatient, patient, EmpiMatchOutcome.NEW_PERSON_MATCH, EmpiLinkSourceEnum.AUTO, null);
fail(); fail();
} catch (InternalErrorException e) { } catch (InternalErrorException e) {
assertThat(e.getMessage(), is(equalTo("EMPI system is not allowed to modify links on manually created links"))); assertThat(e.getMessage(), is(equalTo("EMPI system is not allowed to modify links on manually created links")));
@ -147,13 +148,13 @@ public class EmpiLinkSvcTest extends BaseEmpiR4Test {
@Test @Test
public void testAutomaticallyAddedNO_MATCHEmpiLinksAreNotAllowed() { public void testAutomaticallyAddedNO_MATCHEmpiLinksAreNotAllowed() {
// Patient sourcePatient = createGoldenPatient(buildJaneSourcePatient()); // Patient goldenPatient = createGoldenPatient(buildJaneSourcePatient());
Patient sourcePatient = createGoldenPatient(buildJanePatient()); Patient goldenPatient = createGoldenPatient(buildJanePatient());
Patient patient = createPatient(buildJanePatient()); Patient patient = createPatient(buildJanePatient());
// Test: it should be impossible to have a AUTO NO_MATCH record. The only NO_MATCH records in the system must be MANUAL. // Test: it should be impossible to have a AUTO NO_MATCH record. The only NO_MATCH records in the system must be MANUAL.
try { try {
myEmpiLinkSvc.updateLink(sourcePatient, patient, EmpiMatchOutcome.NO_MATCH, EmpiLinkSourceEnum.AUTO, createContextForUpdate("Patient")); myEmpiLinkSvc.updateLink(goldenPatient, patient, EmpiMatchOutcome.NO_MATCH, EmpiLinkSourceEnum.AUTO, createContextForUpdate("Patient"));
fail(); fail();
} catch (InternalErrorException e) { } catch (InternalErrorException e) {
assertThat(e.getMessage(), is(equalTo("EMPI system is not allowed to automatically NO_MATCH a resource"))); assertThat(e.getMessage(), is(equalTo("EMPI system is not allowed to automatically NO_MATCH a resource")));