Links WIP 2

This commit is contained in:
Nick Goupinets 2020-11-13 17:47:56 -05:00
parent 1ad0246c2a
commit 0ad1b129d3
5 changed files with 13 additions and 8 deletions

View File

@ -78,7 +78,7 @@ public class EmpiLinkUpdaterSvcImpl implements IEmpiLinkUpdaterSvc {
Optional<EmpiLink> oEmpiLink = myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(personId, targetId); Optional<EmpiLink> oEmpiLink = myEmpiLinkDaoSvc.getLinkBySourceResourcePidAndTargetResourcePid(personId, targetId);
if (!oEmpiLink.isPresent()) { if (!oEmpiLink.isPresent()) {
throw new InvalidRequestException("No link exists between " + thePerson.getIdElement().toVersionless() + " and " + theTarget.getIdElement().toVersionless()); throw new InvalidRequestException(myMessageHelper.getMessageForNoLink(thePerson, theTarget));
} }
EmpiLink empiLink = oEmpiLink.get(); EmpiLink empiLink = oEmpiLink.get();
if (empiLink.getMatchResult() == theMatchResult) { if (empiLink.getMatchResult() == theMatchResult) {

View File

@ -27,15 +27,9 @@ import static org.junit.jupiter.api.Assertions.fail;
public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test { public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
// @Autowired
// private IEmpiSettings myEmpiSettings;
@Autowired @Autowired
private MessageHelper myMessageHelper; private MessageHelper myMessageHelper;
@Autowired
private EmpiControllerHelper myEmpiControllerHelper;
@Test @Test
public void testUpdateLinkNoMatch() { public void testUpdateLinkNoMatch() {
assertLinkCount(1); assertLinkCount(1);

View File

@ -79,6 +79,8 @@ public abstract class BaseEmpiProvider {
protected MdmTransactionContext createMdmContext(RequestDetails theRequestDetails, MdmTransactionContext.OperationType theOperationType) { protected MdmTransactionContext createMdmContext(RequestDetails theRequestDetails, MdmTransactionContext.OperationType theOperationType) {
TransactionLogMessages transactionLogMessages = TransactionLogMessages.createFromTransactionGuid(theRequestDetails.getTransactionGuid()); TransactionLogMessages transactionLogMessages = TransactionLogMessages.createFromTransactionGuid(theRequestDetails.getTransactionGuid());
if (true)
throw new RuntimeException("FIXME - NG - We need a way to set resource type here");
return new MdmTransactionContext(transactionLogMessages, theOperationType); return new MdmTransactionContext(transactionLogMessages, theOperationType);
} }

View File

@ -160,7 +160,6 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
ServletRequestDetails theRequestDetails) { ServletRequestDetails theRequestDetails) {
validateUpdateLinkParameters(theGoldenResourceId, theResourceId, theMatchResult); validateUpdateLinkParameters(theGoldenResourceId, theResourceId, theMatchResult);
return myEmpiControllerSvc.updateLink(theGoldenResourceId.getValueNotNull(), theResourceId.getValue(), theMatchResult.getValue(), createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.UPDATE_LINK)); return myEmpiControllerSvc.updateLink(theGoldenResourceId.getValueNotNull(), theResourceId.getValue(), theMatchResult.getValue(), createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.UPDATE_LINK));
} }

View File

@ -7,6 +7,7 @@ import ca.uhn.fhir.empi.api.IEmpiLinkQuerySvc;
import ca.uhn.fhir.empi.api.IEmpiSettings; import ca.uhn.fhir.empi.api.IEmpiSettings;
import ca.uhn.fhir.rest.server.provider.ProviderConstants; import ca.uhn.fhir.rest.server.provider.ProviderConstants;
import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -62,4 +63,13 @@ public class MessageHelper {
return "The target is marked with the " + EmpiConstants.CODE_NO_EMPI_MANAGED return "The target is marked with the " + EmpiConstants.CODE_NO_EMPI_MANAGED
+ " tag which means it may not be EMPI linked."; + " tag which means it may not be EMPI linked.";
} }
public String getMessageForNoLink(IAnyResource theGoldenRecord, IAnyResource theTarget) {
return getMessageForNoLink(theGoldenRecord.getIdElement().toVersionless().toString(),
theTarget.getIdElement().toVersionless().toString());
}
public String getMessageForNoLink(String theGoldenRecord, String theTarget) {
return "No link exists between " + theGoldenRecord + " and " + theTarget;
}
} }