fixed bug in survivorship rebuilding service (#5995)

Co-authored-by: leif stawnyczy <leifstawnyczy@leifs-mbp.home>
This commit is contained in:
TipzCM 2024-06-10 11:21:02 -04:00 committed by GitHub
parent 432167011d
commit 488bf6f18a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 1 deletions

View File

@ -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.
"

View File

@ -29,6 +29,7 @@ import org.junit.jupiter.api.BeforeEach;
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.Map;
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 class MdmSurvivorshipSvcImplTest {
verify(resourceDao)
.update(eq(goldenPatientRebuilt), any(RequestDetails.class));
ArgumentCaptor<List<String>> 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() {

View File

@ -155,7 +155,10 @@ public class MdmSurvivorshipSvcImpl implements IMdmSurvivorshipService {
// we want it ordered
List<String> 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<String, IResourcePersistentId> sourceIdToPid = new HashMap<>();
if (!sourceIds.isEmpty()) {