Skip to content

Commit

Permalink
#178: Updated pathogentest: Filtered the list for type of test, test …
Browse files Browse the repository at this point in the history
…result and second tested disease for ILI
  • Loading branch information
Flava177 committed Nov 18, 2024
1 parent 808fffd commit 434f5ff
Showing 1 changed file with 43 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -66,14 +67,12 @@ public class PathogenTestEditFragment extends BaseEditFragment<FragmentPathogenT
private PathogenTest record;
private Sample sample;
private Disease caseDisease;
private Disease coronaDisease;

// Enum lists

private List<Facility> labList;
private List<Item> testTypeList;
private List<Item> pcrTestSpecificationList;
private List<Item> testResultListSecondDisease;
private List<Item> diseaseList;
private List<Item> diseaseVariantList;
private List<Item> testResultList;
Expand Down Expand Up @@ -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<Disease> diseases = DiseaseConfigurationCache.getInstance().getAllDiseases(true, true, true);
diseaseList = DataUtils.toItems(diseases);
if (record.getTestedDisease() != null && !diseases.contains(record.getTestedDisease())) {
Expand Down Expand Up @@ -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();
Expand All @@ -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() {

Expand Down Expand Up @@ -292,6 +282,8 @@ public void onChange(ControlPropertyField field) {
handleIDSR();
case AHF:
handleAHF();
case NEW_INFLUENZA:
handleILI();
}


Expand Down Expand Up @@ -332,12 +324,12 @@ public int getEditLayout() {
private void handleYellowFever() {
getContentBinding().pathogenTestTestedDisease.setEnabled(false);

List<FinalClassification> values1 = Arrays.stream(FinalClassification.YF_CLASSIFICATION.toArray(new FinalClassification[0]))
/*List<FinalClassification> values1 = Arrays.stream(FinalClassification.YF_CLASSIFICATION.toArray(new FinalClassification[0]))
.filter(c -> fieldVisibilityCheckers.isVisible(FinalClassification.class, c.name()))
.collect(Collectors.toList());
List<Item> itemList = DataUtils.toItems(values1);
getContentBinding().pathogenTestFinalClassification.initializeSpinner(itemList);
getContentBinding().pathogenTestFinalClassification.initializeSpinner(itemList);*/

}

Expand All @@ -352,6 +344,8 @@ public List<FinalClassification> getDiseaseFinalClassifications(Disease disease)
switch (disease) {
case MEASLES:
return FinalClassification.measlesClass;
case YELLOW_FEVER:
return FinalClassification.YF_CLASSIFICATION;
default:
return FinalClassification.DEFAULT;
}
Expand Down Expand Up @@ -393,5 +387,35 @@ private void handleAHF(){
getContentBinding().pathogenTestSampleTestResultImmunoDate.setVisibility(isImmunoSelected ? View.VISIBLE : View.GONE);
});

}

private void handleILI(){
List<PathogenTestType> iliTestTypeList = Arrays.asList(PathogenTestType.PCR_RT_PCR, PathogenTestType.OTHER);
getContentBinding().pathogenTestTestType.initializeSpinner(DataUtils.toItems(iliTestTypeList));

List<PathogenTestResultType> 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<Item> 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);
}



}
}

0 comments on commit 434f5ff

Please sign in to comment.