fix test
This commit is contained in:
parent
b786006183
commit
84da932187
|
@ -196,7 +196,6 @@ public class ExpungeEverythingService {
|
||||||
|
|
||||||
ourLog.info("Have deleted {} entities of type {} in {}", outcome, theEntityType.getSimpleName(), sw.toString());
|
ourLog.info("Have deleted {} entities of type {} in {}", outcome, theEntityType.getSimpleName(), sw.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,5 +205,4 @@ public class ExpungeEverythingService {
|
||||||
ourLog.debug("SqlQuery affected {} rows in {}: {}", outcome, sw.toString(), theQuery);
|
ourLog.debug("SqlQuery affected {} rows in {}: {}", outcome, sw.toString(), theQuery);
|
||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class EmpiStorageInterceptor implements IEmpiStorageInterceptor {
|
||||||
|
|
||||||
@Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_UPDATED)
|
@Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_UPDATED)
|
||||||
public void blockManualPersonManipulationOnUpdate(IBaseResource theOldResource, IBaseResource theNewResource, RequestDetails theRequestDetails, ServletRequestDetails theServletRequestDetails) {
|
public void blockManualPersonManipulationOnUpdate(IBaseResource theOldResource, IBaseResource theNewResource, RequestDetails theRequestDetails, ServletRequestDetails theServletRequestDetails) {
|
||||||
|
|
||||||
//If running in single EID mode, forbid multiple eids.
|
//If running in single EID mode, forbid multiple eids.
|
||||||
if (myEmpiSettings.isPreventMultipleEids()) {
|
if (myEmpiSettings.isPreventMultipleEids()) {
|
||||||
forbidIfHasMultipleEids(theNewResource);
|
forbidIfHasMultipleEids(theNewResource);
|
||||||
|
@ -94,6 +95,7 @@ public class EmpiStorageInterceptor implements IEmpiStorageInterceptor {
|
||||||
}
|
}
|
||||||
forbidIfEmpiManagedTagIsPresent(theOldResource);
|
forbidIfEmpiManagedTagIsPresent(theOldResource);
|
||||||
forbidModifyingEmpiTag(theNewResource, theOldResource);
|
forbidModifyingEmpiTag(theNewResource, theOldResource);
|
||||||
|
|
||||||
if (myEmpiSettings.isPreventEidUpdates()) {
|
if (myEmpiSettings.isPreventEidUpdates()) {
|
||||||
forbidIfModifyingExternalEidOnTarget(theNewResource, theOldResource);
|
forbidIfModifyingExternalEidOnTarget(theNewResource, theOldResource);
|
||||||
}
|
}
|
||||||
|
@ -110,6 +112,10 @@ public class EmpiStorageInterceptor implements IEmpiStorageInterceptor {
|
||||||
private void forbidIfModifyingExternalEidOnTarget(IBaseResource theNewResource, IBaseResource theOldResource) {
|
private void forbidIfModifyingExternalEidOnTarget(IBaseResource theNewResource, IBaseResource theOldResource) {
|
||||||
List<CanonicalEID> newExternalEids = myEIDHelper.getExternalEid(theNewResource);
|
List<CanonicalEID> newExternalEids = myEIDHelper.getExternalEid(theNewResource);
|
||||||
List<CanonicalEID> oldExternalEids = myEIDHelper.getExternalEid(theOldResource);
|
List<CanonicalEID> oldExternalEids = myEIDHelper.getExternalEid(theOldResource);
|
||||||
|
if (oldExternalEids.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!myEIDHelper.eidMatchExists(newExternalEids, oldExternalEids)) {
|
if (!myEIDHelper.eidMatchExists(newExternalEids, oldExternalEids)) {
|
||||||
throwBlockEidChange();
|
throwBlockEidChange();
|
||||||
}
|
}
|
||||||
|
@ -144,7 +150,6 @@ public class EmpiStorageInterceptor implements IEmpiStorageInterceptor {
|
||||||
return theRequestDetails == null;
|
return theRequestDetails == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void forbidIfEmpiManagedTagIsPresent(IBaseResource theResource) {
|
private void forbidIfEmpiManagedTagIsPresent(IBaseResource theResource) {
|
||||||
if (EmpiUtil.isEmpiManaged(theResource)) {
|
if (EmpiUtil.isEmpiManaged(theResource)) {
|
||||||
throwModificationBlockedByEmpi();
|
throwModificationBlockedByEmpi();
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.hl7.fhir.r4.model.Organization;
|
||||||
import org.hl7.fhir.r4.model.Patient;
|
import org.hl7.fhir.r4.model.Patient;
|
||||||
import org.hl7.fhir.r4.model.Person;
|
import org.hl7.fhir.r4.model.Person;
|
||||||
import org.hl7.fhir.r4.model.Practitioner;
|
import org.hl7.fhir.r4.model.Practitioner;
|
||||||
|
import org.hl7.fhir.r4.model.SearchParameter;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static ca.uhn.fhir.empi.api.EmpiConstants.CODE_HAPI_EMPI_MANAGED;
|
import static ca.uhn.fhir.empi.api.EmpiConstants.CODE_HAPI_EMPI_MANAGED;
|
||||||
|
@ -237,7 +239,48 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
setPreventMultipleEids(false);
|
setPreventMultipleEids(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChecksOnlyApplyToRelevantResourceTypes() {
|
||||||
|
setPreventEidUpdates(true);
|
||||||
|
SearchParameter fooSp = new SearchParameter();
|
||||||
|
fooSp.setCode("foo");
|
||||||
|
fooSp.addBase("Bundle");
|
||||||
|
fooSp.setType(Enumerations.SearchParamType.REFERENCE);
|
||||||
|
fooSp.setTitle("FOO SP");
|
||||||
|
fooSp.setExpression("Bundle.entry[0].resource.as(Composition).encounter");
|
||||||
|
fooSp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
|
||||||
|
fooSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
|
||||||
|
|
||||||
|
myEmpiHelper.doCreateResource(fooSp, true);
|
||||||
|
|
||||||
|
fooSp.setXpathUsage(SearchParameter.XPathUsageType.PHONETIC);
|
||||||
|
|
||||||
|
myEmpiHelper.doUpdateResource(fooSp, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPatientsWithNoEIDCanBeUpdated() throws InterruptedException {
|
||||||
|
setPreventEidUpdates(true);
|
||||||
|
Patient p = new Patient();
|
||||||
|
EmpiHelperR4.OutcomeAndLogMessageWrapper wrapper = myEmpiHelper.createWithLatch(p);
|
||||||
|
|
||||||
|
p.setId(wrapper.getDaoMethodOutcome().getId());
|
||||||
|
p.setBirthDate(new Date());
|
||||||
|
myEmpiHelper.updateWithLatch(p);
|
||||||
|
setPreventEidUpdates(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPatientsCanHaveEIDAddedInStrictMode() throws InterruptedException {
|
||||||
|
setPreventEidUpdates(true);
|
||||||
|
Patient p = new Patient();
|
||||||
|
EmpiHelperR4.OutcomeAndLogMessageWrapper messageWrapper = myEmpiHelper.createWithLatch(p);
|
||||||
|
p.setId(messageWrapper.getDaoMethodOutcome().getId());
|
||||||
|
addExternalEID(p, "zoop");
|
||||||
|
myEmpiHelper.updateWithLatch(p);
|
||||||
|
setPreventEidUpdates(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPreventEidUpdates(boolean thePrevent) {
|
private void setPreventEidUpdates(boolean thePrevent) {
|
||||||
|
|
Loading…
Reference in New Issue