Skip to content

Commit 11469cc

Browse files
Merge pull request #13527 from SORMAS-Foundation/bugfix-13526-not-able-to-create-pathogentests-for-events-and-contacts
Fixed the pathogen test failure for event
2 parents a0583a7 + 5162b66 commit 11469cc

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.stream.Collectors;
3030

3131
import de.symeda.sormas.api.DiseaseHelper;
32+
import de.symeda.sormas.api.event.EventReferenceDto;
3233
import de.symeda.sormas.api.sample.PathogenTestType;
3334
import org.apache.commons.collections4.CollectionUtils;
3435

@@ -119,10 +120,25 @@ public CommitDiscardWrapperComponent<PathogenTestForm> getPathogenTestCreateComp
119120
int caseSampleCount,
120121
Consumer<PathogenTestDto> onSavedPathogenTest,
121122
boolean suppressNavigateToCase) {
122-
CaseDataDto caseDataDto = FacadeProvider.getCaseFacade().getByUuid(sampleDto.getAssociatedCase().getUuid());
123-
PathogenTestForm createForm = new PathogenTestForm(sampleDto, true, caseSampleCount, false, true, caseDataDto.getDisease()); // Valid because jurisdiction doesn't matter for entities that are about to be created
123+
// Pathogen tests can be created for a sample that is associated with a case, event participant or contact.
124+
Disease associatedEventOrCaseOrContactDisease = null;
125+
if (sampleDto.getAssociatedCase() != null) {
126+
CaseDataDto caseDataDto = FacadeProvider.getCaseFacade().getByUuid(sampleDto.getAssociatedCase().getUuid());
127+
associatedEventOrCaseOrContactDisease = caseDataDto.getDisease();
128+
}
129+
if (associatedEventOrCaseOrContactDisease == null && sampleDto.getAssociatedEventParticipant() != null) {
130+
EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(sampleDto.getAssociatedEventParticipant().getUuid());
131+
EventReferenceDto eventDto = eventParticipant.getEvent();
132+
EventDto participantEvent = FacadeProvider.getEventFacade().getEventByUuid(eventDto.getUuid(), false);
133+
associatedEventOrCaseOrContactDisease = participantEvent.getDisease();
134+
}
135+
if (associatedEventOrCaseOrContactDisease == null && sampleDto.getAssociatedContact() != null) {
136+
ContactDto contact = FacadeProvider.getContactFacade().getByUuid(sampleDto.getAssociatedContact().getUuid());
137+
associatedEventOrCaseOrContactDisease = contact.getDisease();
138+
}
139+
PathogenTestForm createForm = new PathogenTestForm(sampleDto, true, caseSampleCount, false, true, associatedEventOrCaseOrContactDisease); // Valid because jurisdiction doesn't matter for entities that are about to be created
124140
// Defaulting the case disease as tested disease
125-
pathogenTest.setTestedDisease(caseDataDto.getDisease());
141+
pathogenTest.setTestedDisease(associatedEventOrCaseOrContactDisease);
126142
createForm.setValue(pathogenTest);
127143
final CommitDiscardWrapperComponent<PathogenTestForm> editView =
128144
new CommitDiscardWrapperComponent<>(createForm, UiUtil.permitted(UserRight.PATHOGEN_TEST_CREATE), createForm.getFieldGroup());

0 commit comments

Comments
 (0)