From 434f5ff90cd6600ea6bba02153a546305c4ab98d Mon Sep 17 00:00:00 2001 From: Flava177 Date: Mon, 18 Nov 2024 09:41:36 +0000 Subject: [PATCH] #178: Updated pathogentest: Filtered the list for type of test, test result and second tested disease for ILI --- .../edit/PathogenTestEditFragment.java | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditFragment.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditFragment.java index 9ca859fab5d..606ae423979 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditFragment.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/pathogentest/edit/PathogenTestEditFragment.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -66,14 +67,12 @@ public class PathogenTestEditFragment extends BaseEditFragment labList; private List testTypeList; private List pcrTestSpecificationList; - private List testResultListSecondDisease; private List diseaseList; private List diseaseVariantList; private List testResultList; @@ -108,18 +107,12 @@ record = getActivityRootData(); sample = record.getSample(); testTypeList = DataUtils.getEnumItems(PathogenTestType.class, true, getFieldVisibilityCheckers()); pcrTestSpecificationList = DataUtils.getEnumItems(PCRTestSpecification.class, true); - testResultListSecondDisease = DataUtils.getEnumItems(FinalClassification.class, true); - testResultListSecondDisease.remove(new Item<>(PathogenTestResultType.PENDING.toString(), PathogenTestResultType.PENDING)); - testResultListSecondDisease.remove(new Item<>(PathogenTestResultType.NOT_DONE.toString(), PathogenTestResultType.NOT_DONE)); Disease incomingDisease = record.getSample().getAssociatedCase().getDisease(); - Disease corona = Disease.CORONAVIRUS; if(incomingDisease != null){ caseDisease = incomingDisease; } - coronaDisease = corona; - List diseases = DiseaseConfigurationCache.getInstance().getAllDiseases(true, true, true); diseaseList = DataUtils.toItems(diseases); if (record.getTestedDisease() != null && !diseases.contains(record.getTestedDisease())) { @@ -196,8 +189,6 @@ public void onChange(ControlPropertyField field) { contentBinding.pathogenTestPcrTestSpecification.initializeSpinner(pcrTestSpecificationList); contentBinding.pathogenTestTestedDisease.setValue(caseDisease); - contentBinding.pathogenTestSecondTestedDisease.setValue(coronaDisease); - contentBinding.pathogenTestSecondTestedDisease.setEnabled(false); contentBinding.pathogenTestTestedDisease.initializeSpinner(diseaseList, new ValueChangeListener() { final Disease currentDisease = record.getTestedDisease(); @@ -212,17 +203,16 @@ public void onChange(ControlPropertyField field) { } updateDiseaseVariantsField(contentBinding); - + if(caseDisease != Disease.NEW_INFLUENZA){ testTypeList = DataUtils.toItems( - Arrays.asList(PathogenTestType.values()), - true, - FieldVisibilityCheckers.withDisease((Disease) field.getValue()), - PathogenTestType.class); + Arrays.asList(PathogenTestType.values()), + true, + FieldVisibilityCheckers.withDisease((Disease) field.getValue()), + PathogenTestType.class); contentBinding.pathogenTestTestType.setSpinnerData(testTypeList); - } + }} }); contentBinding.pathogenTestTestedDiseaseVariant.initializeSpinner(diseaseVariantList); - contentBinding.pathogenTestTestResultForSecondDisease.initializeSpinner(testResultListSecondDisease); contentBinding.pathogenTestTestResult.initializeSpinner(testResultList, new ValueChangeListener() { @@ -292,6 +282,8 @@ public void onChange(ControlPropertyField field) { handleIDSR(); case AHF: handleAHF(); + case NEW_INFLUENZA: + handleILI(); } @@ -332,12 +324,12 @@ public int getEditLayout() { private void handleYellowFever() { getContentBinding().pathogenTestTestedDisease.setEnabled(false); - List values1 = Arrays.stream(FinalClassification.YF_CLASSIFICATION.toArray(new FinalClassification[0])) + /*List values1 = Arrays.stream(FinalClassification.YF_CLASSIFICATION.toArray(new FinalClassification[0])) .filter(c -> fieldVisibilityCheckers.isVisible(FinalClassification.class, c.name())) .collect(Collectors.toList()); List itemList = DataUtils.toItems(values1); - getContentBinding().pathogenTestFinalClassification.initializeSpinner(itemList); + getContentBinding().pathogenTestFinalClassification.initializeSpinner(itemList);*/ } @@ -352,6 +344,8 @@ public List getDiseaseFinalClassifications(Disease disease) switch (disease) { case MEASLES: return FinalClassification.measlesClass; + case YELLOW_FEVER: + return FinalClassification.YF_CLASSIFICATION; default: return FinalClassification.DEFAULT; } @@ -393,5 +387,35 @@ private void handleAHF(){ getContentBinding().pathogenTestSampleTestResultImmunoDate.setVisibility(isImmunoSelected ? View.VISIBLE : View.GONE); }); + } + + private void handleILI(){ + List iliTestTypeList = Arrays.asList(PathogenTestType.PCR_RT_PCR, PathogenTestType.OTHER); + getContentBinding().pathogenTestTestType.initializeSpinner(DataUtils.toItems(iliTestTypeList)); + + List iliTestResultType = Arrays.asList(PathogenTestResultType.INDETERMINATE,PathogenTestResultType.POSITIVE, PathogenTestResultType.NEGATIVE); + getContentBinding().pathogenTestTestResult.initializeSpinner(DataUtils.toItems(iliTestResultType)); + getContentBinding().pathogenTestTestResultForSecondDisease.initializeSpinner(DataUtils.toItems(iliTestResultType)); + + // Get the coronavirus disease + Disease coronaDisease = null; + for (Disease disease : DiseaseConfigurationCache.getInstance().getAllDiseases(true, true, true)) { + if (Disease.CORONAVIRUS.equals(disease)) { + coronaDisease = disease; + break; + } + } + + if (coronaDisease != null) { + List coronaDiseaseItemList = Collections.singletonList(DataUtils.toItem(coronaDisease)); + getContentBinding().pathogenTestSecondTestedDisease.initializeSpinner(coronaDiseaseItemList); + + // Set the value of the spinner + getContentBinding().pathogenTestSecondTestedDisease.setValue(DataUtils.toItem(coronaDisease)); + getContentBinding().pathogenTestSecondTestedDisease.setEnabled(false); + } + + + } } \ No newline at end of file