Introduce Filtering service
This commit is contained in:
parent
87d14f26fe
commit
c92a77c889
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue