Introduce Filtering service

This commit is contained in:
Tadgh 2020-08-05 21:48:06 -07:00
parent 87d14f26fe
commit c92a77c889
4 changed files with 38 additions and 4 deletions

View File

@ -28,6 +28,7 @@ import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.empi.svc.EmpiMatchLinkSvc;
import ca.uhn.fhir.jpa.empi.svc.EmpiMessageFilteringSvc;
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.server.TransactionLogMessages;
@ -50,6 +51,8 @@ public class EmpiMessageHandler implements MessageHandler {
private IInterceptorBroadcaster myInterceptorBroadcaster;
@Autowired
private FhirContext myFhirContext;
@Autowired
private EmpiMessageFilteringSvc myEmpiResourceFileringSvc;
@Override
public void handleMessage(Message<?> theMessage) throws MessagingException {
@ -62,13 +65,14 @@ public class EmpiMessageHandler implements MessageHandler {
ResourceModifiedMessage msg = ((ResourceModifiedJsonMessage) theMessage).getPayload();
try {
matchEmpiAndUpdateLinks(msg);
if (myEmpiResourceFileringSvc.shouldBeProcessed(msg)) {
matchEmpiAndUpdateLinks(msg);
}
} catch (Exception e) {
ourLog.error("Failed to handle EMPI Matching Resource:", e);
throw e;
}
}
public void matchEmpiAndUpdateLinks(ResourceModifiedMessage theMsg) {
String resourceType = theMsg.getId(myFhirContext).getResourceType();
validateResourceType(resourceType);

View File

@ -47,6 +47,7 @@ import ca.uhn.fhir.jpa.empi.svc.EmpiLinkSvcImpl;
import ca.uhn.fhir.jpa.empi.svc.EmpiLinkUpdaterSvcImpl;
import ca.uhn.fhir.jpa.empi.svc.EmpiMatchFinderSvcImpl;
import ca.uhn.fhir.jpa.empi.svc.EmpiMatchLinkSvc;
import ca.uhn.fhir.jpa.empi.svc.EmpiMessageFilteringSvc;
import ca.uhn.fhir.jpa.empi.svc.EmpiPersonDeletingSvc;
import ca.uhn.fhir.jpa.empi.svc.EmpiPersonMergerSvcImpl;
import ca.uhn.fhir.jpa.empi.svc.EmpiResetSvcImpl;
@ -211,4 +212,9 @@ public class EmpiConsumerConfig {
EmpiLinkDeleteSvc empiLinkDeleteSvc() {
return new EmpiLinkDeleteSvc();
}
@Bean
EmpiMessageFilteringSvc empiMessageFilteringSvc() {
return new EmpiMessageFilteringSvc();
}
}

View File

@ -0,0 +1,25 @@
package ca.uhn.fhir.jpa.empi.svc;
import ca.uhn.fhir.empi.api.IEmpiSettings;
import ca.uhn.fhir.empi.rules.json.EmpiResourceSearchParamJson;
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class EmpiMessageFilteringSvc {
@Autowired
private IEmpiSettings empiSettings;
@Autowired
EmpiSearchParamSvc myEmpiSearchParamSvc;
public boolean shouldBeProcessed(ResourceModifiedMessage theMsg) {
List<EmpiResourceSearchParamJson> candidateSearchParams = empiSettings.getEmpiRules().getCandidateSearchParams();
List<String> valuesFromResourceForSearchParam = myEmpiSearchParamSvc.getValueFromResourceForSearchParam(theResource, searchParam);
}
}

View File

@ -104,7 +104,7 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
@Test
public void testCreatingPersonWithInsufficentEMPIAttributesIsNotEMPIProcessed() throws InterruptedException {
myEmpiHelper.createWithLatch(new Patient());
myEmpiHelper.doCreateResource(new Patient(), true);
assertLinkCount(0);
}
@ -112,7 +112,6 @@ public class EmpiStorageInterceptorIT extends BaseEmpiR4Test {
public void testCreatingPatientWithOneOrMoreMatchingAttributesIsEMPIProcessed() throws InterruptedException {
myEmpiHelper.createWithLatch(buildPaulPatient());
assertLinkCount(1);
}
@Test