Skip to content

Commit

Permalink
PEPPER-923 . cleanup/refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sampath K. Settipalli committed Nov 7, 2024
1 parent a87104d commit 9feaa25
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -143,26 +142,25 @@ protected Map<Integer, Integer> getParticipantIds(List<OncHistoryRecord> oncHist

String esIndex = new DDPInstanceDao().getDDPInstanceByInstanceName(realm).orElseThrow().getEsParticipantIndex();
for (OncHistoryRecord rec : oncHistoryRecords) {
int participantId = participantIdProvider.getParticipantIdForShortId(rec.getParticipantTextId());
Optional<ElasticSearchParticipantDto> ptpData = elasticSearchService.getParticipantDocumentByShortId(
rec.getParticipantTextId(), esIndex);
if (ptpData.isEmpty()) {
throw new OncHistoryValidationException("Invalid short ID " + rec.getParticipantTextId());
}
if (ptpData.get().getStatus().isPresent() && ptpData.get().getStatus().get().startsWith("EXITED")) {
ElasticSearchParticipantDto ptpData = elasticSearchService.getParticipantDocumentByShortId(
rec.getParticipantTextId(), esIndex).orElseThrow(() -> new OncHistoryValidationException("Invalid short ID " + rec.getParticipantTextId()));
if (ptpData.getStatus().isPresent() && ptpData.getStatus().get().startsWith("EXITED")) {
exitedParticipants.add(rec.getParticipantTextId());
log.info("Participant {} is exited, skipping", rec.getParticipantTextId()); //todo
}

if (!exitedParticipants.isEmpty()) {
continue; //skip MR verify/creation. continuing to collect any other exited participant hruids.
//skip MR verify/creation. continuing to collect any other exited participant hruids.
continue;
}

int participantId;
try {
participantId = ptpData.getDsm().get().getParticipant().get().getParticipantId().intValue();
log.info("Found participant ID {} for short ID {}", participantId, rec.getParticipantTextId());
ParticipantDto participant = participantDao.get(participantId).orElseThrow();
rec.setDdpParticipantId(participant.getDdpParticipantId().orElseThrow());
} catch (Exception e) {
throw new DsmInternalError("Participant not found for id " + participantId, e);
throw new DsmInternalError("Failed to get Participant/Participant Id for " + rec.getParticipantTextId(), e);
}

rec.setParticipantId(participantId);
Expand Down

0 comments on commit 9feaa25

Please sign in to comment.