wip
This commit is contained in:
parent
9d7df0cdda
commit
80b59599fc
|
@ -15,6 +15,7 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.r4.model.StringType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.messaging.MessageChannel;
|
import org.springframework.messaging.MessageChannel;
|
||||||
|
|
||||||
|
@ -36,21 +37,25 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private FhirContext myFhirContext;
|
private FhirContext myFhirContext;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmpiSearchParamSvc myEmpiSearchParamSvc;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IChannelFactory myChannelFactory;
|
private IChannelFactory myChannelFactory;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runEmpiOnAllTargets() {
|
public void runEmpiOnAllTargets(StringType theCriteria) {
|
||||||
runEmpiOnTargetType("Patient");
|
runEmpiOnTargetType("Patient", theCriteria);
|
||||||
runEmpiOnTargetType("Practitioner");
|
runEmpiOnTargetType("Practitioner", theCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runEmpiOnTargetType(String theTargetType) {
|
public void runEmpiOnTargetType(String theTargetType, StringType theCriteria) {
|
||||||
getTargetTypeOrThrowException(theTargetType);
|
getTargetTypeOrThrowException(theTargetType);
|
||||||
|
SearchParameterMap spMap = getSearchParameterMapFromCriteria(theTargetType, theCriteria);
|
||||||
IFhirResourceDao patientDao = myDaoRegistry.getResourceDao(theTargetType);
|
IFhirResourceDao patientDao = myDaoRegistry.getResourceDao(theTargetType);
|
||||||
IBundleProvider search = patientDao.search(new SearchParameterMap().setLoadSynchronous(true));
|
IBundleProvider search = patientDao.search(spMap.setLoadSynchronous(true));
|
||||||
List<IBaseResource> resources = search.getResources(0, search.size());
|
List<IBaseResource> resources = search.getResources(0, search.size());
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +66,16 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
|
||||||
rmjm.setPayload(resourceModifiedMessage);
|
rmjm.setPayload(resourceModifiedMessage);
|
||||||
myEmpiChannelProducer.send(rmjm);
|
myEmpiChannelProducer.send(rmjm);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private SearchParameterMap getSearchParameterMapFromCriteria(String theTargetType, StringType theCriteria) {
|
||||||
|
SearchParameterMap spMap;
|
||||||
|
if (theCriteria != null) {
|
||||||
|
spMap = myEmpiSearchParamSvc.mapFromCriteria(theTargetType, theCriteria.getValueNotNull());
|
||||||
|
} else {
|
||||||
|
spMap = new SearchParameterMap();
|
||||||
|
}
|
||||||
|
return spMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EmpiTargetType getTargetTypeOrThrowException(String theResourceType) {
|
private EmpiTargetType getTargetTypeOrThrowException(String theResourceType) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class EmpiHelperR4 extends BaseEmpiHelper {
|
||||||
}
|
}
|
||||||
public OutcomeAndLogMessageWrapper batchWithLatch(int expectedRuns) throws InterruptedException {
|
public OutcomeAndLogMessageWrapper batchWithLatch(int expectedRuns) throws InterruptedException {
|
||||||
myAfterEmpiLatch.setExpectedCount(expectedRuns);
|
myAfterEmpiLatch.setExpectedCount(expectedRuns);
|
||||||
myEmpiProviderR4.batchRunEmpi(null, null);
|
myEmpiProviderR4.batchRunEmpi(null, null, null);
|
||||||
myAfterEmpiLatch.awaitExpected();
|
myAfterEmpiLatch.awaitExpected();
|
||||||
return new OutcomeAndLogMessageWrapper(null, null);
|
return new OutcomeAndLogMessageWrapper(null, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,15 @@ import ca.uhn.fhir.interceptor.api.IInterceptorService;
|
||||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||||
import ca.uhn.fhir.jpa.empi.BaseEmpiR4Test;
|
import ca.uhn.fhir.jpa.empi.BaseEmpiR4Test;
|
||||||
import ca.uhn.test.concurrency.PointcutLatch;
|
import ca.uhn.test.concurrency.PointcutLatch;
|
||||||
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.hl7.fhir.r4.model.StringType;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
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.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
class EmpiBatchSvcImplTest extends BaseEmpiR4Test {
|
class EmpiBatchSvcImplTest extends BaseEmpiR4Test {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -44,7 +48,7 @@ class EmpiBatchSvcImplTest extends BaseEmpiR4Test {
|
||||||
afterEmpiLatch.setExpectedCount(20);
|
afterEmpiLatch.setExpectedCount(20);
|
||||||
|
|
||||||
//SUT
|
//SUT
|
||||||
myEmpiBatchSvc.runEmpiOnAllTargets();
|
myEmpiBatchSvc.runEmpiOnAllTargets(null);
|
||||||
|
|
||||||
afterEmpiLatch.awaitExpected();
|
afterEmpiLatch.awaitExpected();
|
||||||
assertLinkCount(20);
|
assertLinkCount(20);
|
||||||
|
@ -61,7 +65,7 @@ class EmpiBatchSvcImplTest extends BaseEmpiR4Test {
|
||||||
afterEmpiLatch.setExpectedCount(10);
|
afterEmpiLatch.setExpectedCount(10);
|
||||||
|
|
||||||
//SUT
|
//SUT
|
||||||
myEmpiBatchSvc.runEmpiOnAllTargets();
|
myEmpiBatchSvc.runEmpiOnAllTargets(null);
|
||||||
|
|
||||||
afterEmpiLatch.awaitExpected();
|
afterEmpiLatch.awaitExpected();
|
||||||
assertLinkCount(10);
|
assertLinkCount(10);
|
||||||
|
@ -78,11 +82,24 @@ class EmpiBatchSvcImplTest extends BaseEmpiR4Test {
|
||||||
afterEmpiLatch.setExpectedCount(10);
|
afterEmpiLatch.setExpectedCount(10);
|
||||||
|
|
||||||
//SUT
|
//SUT
|
||||||
myEmpiBatchSvc.runEmpiOnAllTargets();
|
myEmpiBatchSvc.runEmpiOnAllTargets(null);
|
||||||
|
|
||||||
afterEmpiLatch.awaitExpected();
|
afterEmpiLatch.awaitExpected();
|
||||||
assertLinkCount(10);
|
assertLinkCount(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmpiOnTargetTypeWithCriteria() throws InterruptedException {
|
||||||
|
|
||||||
|
createPatient(buildPatientWithNameIdAndBirthday("gary", "gary_id", new Date()));
|
||||||
|
createPatient(buildPatientWithNameIdAndBirthday("john", "john_id", DateUtils.addDays(new Date(), -300)));
|
||||||
|
assertLinkCount(0);
|
||||||
|
|
||||||
|
|
||||||
|
afterEmpiLatch.setExpectedCount(1);
|
||||||
|
myEmpiBatchSvc.runEmpiOnAllTargets(new StringType("Patient?name=gary"));
|
||||||
|
afterEmpiLatch.awaitExpected();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package ca.uhn.fhir.empi.api;
|
package ca.uhn.fhir.empi.api;
|
||||||
|
|
||||||
|
import org.hl7.fhir.r4.model.StringType;
|
||||||
|
|
||||||
public interface IEmpiBatchService {
|
public interface IEmpiBatchService {
|
||||||
|
|
||||||
void runEmpiOnAllTargets();
|
void runEmpiOnAllTargets(StringType theCriteria);
|
||||||
|
|
||||||
void runEmpiOnTargetType(String theTargetType);
|
void runEmpiOnTargetType(String theTargetType, StringType theCriteria);
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,13 +168,14 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
|
||||||
|
|
||||||
@Operation(name = ProviderConstants.EMPI_BATCH_RUN, idempotent = true)
|
@Operation(name = ProviderConstants.EMPI_BATCH_RUN, idempotent = true)
|
||||||
public void batchRunEmpi(@OperationParam(name= ProviderConstants.EMPI_BATCH_RUN_TARGET_TYPE, max=1) StringType theTargetType,
|
public void batchRunEmpi(@OperationParam(name= ProviderConstants.EMPI_BATCH_RUN_TARGET_TYPE, max=1) StringType theTargetType,
|
||||||
@OperationParam(name= ProviderConstants.EMPI_BATCH_RUN_TARGET_TYPE, max=1) StringType theQueryString,
|
@OperationParam(name= ProviderConstants.EMPI_BATCH_RUN_TARGET_TYPE, max=1) StringType theCriteria,
|
||||||
ServletRequestDetails theRequestDetails) {
|
ServletRequestDetails theRequestDetails) {
|
||||||
|
|
||||||
if (theTargetType == null) {
|
if (theTargetType == null) {
|
||||||
myEmpiBatchSvc.runEmpiOnAllTargets();
|
myEmpiBatchSvc.runEmpiOnAllTargets(theCriteria);
|
||||||
} else {
|
} else {
|
||||||
myEmpiBatchSvc.runEmpiOnTargetType(theTargetType.toString());
|
|
||||||
|
myEmpiBatchSvc.runEmpiOnTargetType(theTargetType.toString(), theCriteria);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue