diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5994-fix-bug-in-survivorship-svc.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5994-fix-bug-in-survivorship-svc.yaml new file mode 100644 index 000000000000..048eb038a344 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5994-fix-bug-in-survivorship-svc.yaml @@ -0,0 +1,6 @@ +--- +type: fix +issue: 5994 +title: "Fixed a bug in the MdmSurvivorshipSvcImpl that caused resourceType/id + (as opposed to just id) to be passed on to the IIdHelperService. +" diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmSurvivorshipSvcImplTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmSurvivorshipSvcImplTest.java index b9c6a2668211..fa3a282c4026 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmSurvivorshipSvcImplTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmSurvivorshipSvcImplTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; @@ -43,11 +44,13 @@ import java.util.concurrent.atomic.AtomicInteger; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -195,6 +198,15 @@ public void rebuildGoldenResourceCurrentLinksUsingSurvivorshipRules_withManyLink verify(resourceDao) .update(eq(goldenPatientRebuilt), any(RequestDetails.class)); + + ArgumentCaptor> idsCaptor = ArgumentCaptor.forClass(List.class); + verify(myIIdHelperService).resolveResourcePersistentIds(any(RequestPartitionId.class), anyString(), idsCaptor.capture()); + assertNotNull(idsCaptor.getValue()); + assertFalse(idsCaptor.getValue().isEmpty()); + for (String id : idsCaptor.getValue()) { + assertFalse(id.contains("/")); + assertFalse(id.contains("Patient")); + } } private MdmTransactionContext createTransactionContext() { diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmSurvivorshipSvcImpl.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmSurvivorshipSvcImpl.java index 9c951b0ad01a..4cbff60f78be 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmSurvivorshipSvcImpl.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmSurvivorshipSvcImpl.java @@ -155,7 +155,10 @@ private Stream getMatchedSourceIdsByLinkUpdateDate( // we want it ordered List sourceIds = new ArrayList<>(); linksQuery.forEach(link -> { - sourceIds.add(link.getSourceId()); + String sourceId = link.getSourceId(); + // we want only the id part, not the resource type + sourceId = sourceId.replace(resourceType + "/", ""); + sourceIds.add(sourceId); }); Map sourceIdToPid = new HashMap<>(); if (!sourceIds.isEmpty()) {