Skip to content

Commit

Permalink
Bug/10525 multiple cases from pathogen test in contacts and event par…
Browse files Browse the repository at this point in the history
…tic (SORMAS-Foundation#11222)

* SORMAS-Foundation#10525 refactor backend from case to casePersonUuid

* SORMAS-Foundation#10525 show dialog only when no cases found

* SORMAS-Foundation#10525 changes after reviw

* SORMAS-Foundation#10525 rename parameter
  • Loading branch information
dinua authored Dec 21, 2022
1 parent 406ebae commit 4651358
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void saveBulkEditWithFacilities(

List<CasePersonDto> getDuplicates(@Valid CasePersonDto casePerson);

List<CaseDataDto> getDuplicatesWithPathogenTest(@Valid CaseDataDto caseDataDto, PathogenTestDto pathogenTestDto);
List<CaseDataDto> getDuplicatesWithPathogenTest(@Valid PersonReferenceDto personReferenceDto, PathogenTestDto pathogenTestDto);

List<CaseDataDto> getByPersonUuids(List<String> personUuids);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4199,7 +4199,7 @@ public List<CasePersonDto> getDuplicates(@Valid CasePersonDto casePerson, int re
}

@Override
public List<CaseDataDto> getDuplicatesWithPathogenTest(@Valid CaseDataDto caseDataDto, PathogenTestDto pathogenTestDto) {
public List<CaseDataDto> getDuplicatesWithPathogenTest(@Valid PersonReferenceDto personReferenceDto, PathogenTestDto pathogenTestDto) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Case> cq = cb.createQuery(Case.class);
Root<Case> caseRoot = cq.from(Case.class);
Expand All @@ -4212,7 +4212,7 @@ public List<CaseDataDto> getDuplicatesWithPathogenTest(@Valid CaseDataDto caseDa
cq.select(caseRoot);
Predicate filter = cb.and(
cb.equal(caseRoot.get(Case.DISEASE), pathogenTestDto.getTestedDisease()),
cb.equal(personJoin.get(Person.UUID), caseDataDto.getPerson().getUuid()),
cb.equal(personJoin.get(Person.UUID), personReferenceDto.getUuid()),
cb.equal(caseRoot.get(Case.DISEASE), pathogenTestJoin.get(PathogenTest.TESTED_DISEASE)),
cb.exists(sampleService.exists(cb, cq, samplesJoin, pathogenTestDto.getSample().getUuid())));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3146,7 +3146,7 @@ public void testDuplicatesWithPathogenTest() {
covidCase.setDisease(Disease.ANTHRAX);
CaseDataDto anthraxCase = getCaseFacade().cloneCase(covidCase);

List<CaseDataDto> duplicatedCases = getCaseFacade().getDuplicatesWithPathogenTest(covidCase, pathogenTestDto);
List<CaseDataDto> duplicatedCases = getCaseFacade().getDuplicatesWithPathogenTest(covidCase.getPerson(), pathogenTestDto);
assertEquals(1, duplicatedCases.size());
assertEquals(anthraxCase.getUuid(), duplicatedCases.get(0).getUuid());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private void handleAssociatedCase(
}
});
} else {
List<CaseDataDto> duplicatedCases = FacadeProvider.getCaseFacade().getDuplicatesWithPathogenTest(caze, dto);
List<CaseDataDto> duplicatedCases = FacadeProvider.getCaseFacade().getDuplicatesWithPathogenTest(caze.getPerson(), dto);
if (duplicatedCases == null || duplicatedCases.size() == 0) {
showCaseCloningWithNewDiseaseDialog(
caze,
Expand Down Expand Up @@ -319,7 +319,11 @@ private void handleAssociatedContact(
showChangeAssociatedSampleResultDialog(dto, null);
}
} else {
showCreateContactCaseDialog(contact, dto.getTestedDisease());
List<CaseDataDto> duplicatedCases =
FacadeProvider.getCaseFacade().getDuplicatesWithPathogenTest(contact.getPerson(), dto);
if (duplicatedCases == null || duplicatedCases.size() == 0) {
showCreateContactCaseDialog(contact, dto.getTestedDisease());
}
}
}
};
Expand Down Expand Up @@ -374,11 +378,15 @@ private void handleAssociatedEventParticipant(
showChangeAssociatedSampleResultDialog(dto, null);
}
} else {
showConvertEventParticipantToCaseDialog(eventParticipant, dto.getTestedDisease(), caseCreated -> {
if (eventDisease == null) {
handleCaseCreationFromContactOrEventParticipant(caseCreated, dto);
}
});
List<CaseDataDto> duplicatedCases =
FacadeProvider.getCaseFacade().getDuplicatesWithPathogenTest(eventParticipant.getPerson().toReference(), dto);
if (duplicatedCases == null || duplicatedCases.size() == 0) {
showConvertEventParticipantToCaseDialog(eventParticipant, dto.getTestedDisease(), caseCreated -> {
if (eventDisease == null) {
handleCaseCreationFromContactOrEventParticipant(caseCreated, dto);
}
});
}
}
}
};
Expand Down

0 comments on commit 4651358

Please sign in to comment.