From ff22e55b8f0f1da754a49741a0cd96aded6f4a81 Mon Sep 17 00:00:00 2001 From: Flava177 Date: Fri, 13 Dec 2024 14:26:11 +0000 Subject: [PATCH] #170: implemented symptoms features for Mpox. --- .../app/backend/common/DatabaseHelper.java | 7 +- .../sormas/app/backend/symptoms/Symptoms.java | 20 ++++ .../backend/symptoms/SymptomsDtoHelper.java | 4 + .../app/symptoms/SymptomsEditFragment.java | 65 +++++++++-- .../layout/fragment_symptoms_edit_layout.xml | 102 +++++++++++++++++- 5 files changed, 190 insertions(+), 8 deletions(-) diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java index 407d0c32669..f70216a5e61 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java @@ -231,7 +231,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // public static final int DATABASE_VERSION = 307; //public static final int DATABASE_VERSION = 343; // public static final int DATABASE_VERSION = 410; - public static final int DATABASE_VERSION = 419; + public static final int DATABASE_VERSION = 420; private static DatabaseHelper instance = null; @@ -4309,6 +4309,11 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN regionOfResidence_id bigint REFERENCES region(id);"); getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN districtOfResidence_id bigint REFERENCES district(id);"); + case 419: + currentVersion = 419; + getDao(Symptoms.class).executeRaw("ALTER TABLE symptoms ADD COLUMN dateOfDeath Date;"); + getDao(Symptoms.class).executeRaw("ALTER TABLE symptoms ADD COLUMN placeOfDeath varchar(255);"); + // ATTENTION: break should only be done after last version break; default: diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/Symptoms.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/Symptoms.java index ecd76d2370b..c358bd41b26 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/Symptoms.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/Symptoms.java @@ -659,6 +659,10 @@ public class Symptoms extends PseudonymizableAdo { @Enumerated(EnumType.STRING) private YesNo pregnant; + @DatabaseField(dataType = DataType.DATE_LONG) + private Date dateOfDeath; + @Column + private String placeOfDeath; @Override @@ -2830,4 +2834,20 @@ public CaseOutcome getOutcome() { public void setOutcome(CaseOutcome outcome) { this.outcome = outcome; } + + public Date getDateOfDeath() { + return dateOfDeath; + } + + public void setDateOfDeath(Date dateOfDeath) { + this.dateOfDeath = dateOfDeath; + } + + public String getPlaceOfDeath() { + return placeOfDeath; + } + + public void setPlaceOfDeath(String placeOfDeath) { + this.placeOfDeath = placeOfDeath; + } } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/SymptomsDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/SymptomsDtoHelper.java index 8606d17628f..a930fedac89 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/SymptomsDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/symptoms/SymptomsDtoHelper.java @@ -314,6 +314,8 @@ public void fillInnerFromDto(Symptoms target, SymptomsDto source) { target.setTrimester(source.getTrimester()); target.setPostpartum(source.getPostpartum()); target.setPregnant(source.getPregnant()); + target.setDateOfDeath(source.getDateOfDeath()); + target.setPlaceOfDeath(source.getPlaceOfDeath()); // target.setHealthConditions(healthConditionsDtoHelper.fillOrCreateFromDto(target.getHealthConditions(), source.getHealthConditions())); target.setPseudonymized(source.isPseudonymized()); } @@ -578,6 +580,8 @@ public void fillInnerFromAdo(SymptomsDto target, Symptoms source) { target.setTrimester(source.getTrimester()); target.setPostpartum(source.getPostpartum()); target.setPregnant(source.getPregnant()); + target.setDateOfDeath(source.getDateOfDeath()); + target.setPlaceOfDeath(source.getPlaceOfDeath()); target.setPseudonymized(source.isPseudonymized()); } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/symptoms/SymptomsEditFragment.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/symptoms/SymptomsEditFragment.java index dfeabda7cf9..ad599065b4f 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/symptoms/SymptomsEditFragment.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/symptoms/SymptomsEditFragment.java @@ -19,15 +19,23 @@ import android.view.View; import java.util.ArrayList; +import java.util.Arrays; +import java.util.EnumSet; import java.util.List; +import java.util.Objects; import java.util.Set; +import java.util.stream.Collectors; import de.symeda.sormas.api.Disease; import de.symeda.sormas.api.FormType; import de.symeda.sormas.api.caze.CaseClassification; import de.symeda.sormas.api.caze.CaseOutcome; +import de.symeda.sormas.api.caze.VaccinationStatus; +import de.symeda.sormas.api.hospitalization.SymptomsList; +import de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup; import de.symeda.sormas.api.person.ApproximateAgeType; import de.symeda.sormas.api.sample.IpSampleTestType; +import de.symeda.sormas.api.sample.SampleMaterial; import de.symeda.sormas.api.symptoms.CongenitalHeartDiseaseType; import de.symeda.sormas.api.symptoms.GuineaWormFirstSymptom; import de.symeda.sormas.api.symptoms.SymptomState; @@ -35,6 +43,7 @@ import de.symeda.sormas.api.symptoms.SymptomsDto; import de.symeda.sormas.api.symptoms.SymptomsHelper; import de.symeda.sormas.api.symptoms.TemperatureSource; +import de.symeda.sormas.api.utils.BodyPart; import de.symeda.sormas.api.utils.DependantOn; import de.symeda.sormas.api.utils.InjectionSite; import de.symeda.sormas.api.utils.YesNoUnknown; @@ -78,8 +87,6 @@ public class SymptomsEditFragment extends BaseEditFragment bodyTempList; private List tempSourceList; private List congenitalHeartDiseaseList; - private List caseOutcomeList; - private IEntryItemOnClickListener clearAllCallback; private IEntryItemOnClickListener setClearedToNoCallback; private IEntryItemOnClickListener setClearedToUnknownCallback; @@ -171,10 +178,9 @@ public void onLayoutBinding(final FragmentSymptomsEditLayoutBinding contentBindi contentBinding.setClearAllCallback(clearAllCallback); contentBinding.setSetClearedToNoCallback(setClearedToNoCallback); contentBinding.setSetClearedToUnknownCallback(setClearedToUnknownCallback); - caseOutcomeList = DataUtils.getEnumItems(CaseOutcome.class, true); - contentBinding.symptomsOutcome.setSpinnerData(caseOutcomeList); contentBinding.setYesNoUnknownClass(YesNoUnknown.class); contentBinding.symptomsDateOnsetParalysis.initializeDateField(getFragmentManager()); + contentBinding.symptomsDateOfDeath.initializeDateField(getFragmentManager()); injectionSiteList = DataUtils.getEnumItems(InjectionSite.class, true); contentBinding.symptomsSiteOfParalysis.initializeCheckBoxGroup(injectionSiteList); @@ -225,18 +231,51 @@ public void onAfterLayoutBinding(FragmentSymptomsEditLayoutBinding contentBindin contentBinding.symptomsDateFirstWormEmergence.initializeDateField(getFragmentManager()); contentBinding.symptomsOutcome.initializeSpinner(outcomeList); contentBinding.symptomsDateOfOnset.initializeDateField(getFragmentManager()); + contentBinding.symptomsDateOfOnsetRash.initializeDateField(getFragmentManager()); contentBinding.symptomsTemperature.setSelectionOnOpen(37.0f); + initSymptomFields(contentBinding); initOnsetSymptomField(contentBinding); + Set symptomList = Arrays.stream(SymptomsList.MpoxList()) + .filter(c -> c != null) + .filter(c -> fieldVisibilityCheckers.isVisible(SymptomsList.class, c.name())) + .collect(Collectors.toSet()); + + List compatibleItems = DataUtils.toItems(new ArrayList<>(symptomList)); + compatibleItems.removeIf(item -> item == null || item.toString().isEmpty()); + + contentBinding.symptomsSymptomsSelected.initializeCheckBoxGroup(compatibleItems); + + contentBinding.symptomsSymptomsSelected.setOnValueChangeListener( field -> { + List selectedValues = contentBinding.symptomsSymptomsSelected.getSelectedValues(); + + boolean other = selectedValues != null && selectedValues.contains("Other"); + contentBinding.symptomsSymptomsSelectedOther.setVisibility(other ? View.VISIBLE : View.GONE); + + }); + + List mainItems = DataUtils.getEnumItems(BodyPart.class); + mainItems.removeIf(item -> item == null || item.toString().isEmpty()); + + contentBinding.symptomsRashSymptoms.initializeCheckBoxGroup(mainItems); + + contentBinding.symptomsRashSymptoms.setOnValueChangeListener( field -> { + List selectedValues = contentBinding.symptomsRashSymptoms.getSelectedValues(); + + boolean otherRash = selectedValues != null && selectedValues.contains("Other"); + contentBinding.symptomsRashSymptomsOtherAreas.setVisibility(otherRash ? View.VISIBLE : View.GONE); + + }); + // Remove the Complications heading for CRS; should be done automatically later if (disease == Disease.CONGENITAL_RUBELLA||disease == Disease.MONKEYPOX) { contentBinding.complicationsHeading.setVisibility(GONE); } //TODO: CHANGE FROM IF TO SWITCH AND REMOVE REDUNDANCY CODE - if (disease == Disease.YELLOW_FEVER || disease == Disease.AHF){ + if (disease == Disease.YELLOW_FEVER || disease == Disease.AHF || disease == Disease.MONKEYPOX){ Set outcomesToRemove = Set.of( CaseOutcome.NO_OUTCOME, @@ -247,11 +286,25 @@ public void onAfterLayoutBinding(FragmentSymptomsEditLayoutBinding contentBindin CaseOutcome.RECOVERED ); - contentBinding.symptomsOutcome.initializeSpinner(outcomeList); outcomeList.removeIf(item -> outcomesToRemove.contains(item.getValue())); } + if (disease == Disease.MONKEYPOX) { + contentBinding.symptomsOutcome.setCaption("Status of the Patient"); + + List rashSymptomsList = Arrays.asList( + SymptomsList.MACULAR, + SymptomsList.MACULOPAPULAR, + SymptomsList.VESICULAR, + SymptomsList.PAPULAR, + SymptomsList.PETECHIAL + ); + + contentBinding.symptomsTypeOfRash.initializeSpinner(DataUtils.toItems(rashSymptomsList)); + + } + if (disease == Disease.YELLOW_FEVER || disease == Disease.AHF){ contentBinding.symptomsDateOfOnset.setCaption("Date Of Onset For The Fever"); } diff --git a/sormas-app/app/src/main/res/layout/fragment_symptoms_edit_layout.xml b/sormas-app/app/src/main/res/layout/fragment_symptoms_edit_layout.xml index 4cfef1e16af..f149fbf4ff5 100644 --- a/sormas-app/app/src/main/res/layout/fragment_symptoms_edit_layout.xml +++ b/sormas-app/app/src/main/res/layout/fragment_symptoms_edit_layout.xml @@ -31,9 +31,13 @@ + + + + @@ -1710,12 +1714,17 @@ style="@style/ControlSingleColumnStyle" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +