Fix operation name. Remove unnecessary beans

This commit is contained in:
Tadgh 2020-07-16 09:48:58 -07:00
parent acd881ca76
commit 31e9f140ad
3 changed files with 6 additions and 37 deletions

View File

@ -1,53 +1,32 @@
package ca.uhn.fhir.jpa.empi.svc;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.empi.api.IEmpiBatchService;
import ca.uhn.fhir.empi.api.IEmpiQueueSubmitterSvc;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.entity.EmpiTargetType;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.subscription.channel.api.ChannelProducerSettings;
import ca.uhn.fhir.jpa.subscription.channel.api.IChannelFactory;
import ca.uhn.fhir.jpa.subscription.channel.subscription.IChannelNamer;
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
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.messaging.MessageChannel;
import javax.annotation.PostConstruct;
import java.util.List;
import static ca.uhn.fhir.empi.api.IEmpiSettings.EMPI_CHANNEL_NAME;
public class EmpiBatchSvcImpl implements IEmpiBatchService {
@Autowired
private DaoRegistry myDaoRegistry;
@Autowired
private IChannelNamer myChannelNamer;
private MessageChannel myEmpiChannelProducer;
@Autowired
private FhirContext myFhirContext;
@Autowired
private EmpiSearchParamSvc myEmpiSearchParamSvc;
@Autowired
private IEmpiQueueSubmitterSvc myEmpiQueueSubmitterSvc;
@Autowired
private IChannelFactory myChannelFactory;
private static final int queueAddingPageSize = 100;
@Override
public void runEmpiOnAllTargets(StringType theCriteria) {
runEmpiOnTargetType("Patient", theCriteria);
@ -56,7 +35,7 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
@Override
public void runEmpiOnTargetType(String theTargetType, StringType theCriteria) {
getTargetTypeOrThrowException(theTargetType);
resolveTargetTypeOrThrowException(theTargetType);
SearchParameterMap spMap = getSearchParameterMapFromCriteria(theTargetType, theCriteria);
IFhirResourceDao patientDao = myDaoRegistry.getResourceDao(theTargetType);
IBundleProvider search = patientDao.search(spMap);
@ -82,20 +61,9 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
return spMap;
}
private EmpiTargetType getTargetTypeOrThrowException(String theResourceType) {
if (theResourceType.equalsIgnoreCase("Patient")) {
return EmpiTargetType.PATIENT;
} else if(theResourceType.equalsIgnoreCase("Practitioner")) {
return EmpiTargetType.PRACTITIONER;
} else {
private void resolveTargetTypeOrThrowException(String theResourceType) {
if (!theResourceType.equalsIgnoreCase("Patient") && !theResourceType.equalsIgnoreCase("Practitioner")) {
throw new InvalidRequestException(ProviderConstants.EMPI_BATCH_RUN+ " does not support resource type: " + theResourceType);
}
}
@PostConstruct
private void init() {
ChannelProducerSettings channelSettings = new ChannelProducerSettings();
String channelName = myChannelNamer.getChannelName(EMPI_CHANNEL_NAME, channelSettings);
myEmpiChannelProducer= myChannelFactory.getOrCreateProducer(channelName, ResourceModifiedJsonMessage.class, channelSettings);
}
}

View File

@ -168,7 +168,7 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
@Operation(name = ProviderConstants.EMPI_BATCH_RUN, idempotent = true)
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 theCriteria,
@OperationParam(name= ProviderConstants.EMPI_BATCH_RUN_CRITERIA, max=1) StringType theCriteria,
ServletRequestDetails theRequestDetails) {
if (theTargetType == null) {

View File

@ -84,7 +84,8 @@ public class ProviderConstants {
public static final String EMPI_CLEAR = "$empi-clear";
public static final String EMPI_CLEAR_TARGET_TYPE = "targetType";
public static final String EMPI_BATCH_RUN = "$empi-run";
public static final String EMPI_BATCH_RUN = "$empi-batch-run";
public static final String EMPI_BATCH_RUN_TARGET_TYPE = "targetType" ;
public static final String EMPI_BATCH_RUN_CRITERIA= "targetType" ;
public static final String EMPI_BATCH_RUN_RESOURCE_IDS = "resourceIds" ;
}