links = myMdmLinkDao.findAll();
assertEquals(theExpectedValues.length, links.size());
for (int i = 0; i < links.size(); ++i) {
assertEquals(theExpectedValues[i], theAccessor.apply(links.get(i)), "Value at index " + i + " was not equal");
@@ -524,7 +530,7 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
protected void printLinks() {
- myEmpiLinkDao.findAll().forEach(empiLink -> {
+ myMdmLinkDao.findAll().forEach(empiLink -> {
ourLog.info(String.valueOf(empiLink));
});
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/config/BaseTestEmpiConfig.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/config/BaseTestMdmConfig.java
similarity index 65%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/config/BaseTestEmpiConfig.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/config/BaseTestMdmConfig.java
index 2eeebefc5e9..2258e851d65 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/config/BaseTestEmpiConfig.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/config/BaseTestMdmConfig.java
@@ -1,9 +1,9 @@
-package ca.uhn.fhir.jpa.empi.config;
+package ca.uhn.fhir.jpa.mdm.config;
-import ca.uhn.fhir.empi.api.IEmpiSettings;
-import ca.uhn.fhir.empi.rules.config.EmpiRuleValidator;
-import ca.uhn.fhir.empi.rules.config.EmpiSettings;
-import ca.uhn.fhir.jpa.empi.helper.EmpiLinkHelper;
+import ca.uhn.fhir.mdm.api.IMdmSettings;
+import ca.uhn.fhir.mdm.rules.config.MdmRuleValidator;
+import ca.uhn.fhir.mdm.rules.config.MdmSettings;
+import ca.uhn.fhir.jpa.mdm.helper.MdmLinkHelper;
import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Value;
@@ -15,7 +15,7 @@ import org.springframework.core.io.Resource;
import java.io.IOException;
@Configuration
-public abstract class BaseTestEmpiConfig {
+public abstract class BaseTestMdmConfig {
@Value("${empi.prevent_eid_updates:true}")
boolean myPreventEidUpdates;
@@ -24,11 +24,11 @@ public abstract class BaseTestEmpiConfig {
boolean myPreventMultipleEids;
@Bean
- IEmpiSettings empiSettings(EmpiRuleValidator theEmpiRuleValidator) throws IOException {
+ IMdmSettings mdmSettings(MdmRuleValidator theMdmRuleValidator) throws IOException {
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
Resource resource = resourceLoader.getResource("empi/empi-rules.json");
String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8);
- return new EmpiSettings(theEmpiRuleValidator)
+ return new MdmSettings(theMdmRuleValidator)
.setEnabled(false)
.setScriptText(json)
.setPreventEidUpdates(myPreventEidUpdates)
@@ -36,7 +36,7 @@ public abstract class BaseTestEmpiConfig {
}
@Bean
- EmpiLinkHelper empiLinkHelper() {
- return new EmpiLinkHelper();
+ MdmLinkHelper mdmLinkHelper() {
+ return new MdmLinkHelper();
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/config/TestEmpiConfigR4.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/config/TestMdmConfigR4.java
similarity index 75%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/config/TestEmpiConfigR4.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/config/TestMdmConfigR4.java
index 50ae0500ed6..204db38ffdd 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/config/TestEmpiConfigR4.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/config/TestMdmConfigR4.java
@@ -1,9 +1,9 @@
-package ca.uhn.fhir.jpa.empi.config;
+package ca.uhn.fhir.jpa.mdm.config;
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
import ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig;
import org.springframework.context.annotation.Import;
@Import({SubscriptionSubmitterConfig.class, SubscriptionChannelConfig.class})
-public class TestEmpiConfigR4 extends BaseTestEmpiConfig {
+public class TestMdmConfigR4 extends BaseTestMdmConfig {
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java
new file mode 100644
index 00000000000..5e054870000
--- /dev/null
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java
@@ -0,0 +1,55 @@
+package ca.uhn.fhir.jpa.mdm.dao;
+
+import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
+import ca.uhn.fhir.mdm.api.IMdmSettings;
+import ca.uhn.fhir.mdm.rules.json.MdmRulesJson;
+import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test;
+import ca.uhn.fhir.jpa.entity.MdmLink;
+import ca.uhn.fhir.jpa.util.TestUtil;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class MdmLinkDaoSvcTest extends BaseMdmR4Test {
+ @Autowired
+ MdmLinkDaoSvc myMdmLinkDaoSvc;
+ @Autowired
+ IMdmSettings myEmpiSettings;
+
+ @Test
+ public void testCreate() {
+ MdmLink mdmLink = createResourcesAndBuildTestMDMLink();
+ assertThat(mdmLink.getCreated(), is(nullValue()));
+ assertThat(mdmLink.getUpdated(), is(nullValue()));
+ myMdmLinkDaoSvc.save(mdmLink);
+ assertThat(mdmLink.getCreated(), is(notNullValue()));
+ assertThat(mdmLink.getUpdated(), is(notNullValue()));
+ assertTrue(mdmLink.getUpdated().getTime() - mdmLink.getCreated().getTime() < 1000);
+ }
+
+ @Test
+ public void testUpdate() {
+ MdmLink createdLink = myMdmLinkDaoSvc.save(createResourcesAndBuildTestMDMLink());
+ assertThat(createdLink.getLinkSource(), is(MdmLinkSourceEnum.MANUAL));
+ TestUtil.sleepOneClick();
+ createdLink.setLinkSource(MdmLinkSourceEnum.AUTO);
+ MdmLink updatedLink = myMdmLinkDaoSvc.save(createdLink);
+ assertNotEquals(updatedLink.getCreated(), updatedLink.getUpdated());
+ }
+
+ @Test
+ public void testNew() {
+ MdmLink newLink = myMdmLinkDaoSvc.newMdmLink();
+ MdmRulesJson rules = myEmpiSettings.getMdmRules();
+ assertEquals("1", rules.getVersion());
+ assertEquals(rules.getVersion(), newLink.getVersion());
+ }
+
+}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/entity/MdmEnumTest.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/entity/MdmEnumTest.java
new file mode 100644
index 00000000000..8399033ad3b
--- /dev/null
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/entity/MdmEnumTest.java
@@ -0,0 +1,20 @@
+package ca.uhn.fhir.jpa.mdm.entity;
+
+import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class MdmEnumTest {
+ @Test
+ public void empiEnumOrdinals() {
+ // This test is here to enforce that new values in these enums are always added to the end
+
+ assertEquals(6, MdmMatchResultEnum.values().length);
+ assertEquals(MdmMatchResultEnum.REDIRECT, MdmMatchResultEnum.values()[MdmMatchResultEnum.values().length - 1]);
+
+ assertEquals(2, MdmLinkSourceEnum.values().length);
+ assertEquals(MdmLinkSourceEnum.MANUAL, MdmLinkSourceEnum.values()[MdmLinkSourceEnum.values().length - 1]);
+ }
+}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/BaseEmpiHelper.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/BaseMdmHelper.java
similarity index 73%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/BaseEmpiHelper.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/BaseMdmHelper.java
index fab4e3c4895..1389c4c5ea1 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/BaseEmpiHelper.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/BaseMdmHelper.java
@@ -1,11 +1,11 @@
-package ca.uhn.fhir.jpa.empi.helper;
+package ca.uhn.fhir.jpa.mdm.helper;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.IInterceptorService;
import ca.uhn.fhir.interceptor.api.Pointcut;
-import ca.uhn.fhir.jpa.empi.broker.EmpiQueueConsumerLoader;
-import ca.uhn.fhir.jpa.empi.config.EmpiSubscriptionLoader;
+import ca.uhn.fhir.jpa.mdm.broker.MdmQueueConsumerLoader;
+import ca.uhn.fhir.jpa.mdm.config.MdmSubscriptionLoader;
import ca.uhn.fhir.jpa.subscription.channel.impl.LinkedBlockingChannel;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
@@ -27,21 +27,21 @@ import static org.mockito.Mockito.when;
/**
* How to use this Rule:
*
- * This rule is to be used whenever you want to have the EmpiInterceptor loaded, and be able
- * to execute creates/updates/deletes while being assured that all EMPI work has been done before exiting.
+ * This rule is to be used whenever you want to have the MdmInterceptor loaded, and be able
+ * to execute creates/updates/deletes while being assured that all MDM work has been done before exiting.
* Provides two types of method:
*
- * 1. doUpdate/doCreate. These methods do not wait for Asynchronous EMPI work to be done. Use these when you are expecting
+ * 1. doUpdate/doCreate. These methods do not wait for Asynchronous MDM work to be done. Use these when you are expecting
* the calls to fail, as those hooks will never be called.
*
- * 2. createWithLatch/updateWithLatch. These methods will await the EMPI hooks, which are only triggered post-EMPI processing
- * You should use these when you are expecting successful processing of the resource, and need to wait for async EMPI linking
+ * 2. createWithLatch/updateWithLatch. These methods will await the MDM hooks, which are only triggered post-MDM processing
+ * You should use these when you are expecting successful processing of the resource, and need to wait for async MDM linking
* work to be done.
*
* Note: all create/update functions take an optional isExternalHttpRequest boolean, to make it appear as though the request's
* origin is an HTTP request.
*/
-public abstract class BaseEmpiHelper implements BeforeEachCallback, AfterEachCallback {
+public abstract class BaseMdmHelper implements BeforeEachCallback, AfterEachCallback {
@Mock
protected ServletRequestDetails myMockSrd;
@Mock
@@ -50,15 +50,15 @@ public abstract class BaseEmpiHelper implements BeforeEachCallback, AfterEachCal
protected RestfulServer myMockRestfulServer;
@Mock
protected FhirContext myMockFhirContext;
- protected PointcutLatch myAfterEmpiLatch = new PointcutLatch(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED);
+ protected PointcutLatch myAfterMdmLatch = new PointcutLatch(Pointcut.MDM_AFTER_PERSISTED_RESOURCE_CHECKED);
@Autowired
- EmpiQueueConsumerLoader myEmpiQueueConsumerLoader;
+ MdmQueueConsumerLoader myMdmQueueConsumerLoader;
@Autowired
SubscriptionRegistry mySubscriptionRegistry;
@Autowired
SubscriptionLoader mySubscriptionLoader;
@Autowired
- EmpiSubscriptionLoader myEmpiSubscriptionLoader;
+ MdmSubscriptionLoader myMdmSubscriptionLoader;
@Mock
private IInterceptorBroadcaster myMockInterceptorBroadcaster;
@Autowired
@@ -66,9 +66,9 @@ public abstract class BaseEmpiHelper implements BeforeEachCallback, AfterEachCal
@Override
public void afterEach(ExtensionContext context) throws Exception {
- myInterceptorService.unregisterInterceptor(myAfterEmpiLatch);
- myAfterEmpiLatch.clear();
- waitUntilEmpiQueueIsEmpty();
+ myInterceptorService.unregisterInterceptor(myAfterMdmLatch);
+ myAfterMdmLatch.clear();
+ waitUntilMdmQueueIsEmpty();
}
@Override
@@ -83,11 +83,11 @@ public abstract class BaseEmpiHelper implements BeforeEachCallback, AfterEachCal
when(myMockRestfulServer.getFhirContext()).thenReturn(myMockFhirContext);
//This sets up our basic interceptor, and also attached the latch so we can await the hook calls.
- myInterceptorService.registerAnonymousInterceptor(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED, myAfterEmpiLatch);
+ myInterceptorService.registerAnonymousInterceptor(Pointcut.MDM_AFTER_PERSISTED_RESOURCE_CHECKED, myAfterMdmLatch);
// We need to call this because subscriptions will get deleted in @After cleanup
waitForActivatedSubscriptionCount(0);
- myEmpiSubscriptionLoader.daoUpdateEmpiSubscriptions();
+ myMdmSubscriptionLoader.daoUpdateMdmSubscriptions();
mySubscriptionLoader.syncSubscriptions();
waitForActivatedSubscriptionCount(2);
}
@@ -97,12 +97,12 @@ public abstract class BaseEmpiHelper implements BeforeEachCallback, AfterEachCal
await("Active Subscription Count has reached " + theSize).until(() -> mySubscriptionRegistry.size() >= theSize);
}
- private void waitUntilEmpiQueueIsEmpty() {
+ private void waitUntilMdmQueueIsEmpty() {
await().until(() -> getExecutorQueueSize() == 0);
}
public int getExecutorQueueSize() {
- LinkedBlockingChannel channel = (LinkedBlockingChannel) myEmpiQueueConsumerLoader.getEmpiChannelForUnitTest();
+ LinkedBlockingChannel channel = (LinkedBlockingChannel) myMdmQueueConsumerLoader.getMdmChannelForUnitTest();
return channel.getQueueSizeForUnitTest();
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/EmpiHelperConfig.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmHelperConfig.java
similarity index 63%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/EmpiHelperConfig.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmHelperConfig.java
index 8e9a91e1c56..69184bcdb85 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/EmpiHelperConfig.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmHelperConfig.java
@@ -1,8 +1,8 @@
-package ca.uhn.fhir.jpa.empi.helper;
+package ca.uhn.fhir.jpa.mdm.helper;
-import ca.uhn.fhir.empi.api.IEmpiSettings;
-import ca.uhn.fhir.empi.rules.config.EmpiRuleValidator;
-import ca.uhn.fhir.empi.rules.config.EmpiSettings;
+import ca.uhn.fhir.mdm.api.IMdmSettings;
+import ca.uhn.fhir.mdm.rules.config.MdmRuleValidator;
+import ca.uhn.fhir.mdm.rules.config.MdmSettings;
import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Value;
@@ -13,27 +13,27 @@ import org.springframework.core.io.Resource;
import java.io.IOException;
-public class EmpiHelperConfig {
+public class MdmHelperConfig {
@Bean
- public EmpiHelperR4 empiHelperR4() {
- return new EmpiHelperR4();
+ public MdmHelperR4 mdmHelperR4() {
+ return new MdmHelperR4();
}
- @Value("${empi.prevent_eid_updates:false}")
+ @Value("${mdm.prevent_eid_updates:false}")
boolean myPreventEidUpdates;
- @Value("${empi.prevent_multiple_eids:true}")
+ @Value("${mdm.prevent_multiple_eids:true}")
boolean myPreventMultipleEids;
@Primary
@Bean
- IEmpiSettings empiSettings(EmpiRuleValidator theEmpiRuleValidator) throws IOException {
+ IMdmSettings empiSettings(MdmRuleValidator theMdmRuleValidator) throws IOException {
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
Resource resource = resourceLoader.getResource("empi/empi-rules.json");
String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8);
// Set Enabled to true, and set strict mode.
- return new EmpiSettings(theEmpiRuleValidator)
+ return new MdmSettings(theMdmRuleValidator)
.setEnabled(true)
.setScriptText(json)
.setPreventEidUpdates(myPreventEidUpdates)
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/EmpiHelperR4.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmHelperR4.java
similarity index 87%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/EmpiHelperR4.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmHelperR4.java
index 9e7a3f19c00..86e47a7b1fb 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/helper/EmpiHelperR4.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmHelperR4.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.empi.helper;
+package ca.uhn.fhir.jpa.mdm.helper;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
@@ -8,7 +8,7 @@ import ca.uhn.fhir.rest.server.TransactionLogMessages;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.beans.factory.annotation.Autowired;
-public class EmpiHelperR4 extends BaseEmpiHelper {
+public class MdmHelperR4 extends BaseMdmHelper {
@Autowired
private FhirContext myFhirContext;
@Autowired
@@ -19,10 +19,10 @@ public class EmpiHelperR4 extends BaseEmpiHelper {
}
public OutcomeAndLogMessageWrapper createWithLatch(IBaseResource theBaseResource, boolean isExternalHttpRequest) throws InterruptedException {
- myAfterEmpiLatch.setExpectedCount(1);
+ myAfterMdmLatch.setExpectedCount(1);
DaoMethodOutcome daoMethodOutcome = doCreateResource(theBaseResource, isExternalHttpRequest);
- myAfterEmpiLatch.awaitExpected();
- return new OutcomeAndLogMessageWrapper(daoMethodOutcome, myAfterEmpiLatch.getLatchInvocationParameterOfType(TransactionLogMessages.class));
+ myAfterMdmLatch.awaitExpected();
+ return new OutcomeAndLogMessageWrapper(daoMethodOutcome, myAfterMdmLatch.getLatchInvocationParameterOfType(TransactionLogMessages.class));
}
public OutcomeAndLogMessageWrapper updateWithLatch(IBaseResource theIBaseResource) throws InterruptedException {
@@ -30,10 +30,10 @@ public class EmpiHelperR4 extends BaseEmpiHelper {
}
public OutcomeAndLogMessageWrapper updateWithLatch(IBaseResource theIBaseResource, boolean isExternalHttpRequest) throws InterruptedException {
- myAfterEmpiLatch.setExpectedCount(1);
+ myAfterMdmLatch.setExpectedCount(1);
DaoMethodOutcome daoMethodOutcome = doUpdateResource(theIBaseResource, isExternalHttpRequest);
- myAfterEmpiLatch.awaitExpected();
- return new OutcomeAndLogMessageWrapper(daoMethodOutcome, myAfterEmpiLatch.getLatchInvocationParameterOfType(TransactionLogMessages.class));
+ myAfterMdmLatch.awaitExpected();
+ return new OutcomeAndLogMessageWrapper(daoMethodOutcome, myAfterMdmLatch.getLatchInvocationParameterOfType(TransactionLogMessages.class));
}
public DaoMethodOutcome doCreateResource(IBaseResource theResource, boolean isExternalHttpRequest) {
@@ -52,7 +52,7 @@ public class EmpiHelperR4 extends BaseEmpiHelper {
/**
* OutcomeAndLogMessageWrapper is a simple wrapper class which is _excellent_. It allows us to skip the fact that java doesn't allow
* multiple returns, and wraps both the Method Outcome of the DAO, _and_ the TransactionLogMessages that were passed to the pointcut
- * by the EMPI module.
+ * by the MDM module.
*/
public class OutcomeAndLogMessageWrapper {
DaoMethodOutcome myDaoMethodOutcome;
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmLinkHelper.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmLinkHelper.java
new file mode 100644
index 00000000000..b479fd5192e
--- /dev/null
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmLinkHelper.java
@@ -0,0 +1,31 @@
+package ca.uhn.fhir.jpa.mdm.helper;
+
+import ca.uhn.fhir.jpa.dao.data.IMdmLinkDao;
+import ca.uhn.fhir.jpa.entity.MdmLink;
+import ca.uhn.fhir.model.primitive.IdDt;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+@Service
+public class MdmLinkHelper {
+ private static final Logger ourLog = LoggerFactory.getLogger(MdmLinkHelper.class);
+
+ @Autowired
+ IMdmLinkDao myMdmLinkDao;
+
+ @Transactional
+ public void logMdmLinks() {
+ List links = myMdmLinkDao.findAll();
+ ourLog.info("All MDM Links:");
+ for (MdmLink link : links) {
+ IdDt goldenResourceId = link.getGoldenResource().getIdDt().toVersionless();
+ IdDt targetId = link.getTarget().getIdDt().toVersionless();
+ ourLog.info("{}: {}, {}, {}, {}", link.getId(), goldenResourceId, targetId, link.getMatchResult(), link.getLinkSource());
+ }
+ }
+}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/interceptor/EmpiExpungeTest.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmExpungeTest.java
similarity index 71%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/interceptor/EmpiExpungeTest.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmExpungeTest.java
index ff2b74163ac..e7925fdca33 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/interceptor/EmpiExpungeTest.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmExpungeTest.java
@@ -1,14 +1,13 @@
-package ca.uhn.fhir.jpa.empi.interceptor;
+package ca.uhn.fhir.jpa.mdm.interceptor;
-import ca.uhn.fhir.empi.api.EmpiLinkSourceEnum;
-import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
import ca.uhn.fhir.interceptor.api.IInterceptorService;
import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.api.model.ExpungeOptions;
-import ca.uhn.fhir.jpa.dao.data.IEmpiLinkDao;
-import ca.uhn.fhir.jpa.empi.BaseEmpiR4Test;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.jpa.entity.MdmLink;
+import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test;
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
+import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import org.hl7.fhir.r4.model.Patient;
@@ -22,16 +21,14 @@ import static org.hamcrest.core.StringContains.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
-public class EmpiExpungeTest extends BaseEmpiR4Test {
+public class MdmExpungeTest extends BaseMdmR4Test {
@Autowired
IInterceptorService myInterceptorService;
@Autowired
- IEmpiStorageInterceptor myEmpiStorageInterceptor;
+ IMdmStorageInterceptor myEmpiStorageInterceptor;
@Autowired
DaoConfig myDaoConfig;
- @Autowired
- IEmpiLinkDao myEmpiLinkDao;
private ResourceTable myTargetEntity;
private ResourceTable mySourceEntity;
private IdDt myTargetId;
@@ -44,19 +41,19 @@ public class EmpiExpungeTest extends BaseEmpiR4Test {
myTargetId = myTargetEntity.getIdDt().toVersionless();
mySourceEntity = (ResourceTable) myPatientDao.create(new Patient()).getEntity();
- EmpiLink empiLink = myEmpiLinkDaoSvc.newEmpiLink();
- empiLink.setLinkSource(EmpiLinkSourceEnum.MANUAL);
- empiLink.setMatchResult(EmpiMatchResultEnum.MATCH);
- empiLink.setGoldenResourcePid(mySourceEntity.getId());
- empiLink.setTargetPid(myTargetEntity.getId());
- saveLink(empiLink);
+ MdmLink mdmLink = myMdmLinkDaoSvc.newMdmLink();
+ mdmLink.setLinkSource(MdmLinkSourceEnum.MANUAL);
+ mdmLink.setMatchResult(MdmMatchResultEnum.MATCH);
+ mdmLink.setGoldenResourcePid(mySourceEntity.getId());
+ mdmLink.setTargetPid(myTargetEntity.getId());
+ saveLink(mdmLink);
}
@Test
public void testUninterceptedDeleteRemovesEMPIReference() {
- assertEquals(1, myEmpiLinkDao.count());
+ assertEquals(1, myMdmLinkDao.count());
myPatientDao.delete(myTargetEntity.getIdDt());
- assertEquals(1, myEmpiLinkDao.count());
+ assertEquals(1, myMdmLinkDao.count());
ExpungeOptions expungeOptions = new ExpungeOptions();
expungeOptions.setExpungeDeletedResources(true);
try {
@@ -68,7 +65,7 @@ public class EmpiExpungeTest extends BaseEmpiR4Test {
}
myInterceptorService.registerInterceptor(myEmpiStorageInterceptor);
myPatientDao.expunge(myTargetId.toVersionless(), expungeOptions, null);
- assertEquals(0, myEmpiLinkDao.count());
+ assertEquals(0, myMdmLinkDao.count());
}
@AfterEach
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/interceptor/EmpiStorageInterceptorIT.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptorIT.java
similarity index 55%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/interceptor/EmpiStorageInterceptorIT.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptorIT.java
index 410954913d2..8af880b5ffe 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/interceptor/EmpiStorageInterceptorIT.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptorIT.java
@@ -1,14 +1,13 @@
-package ca.uhn.fhir.jpa.empi.interceptor;
+package ca.uhn.fhir.jpa.mdm.interceptor;
-import ca.uhn.fhir.empi.model.CanonicalEID;
-import ca.uhn.fhir.empi.rules.config.EmpiSettings;
+import ca.uhn.fhir.mdm.model.CanonicalEID;
+import ca.uhn.fhir.mdm.rules.config.MdmSettings;
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
-import ca.uhn.fhir.jpa.empi.BaseEmpiR4Test;
-import ca.uhn.fhir.jpa.empi.helper.EmpiHelperConfig;
-import ca.uhn.fhir.jpa.empi.helper.EmpiHelperR4;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
-import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
+import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test;
+import ca.uhn.fhir.jpa.mdm.helper.MdmHelperConfig;
+import ca.uhn.fhir.jpa.mdm.helper.MdmHelperR4;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
import ca.uhn.fhir.rest.server.TransactionLogMessages;
@@ -17,6 +16,7 @@ import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.Enumerations;
+import org.hl7.fhir.r4.model.Medication;
import org.hl7.fhir.r4.model.Organization;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person;
@@ -32,11 +32,15 @@ import org.springframework.test.context.ContextConfiguration;
import java.util.Date;
import java.util.List;
-import static ca.uhn.fhir.empi.api.EmpiConstants.CODE_HAPI_MDM_MANAGED;
-import static ca.uhn.fhir.empi.api.EmpiConstants.SYSTEM_MDM_MANAGED;
+import static ca.uhn.fhir.mdm.api.MdmConstants.CODE_GOLDEN_RECORD;
+import static ca.uhn.fhir.mdm.api.MdmConstants.CODE_GOLDEN_RECORD_REDIRECTED;
+import static ca.uhn.fhir.mdm.api.MdmConstants.CODE_HAPI_MDM_MANAGED;
+import static ca.uhn.fhir.mdm.api.MdmConstants.SYSTEM_GOLDEN_RECORD_STATUS;
+import static ca.uhn.fhir.mdm.api.MdmConstants.SYSTEM_MDM_MANAGED;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.nullValue;
@@ -46,31 +50,31 @@ import static org.junit.jupiter.api.Assertions.fail;
import static org.slf4j.LoggerFactory.getLogger;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
-@ContextConfiguration(classes = {EmpiHelperConfig.class})
-public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
+@ContextConfiguration(classes = {MdmHelperConfig.class})
+public class MdmStorageInterceptorIT extends BaseMdmR4Test {
- private static final Logger ourLog = getLogger(EmpiStorageInterceptorIT.class);
+ private static final Logger ourLog = getLogger(MdmStorageInterceptorIT.class);
@RegisterExtension
@Autowired
- public EmpiHelperR4 myEmpiHelper;
+ public MdmHelperR4 myMdmHelper;
@Autowired
private IdHelperService myIdHelperService;
@BeforeEach
public void before() {
- super.loadEmpiSearchParameters();
+ super.loadMdmSearchParameters();
}
@Test
public void testCreatePractitioner() throws InterruptedException {
- myEmpiHelper.createWithLatch(buildPractitionerWithNameAndId("somename", "some_id"));
+ myMdmHelper.createWithLatch(buildPractitionerWithNameAndId("somename", "some_id"));
assertLinkCount(1);
}
@Test
public void testDeletePersonDeletesLinks() throws InterruptedException {
- myEmpiHelper.createWithLatch(buildPaulPatient());
+ myMdmHelper.createWithLatch(buildPaulPatient());
assertLinkCount(1);
Patient sourcePatient = getOnlyGoldenPatient();
myPatientDao.delete(sourcePatient.getIdElement());
@@ -78,64 +82,88 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
}
@Test
- public void testCreatePersonWithEmpiTagForbidden() throws InterruptedException {
- //Creating a person with the EMPI-MANAGED tag should fail
- Person person = new Person();
- person.getMeta().addTag(SYSTEM_MDM_MANAGED, CODE_HAPI_MDM_MANAGED, "User is managed by EMPI");
+ public void testCreatePatientWithMdmTagForbidden() throws InterruptedException {
+ //Creating a person with the MDM-MANAGED tag should fail
+ Patient patient = new Patient();
+ patient.getMeta().addTag(SYSTEM_MDM_MANAGED, CODE_HAPI_MDM_MANAGED, "User is managed by MDM");
try {
- myEmpiHelper.doCreateResource(person, true);
+ myMdmHelper.doCreateResource(patient, true);
fail();
} catch (ForbiddenOperationException e) {
- assertEquals("Cannot create or modify Resources that are managed by EMPI.", e.getMessage());
+ assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM."));
}
}
@Test
- public void testCreatingPersonWithInsufficentEMPIAttributesIsNotEMPIProcessed() throws InterruptedException {
- myEmpiHelper.doCreateResource(new Patient(), true);
+ public void testCreatePatientWithGoldenRecordTagForbidden() throws InterruptedException {
+ Patient patient = new Patient();
+ patient.getMeta().addTag(SYSTEM_GOLDEN_RECORD_STATUS, CODE_GOLDEN_RECORD, "Golden Record");
+ try {
+ myMdmHelper.doCreateResource(patient, true);
+ fail();
+ } catch (ForbiddenOperationException e) {
+ assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM."));
+ }
+ }
+
+ @Test
+ public void testCreateMedicationWithGoldenRecordRedirectTagForbidden() throws InterruptedException {
+ Medication medication = new Medication();
+ medication.getMeta().addTag(SYSTEM_GOLDEN_RECORD_STATUS, CODE_GOLDEN_RECORD_REDIRECTED, "Golden Record");
+ try {
+ myMdmHelper.doCreateResource(medication, true);
+ fail();
+ } catch (ForbiddenOperationException e) {
+ assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM."));
+ }
+ }
+
+ @Test
+ public void testCreatingPersonWithInsufficentMDMAttributesIsNotMDMProcessed() throws InterruptedException {
+ myMdmHelper.doCreateResource(new Patient(), true);
assertLinkCount(0);
}
@Test
- public void testCreatingPatientWithOneOrMoreMatchingAttributesIsEMPIProcessed() throws InterruptedException {
- myEmpiHelper.createWithLatch(buildPaulPatient());
+ public void testCreatingPatientWithOneOrMoreMatchingAttributesIsMDMProcessed() throws InterruptedException {
+ myMdmHelper.createWithLatch(buildPaulPatient());
assertLinkCount(1);
}
@Test
- public void testCreateOrganizationWithEmpiTagForbidden() throws InterruptedException {
- //Creating a organization with the EMPI-MANAGED tag should fail
+ public void testCreateOrganizationWithMdmTagForbidden() throws InterruptedException {
+ //Creating a organization with the MDM-MANAGED tag should fail
Organization organization = new Organization();
- organization.getMeta().addTag(SYSTEM_MDM_MANAGED, CODE_HAPI_MDM_MANAGED, "User is managed by EMPI");
+ organization.getMeta().addTag(SYSTEM_MDM_MANAGED, CODE_HAPI_MDM_MANAGED, "User is managed by MDM");
try {
- myEmpiHelper.doCreateResource(organization, true);
+ myMdmHelper.doCreateResource(organization, true);
fail();
} catch (ForbiddenOperationException e) {
- assertEquals("Cannot create or modify Resources that are managed by EMPI.", e.getMessage());
+ assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM."));
}
}
@Test
- public void testUpdateOrganizationWithEmpiTagForbidden() throws InterruptedException {
- //Creating a organization with the EMPI-MANAGED tag should fail
+ public void testUpdateOrganizationWithMdmTagForbidden() throws InterruptedException {
+ //Creating a organization with the MDM-MANAGED tag should fail
Organization organization = new Organization();
- myEmpiHelper.doCreateResource(organization, true);
- organization.getMeta().addTag(SYSTEM_MDM_MANAGED, CODE_HAPI_MDM_MANAGED, "User is managed by EMPI");
+ myMdmHelper.doCreateResource(organization, true);
+ organization.getMeta().addTag(SYSTEM_MDM_MANAGED, CODE_HAPI_MDM_MANAGED, "User is managed by MDM");
try {
- myEmpiHelper.doUpdateResource(organization, true);
+ myMdmHelper.doUpdateResource(organization, true);
fail();
} catch (ForbiddenOperationException e) {
- assertEquals("The HAPI-EMPI tag on a resource may not be changed once created.", e.getMessage());
+ assertEquals("The HAPI-MDM tag on a resource may not be changed once created.", e.getMessage());
}
}
@Test
- public void testPersonRecordsManagedByEmpiAllShareSameTag() throws InterruptedException {
- myEmpiHelper.createWithLatch(buildJanePatient());
- myEmpiHelper.createWithLatch(buildPaulPatient());
+ public void testPersonRecordsManagedByMdmAllShareSameTag() throws InterruptedException {
+ myMdmHelper.createWithLatch(buildJanePatient());
+ myMdmHelper.createWithLatch(buildPaulPatient());
//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));
+ IBundleProvider search = myPatientDao.search(buildGoldenResourceSearchParameterMap());
List resources = search.getResources(0, search.size());
for (IBaseResource person : resources) {
@@ -144,46 +172,46 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
}
@Test
- public void testNonEmpiManagedPersonCannotHaveEmpiManagedTagAddedToThem() {
+ public void testNonMdmManagedPersonCannotHaveMdmManagedTagAddedToThem() {
//Person created manually.
Person person = new Person();
- DaoMethodOutcome daoMethodOutcome = myEmpiHelper.doCreateResource(person, true);
+ DaoMethodOutcome daoMethodOutcome = myMdmHelper.doCreateResource(person, true);
assertNotNull(daoMethodOutcome.getId());
- //Updating that person to set them as EMPI managed is not allowed.
+ //Updating that person to set them as MDM managed is not allowed.
person.getMeta().addTag(SYSTEM_MDM_MANAGED, CODE_HAPI_MDM_MANAGED, "User is managed by EMPI");
try {
- myEmpiHelper.doUpdateResource(person, true);
+ myMdmHelper.doUpdateResource(person, true);
fail();
} catch (ForbiddenOperationException e) {
- assertEquals("The HAPI-EMPI tag on a resource may not be changed once created.", e.getMessage());
+ assertEquals("The HAPI-MDM tag on a resource may not be changed once created.", e.getMessage());
}
}
@Test
- public void testEmpiManagedPersonCannotBeModifiedByPersonUpdateRequest() throws InterruptedException {
+ public void testMdmManagedPersonCannotBeModifiedByPersonUpdateRequest() throws InterruptedException {
// When EMPI is enabled, only the EMPI system is allowed to modify Person links of Persons with the EMPI-MANAGED tag.
Patient patient = new Patient();
- IIdType patientId = myEmpiHelper.createWithLatch(buildPaulPatient()).getDaoMethodOutcome().getId().toUnqualifiedVersionless();
+ IIdType patientId = myMdmHelper.createWithLatch(buildPaulPatient()).getDaoMethodOutcome().getId().toUnqualifiedVersionless();
patient.setId(patientId);
//Updating a Person who was created via EMPI should fail.
- EmpiLink empiLink = myEmpiLinkDaoSvc.getMatchedLinkForTargetPid(myIdHelperService.getPidOrNull(patient)).get();
- Long sourcePatientPid = empiLink.getSourceResourcePid();
+ MdmLink mdmLink = myMdmLinkDaoSvc.getMatchedLinkForTargetPid(myIdHelperService.getPidOrNull(patient)).get();
+ Long sourcePatientPid = mdmLink.getGoldenResourcePid();
Patient empiSourcePatient = (Patient) myPatientDao.readByPid(new ResourcePersistentId(sourcePatientPid));
empiSourcePatient.setGender(Enumerations.AdministrativeGender.MALE);
try {
- myEmpiHelper.doUpdateResource(empiSourcePatient, true);
+ myMdmHelper.doUpdateResource(empiSourcePatient, true);
fail();
} catch (ForbiddenOperationException e) {
- assertEquals("Cannot create or modify Resources that are managed by EMPI.", e.getMessage());
+ assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM."));
}
}
@Test
- public void testEmpiPointcutReceivesTransactionLogMessages() throws InterruptedException {
- EmpiHelperR4.OutcomeAndLogMessageWrapper wrapper = myEmpiHelper.createWithLatch(buildJanePatient());
+ public void testMdmPointcutReceivesTransactionLogMessages() throws InterruptedException {
+ MdmHelperR4.OutcomeAndLogMessageWrapper wrapper = myMdmHelper.createWithLatch(buildJanePatient());
TransactionLogMessages empiTransactionLogMessages = wrapper.getLogMessages();
@@ -197,12 +225,12 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
@Test
public void testWhenASingularPatientUpdatesExternalEidThatPersonEidIsUpdated() throws InterruptedException {
Patient jane = addExternalEID(buildJanePatient(), "some_eid");
- EmpiHelperR4.OutcomeAndLogMessageWrapper latch = myEmpiHelper.createWithLatch(jane);
+ MdmHelperR4.OutcomeAndLogMessageWrapper latch = myMdmHelper.createWithLatch(jane);
jane.setId(latch.getDaoMethodOutcome().getId());
clearExternalEIDs(jane);
jane = addExternalEID(jane, "some_new_eid");
- EmpiHelperR4.OutcomeAndLogMessageWrapper outcomeWrapper = myEmpiHelper.updateWithLatch(jane);
+ MdmHelperR4.OutcomeAndLogMessageWrapper outcomeWrapper = myMdmHelper.updateWithLatch(jane);
IAnyResource person = getGoldenResourceFromTargetResource(jane);
List externalEids = myEIDHelper.getExternalEid(person);
assertThat(externalEids, hasSize(1));
@@ -213,12 +241,12 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
public void testWhenEidUpdatesAreDisabledForbidsUpdatesToEidsOnTargets() throws InterruptedException {
setPreventEidUpdates(true);
Patient jane = addExternalEID(buildJanePatient(), "some_eid");
- EmpiHelperR4.OutcomeAndLogMessageWrapper latch = myEmpiHelper.createWithLatch(jane);
+ MdmHelperR4.OutcomeAndLogMessageWrapper latch = myMdmHelper.createWithLatch(jane);
jane.setId(latch.getDaoMethodOutcome().getId());
clearExternalEIDs(jane);
jane = addExternalEID(jane, "some_new_eid");
try {
- myEmpiHelper.doUpdateResource(jane, true);
+ myMdmHelper.doUpdateResource(jane, true);
fail();
} catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), is(equalTo("While running with EID updates disabled, EIDs may not be updated on Patient/Practitioner resources")));
@@ -233,7 +261,7 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
addExternalEID(patient, "123");
addExternalEID(patient, "456");
try {
- myEmpiHelper.doCreateResource(patient, true);
+ myMdmHelper.doCreateResource(patient, true);
fail();
} catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), is(equalTo("While running with multiple EIDs disabled, Patient/Practitioner resources may have at most one EID.")));
@@ -243,7 +271,7 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
}
@Test
- public void testInterceptorHandlesNonEmpiResources() {
+ public void testInterceptorHandlesNonMdmResources() {
setPreventEidUpdates(true);
//Create some arbitrary resource.
@@ -256,20 +284,20 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
fooSp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
fooSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
- myEmpiHelper.doCreateResource(fooSp, true);
+ myMdmHelper.doCreateResource(fooSp, true);
fooSp.setXpathUsage(SearchParameter.XPathUsageType.PHONETIC);
- myEmpiHelper.doUpdateResource(fooSp, true);
+ myMdmHelper.doUpdateResource(fooSp, true);
}
@Test
public void testPatientsWithNoEIDCanBeUpdated() throws InterruptedException {
setPreventEidUpdates(true);
Patient p = buildPaulPatient();
- EmpiHelperR4.OutcomeAndLogMessageWrapper wrapper = myEmpiHelper.createWithLatch(p);
+ MdmHelperR4.OutcomeAndLogMessageWrapper wrapper = myMdmHelper.createWithLatch(p);
p.setId(wrapper.getDaoMethodOutcome().getId());
p.setBirthDate(new Date());
- myEmpiHelper.updateWithLatch(p);
+ myMdmHelper.updateWithLatch(p);
setPreventEidUpdates(false);
}
@@ -277,19 +305,19 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
public void testPatientsCanHaveEIDAddedInStrictMode() throws InterruptedException {
setPreventEidUpdates(true);
Patient p = buildPaulPatient();
- EmpiHelperR4.OutcomeAndLogMessageWrapper messageWrapper = myEmpiHelper.createWithLatch(p);
+ MdmHelperR4.OutcomeAndLogMessageWrapper messageWrapper = myMdmHelper.createWithLatch(p);
p.setId(messageWrapper.getDaoMethodOutcome().getId());
addExternalEID(p, "external eid");
- myEmpiHelper.updateWithLatch(p);
+ myMdmHelper.updateWithLatch(p);
setPreventEidUpdates(false);
}
private void setPreventEidUpdates(boolean thePrevent) {
- ((EmpiSettings) myEmpiConfig).setPreventEidUpdates(thePrevent);
+ ((MdmSettings) myMdmSettings).setPreventEidUpdates(thePrevent);
}
private void setPreventMultipleEids(boolean thePrevent) {
- ((EmpiSettings) myEmpiConfig).setPreventMultipleEids(thePrevent);
+ ((MdmSettings) myMdmSettings).setPreventMultipleEids(thePrevent);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/BaseSourceResourceMatcher.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/BaseSourceResourceMatcher.java
similarity index 50%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/BaseSourceResourceMatcher.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/BaseSourceResourceMatcher.java
index 3ef10370680..d66d905ccb4 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/BaseSourceResourceMatcher.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/BaseSourceResourceMatcher.java
@@ -1,11 +1,10 @@
-package ca.uhn.fhir.jpa.empi.matcher;
+package ca.uhn.fhir.jpa.mdm.matcher;
-import ca.uhn.fhir.empi.api.EmpiConstants;
-import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
-import ca.uhn.fhir.empi.util.EmpiUtil;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
+import ca.uhn.fhir.mdm.util.MdmUtil;
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
-import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import org.hamcrest.TypeSafeMatcher;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.slf4j.Logger;
@@ -22,13 +21,13 @@ public abstract class BaseSourceResourceMatcher extends TypeSafeMatcher myBaseResources;
protected String myTargetType;
- protected BaseSourceResourceMatcher(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
+ protected BaseSourceResourceMatcher(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
myIdHelperService = theIdHelperService;
- myEmpiLinkDaoSvc = theEmpiLinkDaoSvc;
+ myMdmLinkDaoSvc = theMdmLinkDaoSvc;
myBaseResources = Arrays.stream(theBaseResource).collect(Collectors.toList());
}
@@ -36,39 +35,39 @@ public abstract class BaseSourceResourceMatcher extends TypeSafeMatcher getPossibleMatchedSourceResourcePidsFromTarget(IAnyResource theBaseResource) {
- return getEmpiLinksForTarget(theBaseResource, EmpiMatchResultEnum.POSSIBLE_MATCH).stream().map(EmpiLink::getSourceResourcePid).collect(Collectors.toList());
+ return getEmpiLinksForTarget(theBaseResource, MdmMatchResultEnum.POSSIBLE_MATCH).stream().map(MdmLink::getGoldenResourcePid).collect(Collectors.toList());
}
- protected EmpiLink getMatchedEmpiLink(IAnyResource thePatientOrPractitionerResource) {
- List empiLinks = getEmpiLinksForTarget(thePatientOrPractitionerResource, EmpiMatchResultEnum.MATCH);
- if (empiLinks.size() == 0) {
+ protected MdmLink getMatchedEmpiLink(IAnyResource thePatientOrPractitionerResource) {
+ List mdmLinks = getEmpiLinksForTarget(thePatientOrPractitionerResource, MdmMatchResultEnum.MATCH);
+ if (mdmLinks.size() == 0) {
return null;
- } else if (empiLinks.size() == 1) {
- return empiLinks.get(0);
+ } else if (mdmLinks.size() == 1) {
+ return mdmLinks.get(0);
} else {
- throw new IllegalStateException("Its illegal to have more than 1 match for a given target! we found " + empiLinks.size() + " for resource with id: " + thePatientOrPractitionerResource.getIdElement().toUnqualifiedVersionless());
+ throw new IllegalStateException("Its illegal to have more than 1 match for a given target! we found " + mdmLinks.size() + " for resource with id: " + thePatientOrPractitionerResource.getIdElement().toUnqualifiedVersionless());
}
}
- protected List getEmpiLinksForTarget(IAnyResource theTargetResource, EmpiMatchResultEnum theMatchResult) {
+ protected List getEmpiLinksForTarget(IAnyResource theTargetResource, MdmMatchResultEnum theMatchResult) {
Long pidOrNull = myIdHelperService.getPidOrNull(theTargetResource);
- List matchLinkForTarget = myEmpiLinkDaoSvc.getEmpiLinksByTargetPidAndMatchResult(pidOrNull, theMatchResult);
+ List matchLinkForTarget = myMdmLinkDaoSvc.getMdmLinksByTargetPidAndMatchResult(pidOrNull, theMatchResult);
if (!matchLinkForTarget.isEmpty()) {
return matchLinkForTarget;
} else {
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsLinkedTo.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsLinkedTo.java
similarity index 73%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsLinkedTo.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsLinkedTo.java
index 6d6097a5d88..f06713f06d9 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsLinkedTo.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsLinkedTo.java
@@ -1,7 +1,7 @@
-package ca.uhn.fhir.jpa.empi.matcher;
+package ca.uhn.fhir.jpa.mdm.matcher;
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
-import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
+import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hl7.fhir.instance.model.api.IAnyResource;
@@ -19,8 +19,8 @@ public class IsLinkedTo extends BaseSourceResourceMatcher {
private List baseResourcePersonPids;
private Long incomingResourcePersonPid;
- protected IsLinkedTo(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- super(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ protected IsLinkedTo(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
@@ -42,7 +42,7 @@ public class IsLinkedTo extends BaseSourceResourceMatcher {
public void describeTo(Description theDescription) {
}
- public static Matcher linkedTo(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- return new IsLinkedTo(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ public static Matcher linkedTo(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ return new IsLinkedTo(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsMatchedToAPerson.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsMatchedToAPerson.java
similarity index 51%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsMatchedToAPerson.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsMatchedToAPerson.java
index 4d4fcd9d1e5..d4b75908ca8 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsMatchedToAPerson.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsMatchedToAPerson.java
@@ -1,8 +1,8 @@
-package ca.uhn.fhir.jpa.empi.matcher;
+package ca.uhn.fhir.jpa.mdm.matcher;
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
-import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
@@ -13,16 +13,16 @@ import java.util.Optional;
public class IsMatchedToAPerson extends TypeSafeMatcher {
private final IdHelperService myIdHelperService;
- private final EmpiLinkDaoSvc myEmpiLinkDaoSvc;
+ private final MdmLinkDaoSvc myMdmLinkDaoSvc;
- public IsMatchedToAPerson(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc) {
+ public IsMatchedToAPerson(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc) {
myIdHelperService = theIdHelperService;
- myEmpiLinkDaoSvc = theEmpiLinkDaoSvc;
+ myMdmLinkDaoSvc = theMdmLinkDaoSvc;
}
@Override
protected boolean matchesSafely(IAnyResource theIncomingResource) {
- Optional matchedLinkForTargetPid = myEmpiLinkDaoSvc.getMatchedLinkForTargetPid(myIdHelperService.getPidOrNull(theIncomingResource));
+ Optional matchedLinkForTargetPid = myMdmLinkDaoSvc.getMatchedLinkForTargetPid(myIdHelperService.getPidOrNull(theIncomingResource));
return matchedLinkForTargetPid.isPresent();
}
@@ -31,7 +31,7 @@ public class IsMatchedToAPerson extends TypeSafeMatcher {
theDescription.appendText("patient/practitioner was not linked to a Person.");
}
- public static Matcher matchedToAPerson(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc) {
- return new IsMatchedToAPerson(theIdHelperService, theEmpiLinkDaoSvc);
+ public static Matcher matchedToAGoldenResource(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc) {
+ return new IsMatchedToAPerson(theIdHelperService, theMdmLinkDaoSvc);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleDuplicateOf.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleDuplicateOf.java
similarity index 54%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleDuplicateOf.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleDuplicateOf.java
index f18cc8ba5dc..443baac8649 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleDuplicateOf.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleDuplicateOf.java
@@ -1,9 +1,9 @@
-package ca.uhn.fhir.jpa.empi.matcher;
+package ca.uhn.fhir.jpa.mdm.matcher;
-import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
-import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hl7.fhir.instance.model.api.IAnyResource;
@@ -14,13 +14,13 @@ import java.util.stream.Collectors;
public class IsPossibleDuplicateOf extends BaseSourceResourceMatcher {
/**
- * Matcher with tells us if there is an EmpiLink with between these two resources that are considered POSSIBLE DUPLICATE.
+ * Matcher with tells us if there is an MdmLink with between these two resources that are considered POSSIBLE DUPLICATE.
* For use only on persons.
*/
private Long incomingPersonPid;
- protected IsPossibleDuplicateOf(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- super(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ protected IsPossibleDuplicateOf(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
@Override
@@ -36,9 +36,9 @@ public class IsPossibleDuplicateOf extends BaseSourceResourceMatcher {
//Returns true if there is a POSSIBLE_DUPLICATE between the incoming resource, and all of the resources passed in via the constructor.
return personPidsToMatch.stream()
.map(baseResourcePid -> {
- Optional duplicateLink = myEmpiLinkDaoSvc.getEmpiLinksByPersonPidTargetPidAndMatchResult(baseResourcePid, incomingPersonPid, EmpiMatchResultEnum.POSSIBLE_DUPLICATE);
+ Optional duplicateLink = myMdmLinkDaoSvc.getMdmLinksByPersonPidTargetPidAndMatchResult(baseResourcePid, incomingPersonPid, MdmMatchResultEnum.POSSIBLE_DUPLICATE);
if (!duplicateLink.isPresent()) {
- duplicateLink = myEmpiLinkDaoSvc.getEmpiLinksByPersonPidTargetPidAndMatchResult(incomingPersonPid, baseResourcePid, EmpiMatchResultEnum.POSSIBLE_DUPLICATE);
+ duplicateLink = myMdmLinkDaoSvc.getMdmLinksByPersonPidTargetPidAndMatchResult(incomingPersonPid, baseResourcePid, MdmMatchResultEnum.POSSIBLE_DUPLICATE);
}
return duplicateLink;
}).allMatch(Optional::isPresent);
@@ -46,16 +46,16 @@ public class IsPossibleDuplicateOf extends BaseSourceResourceMatcher {
@Override
public void describeTo(Description theDescription) {
- theDescription.appendText("Person was not duplicate of Person/" + incomingPersonPid);
+ theDescription.appendText("Resource was not duplicate of Resource/" + incomingPersonPid);
}
@Override
protected void describeMismatchSafely(IAnyResource item, Description mismatchDescription) {
super.describeMismatchSafely(item, mismatchDescription);
- mismatchDescription.appendText("No Empi Link With POSSIBLE_DUPLICATE was found");
+ mismatchDescription.appendText("No MdmLink With POSSIBLE_DUPLICATE was found");
}
- public static Matcher possibleDuplicateOf(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- return new IsPossibleDuplicateOf(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ public static Matcher possibleDuplicateOf(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ return new IsPossibleDuplicateOf(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleLinkedTo.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleLinkedTo.java
similarity index 76%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleLinkedTo.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleLinkedTo.java
index 200f478529e..dbb575e578b 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleLinkedTo.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleLinkedTo.java
@@ -1,7 +1,7 @@
-package ca.uhn.fhir.jpa.empi.matcher;
+package ca.uhn.fhir.jpa.mdm.matcher;
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
-import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
+import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hl7.fhir.instance.model.api.IAnyResource;
@@ -19,8 +19,8 @@ public class IsPossibleLinkedTo extends BaseSourceResourceMatcher {
private List baseResourcePersonPids;
private Long incomingResourcePersonPid;
- protected IsPossibleLinkedTo(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theTargetResources) {
- super(theIdHelperService, theEmpiLinkDaoSvc, theTargetResources);
+ protected IsPossibleLinkedTo(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theTargetResources) {
+ super(theIdHelperService, theMdmLinkDaoSvc, theTargetResources);
}
@Override
@@ -41,7 +41,7 @@ public class IsPossibleLinkedTo extends BaseSourceResourceMatcher {
public void describeTo(Description theDescription) {
}
- public static Matcher possibleLinkedTo(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- return new IsPossibleLinkedTo(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ public static Matcher possibleLinkedTo(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ return new IsPossibleLinkedTo(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleMatchWith.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleMatchWith.java
similarity index 62%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleMatchWith.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleMatchWith.java
index 7783ae84b67..a68cea8958a 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsPossibleMatchWith.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleMatchWith.java
@@ -1,9 +1,9 @@
-package ca.uhn.fhir.jpa.empi.matcher;
+package ca.uhn.fhir.jpa.mdm.matcher;
-import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
-import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hl7.fhir.instance.model.api.IAnyResource;
@@ -13,17 +13,17 @@ import java.util.Objects;
import java.util.stream.Collectors;
/**
- * Matcher with tells us if there is an EmpiLink with between these two resources that are considered POSSIBLE_MATCH
+ * Matcher with tells us if there is an MdmLink with between these two resources that are considered POSSIBLE_MATCH
*/
public class IsPossibleMatchWith extends BaseSourceResourceMatcher {
- protected IsPossibleMatchWith(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- super(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ protected IsPossibleMatchWith(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
@Override
protected boolean matchesSafely(IAnyResource theIncomingResource) {
- List empiLinks = getEmpiLinksForTarget(theIncomingResource, EmpiMatchResultEnum.POSSIBLE_MATCH);
+ List mdmLinks = getEmpiLinksForTarget(theIncomingResource, MdmMatchResultEnum.POSSIBLE_MATCH);
List personPidsToMatch = myBaseResources.stream()
.map(this::getMatchedResourcePidFromResource)
@@ -36,7 +36,7 @@ public class IsPossibleMatchWith extends BaseSourceResourceMatcher {
.collect(Collectors.toList());
}
- List empiLinkSourcePersonPids = empiLinks.stream().map(EmpiLink::getSourceResourcePid).collect(Collectors.toList());
+ List empiLinkSourcePersonPids = mdmLinks.stream().map(MdmLink::getGoldenResourcePid).collect(Collectors.toList());
return empiLinkSourcePersonPids.containsAll(personPidsToMatch);
}
@@ -51,7 +51,7 @@ public class IsPossibleMatchWith extends BaseSourceResourceMatcher {
mismatchDescription.appendText("No Empi Link With POSSIBLE_MATCH was found");
}
- public static Matcher possibleMatchWith(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- return new IsPossibleMatchWith(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ public static Matcher possibleMatchWith(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ return new IsPossibleMatchWith(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsSameSourceResourceAs.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsSameSourceResourceAs.java
similarity index 81%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsSameSourceResourceAs.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsSameSourceResourceAs.java
index 8c21ef2da83..ac76162ec55 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/matcher/IsSameSourceResourceAs.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsSameSourceResourceAs.java
@@ -1,7 +1,7 @@
-package ca.uhn.fhir.jpa.empi.matcher;
+package ca.uhn.fhir.jpa.mdm.matcher;
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
-import ca.uhn.fhir.jpa.empi.dao.EmpiLinkDaoSvc;
+import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hl7.fhir.instance.model.api.IAnyResource;
@@ -14,8 +14,8 @@ public class IsSameSourceResourceAs extends BaseSourceResourceMatcher {
private List sourceResourcePidsToMatch;
private Long incomingSourceResourcePid;
- public IsSameSourceResourceAs(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- super(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ public IsSameSourceResourceAs(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
@Override
@@ -40,7 +40,7 @@ public class IsSameSourceResourceAs extends BaseSourceResourceMatcher {
mismatchDescription.appendText(String.format(" was actually linked to %s/%s", myTargetType, incomingSourceResourcePid));
}
- public static Matcher sameSourceResourceAs(IdHelperService theIdHelperService, EmpiLinkDaoSvc theEmpiLinkDaoSvc, IAnyResource... theBaseResource) {
- return new IsSameSourceResourceAs(theIdHelperService, theEmpiLinkDaoSvc, theBaseResource);
+ public static Matcher sameSourceResourceAs(IdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
+ return new IsSameSourceResourceAs(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/BaseLinkR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/BaseLinkR4Test.java
similarity index 71%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/BaseLinkR4Test.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/BaseLinkR4Test.java
index 45e383599e7..022a573ea63 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/BaseLinkR4Test.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/BaseLinkR4Test.java
@@ -1,9 +1,9 @@
-package ca.uhn.fhir.jpa.empi.provider;
+package ca.uhn.fhir.jpa.mdm.provider;
-import ca.uhn.fhir.empi.api.EmpiLinkSourceEnum;
-import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
+import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
import ca.uhn.fhir.jpa.api.config.DaoConfig;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.StringType;
@@ -18,17 +18,17 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
public abstract class BaseLinkR4Test extends BaseProviderR4Test {
- protected static final StringType NO_MATCH_RESULT = new StringType(EmpiMatchResultEnum.NO_MATCH.name());
- protected static final StringType MATCH_RESULT = new StringType(EmpiMatchResultEnum.MATCH.name());
- protected static final StringType POSSIBLE_MATCH_RESULT = new StringType(EmpiMatchResultEnum.POSSIBLE_MATCH.name());
- protected static final StringType POSSIBLE_DUPLICATE_RESULT = new StringType(EmpiMatchResultEnum.POSSIBLE_DUPLICATE.name());
+ protected static final StringType NO_MATCH_RESULT = new StringType(MdmMatchResultEnum.NO_MATCH.name());
+ protected static final StringType MATCH_RESULT = new StringType(MdmMatchResultEnum.MATCH.name());
+ protected static final StringType POSSIBLE_MATCH_RESULT = new StringType(MdmMatchResultEnum.POSSIBLE_MATCH.name());
+ protected static final StringType POSSIBLE_DUPLICATE_RESULT = new StringType(MdmMatchResultEnum.POSSIBLE_DUPLICATE.name());
@Autowired
DaoConfig myDaoConfig;
protected Patient myPatient;
protected IAnyResource mySourcePatient;
- protected EmpiLink myLink;
+ protected MdmLink myLink;
protected StringType myPatientId;
protected StringType mySourcePatientId;
protected StringType myVersionlessGodlenResourceId;
@@ -47,9 +47,9 @@ public abstract class BaseLinkR4Test extends BaseProviderR4Test {
myLink = getOnlyPatientLink();
// Tests require our initial link to be a POSSIBLE_MATCH
- myLink.setMatchResult(EmpiMatchResultEnum.POSSIBLE_MATCH);
+ myLink.setMatchResult(MdmMatchResultEnum.POSSIBLE_MATCH);
saveLink(myLink);
- assertEquals(EmpiLinkSourceEnum.AUTO, myLink.getLinkSource());
+ assertEquals(MdmLinkSourceEnum.AUTO, myLink.getLinkSource());
myDaoConfig.setExpungeEnabled(true);
}
@@ -60,12 +60,12 @@ public abstract class BaseLinkR4Test extends BaseProviderR4Test {
}
@Nonnull
- protected EmpiLink getOnlyPatientLink() {
- return myEmpiLinkDaoSvc.findEmpiLinkByTarget(myPatient).get();
+ protected MdmLink getOnlyPatientLink() {
+ return myMdmLinkDaoSvc.findMdmLinkByTarget(myPatient).get();
}
@Nonnull
- protected List getPatientLinks() {
- return myEmpiLinkDaoSvc.findEmpiLinksByTarget(myPatient);
+ protected List getPatientLinks() {
+ return myMdmLinkDaoSvc.findMdmLinksByTarget(myPatient);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/BaseProviderR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/BaseProviderR4Test.java
new file mode 100644
index 00000000000..4418b6d904d
--- /dev/null
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/BaseProviderR4Test.java
@@ -0,0 +1,53 @@
+package ca.uhn.fhir.jpa.mdm.provider;
+
+import ca.uhn.fhir.mdm.api.IMdmControllerSvc;
+import ca.uhn.fhir.mdm.api.IMdmExpungeSvc;
+import ca.uhn.fhir.mdm.api.IMdmMatchFinderSvc;
+import ca.uhn.fhir.mdm.api.IMdmSubmitSvc;
+import ca.uhn.fhir.mdm.provider.MdmProviderR4;
+import ca.uhn.fhir.mdm.rules.config.MdmSettings;
+import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test;
+import com.google.common.base.Charsets;
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.core.io.Resource;
+
+import java.io.IOException;
+
+public abstract class BaseProviderR4Test extends BaseMdmR4Test {
+ MdmProviderR4 myMdmProviderR4;
+ @Autowired
+ private IMdmMatchFinderSvc myMdmMatchFinderSvc;
+ @Autowired
+ private IMdmControllerSvc myMdmControllerSvc;
+ @Autowired
+ private IMdmExpungeSvc myMdmExpungeSvc;
+ @Autowired
+ private IMdmSubmitSvc myMdmSubmitSvc;
+ @Autowired
+ private MdmSettings myMdmSettings;
+
+ private String defaultScript;
+
+ protected void setEmpiRuleJson(String theString) throws IOException {
+ DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
+ Resource resource = resourceLoader.getResource(theString);
+ String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8);
+ myMdmSettings.setScriptText(json);
+
+ }
+
+ @BeforeEach
+ public void before() {
+ myMdmProviderR4 = new MdmProviderR4(myFhirContext, myMdmControllerSvc, myMdmMatchFinderSvc, myMdmExpungeSvc, myMdmSubmitSvc);
+ defaultScript = myMdmSettings.getScriptText();
+ }
+ @AfterEach
+ public void after() throws IOException {
+ super.after();
+ myMdmSettings.setScriptText(defaultScript);
+ }
+}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderBatchR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderBatchR4Test.java
similarity index 67%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderBatchR4Test.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderBatchR4Test.java
index 4e17759e770..6ec35e3b50c 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderBatchR4Test.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderBatchR4Test.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.empi.provider;
+package ca.uhn.fhir.jpa.mdm.provider;
import ca.uhn.fhir.interceptor.api.IInterceptorService;
import ca.uhn.fhir.interceptor.api.Pointcut;
@@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.fail;
-public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
+public class MdmProviderBatchR4Test extends BaseLinkR4Test {
public static final String ORGANIZATION_DUMMY = "Organization/dummy";
protected Practitioner myPractitioner;
@@ -38,7 +38,7 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
@Autowired
IInterceptorService myInterceptorService;
- PointcutLatch afterEmpiLatch = new PointcutLatch(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED);
+ PointcutLatch afterMdmLatch = new PointcutLatch(Pointcut.MDM_AFTER_PERSISTED_RESOURCE_CHECKED);
@BeforeEach
@@ -59,44 +59,44 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
myGoldenMedicationId = new StringType(myGoldenMedication.getIdElement().getValue());
- myInterceptorService.registerAnonymousInterceptor(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED, afterEmpiLatch);
+ myInterceptorService.registerAnonymousInterceptor(Pointcut.MDM_AFTER_PERSISTED_RESOURCE_CHECKED, afterMdmLatch);
}
@AfterEach
public void after() throws IOException {
- myInterceptorService.unregisterInterceptor(afterEmpiLatch);
+ myInterceptorService.unregisterInterceptor(afterMdmLatch);
super.after();
}
@Test
public void testBatchRunOnAllMedications() throws InterruptedException {
StringType criteria = null;
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
- afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchOnAllTargets(new StringType("Medication"), criteria, null));
+ afterMdmLatch.runWithExpectedCount(1, () -> myMdmProviderR4.empiBatchOnAllTargets(new StringType("Medication"), criteria, null));
assertLinkCount(1);
}
@Test
public void testBatchRunOnAllPractitioners() throws InterruptedException {
StringType criteria = null;
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
- afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPractitionerType(criteria, null));
+ afterMdmLatch.runWithExpectedCount(1, () -> myMdmProviderR4.empiBatchPractitionerType(criteria, null));
assertLinkCount(1);
}
@Test
public void testBatchRunOnSpecificPractitioner() throws InterruptedException {
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
- afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPractitionerInstance(myPractitioner.getIdElement(), null));
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
+ afterMdmLatch.runWithExpectedCount(1, () -> myMdmProviderR4.empiBatchPractitionerInstance(myPractitioner.getIdElement(), null));
assertLinkCount(1);
}
@Test
public void testBatchRunOnNonExistentSpecificPractitioner() {
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
try {
- myEmpiProviderR4.empiBatchPractitionerInstance(new IdType("Practitioner/999"), null);
+ myMdmProviderR4.empiBatchPractitionerInstance(new IdType("Practitioner/999"), null);
fail();
} catch (ResourceNotFoundException e){}
}
@@ -105,25 +105,25 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
public void testBatchRunOnAllPatients() throws InterruptedException {
assertLinkCount(3);
StringType criteria = null;
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
- afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPatientType(criteria, null));
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
+ afterMdmLatch.runWithExpectedCount(1, () -> myMdmProviderR4.empiBatchPatientType(criteria, null));
assertLinkCount(1);
}
@Test
public void testBatchRunOnSpecificPatient() throws InterruptedException {
assertLinkCount(3);
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
- afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPatientInstance(myPatient.getIdElement(), null));
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
+ afterMdmLatch.runWithExpectedCount(1, () -> myMdmProviderR4.empiBatchPatientInstance(myPatient.getIdElement(), null));
assertLinkCount(1);
}
@Test
public void testBatchRunOnNonExistentSpecificPatient() {
assertLinkCount(3);
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
try {
- myEmpiProviderR4.empiBatchPatientInstance(new IdType("Patient/999"), null);
+ myMdmProviderR4.empiBatchPatientInstance(new IdType("Patient/999"), null);
fail();
} catch (ResourceNotFoundException e){}
}
@@ -132,9 +132,9 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
public void testBatchRunOnAllTypes() throws InterruptedException {
assertLinkCount(3);
StringType criteria = new StringType("");
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
- afterEmpiLatch.runWithExpectedCount(3, () -> {
- myEmpiProviderR4.empiBatchOnAllTargets(null, criteria, null);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
+ afterMdmLatch.runWithExpectedCount(3, () -> {
+ myMdmProviderR4.empiBatchOnAllTargets(null, criteria, null);
});
assertLinkCount(3);
}
@@ -143,10 +143,10 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
public void testBatchRunOnAllTypesWithInvalidCriteria() {
assertLinkCount(3);
StringType criteria = new StringType("death-date=2020-06-01");
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
try {
- myEmpiProviderR4.empiBatchPractitionerType(criteria, null);
+ myMdmProviderR4.empiBatchPractitionerType(criteria, null);
fail();
} catch(InvalidRequestException e) {
assertThat(e.getMessage(), is(equalTo("Failed to parse match URL[death-date=2020-06-01] - Resource type Practitioner does not have a parameter with name: death-date")));
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderClearLinkR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderClearLinkR4Test.java
similarity index 83%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderClearLinkR4Test.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderClearLinkR4Test.java
index e3e279928db..7bae41b46f1 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderClearLinkR4Test.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderClearLinkR4Test.java
@@ -1,8 +1,8 @@
-package ca.uhn.fhir.jpa.empi.provider;
+package ca.uhn.fhir.jpa.mdm.provider;
-import ca.uhn.fhir.empi.api.EmpiConstants;
-import ca.uhn.fhir.empi.api.EmpiLinkSourceEnum;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.mdm.api.MdmConstants;
+import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import javax.annotation.Nonnull;
import java.util.List;
-import static ca.uhn.fhir.empi.api.EmpiMatchOutcome.POSSIBLE_MATCH;
+import static ca.uhn.fhir.mdm.api.MdmMatchOutcome.POSSIBLE_MATCH;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
@@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.fail;
-public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
+public class MdmProviderClearLinkR4Test extends BaseLinkR4Test {
protected Practitioner myPractitioner;
protected StringType myPractitionerId;
protected IAnyResource myPractitionerSourceResource;
@@ -47,7 +47,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
@Test
public void testClearAllLinks() {
assertLinkCount(2);
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
assertNoLinksExist();
}
@@ -69,7 +69,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
assertLinkCount(2);
Patient read = myPatientDao.read(new IdDt(mySourcePatientId.getValueAsString()).toVersionless());
assertThat(read, is(notNullValue()));
- myEmpiProviderR4.clearEmpiLinks(new StringType("Patient"), myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(new StringType("Patient"), myRequestDetails);
assertNoPatientLinksExist();
try {
myPatientDao.read(new IdDt(mySourcePatientId.getValueAsString()).toVersionless());
@@ -86,7 +86,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
Patient patientAndUpdateLinks = createPatientAndUpdateLinks(buildJanePatient());
IAnyResource person = getGoldenResourceFromTargetResource(patientAndUpdateLinks);
assertThat(person, is(notNullValue()));
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
assertNoPatientLinksExist();
person = getGoldenResourceFromTargetResource(patientAndUpdateLinks);
assertThat(person, is(nullValue()));
@@ -103,7 +103,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
linkPersons(personFromTarget, personFromTarget2);
//SUT
- myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
assertNoPatientLinksExist();
IBundleProvider search = myPatientDao.search(buildSourceResourceParameterMap());
@@ -115,7 +115,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
* @return
*/
private SearchParameterMap buildSourceResourceParameterMap() {
- return new SearchParameterMap().setLoadSynchronous(true).add("_tag", new TokenParam(EmpiConstants.SYSTEM_MDM_MANAGED, EmpiConstants.CODE_HAPI_MDM_MANAGED));
+ return new SearchParameterMap().setLoadSynchronous(true).add("_tag", new TokenParam(MdmConstants.SYSTEM_MDM_MANAGED, MdmConstants.CODE_HAPI_MDM_MANAGED));
}
@Test
@@ -134,7 +134,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
linkPersons(personFromTarget2, personFromTarget);
//SUT
- Parameters parameters = myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
+ Parameters parameters = myMdmProviderR4.clearMdmLinks(null, myRequestDetails);
printLinks();
@@ -148,7 +148,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
private void linkPersons(IAnyResource theGoldenResource, IAnyResource theTargetResource) {
// TODO NG - Should be ok to leave this - not really
// throw new UnsupportedOperationException("We need to fix this!");
- myEmpiLinkDaoSvc.createOrUpdateLinkEntity(theGoldenResource, theTargetResource, POSSIBLE_MATCH, EmpiLinkSourceEnum.AUTO, createContextForCreate("Patient"));
+ myMdmLinkDaoSvc.createOrUpdateLinkEntity(theGoldenResource, theTargetResource, POSSIBLE_MATCH, MdmLinkSourceEnum.AUTO, createContextForCreate("Patient"));
}
@Test
@@ -156,7 +156,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
assertLinkCount(2);
Practitioner read = myPractitionerDao.read(new IdDt(myPractitionerSourceResourceId.getValueAsString()).toVersionless());
assertThat(read, is(notNullValue()));
- myEmpiProviderR4.clearEmpiLinks(new StringType("Practitioner"), myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(new StringType("Practitioner"), myRequestDetails);
assertNoPractitionerLinksExist();
try {
myPractitionerDao.read(new IdDt(myPractitionerSourceResourceId.getValueAsString()).toVersionless());
@@ -167,7 +167,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
@Test
public void testClearInvalidTargetType() {
try {
- myEmpiProviderR4.clearEmpiLinks(new StringType("Observation"), myRequestDetails);
+ myMdmProviderR4.clearMdmLinks(new StringType("Observation"), myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertThat(e.getMessage(), is(equalTo("$mdm-clear does not support resource type: Observation")));
@@ -175,7 +175,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
}
@Nonnull
- protected List getPractitionerLinks() {
- return myEmpiLinkDaoSvc.findEmpiLinksByTarget(myPractitioner);
+ protected List getPractitionerLinks() {
+ return myMdmLinkDaoSvc.findMdmLinksByTarget(myPractitioner);
}
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderMatchR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderMatchR4Test.java
similarity index 84%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderMatchR4Test.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderMatchR4Test.java
index beb3065d082..be4fa0ab0ec 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderMatchR4Test.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderMatchR4Test.java
@@ -1,11 +1,10 @@
-package ca.uhn.fhir.jpa.empi.provider;
+package ca.uhn.fhir.jpa.mdm.provider;
-import ca.uhn.fhir.empi.api.EmpiConstants;
+import ca.uhn.fhir.mdm.api.MdmConstants;
import com.google.common.collect.Ordering;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Extension;
import org.hl7.fhir.r4.model.Medication;
-import org.hl7.fhir.r4.model.Organization;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.codesystems.MatchGrade;
@@ -21,9 +20,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
+public class MdmProviderMatchR4Test extends BaseProviderR4Test {
- private static final Logger ourLog = LoggerFactory.getLogger(EmpiProviderMatchR4Test.class);
+ private static final Logger ourLog = LoggerFactory.getLogger(MdmProviderMatchR4Test.class);
public static final String NAME_GIVEN_JANET = NAME_GIVEN_JANE + "t";
@@ -31,7 +30,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
@BeforeEach
public void before() {
super.before();
- super.loadEmpiSearchParameters();
+ super.loadMdmSearchParameters();
}
@Test
@@ -41,7 +40,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
Patient createdJane = createPatient(jane);
Patient newJane = buildJanePatient();
- Bundle result = myEmpiProviderR4.match(newJane);
+ Bundle result = myMdmProviderR4.match(newJane);
assertEquals(1, result.getEntry().size());
Bundle.BundleEntryComponent entry0 = result.getEntry().get(0);
@@ -51,7 +50,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
assertEquals(Bundle.SearchEntryMode.MATCH, searchComponent.getMode());
assertEquals(2.0 / 3.0, searchComponent.getScore().doubleValue(), 0.01);
- Extension matchGradeExtension = searchComponent.getExtensionByUrl(EmpiConstants.FIHR_STRUCTURE_DEF_MATCH_GRADE_URL_NAMESPACE);
+ Extension matchGradeExtension = searchComponent.getExtensionByUrl(MdmConstants.FIHR_STRUCTURE_DEF_MATCH_GRADE_URL_NAMESPACE);
assertNotNull(matchGradeExtension);
assertEquals(MatchGrade.CERTAIN.toCode(), matchGradeExtension.getValue().toString());
}
@@ -65,7 +64,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
Medication createdMedication = createMedication(medication);
Medication newMedication = buildMedication("Organization/mfr");
- Bundle result = myEmpiProviderR4.serverMatch(newMedication, new StringType("Medication"));
+ Bundle result = myMdmProviderR4.serverMatch(newMedication, new StringType("Medication"));
assertEquals(1, result.getEntry().size());
Bundle.BundleEntryComponent entry0 = result.getEntry().get(0);
@@ -76,7 +75,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
//Since there is only
assertEquals(1.0 / 1.0, searchComponent.getScore().doubleValue(), 0.01);
- Extension matchGradeExtension = searchComponent.getExtensionByUrl(EmpiConstants.FIHR_STRUCTURE_DEF_MATCH_GRADE_URL_NAMESPACE);
+ Extension matchGradeExtension = searchComponent.getExtensionByUrl(MdmConstants.FIHR_STRUCTURE_DEF_MATCH_GRADE_URL_NAMESPACE);
assertNotNull(matchGradeExtension);
assertEquals(MatchGrade.CERTAIN.toCode(), matchGradeExtension.getValue().toString());
@@ -90,7 +89,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
Patient createdJane = createPatient(jane);
Patient newJane = buildJanePatient();
- Bundle result = myEmpiProviderR4.serverMatch(newJane, new StringType("Patient"));
+ Bundle result = myMdmProviderR4.serverMatch(newJane, new StringType("Patient"));
assertEquals(1, result.getEntry().size());
Bundle.BundleEntryComponent entry0 = result.getEntry().get(0);
@@ -100,7 +99,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
assertEquals(Bundle.SearchEntryMode.MATCH, searchComponent.getMode());
assertEquals(2.0 / 3.0, searchComponent.getScore().doubleValue(), 0.01);
- Extension matchGradeExtension = searchComponent.getExtensionByUrl(EmpiConstants.FIHR_STRUCTURE_DEF_MATCH_GRADE_URL_NAMESPACE);
+ Extension matchGradeExtension = searchComponent.getExtensionByUrl(MdmConstants.FIHR_STRUCTURE_DEF_MATCH_GRADE_URL_NAMESPACE);
assertNotNull(matchGradeExtension);
assertEquals(MatchGrade.CERTAIN.toCode(), matchGradeExtension.getValue().toString());
}
@@ -116,7 +115,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
Patient newJane = buildJanePatient();
- Bundle result = myEmpiProviderR4.match(newJane);
+ Bundle result = myMdmProviderR4.match(newJane);
assertEquals(2, result.getEntry().size());
Bundle.BundleEntryComponent entry0 = result.getEntry().get(0);
@@ -140,7 +139,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
Patient paul = buildPaulPatient();
paul.setActive(true);
- Bundle result = myEmpiProviderR4.match(paul);
+ Bundle result = myMdmProviderR4.match(paul);
assertEquals(0, result.getEntry().size());
}
@@ -152,7 +151,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
Patient createdJane = createPatient(jane);
Patient newJane = buildJanePatient();
- Bundle result = myEmpiProviderR4.match(newJane);
+ Bundle result = myMdmProviderR4.match(newJane);
assertEquals(1, result.getEntry().size());
assertEquals(createdJane.getId(), result.getEntryFirstRep().getResource().getId());
}
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderMergePersonsR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderMergePersonsR4Test.java
similarity index 75%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderMergePersonsR4Test.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderMergePersonsR4Test.java
index bb9b92217c3..97aee626373 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderMergePersonsR4Test.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderMergePersonsR4Test.java
@@ -1,22 +1,17 @@
-package ca.uhn.fhir.jpa.empi.provider;
+package ca.uhn.fhir.jpa.mdm.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.empi.util.EmpiUtil;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
+import ca.uhn.fhir.mdm.util.MdmUtil;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
-import org.hl7.fhir.instance.model.api.IAnyResource;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.StringType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;
-import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
@@ -24,7 +19,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
-public class EmpiProviderMergePersonsR4Test extends BaseProviderR4Test {
+public class MdmProviderMergePersonsR4Test extends BaseProviderR4Test {
private Patient myFromSourcePatient;
private StringType myFromSourcePatientId;
@@ -35,7 +30,7 @@ public class EmpiProviderMergePersonsR4Test extends BaseProviderR4Test {
@BeforeEach
public void before() {
super.before();
- super.loadEmpiSearchParameters();
+ super.loadMdmSearchParameters();
myFromSourcePatient = createGoldenPatient();
myFromSourcePatientId = new StringType(myFromSourcePatient.getIdElement().getValue());
@@ -45,10 +40,10 @@ public class EmpiProviderMergePersonsR4Test extends BaseProviderR4Test {
@Test
public void testMerge() {
- Patient mergedSourcePatient = (Patient) myEmpiProviderR4.mergeGoldenResources(myFromSourcePatientId,
+ Patient mergedSourcePatient = (Patient) myMdmProviderR4.mergeGoldenResources(myFromSourcePatientId,
myToSourcePatientId, myRequestDetails);
- assertTrue(EmpiUtil.isGoldenRecord(myFromSourcePatient));
+ assertTrue(MdmUtil.isGoldenRecord(myFromSourcePatient));
assertEquals(myToSourcePatient.getIdElement(), mergedSourcePatient.getIdElement());
assertThat(mergedSourcePatient, is(sameSourceResourceAs(myToSourcePatient)));
assertEquals(1, getAllRedirectedGoldenPatients().size());
@@ -56,20 +51,20 @@ public class EmpiProviderMergePersonsR4Test extends BaseProviderR4Test {
Patient fromSourcePatient = myPatientDao.read(myFromSourcePatient.getIdElement().toUnqualifiedVersionless());
assertThat(fromSourcePatient.getActive(), is(false));
- assertTrue(EmpiUtil.isGoldenRecordRedirected(fromSourcePatient));
+ assertTrue(MdmUtil.isGoldenRecordRedirected(fromSourcePatient));
//TODO GGG eventually this will need to check a redirect... this is a hack which doesnt work
// Optional redirect = fromSourcePatient.getIdentifier().stream().filter(theIdentifier -> theIdentifier.getSystem().equals("REDIRECT")).findFirst();
// assertThat(redirect.get().getValue(), is(equalTo(myToSourcePatient.getIdElement().toUnqualified().getValue())));
- List links = myEmpiLinkDaoSvc.findEmpiLinksByTarget(myFromSourcePatient);
+ List links = myMdmLinkDaoSvc.findMdmLinksByTarget(myFromSourcePatient);
assertThat(links, hasSize(1));
- EmpiLink link = links.get(0);
+ MdmLink link = links.get(0);
assertEquals(link.getTargetPid(), myFromSourcePatient.getIdElement().toUnqualifiedVersionless().getIdPartAsLong());
- assertEquals(link.getSourceResourcePid(), myToSourcePatient.getIdElement().toUnqualifiedVersionless().getIdPartAsLong());
- assertEquals(link.getMatchResult(), EmpiMatchResultEnum.REDIRECT);
- assertEquals(link.getLinkSource(), EmpiLinkSourceEnum.MANUAL);
+ assertEquals(link.getGoldenResourcePid(), myToSourcePatient.getIdElement().toUnqualifiedVersionless().getIdPartAsLong());
+ assertEquals(link.getMatchResult(), MdmMatchResultEnum.REDIRECT);
+ assertEquals(link.getLinkSource(), MdmLinkSourceEnum.MANUAL);
// assertThat(links.get(0).getAssurance(), is (AssuranceLevelUtil.getAssuranceLevel(EmpiMatchResultEnum.REDIRECT, EmpiLinkSourceEnum.MANUAL).toR4()));
//List links = fromSourcePatient.getLink();
//assertThat(links, hasSize(1));
@@ -82,7 +77,7 @@ public class EmpiProviderMergePersonsR4Test extends BaseProviderR4Test {
StringType fromPersonId = new StringType(createPatient().getIdElement().getValue());
StringType toPersonId = new StringType(createPatient().getIdElement().getValue());
try {
- myEmpiProviderR4.mergeGoldenResources(fromPersonId, toPersonId, myRequestDetails);
+ myMdmProviderR4.mergeGoldenResources(fromPersonId, toPersonId, myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertEquals("Only MDM managed resources can be merged. MDM managed resources must have the HAPI-MDM tag.", e.getMessage());
@@ -106,19 +101,19 @@ public class EmpiProviderMergePersonsR4Test extends BaseProviderR4Test {
@Test
public void testNullParams() {
try {
- myEmpiProviderR4.mergeGoldenResources(null, null, myRequestDetails);
+ myMdmProviderR4.mergeGoldenResources(null, null, myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertEquals("fromGoldenResourceId cannot be null", e.getMessage());
}
try {
- myEmpiProviderR4.mergeGoldenResources(null, myToSourcePatientId, myRequestDetails);
+ myMdmProviderR4.mergeGoldenResources(null, myToSourcePatientId, myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertEquals("fromGoldenResourceId cannot be null", e.getMessage());
}
try {
- myEmpiProviderR4.mergeGoldenResources(myFromSourcePatientId, null, myRequestDetails);
+ myMdmProviderR4.mergeGoldenResources(myFromSourcePatientId, null, myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertEquals("toGoldenResourceId cannot be null", e.getMessage());
@@ -146,21 +141,21 @@ public class EmpiProviderMergePersonsR4Test extends BaseProviderR4Test {
// }
try {
- myEmpiProviderR4.mergeGoldenResources(new StringType("Person/1"), new StringType("Person/1"), myRequestDetails);
+ myMdmProviderR4.mergeGoldenResources(new StringType("Person/1"), new StringType("Person/1"), myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertEquals("fromPersonId must be different from toPersonId", e.getMessage());
}
try {
- myEmpiProviderR4.mergeGoldenResources(new StringType("Person/abc"), myToSourcePatientId, myRequestDetails);
+ myMdmProviderR4.mergeGoldenResources(new StringType("Person/abc"), myToSourcePatientId, myRequestDetails);
fail();
} catch (ResourceNotFoundException e) {
assertEquals("Resource Person/abc is not known", e.getMessage());
}
try {
- myEmpiProviderR4.mergeGoldenResources(myFromSourcePatientId, new StringType("Person/abc"), myRequestDetails);
+ myMdmProviderR4.mergeGoldenResources(myFromSourcePatientId, new StringType("Person/abc"), myRequestDetails);
fail();
} catch (ResourceNotFoundException e) {
assertEquals("Resource Person/abc is not known", e.getMessage());
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderQueryLinkR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderQueryLinkR4Test.java
similarity index 70%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderQueryLinkR4Test.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderQueryLinkR4Test.java
index 8da3c32cd91..3bcb73cdbf8 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderQueryLinkR4Test.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderQueryLinkR4Test.java
@@ -1,8 +1,8 @@
-package ca.uhn.fhir.jpa.empi.provider;
+package ca.uhn.fhir.jpa.mdm.provider;
-import ca.uhn.fhir.empi.api.EmpiLinkSourceEnum;
-import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import org.hl7.fhir.instance.model.api.IAnyResource;
@@ -26,8 +26,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
-public class EmpiProviderQueryLinkR4Test extends BaseLinkR4Test {
- private static final Logger ourLog = LoggerFactory.getLogger(EmpiProviderQueryLinkR4Test.class);
+public class MdmProviderQueryLinkR4Test extends BaseLinkR4Test {
+ private static final Logger ourLog = LoggerFactory.getLogger(MdmProviderQueryLinkR4Test.class);
private StringType myLinkSource;
private StringType myPerson1Id;
private StringType myPerson2Id;
@@ -41,7 +41,7 @@ public class EmpiProviderQueryLinkR4Test extends BaseLinkR4Test {
createPatientAndUpdateLinks(buildJanePatient());
// Add a possible duplicate
- myLinkSource = new StringType(EmpiLinkSourceEnum.AUTO.name());
+ myLinkSource = new StringType(MdmLinkSourceEnum.AUTO.name());
Patient sourcePatient1 = createGoldenPatient();
myPerson1Id = new StringType(sourcePatient1.getIdElement().toVersionless().getValue());
Long sourcePatient1Pid = myIdHelperService.getPidOrNull(sourcePatient1);
@@ -49,19 +49,19 @@ public class EmpiProviderQueryLinkR4Test extends BaseLinkR4Test {
myPerson2Id = new StringType(sourcePatient2.getIdElement().toVersionless().getValue());
Long sourcePatient2Pid = myIdHelperService.getPidOrNull(sourcePatient2);
- EmpiLink possibleDuplicateEmpiLink = myEmpiLinkDaoSvc.newEmpiLink().setGoldenResourcePid(sourcePatient1Pid).setTargetPid(sourcePatient2Pid).setMatchResult(EmpiMatchResultEnum.POSSIBLE_DUPLICATE).setLinkSource(EmpiLinkSourceEnum.AUTO);
- saveLink(possibleDuplicateEmpiLink);
+ MdmLink possibleDuplicateMdmLink = myMdmLinkDaoSvc.newMdmLink().setGoldenResourcePid(sourcePatient1Pid).setTargetPid(sourcePatient2Pid).setMatchResult(MdmMatchResultEnum.POSSIBLE_DUPLICATE).setLinkSource(MdmLinkSourceEnum.AUTO);
+ saveLink(possibleDuplicateMdmLink);
}
@Test
public void testQueryLinkOneMatch() {
- Parameters result = myEmpiProviderR4.queryLinks(mySourcePatientId, myPatientId, null, null, myRequestDetails);
+ Parameters result = myMdmProviderR4.queryLinks(mySourcePatientId, myPatientId, null, null, myRequestDetails);
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(result));
List list = result.getParameter();
assertThat(list, hasSize(1));
List part = list.get(0).getPart();
- assertEmpiLink(7, part, mySourcePatientId.getValue(), myPatientId.getValue(), EmpiMatchResultEnum.POSSIBLE_MATCH, "false", "true", null);
+ assertMdmLink(7, part, mySourcePatientId.getValue(), myPatientId.getValue(), MdmMatchResultEnum.POSSIBLE_MATCH, "false", "true", null);
}
@Test
@@ -72,38 +72,38 @@ public class EmpiProviderQueryLinkR4Test extends BaseLinkR4Test {
IAnyResource person = getGoldenResourceFromTargetResource(patient);
IIdType personId = person.getIdElement().toVersionless();
- Parameters result = myEmpiProviderR4.queryLinks(null, null, null, myLinkSource, myRequestDetails);
+ Parameters result = myMdmProviderR4.queryLinks(null, null, null, myLinkSource, myRequestDetails);
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(result));
List list = result.getParameter();
assertThat(list, hasSize(3));
List part = list.get(2).getPart();
- assertEmpiLink(7, part, personId.getValue(), patientId.getValue(), EmpiMatchResultEnum.MATCH, "false", "false", "2");
+ assertMdmLink(7, part, personId.getValue(), patientId.getValue(), MdmMatchResultEnum.MATCH, "false", "false", "2");
}
@Test
public void testQueryPossibleDuplicates() {
- Parameters result = myEmpiProviderR4.getDuplicateGoldenResources(myRequestDetails);
+ Parameters result = myMdmProviderR4.getDuplicateGoldenResources(myRequestDetails);
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(result));
List list = result.getParameter();
assertThat(list, hasSize(1));
List part = list.get(0).getPart();
- assertEmpiLink(2, part, myPerson1Id.getValue(), myPerson2Id.getValue(), EmpiMatchResultEnum.POSSIBLE_DUPLICATE, "false", "false", null);
+ assertMdmLink(2, part, myPerson1Id.getValue(), myPerson2Id.getValue(), MdmMatchResultEnum.POSSIBLE_DUPLICATE, "false", "false", null);
}
@Test
public void testNotDuplicate() {
{
- Parameters result = myEmpiProviderR4.getDuplicateGoldenResources(myRequestDetails);
+ Parameters result = myMdmProviderR4.getDuplicateGoldenResources(myRequestDetails);
List list = result.getParameter();
assertThat(list, hasSize(1));
}
{
- Parameters result = myEmpiProviderR4.notDuplicate(myPerson1Id, myPerson2Id, myRequestDetails);
+ Parameters result = myMdmProviderR4.notDuplicate(myPerson1Id, myPerson2Id, myRequestDetails);
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(result));
assertEquals("success", result.getParameterFirstRep().getName());
assertTrue(((BooleanType) (result.getParameterFirstRep().getValue())).booleanValue());
}
- Parameters result = myEmpiProviderR4.getDuplicateGoldenResources(myRequestDetails);
+ Parameters result = myMdmProviderR4.getDuplicateGoldenResources(myRequestDetails);
List list = result.getParameter();
assertThat(list, hasSize(0));
}
@@ -111,14 +111,14 @@ public class EmpiProviderQueryLinkR4Test extends BaseLinkR4Test {
@Test
public void testNotDuplicateBadId() {
try {
- myEmpiProviderR4.notDuplicate(myPerson1Id, new StringType("Person/notAnId123"), myRequestDetails);
+ myMdmProviderR4.notDuplicate(myPerson1Id, new StringType("Person/notAnId123"), myRequestDetails);
fail();
} catch (ResourceNotFoundException e) {
assertEquals("Resource Person/notAnId123 is not known", e.getMessage());
}
}
- private void assertEmpiLink(int theExpectedSize, List thePart, String thePersonId, String theTargetId, EmpiMatchResultEnum theMatchResult, String theEidMatch, String theNewPerson, String theScore) {
+ private void assertMdmLink(int theExpectedSize, List thePart, String thePersonId, String theTargetId, MdmMatchResultEnum theMatchResult, String theEidMatch, String theNewPerson, String theScore) {
assertThat(thePart, hasSize(theExpectedSize));
assertThat(thePart.get(0).getName(), is("goldenResourceId"));
assertThat(thePart.get(0).getValue().toString(), is(removeVersion(thePersonId)));
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderUpdateLinkR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderUpdateLinkR4Test.java
similarity index 57%
rename from hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderUpdateLinkR4Test.java
rename to hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderUpdateLinkR4Test.java
index 51181bd3b32..d321438186f 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderUpdateLinkR4Test.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderUpdateLinkR4Test.java
@@ -1,10 +1,10 @@
-package ca.uhn.fhir.jpa.empi.provider;
+package ca.uhn.fhir.jpa.mdm.provider;
-import ca.uhn.fhir.empi.api.EmpiConstants;
-import ca.uhn.fhir.empi.api.EmpiLinkSourceEnum;
-import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
-import ca.uhn.fhir.empi.util.MessageHelper;
-import ca.uhn.fhir.jpa.entity.EmpiLink;
+import ca.uhn.fhir.mdm.api.MdmConstants;
+import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
+import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
+import ca.uhn.fhir.mdm.util.MessageHelper;
+import ca.uhn.fhir.jpa.entity.MdmLink;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
import org.hl7.fhir.r4.model.Patient;
@@ -18,7 +18,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.*;
-public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
+public class MdmProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Autowired
private MessageHelper myMessageHelper;
@@ -26,36 +26,36 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test
public void testUpdateLinkNoMatch() {
assertLinkCount(1);
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
assertLinkCount(2);
- List links = getPatientLinks();
- assertEquals(EmpiLinkSourceEnum.MANUAL, links.get(0).getLinkSource());
- assertEquals(EmpiMatchResultEnum.NO_MATCH, links.get(0).getMatchResult());
- assertEquals(EmpiLinkSourceEnum.AUTO, links.get(1).getLinkSource());
- assertEquals(EmpiMatchResultEnum.MATCH, links.get(1).getMatchResult());
- assertNotEquals(links.get(0).getSourceResourcePid(), links.get(1).getSourceResourcePid());
+ List links = getPatientLinks();
+ assertEquals(MdmLinkSourceEnum.MANUAL, links.get(0).getLinkSource());
+ assertEquals(MdmMatchResultEnum.NO_MATCH, links.get(0).getMatchResult());
+ assertEquals(MdmLinkSourceEnum.AUTO, links.get(1).getLinkSource());
+ assertEquals(MdmMatchResultEnum.MATCH, links.get(1).getMatchResult());
+ assertNotEquals(links.get(0).getGoldenResourcePid(), links.get(1).getGoldenResourcePid());
}
@Test
public void testUpdateLinkMatch() {
assertLinkCount(1);
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
assertLinkCount(1);
- List links = getPatientLinks();
- assertEquals(EmpiLinkSourceEnum.MANUAL, links.get(0).getLinkSource());
- assertEquals(EmpiMatchResultEnum.MATCH, links.get(0).getMatchResult());
+ List links = getPatientLinks();
+ assertEquals(MdmLinkSourceEnum.MANUAL, links.get(0).getLinkSource());
+ assertEquals(MdmMatchResultEnum.MATCH, links.get(0).getMatchResult());
}
@Test
public void testUpdateLinkTwiceFailsDueToWrongVersion() {
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
materiallyChangeGoldenPatient();
try {
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
fail();
} catch (ResourceVersionConflictException e) {
assertThat(e.getMessage(), matchesPattern("Requested resource Patient/\\d+/_history/1 is not the latest version. Latest version is Patient/\\d+/_history/2"));
@@ -70,19 +70,19 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test
public void testUpdateLinkTwiceDoesNotThrowValidationErrorWhenNoVersionIsProvided() {
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
- Patient patient = (Patient) myEmpiProviderR4.updateLink(myVersionlessGodlenResourceId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
+ Patient patient = (Patient) myMdmProviderR4.updateLink(myVersionlessGodlenResourceId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
assertNotNull(patient); // if this wasn't allowed - a validation exception would be thrown
}
@Test
public void testUnlinkLink() {
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, NO_MATCH_RESULT, myRequestDetails);
materiallyChangeGoldenPatient();
try {
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, MATCH_RESULT, myRequestDetails);
fail();
} catch (ResourceVersionConflictException e) {
assertThat(e.getMessage(), matchesPattern("Requested resource Patient/\\d+/_history/1 is not the latest version. Latest version is Patient/\\d+/_history/2"));
@@ -92,7 +92,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test
public void testUpdateIllegalResultForPossibleMatch() {
try {
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, POSSIBLE_MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, POSSIBLE_MATCH_RESULT, myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertEquals("$mdm-update-link illegal matchResult value 'POSSIBLE_MATCH'. Must be NO_MATCH or MATCH", e.getMessage());
@@ -102,7 +102,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test
public void testUpdateIllegalResultPD() {
try {
- myEmpiProviderR4.updateLink(mySourcePatientId, myPatientId, POSSIBLE_DUPLICATE_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(mySourcePatientId, myPatientId, POSSIBLE_DUPLICATE_RESULT, myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertEquals("$mdm-update-link illegal matchResult value 'POSSIBLE_DUPLICATE'. Must be NO_MATCH or MATCH", e.getMessage());
@@ -112,7 +112,7 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test
public void testUpdateIllegalSecondArg() {
try {
- myEmpiProviderR4.updateLink(myPatientId, new StringType(""), NO_MATCH_RESULT, myRequestDetails);
+ myMdmProviderR4.updateLink(myPatientId, new StringType(""), NO_MATCH_RESULT, myRequestDetails);
fail();
} catch (InvalidRequestException e) {
assertThat(e.getMessage(), endsWith(" must have form / where