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());
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
@ -206,5 +205,4 @@ public class ExpungeEverythingService {
|
|||
ourLog.debug("SqlQuery affected {} rows in {}: {}", outcome, sw.toString(), theQuery);
|
||||
return outcome;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ public class EmpiStorageInterceptor implements IEmpiStorageInterceptor {
|
|||
|
||||
@Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_UPDATED)
|
||||
public void blockManualPersonManipulationOnUpdate(IBaseResource theOldResource, IBaseResource theNewResource, RequestDetails theRequestDetails, ServletRequestDetails theServletRequestDetails) {
|
||||
|
||||
//If running in single EID mode, forbid multiple eids.
|
||||
if (myEmpiSettings.isPreventMultipleEids()) {
|
||||
forbidIfHasMultipleEids(theNewResource);
|
||||
|
@ -94,6 +95,7 @@ public class EmpiStorageInterceptor implements IEmpiStorageInterceptor {
|
|||
}
|
||||
forbidIfEmpiManagedTagIsPresent(theOldResource);
|
||||
forbidModifyingEmpiTag(theNewResource, theOldResource);
|
||||
|
||||
if (myEmpiSettings.isPreventEidUpdates()) {
|
||||
forbidIfModifyingExternalEidOnTarget(theNewResource, theOldResource);
|
||||
}
|
||||
|
@ -110,6 +112,10 @@ public class EmpiStorageInterceptor implements IEmpiStorageInterceptor {
|
|||
private void forbidIfModifyingExternalEidOnTarget(IBaseResource theNewResource, IBaseResource theOldResource) {
|
||||
List<CanonicalEID> newExternalEids = myEIDHelper.getExternalEid(theNewResource);
|
||||
List<CanonicalEID> oldExternalEids = myEIDHelper.getExternalEid(theOldResource);
|
||||
if (oldExternalEids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!myEIDHelper.eidMatchExists(newExternalEids, oldExternalEids)) {
|
||||
throwBlockEidChange();
|
||||
}
|
||||
|
@ -144,7 +150,6 @@ public class EmpiStorageInterceptor implements IEmpiStorageInterceptor {
|
|||
return theRequestDetails == null;
|
||||
}
|
||||
|
||||
|
||||
private void forbidIfEmpiManagedTagIsPresent(IBaseResource theResource) {
|
||||
if (EmpiUtil.isEmpiManaged(theResource)) {
|
||||
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.Person;
|
||||
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.Test;
|
||||
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.context.ContextConfiguration;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static ca.uhn.fhir.empi.api.EmpiConstants.CODE_HAPI_EMPI_MANAGED;
|
||||
|
@ -237,7 +239,48 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue