Added config fix

This commit is contained in:
Nick Goupinets 2020-11-13 17:16:10 -05:00
parent 176f7f0412
commit 1ad0246c2a
4 changed files with 41 additions and 9 deletions

View File

@ -112,6 +112,11 @@ public class EmpiConsumerConfig {
return new PersonHelper(theFhirContext);
}
@Bean
MessageHelper messageHelper(IEmpiSettings theEmpiSettings, FhirContext theFhirContext) {
return new MessageHelper(theEmpiSettings, theFhirContext);
}
@Bean
EmpiSubscriptionLoader empiSubscriptionLoader() {
return new EmpiSubscriptionLoader();
@ -123,7 +128,7 @@ public class EmpiConsumerConfig {
}
@Bean
EmpiSourceResourceFindingSvc empiPersonFindingSvc() {
EmpiSourceResourceFindingSvc empiPersonFindingSvc() {
return new EmpiSourceResourceFindingSvc();
}
@ -169,7 +174,7 @@ public class EmpiConsumerConfig {
}
@Bean
IEmpiExpungeSvc empiResetSvc(EmpiLinkDaoSvc theEmpiLinkDaoSvc, EmpiPersonDeletingSvc theEmpiPersonDeletingSvcImpl ) {
IEmpiExpungeSvc empiResetSvc(EmpiLinkDaoSvc theEmpiLinkDaoSvc, EmpiPersonDeletingSvc theEmpiPersonDeletingSvcImpl) {
return new EmpiClearSvcImpl(theEmpiLinkDaoSvc, theEmpiPersonDeletingSvcImpl);
}
@ -184,7 +189,7 @@ public class EmpiConsumerConfig {
}
@Bean
EmpiResourceMatcherSvc empiResourceComparatorSvc(FhirContext theFhirContext, IEmpiSettings theEmpiConfig) {
EmpiResourceMatcherSvc empiResourceComparatorSvc(FhirContext theFhirContext, IEmpiSettings theEmpiConfig) {
return new EmpiResourceMatcherSvc(theFhirContext, theEmpiConfig);
}
@ -229,5 +234,7 @@ public class EmpiConsumerConfig {
}
@Bean
IEmpiControllerSvc empiControllerSvc() {return new EmpiControllerSvcImpl(); }
IEmpiControllerSvc empiControllerSvc() {
return new EmpiControllerSvcImpl();
}
}

View File

@ -42,6 +42,7 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
import java.util.Optional;
public class EmpiLinkUpdaterSvcImpl implements IEmpiLinkUpdaterSvc {
@ -107,19 +108,23 @@ public class EmpiLinkUpdaterSvcImpl implements IEmpiLinkUpdaterSvc {
}
if (!myEmpiSettings.isSupportedMdmType(goldenRecordType)) {
throw new InvalidRequestException("First argument to " + ProviderConstants.MDM_UPDATE_LINK + " must be a Person. Was " + goldenRecordType);
throw new InvalidRequestException(myMessageHelper.getMessageForUnsupportedFirstArgumentTypeInUpdate(goldenRecordType));
}
if (!myEmpiSettings.isSupportedMdmType(theTargetType)) {
throw new InvalidRequestException("Second argument to " + ProviderConstants.MDM_UPDATE_LINK + " must be a Patient or Practitioner. Was " + theTargetType);
throw new InvalidRequestException(myMessageHelper.getMessageForUnsupportedSecondArgumentTypeInUpdate(theTargetType));
}
if (!Objects.equals(goldenRecordType, theTargetType)) {
throw new InvalidRequestException(myMessageHelper.getMessageForArgumentTypeMismatchInUpdate(goldenRecordType, theTargetType));
}
if (!EmpiUtil.isEmpiManaged(theGoldenRecord)) {
throw new InvalidRequestException("Only MDM managed rerson resources may be updated via this operation. The Person resource provided is not tagged as managed by hapi-empi");
throw new InvalidRequestException(myMessageHelper.getMessageForUnmanagedResource());
}
if (!EmpiUtil.isEmpiAccessible(theTarget)) {
throw new InvalidRequestException("The target is marked with the " + EmpiConstants.CODE_NO_EMPI_MANAGED + " tag which means it may not be EMPI linked.");
throw new InvalidRequestException(myMessageHelper.getMessageForUnsupportedTarget());
}
}

View File

@ -132,7 +132,6 @@ public class EmpiProviderUpdateLinkR4Test extends BaseLinkR4Test {
@Test
public void testUpdateStrangePerson() {
// TODO NG - OK? Patient person = createUnmanagedSourceResource();
Patient person = createPatient();
try {
myEmpiProviderR4.updateLink(new StringType(person.getIdElement().getValue()), myPatientId, NO_MATCH_RESULT, myRequestDetails);

View File

@ -5,6 +5,7 @@ import ca.uhn.fhir.empi.api.EmpiConstants;
import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
import ca.uhn.fhir.empi.api.IEmpiLinkQuerySvc;
import ca.uhn.fhir.empi.api.IEmpiSettings;
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -41,4 +42,24 @@ public class MessageHelper {
public String getMessageForUnsupportedMatchResult() {
return "Match Result may only be set to " + EmpiMatchResultEnum.NO_MATCH + " or " + EmpiMatchResultEnum.MATCH;
}
public String getMessageForUnsupportedFirstArgumentTypeInUpdate(String goldenRecordType) {
return "First argument to " + ProviderConstants.MDM_UPDATE_LINK + " must be a "
+ myEmpiSettings.getSupportedMdmTypeNames() + ". Was " + goldenRecordType;
}
public String getMessageForUnsupportedSecondArgumentTypeInUpdate(String theGoldenRecordType) {
return "First argument to " + ProviderConstants.MDM_UPDATE_LINK + " must be a "
+ myEmpiSettings.getSupportedMdmTypeNames() + ". Was " + theGoldenRecordType;
}
public String getMessageForArgumentTypeMismatchInUpdate(String theGoldenRecordType, String theTargetType) {
return "Arguments to " + ProviderConstants.MDM_UPDATE_LINK + " must be of the same type. Were " +
theGoldenRecordType + " and " + theTargetType;
}
public String getMessageForUnsupportedTarget() {
return "The target is marked with the " + EmpiConstants.CODE_NO_EMPI_MANAGED
+ " tag which means it may not be EMPI linked.";
}
}