Fixed todos and reverted FK check in the test
This commit is contained in:
parent
aef84c9fe9
commit
efb429b319
|
@ -20,10 +20,9 @@ package ca.uhn.fhir.jpa.dao.mdm;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.MdmLink;
|
|
||||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
|
||||||
import ca.uhn.fhir.jpa.dao.data.IMdmLinkDao;
|
import ca.uhn.fhir.jpa.dao.data.IMdmLinkDao;
|
||||||
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
|
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
|
||||||
|
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -53,7 +52,7 @@ public class MdmLinkDeleteSvc {
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deleteNonRedirectWithWithAnyReferenceTo(IBaseResource theResource) {
|
public int deleteNonRedirectWithAnyReferenceTo(IBaseResource theResource) {
|
||||||
Long pid = myIdHelperService.getPidOrThrowException(theResource.getIdElement());
|
Long pid = myIdHelperService.getPidOrThrowException(theResource.getIdElement());
|
||||||
int removed = myMdmLinkDao.deleteWithAnyReferenceToPidAndMatchResultNot(pid, MdmMatchResultEnum.REDIRECT);
|
int removed = myMdmLinkDao.deleteWithAnyReferenceToPidAndMatchResultNot(pid, MdmMatchResultEnum.REDIRECT);
|
||||||
if (removed > 0) {
|
if (removed > 0) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class MdmStorageInterceptor implements IMdmStorageInterceptor {
|
||||||
forbidIfHasMultipleEids(theBaseResource);
|
forbidIfHasMultipleEids(theBaseResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO GGG MDM find a better way to identify i nternal calls?
|
// TODO GGG MDM find a better way to identify internal calls?
|
||||||
if (isInternalRequest(theRequestDetails)) {
|
if (isInternalRequest(theRequestDetails)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -84,10 +84,9 @@ public class MdmStorageInterceptor implements IMdmStorageInterceptor {
|
||||||
forbidIfHasMultipleEids(theUpdatedResource);
|
forbidIfHasMultipleEids(theUpdatedResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO GGG MDM: Check if this is actually handled already in mdm update code or not.
|
|
||||||
if (myGoldenResourceHelper.isDeactivated(theUpdatedResource)) {
|
if (myGoldenResourceHelper.isDeactivated(theUpdatedResource)) {
|
||||||
ourLog.debug("Deleting MDM links to deactivated Golden resource {}", theUpdatedResource.getIdElement().toUnqualifiedVersionless());
|
ourLog.debug("Deleting MDM links to deactivated Golden resource {}", theUpdatedResource.getIdElement().toUnqualifiedVersionless());
|
||||||
int deleted = myMdmLinkDeleteSvc.deleteNonRedirectWithWithAnyReferenceTo(theUpdatedResource);
|
int deleted = myMdmLinkDeleteSvc.deleteNonRedirectWithAnyReferenceTo(theUpdatedResource);
|
||||||
if (deleted > 0) {
|
if (deleted > 0) {
|
||||||
ourLog.debug("Deleted {} MDM links", deleted);
|
ourLog.debug("Deleted {} MDM links", deleted);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +124,7 @@ public class MdmStorageInterceptor implements IMdmStorageInterceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void throwBlockEidChange() {
|
private void throwBlockEidChange() {
|
||||||
throw new ForbiddenOperationException("While running with EID updates disabled, EIDs may not be updated on Patient/Practitioner resources");
|
throw new ForbiddenOperationException("While running with EID updates disabled, EIDs may not be updated on source resources");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -139,7 +138,7 @@ public class MdmStorageInterceptor implements IMdmStorageInterceptor {
|
||||||
|
|
||||||
private void forbidIfHasMultipleEids(IBaseResource theResource) {
|
private void forbidIfHasMultipleEids(IBaseResource theResource) {
|
||||||
String resourceType = extractResourceType(theResource);
|
String resourceType = extractResourceType(theResource);
|
||||||
if (resourceType.equalsIgnoreCase("Patient") || resourceType.equalsIgnoreCase("Practitioner")) {
|
if (myMdmSettings.isSupportedMdmType(resourceType)) {
|
||||||
if (myEIDHelper.getExternalEid(theResource).size() > 1) {
|
if (myEIDHelper.getExternalEid(theResource).size() > 1) {
|
||||||
throwBlockMultipleEids();
|
throwBlockMultipleEids();
|
||||||
}
|
}
|
||||||
|
@ -171,7 +170,7 @@ public class MdmStorageInterceptor implements IMdmStorageInterceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void throwBlockMultipleEids() {
|
private void throwBlockMultipleEids() {
|
||||||
throw new ForbiddenOperationException("While running with multiple EIDs disabled, Patient/Practitioner resources may have at most one EID.");
|
throw new ForbiddenOperationException("While running with multiple EIDs disabled, source resources may have at most one EID.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String extractResourceType(IBaseResource theResource) {
|
private String extractResourceType(IBaseResource theResource) {
|
||||||
|
|
|
@ -56,11 +56,11 @@ public class MdmResourceFilteringSvc {
|
||||||
* @return whether or not MDM processing should proceed
|
* @return whether or not MDM processing should proceed
|
||||||
*/
|
*/
|
||||||
public boolean shouldBeProcessed(IAnyResource theResource) {
|
public boolean shouldBeProcessed(IAnyResource theResource) {
|
||||||
//TODO GGG ask KHS: Skip the infinite loop, whoops. Better way to do this? tighter subscription criteria?
|
|
||||||
if (MdmUtil.isMdmManaged(theResource)) {
|
if (MdmUtil.isMdmManaged(theResource)) {
|
||||||
ourLog.debug("MDM Message handler is dropping [{}] as it is MDM-managed.", theResource);
|
ourLog.debug("MDM Message handler is dropping [{}] as it is MDM-managed.", theResource);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String resourceType = myFhirContext.getResourceType(theResource);
|
String resourceType = myFhirContext.getResourceType(theResource);
|
||||||
List<MdmResourceSearchParamJson> candidateSearchParams = myMdmSettings.getMdmRules().getCandidateSearchParams();
|
List<MdmResourceSearchParamJson> candidateSearchParams = myMdmSettings.getMdmRules().getCandidateSearchParams();
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class MdmExpungeTest extends BaseMdmR4Test {
|
||||||
fail();
|
fail();
|
||||||
} catch (InternalErrorException e) {
|
} catch (InternalErrorException e) {
|
||||||
assertThat(e.getMessage(), containsString("ViolationException"));
|
assertThat(e.getMessage(), containsString("ViolationException"));
|
||||||
assertThat(e.getMessage(), containsString("FK_MDM_LINK_SOURCE"));
|
assertThat(e.getMessage(), containsString("FK_EMPI_LINK_TARGET"));
|
||||||
}
|
}
|
||||||
myInterceptorService.registerInterceptor(myMdmStorageInterceptor);
|
myInterceptorService.registerInterceptor(myMdmStorageInterceptor);
|
||||||
myPatientDao.expunge(myTargetId.toVersionless(), expungeOptions, null);
|
myPatientDao.expunge(myTargetId.toVersionless(), expungeOptions, null);
|
||||||
|
|
Loading…
Reference in New Issue