WIP after persistence checked
This commit is contained in:
parent
2bc024fef9
commit
4be3334f6f
|
@ -138,7 +138,7 @@ public class FhirResourceDaoCodeSystemR4 extends BaseHapiFhirResourceDao<CodeSys
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceTable 4updateEntity(RequestDetails theRequest, IBaseResource theResource, IBasePersistedResource theEntity, Date theDeletedTimestampOrNull, boolean thePerformIndexing,
|
||||
public ResourceTable updateEntity(RequestDetails theRequest, IBaseResource theResource, IBasePersistedResource theEntity, Date theDeletedTimestampOrNull, boolean thePerformIndexing,
|
||||
boolean theUpdateVersion, TransactionDetails theTransactionDetails, boolean theForceUpdate, boolean theCreateNewHistoryEntry) {
|
||||
ResourceTable retVal = super.updateEntity(theRequest, theResource, theEntity, theDeletedTimestampOrNull, thePerformIndexing, theUpdateVersion, theTransactionDetails, theForceUpdate, theCreateNewHistoryEntry);
|
||||
|
||||
|
|
|
@ -24,11 +24,15 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
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.entity.MdmLink;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.jpa.mdm.svc.MdmLinkSvcImpl;
|
||||
import ca.uhn.fhir.jpa.mdm.svc.MdmMatchLinkSvc;
|
||||
import ca.uhn.fhir.jpa.mdm.svc.MdmResourceFilteringSvc;
|
||||
import ca.uhn.fhir.jpa.mdm.svc.candidate.TooManyCandidatesException;
|
||||
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
|
||||
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
|
||||
import ca.uhn.fhir.mdm.api.IMdmLinkSvc;
|
||||
import ca.uhn.fhir.mdm.api.IMdmSettings;
|
||||
import ca.uhn.fhir.mdm.api.MdmLinkChangeEvent;
|
||||
import ca.uhn.fhir.mdm.log.Logs;
|
||||
|
@ -46,11 +50,15 @@ import org.springframework.messaging.MessageHandler;
|
|||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class MdmMessageHandler implements MessageHandler {
|
||||
|
||||
private static final Logger ourLog = Logs.getMdmTroubleshootingLog();
|
||||
|
||||
@Autowired
|
||||
private MdmLinkDaoSvc myMdmLinkDaoSvc;
|
||||
@Autowired
|
||||
private MdmMatchLinkSvc myMdmMatchLinkSvc;
|
||||
@Autowired
|
||||
|
@ -102,16 +110,30 @@ public class MdmMessageHandler implements MessageHandler {
|
|||
default:
|
||||
ourLog.trace("Not processing modified message for {}", theMsg.getOperationType());
|
||||
}
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log(mdmContext, "Failure during MDM processing: " + e.getMessage(), e);
|
||||
mdmContext.addTransactionLogMessage(e.getMessage());
|
||||
} finally {
|
||||
|
||||
// Interceptor call: MDM_AFTER_PERSISTED_RESOURCE_CHECKED
|
||||
IBaseResource targetResource = theMsg.getPayload(myFhirContext);
|
||||
ResourceOperationMessage outgoingMsg = new ResourceOperationMessage(myFhirContext, targetResource, theMsg.getOperationType());
|
||||
outgoingMsg.setTransactionId(theMsg.getTransactionId());
|
||||
|
||||
MdmLinkChangeEvent linkChangeEvent = mdmContext.getMdmLinkChangeEvent();
|
||||
Optional<MdmLink> mdmLinkBySource = myMdmLinkDaoSvc.findMdmLinkBySource(targetResource);
|
||||
if (!mdmLinkBySource.isPresent()) {
|
||||
ourLog.warn("Unable to find link by source for {}", targetResource.getIdElement());
|
||||
}
|
||||
|
||||
mdmLinkBySource.ifPresent(link -> {
|
||||
linkChangeEvent.setMdmMatchResult(link.getMatchResult());
|
||||
linkChangeEvent.setMdmLinkSource(link.getLinkSource());
|
||||
linkChangeEvent.setEidMatch(link.isEidMatchPresent());
|
||||
linkChangeEvent.setNewGoldenResource(link.getHadToCreateNewGoldenResource());
|
||||
linkChangeEvent.setScore(link.getScore());
|
||||
linkChangeEvent.setRuleCount(link.getRuleCount());
|
||||
});
|
||||
|
||||
HookParams params = new HookParams()
|
||||
.add(ResourceOperationMessage.class, outgoingMsg)
|
||||
.add(TransactionLogMessages.class, mdmContext.getTransactionLogMessages())
|
||||
|
|
Loading…
Reference in New Issue