[Bugfix] mdm pointcut missing link update (#6296)

* add failing test

* add side-effect link updates to link event

* add to contributor list
This commit is contained in:
Jake Gillberg 2024-10-07 11:06:08 -05:00 committed by GitHub
parent 43e28da0c5
commit 32651e1c36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 61 additions and 0 deletions

View File

@ -188,6 +188,12 @@ public class MdmLinkUpdaterSvcImpl implements IMdmLinkUpdaterSvc {
// pointcut for MDM_POST_UPDATE_LINK // pointcut for MDM_POST_UPDATE_LINK
MdmLinkEvent event = new MdmLinkEvent(); MdmLinkEvent event = new MdmLinkEvent();
event.addMdmLink(myModelConverter.toJson(mdmLink)); event.addMdmLink(myModelConverter.toJson(mdmLink));
// add any link updates from side effects
mdmContext.getMdmLinks().stream().forEach(link -> {
event.addMdmLink(myModelConverter.toJson(link));
});
HookParams hookParams = new HookParams(); HookParams hookParams = new HookParams();
hookParams.add(RequestDetails.class, theParams.getRequestDetails()).add(MdmLinkEvent.class, event); hookParams.add(RequestDetails.class, theParams.getRequestDetails()).add(MdmLinkEvent.class, event);
myInterceptorBroadcaster.callHooks(Pointcut.MDM_POST_UPDATE_LINK, hookParams); myInterceptorBroadcaster.callHooks(Pointcut.MDM_POST_UPDATE_LINK, hookParams);

View File

@ -601,5 +601,55 @@ public class MdmOperationPointcutsIT extends BaseProviderR4Test {
assertFalse(retval.isEmpty()); assertFalse(retval.isEmpty());
} }
@Test
public void updateLink_NoMatch_LinkEvent_allUpdates() {
// When a Link is set to "NO_MATCH", it can cause other link updates.
// If a source record would be left unlinked to any
// golden record, a new link / golden record would be created.
// setup
String inputState = """
GP1, AUTO, MATCH, P1
""";
MDMState<Patient, JpaPid> state = new MDMState<>();
state.setInputState(inputState);
// we won't use for validation, just setup
myMdmLinkHelper.setup(state);
Patient patient = state.getParameter("P1");
Patient originalPatientGolden = state.getParameter("GP1");
AtomicBoolean called = new AtomicBoolean(false);
Object interceptor = new Object() {
@Hook(Pointcut.MDM_POST_UPDATE_LINK)
void onUpdate(RequestDetails theDetails, MdmLinkEvent theEvent) {
called.getAndSet(true);
assertThat(theEvent.getMdmLinks()).hasSize(2);
MdmLinkJson originalLink = theEvent.getMdmLinks().get(0);
MdmLinkJson newLink = theEvent.getMdmLinks().get(1);
String original_target = "Patient/" + originalPatientGolden.getIdPart();
assertThat(originalLink.getGoldenResourceId()).isEqualTo(original_target);
assertThat(newLink.getGoldenResourceId()).isNotEqualTo(original_target);
}
};
myInterceptors.add(interceptor);
myInterceptorService.registerInterceptor(interceptor);
// test
myMdmProvider.updateLink(
new StringType("Patient/" + originalPatientGolden.getIdPart()),
new StringType("Patient/" + patient.getIdPart()),
new StringType("NO_MATCH"),
new ServletRequestDetails()
);
// verify
assertTrue(called.get());
}
} }

View File

@ -921,6 +921,11 @@
<name>Adrienne Sox</name> <name>Adrienne Sox</name>
<organization>Galileo, Inc.</organization> <organization>Galileo, Inc.</organization>
</developer> </developer>
<developer>
<id>Jake-Gillberg</id>
<name>Jake Gillberg</name>
<organization>Galileo, Inc.</organization>
</developer>
<developer> <developer>
<id>melihaydogd</id> <id>melihaydogd</id>
<name>Ahmet Melih Aydoğdu</name> <name>Ahmet Melih Aydoğdu</name>