Survivorship 7
This commit is contained in:
parent
57662eedb3
commit
6781718702
|
@ -73,6 +73,8 @@ public class GoldenResourceMergerSvcImpl implements IGoldenResourceMergerSvc {
|
||||||
|
|
||||||
//Merge the links from the FROM to the TO resource. Clean up dangling links.
|
//Merge the links from the FROM to the TO resource. Clean up dangling links.
|
||||||
mergeGoldenResourceLinks(theFromGoldenResource, theToGoldenResource, toGoldenResourcePid, theMdmTransactionContext);
|
mergeGoldenResourceLinks(theFromGoldenResource, theToGoldenResource, toGoldenResourcePid, theMdmTransactionContext);
|
||||||
|
//Save changes to the golden resource
|
||||||
|
myMdmResourceDaoSvc.upsertGoldenResource(theToGoldenResource, resourceType);
|
||||||
|
|
||||||
//Create the new REDIRECT link
|
//Create the new REDIRECT link
|
||||||
addMergeLink(toGoldenResourcePid, fromGoldenResourcePid, resourceType);
|
addMergeLink(toGoldenResourcePid, fromGoldenResourcePid, resourceType);
|
||||||
|
|
|
@ -51,13 +51,12 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
||||||
|
|
||||||
assertEquals(myFromGoldenPatient.getName().size(), mergedSourcePatient.getName().size());
|
assertEquals(myFromGoldenPatient.getName().size(), mergedSourcePatient.getName().size());
|
||||||
assertEquals(myFromGoldenPatient.getName().get(0).getNameAsSingleString(), mergedSourcePatient.getName().get(0).getNameAsSingleString());
|
assertEquals(myFromGoldenPatient.getName().get(0).getNameAsSingleString(), mergedSourcePatient.getName().get(0).getNameAsSingleString());
|
||||||
|
|
||||||
assertEquals(myFromGoldenPatient.getCommunication().size(), mergedSourcePatient.getCommunication().size());
|
assertEquals(myFromGoldenPatient.getCommunication().size(), mergedSourcePatient.getCommunication().size());
|
||||||
assertEquals(myFromGoldenPatient.getExtension().size(), mergedSourcePatient.getExtension().size());
|
assertEquals(myFromGoldenPatient.getExtension().size(), mergedSourcePatient.getExtension().size());
|
||||||
|
|
||||||
Patient fromSourcePatient = myPatientDao.read(myFromGoldenPatient.getIdElement().toUnqualifiedVersionless());
|
Patient toGoldenPatient = myPatientDao.read(myToGoldenPatient.getIdElement().toUnqualifiedVersionless());
|
||||||
assertEquals(fromSourcePatient.getName().size(), mergedSourcePatient.getName().size());
|
assertEquals(toGoldenPatient.getName().size(), mergedSourcePatient.getName().size());
|
||||||
assertEquals(fromSourcePatient.getName().get(0).getNameAsSingleString(), mergedSourcePatient.getName().get(0).getNameAsSingleString());
|
assertEquals(toGoldenPatient.getName().get(0).getNameAsSingleString(), mergedSourcePatient.getName().get(0).getNameAsSingleString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,6 +98,7 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
||||||
Patient mergedSourcePatient = (Patient) myMdmProvider.mergeGoldenResources(myFromGoldenPatientId,
|
Patient mergedSourcePatient = (Patient) myMdmProvider.mergeGoldenResources(myFromGoldenPatientId,
|
||||||
myToGoldenPatientId, myFromGoldenPatient, myRequestDetails);
|
myToGoldenPatientId, myFromGoldenPatient, myRequestDetails);
|
||||||
|
|
||||||
|
myFromGoldenPatient = (Patient) myPatientDao.read(myFromGoldenPatient.getIdElement().toUnqualifiedVersionless());
|
||||||
assertTrue(!MdmResourceUtil.isGoldenRecord(myFromGoldenPatient));
|
assertTrue(!MdmResourceUtil.isGoldenRecord(myFromGoldenPatient));
|
||||||
assertTrue(MdmResourceUtil.isGoldenRecordRedirected(myFromGoldenPatient));
|
assertTrue(MdmResourceUtil.isGoldenRecordRedirected(myFromGoldenPatient));
|
||||||
|
|
||||||
|
@ -164,20 +164,6 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
||||||
assertEquals("fromGoldenResourceId must be different from toGoldenResourceId", e.getMessage());
|
assertEquals("fromGoldenResourceId must be different from toGoldenResourceId", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
myMdmProvider.mergeGoldenResources(myFromGoldenPatientId, myToGoldenPatientId, new Patient(), myRequestDetails);
|
|
||||||
fail();
|
|
||||||
} catch (InvalidRequestException e) {
|
|
||||||
assertEquals("resource.id cannot be null", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
myMdmProvider.mergeGoldenResources(myFromGoldenPatientId, myToGoldenPatientId, myToGoldenPatient, myRequestDetails);
|
|
||||||
fail();
|
|
||||||
} catch (InvalidRequestException e) {
|
|
||||||
assertEquals("resource must be different from the one with toGoldenResourceId", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
myMdmProvider.mergeGoldenResources(new StringType("Patient/abc"), myToGoldenPatientId, null, myRequestDetails);
|
myMdmProvider.mergeGoldenResources(new StringType("Patient/abc"), myToGoldenPatientId, null, myRequestDetails);
|
||||||
fail();
|
fail();
|
||||||
|
|
|
@ -346,7 +346,7 @@ public class MdmMatchLinkSvcTest extends BaseMdmR4Test {
|
||||||
|
|
||||||
//In a normal situation, janePatient2 would just match to jane patient, but here we need to hack it so they are their
|
//In a normal situation, janePatient2 would just match to jane patient, but here we need to hack it so they are their
|
||||||
//own individual GoldenResource for the purpose of this test.
|
//own individual GoldenResource for the purpose of this test.
|
||||||
IAnyResource goldenResource = myGoldenResourceHelper.createGoldenResourceFromMdmSourceResource(janePatient2, new MdmTransactionContext());
|
IAnyResource goldenResource = myGoldenResourceHelper.createGoldenResourceFromMdmSourceResource(janePatient2, new MdmTransactionContext(MdmTransactionContext.OperationType.CREATE_RESOURCE));
|
||||||
myMdmLinkSvc.updateLink(goldenResource, janePatient2, MdmMatchOutcome.NEW_GOLDEN_RESOURCE_MATCH, MdmLinkSourceEnum.AUTO, createContextForCreate("Patient"));
|
myMdmLinkSvc.updateLink(goldenResource, janePatient2, MdmMatchOutcome.NEW_GOLDEN_RESOURCE_MATCH, MdmLinkSourceEnum.AUTO, createContextForCreate("Patient"));
|
||||||
assertThat(janePatient, is(not(sameGoldenResourceAs(janePatient2))));
|
assertThat(janePatient, is(not(sameGoldenResourceAs(janePatient2))));
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ public class MdmMatchLinkSvcTest extends BaseMdmR4Test {
|
||||||
public void testCreateGoldenResourceFromMdmTarget() {
|
public void testCreateGoldenResourceFromMdmTarget() {
|
||||||
// Create Use Case #2 - adding patient with no EID
|
// Create Use Case #2 - adding patient with no EID
|
||||||
Patient janePatient = buildJanePatient();
|
Patient janePatient = buildJanePatient();
|
||||||
Patient janeGoldenResourcePatient = myGoldenResourceHelper.createGoldenResourceFromMdmSourceResource(janePatient, new MdmTransactionContext());
|
Patient janeGoldenResourcePatient = myGoldenResourceHelper.createGoldenResourceFromMdmSourceResource(janePatient, new MdmTransactionContext(MdmTransactionContext.OperationType.CREATE_RESOURCE));
|
||||||
|
|
||||||
// golden record now contains HAPI-generated EID and HAPI tag
|
// golden record now contains HAPI-generated EID and HAPI tag
|
||||||
assertTrue(MdmResourceUtil.isMdmManaged(janeGoldenResourcePatient));
|
assertTrue(MdmResourceUtil.isMdmManaged(janeGoldenResourcePatient));
|
||||||
|
|
|
@ -52,11 +52,15 @@ public class MdmTransactionContext {
|
||||||
public MdmTransactionContext() {
|
public MdmTransactionContext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MdmTransactionContext(TransactionLogMessages theTransactionLogMessages, OperationType theRestOperation) {
|
public MdmTransactionContext(OperationType theRestOperation) {
|
||||||
myTransactionLogMessages = theTransactionLogMessages;
|
|
||||||
myRestOperation = theRestOperation;
|
myRestOperation = theRestOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MdmTransactionContext(TransactionLogMessages theTransactionLogMessages, OperationType theRestOperation) {
|
||||||
|
this(theRestOperation);
|
||||||
|
myTransactionLogMessages = theTransactionLogMessages;
|
||||||
|
}
|
||||||
|
|
||||||
public MdmTransactionContext(TransactionLogMessages theTransactionLogMessages, OperationType theRestOperation, String theResourceType) {
|
public MdmTransactionContext(TransactionLogMessages theTransactionLogMessages, OperationType theRestOperation, String theResourceType) {
|
||||||
this(theTransactionLogMessages, theRestOperation);
|
this(theTransactionLogMessages, theRestOperation);
|
||||||
setResourceType(theResourceType);
|
setResourceType(theResourceType);
|
||||||
|
|
|
@ -29,7 +29,6 @@ import ca.uhn.fhir.rest.server.TransactionLogMessages;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
||||||
import ca.uhn.fhir.util.ParametersUtil;
|
import ca.uhn.fhir.util.ParametersUtil;
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
@ -51,18 +50,6 @@ public abstract class BaseMdmProvider {
|
||||||
throw new InvalidRequestException("fromGoldenResourceId must be different from toGoldenResourceId");
|
throw new InvalidRequestException("fromGoldenResourceId must be different from toGoldenResourceId");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected void validateOptionalMergeResource(IAnyResource theFromGoldenResource, IPrimitiveType<String> theToGoldenResourceId) {
|
|
||||||
if (theFromGoldenResource == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME NG - ID is proveded as a param anyways - can always retrived it there
|
|
||||||
validateNotNull(ProviderConstants.MDM_MERGE_RESOURCE_ID, theFromGoldenResource.getIdElement());
|
|
||||||
if (theFromGoldenResource.getIdElement().getValue().equals(theToGoldenResourceId.getValue())) {
|
|
||||||
throw new InvalidRequestException("resource must be different from the one with toGoldenResourceId");
|
|
||||||
}
|
|
||||||
validateMergeParameters(theFromGoldenResource.getIdElement(), theToGoldenResourceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateNotNull(String theName, IPrimitiveType<String> theString) {
|
private void validateNotNull(String theName, IPrimitiveType<String> theString) {
|
||||||
if (theString == null || theString.getValue() == null) {
|
if (theString == null || theString.getValue() == null) {
|
||||||
|
|
|
@ -147,7 +147,6 @@ public class MdmProviderDstu3Plus extends BaseMdmProvider {
|
||||||
@OperationParam(name = ProviderConstants.MDM_MERGE_RESOURCE, max = 1) IAnyResource theMergedResource,
|
@OperationParam(name = ProviderConstants.MDM_MERGE_RESOURCE, max = 1) IAnyResource theMergedResource,
|
||||||
RequestDetails theRequestDetails) {
|
RequestDetails theRequestDetails) {
|
||||||
validateMergeParameters(theFromGoldenResourceId, theToGoldenResourceId);
|
validateMergeParameters(theFromGoldenResourceId, theToGoldenResourceId);
|
||||||
validateOptionalMergeResource(theMergedResource, theToGoldenResourceId);
|
|
||||||
|
|
||||||
MdmTransactionContext.OperationType operationType = (theMergedResource == null) ?
|
MdmTransactionContext.OperationType operationType = (theMergedResource == null) ?
|
||||||
MdmTransactionContext.OperationType.MERGE_GOLDEN_RESOURCES : MdmTransactionContext.OperationType.MANUAL_MERGE_GOLDEN_RESOURCES;
|
MdmTransactionContext.OperationType.MERGE_GOLDEN_RESOURCES : MdmTransactionContext.OperationType.MANUAL_MERGE_GOLDEN_RESOURCES;
|
||||||
|
|
Loading…
Reference in New Issue