Skip to content

Commit bd465c8

Browse files
authored
Merge pull request #13878 from SORMAS-Foundation/feature/13858-tube-field-handler
Pathogen Test Form Refactor (Part 1)
2 parents 230943b + 19a2b90 commit bd465c8

38 files changed

Lines changed: 4096 additions & 1148 deletions

sormas-api/src/main/java/de/symeda/sormas/api/utils/Diseases.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ public static boolean isDefined(Class<?> clazz, String propertyName, Disease dis
9090
return diseaseConfig.get(propertyName).contains(disease);
9191
}
9292

93+
public static <E extends Enum<E>> List<E> getVisibleValues(Class<E> enumClass, Disease disease) {
94+
return Arrays.stream(enumClass.getEnumConstants())
95+
.filter(e -> isDefinedOrMissing(enumClass, e.name(), disease))
96+
.collect(Collectors.toList());
97+
}
98+
9399
private static synchronized void readDiseaseConfig(Class<?> clazz) {
94100

95101
HashMap<String, List<Disease>> diseaseConfig = new HashMap<>();

sormas-backend/src/main/resources/sql/sormas_schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15770,4 +15770,4 @@ UPDATE diseaseconfiguration SET exposurecategories = 'VECTOR_BORNE' WHERE diseas
1577015770

1577115771
INSERT INTO schema_version (version_number, comment) VALUES (622, '#13887 default disease exposure category configuration');
1577215772

15773-
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***
15773+
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import de.symeda.sormas.api.caze.CaseClassification;
4343
import de.symeda.sormas.api.caze.CaseDataDto;
4444
import de.symeda.sormas.api.caze.CaseReferenceDto;
45-
import de.symeda.sormas.api.common.DeletionReason;
4645
import de.symeda.sormas.api.contact.ContactDto;
4746
import de.symeda.sormas.api.contact.ContactReferenceDto;
4847
import de.symeda.sormas.api.contact.ContactStatus;
@@ -137,10 +136,10 @@ public CommitDiscardWrapperComponent<PathogenTestForm> getPathogenTestCreateComp
137136
ContactDto contact = FacadeProvider.getContactFacade().getByUuid(sampleDto.getAssociatedContact().getUuid());
138137
associatedEventOrCaseOrContactDisease = contact.getDisease();
139138
}
140-
PathogenTestForm createForm = new PathogenTestForm(sampleDto, true, caseSampleCount, false, true, associatedEventOrCaseOrContactDisease); // Valid because jurisdiction doesn't matter for entities that are about to be created
141-
// Defaulting the case disease as tested disease
139+
PathogenTestForm createForm = new PathogenTestForm(sampleDto, true, caseSampleCount, false, true, associatedEventOrCaseOrContactDisease);
142140
pathogenTest.setTestedDisease(associatedEventOrCaseOrContactDisease);
143141
createForm.setValue(pathogenTest);
142+
144143
final CommitDiscardWrapperComponent<PathogenTestForm> editView =
145144
new CommitDiscardWrapperComponent<>(createForm, UiUtil.permitted(UserRight.PATHOGEN_TEST_CREATE), createForm.getFieldGroup());
146145

@@ -254,10 +253,7 @@ public CommitDiscardWrapperComponent<PathogenTestForm> getPathogenTestEditCompon
254253
});
255254

256255
if (pathogenTest.isDeleted()) {
257-
editView.getWrappedComponent().getField(PathogenTestDto.DELETION_REASON).setVisible(true);
258-
if (editView.getWrappedComponent().getField(PathogenTestDto.DELETION_REASON).getValue() == DeletionReason.OTHER_REASON) {
259-
editView.getWrappedComponent().getField(PathogenTestDto.OTHER_DELETION_REASON).setVisible(true);
260-
}
256+
editView.getWrappedComponent().showDeletionInfo(pathogenTest.getDeletionReason());
261257
}
262258
editView.restrictEditableComponentsOnEditView(
263259
forHumanSample ? UserRight.SAMPLE_EDIT : UserRight.ENVIRONMENT_SAMPLE_EDIT,
@@ -354,14 +350,17 @@ public void savePathogenTests(List<PathogenTestDto> pathogenTests, SampleReferen
354350
/**
355351
* Handles the association of a pathogen test with a case.
356352
* Based on pathogen test results the following logic is applied:
357-
*
358-
* <p>Negative test result AND test result verified
353+
*
354+
* <p>
355+
* Negative test result AND test result verified
359356
* <ol>
360-
* <li>Tested disease == case disease AND test result != sample pathogen test result: Ask user whether to update the sample pathogen test result</li>
357+
* <li>Tested disease == case disease AND test result != sample pathogen test result: Ask user whether to update the sample pathogen
358+
* test result</li>
361359
* <li>Tested disease != case disease: Do nothing</li>
362360
* </ol>
363361
* </p>
364-
* <p>Positive test result AND test result verified
362+
* <p>
363+
* Positive test result AND test result verified
365364
* <ol>
366365
* <li>Tested disease == case disease: Ask user whether to update the sample pathogen test result
367366
* <ol>
@@ -372,12 +371,15 @@ public void savePathogenTests(List<PathogenTestDto> pathogenTests, SampleReferen
372371
* <li>Tested disease != case disease: Ask user to create a new case for the tested disease</li>
373372
* </ol>
374373
* </p>
375-
*
376-
* @param pathogenTests the pathogen tests
377-
* @param associatedCase the associated case
378-
* @param suppressNavigateToCase whether to suppress navigation to the case
379-
*
380-
*/
374+
*
375+
* @param pathogenTests
376+
* the pathogen tests
377+
* @param associatedCase
378+
* the associated case
379+
* @param suppressNavigateToCase
380+
* whether to suppress navigation to the case
381+
*
382+
*/
381383
private void handleAssociatedCase(List<PathogenTestDto> pathogenTests, CaseReferenceDto associatedCase, boolean suppressNavigateToCase) {
382384

383385
if (!UiUtil.permitted(UserRight.CASE_EDIT)) {
@@ -413,7 +415,6 @@ private void handleAssociatedCase(List<PathogenTestDto> pathogenTests, CaseRefer
413415

414416
final boolean hasVerifiedTests = hasVerifiedPositiveTest || hasVerifiedNegativeTest;
415417

416-
417418
// 1. Ask user to update sample overall result if latest test result is different
418419
// 2. Ask user to update disease variant if case variant is different
419420
// 3. Ask user if they want to confirm the case only if any of the tests are verified either positive or negative (not pending or other)
@@ -436,7 +437,7 @@ private void handleAssociatedCase(List<PathogenTestDto> pathogenTests, CaseRefer
436437
// We decided this based on the intented text in the dialog but based on the test results instead of the sample overall result
437438
if (hasVerifiedPositiveTest) {
438439
// The final laboratory result of the sample the saved pathogen test belongs to is positive. <-- sample overall result
439-
// However, the case cannot be automatically classified as a confirmed case because it is missing some information.
440+
// However, the case cannot be automatically classified as a confirmed case because it is missing some information.
440441
// Do you want to set the case classification to confirmed anyway?
441442
this.showConfirmCaseDialog(c); // Case classification
442443
}

0 commit comments

Comments
 (0)