From 901b05c9d19b4b7a5127495a383f38c897c849c4 Mon Sep 17 00:00:00 2001 From: Flava177 Date: Fri, 15 Nov 2024 10:36:19 +0000 Subject: [PATCH] #178: Added terminationDateHospitalStay field to hospitalization. Updated EpidemiologicalDataEditFragment by setting fields visibility to gone. Updated layout style of sample_shipped. --- .../app/backend/common/DatabaseHelper.java | 6 +- .../hospitalization/Hospitalization.java | 8 ++ .../edit/CaseEditHospitalizationFragment.java | 56 +++++--- .../EpidemiologicalDataEditFragment.java | 11 ++ ...gment_case_edit_hospitalization_layout.xml | 122 +++++++----------- .../res/layout/fragment_edit_epid_layout.xml | 64 ++++----- .../layout/fragment_sample_edit_layout.xml | 2 +- 7 files changed, 146 insertions(+), 123 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 0886956f0b5..12d4d73695e 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 @@ -218,7 +218,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 = 397; + public static final int DATABASE_VERSION = 398; private static DatabaseHelper instance = null; @@ -3886,6 +3886,10 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int getDao(Person.class).executeRaw("ALTER TABLE person ADD COLUMN investigatorAddress varchar(255) ;"); getDao(Person.class).executeRaw("ALTER TABLE person ADD COLUMN investigatorTel varchar(255) ;"); + case 397: + currentVersion = 397; + getDao(Hospitalization.class).executeRaw("ALTER TABLE hospitalizations ADD COLUMN terminationDateHospitalStay DATE ;"); + // ATTENTION: break should only be done after last version break; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/hospitalization/Hospitalization.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/hospitalization/Hospitalization.java index 66f61ec9a12..a32d136befa 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/hospitalization/Hospitalization.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/hospitalization/Hospitalization.java @@ -112,6 +112,8 @@ public class Hospitalization extends AbstractDomainObject { private YesNoUnknown seenAtAHealthFacility; @Enumerated(EnumType.STRING) private YesNoUnknown wasPatientAdmitted; + @DatabaseField(dataType = DataType.DATE_LONG) + private Date terminationDateHospitalStay; public Date getAdmissionDate() { @@ -345,4 +347,10 @@ public void setWasPatientAdmitted(YesNoUnknown wasPatientAdmitted) { this.wasPatientAdmitted = wasPatientAdmitted; } + public Date getTerminationDateHospitalStay() { + return terminationDateHospitalStay; + } + public void setTerminationDateHospitalStay(Date terminationDateHospitalStay) { + this.terminationDateHospitalStay = terminationDateHospitalStay; + } } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditHospitalizationFragment.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditHospitalizationFragment.java index 2511fc680e3..f7824b1fa9b 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditHospitalizationFragment.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditHospitalizationFragment.java @@ -24,6 +24,7 @@ import androidx.databinding.ObservableArrayList; +import java.util.Arrays; import java.util.List; import de.symeda.sormas.api.Disease; @@ -45,7 +46,6 @@ import de.symeda.sormas.app.R; import de.symeda.sormas.app.backend.caze.Case; import de.symeda.sormas.app.backend.common.DatabaseHelper; -import de.symeda.sormas.app.backend.facility.Facility; import de.symeda.sormas.app.backend.hospitalization.Hospitalization; import de.symeda.sormas.app.backend.hospitalization.PreviousHospitalization; import de.symeda.sormas.app.component.Item; @@ -66,6 +66,7 @@ public class CaseEditHospitalizationFragment extends BaseEditFragment outcomeList; private List inpatientOutpatientList; + private Disease disease; // Static methods @@ -170,6 +171,7 @@ record = caze.getHospitalization(); patientCondition = DataUtils.getEnumItems(MildModerateSevereCritical.class, true); outcomeList = DataUtils.getEnumItems(CaseOutcome.class, true); inpatientOutpatientList = DataUtils.getEnumItems(InpatOutpat.class, true); + disease = caze.getDisease(); } @Override @@ -200,12 +202,8 @@ public void onLayoutBinding(final FragmentCaseEditHospitalizationLayoutBinding c verifyPrevHospitalizationStatus(); }); - if(caze.getDisease() != null){ - hideFieldsForDisease(caze.getDisease(), contentBinding.mainContent, FormType.HOSPITALIZATION_EDIT); - } - - if(caze.getDisease() == Disease.AHF){ - handleAHF(); + if (disease != null) { + hideFieldsForDisease(disease, contentBinding.mainContent, FormType.HOSPITALIZATION_EDIT); } } @@ -225,17 +223,19 @@ protected void onAfterLayoutBinding(FragmentCaseEditHospitalizationLayoutBinding contentBinding.caseHospitalizationIsolationDate.initializeDateField(getFragmentManager()); contentBinding.caseHospitalizationDateFirstSeen.initializeDateField(getFragmentManager()); contentBinding.caseHospitalizationNotifyDistrictDate.initializeDateField(getFragmentManager()); - contentBinding.caseHospitalizationDateFormSentToDistrict.initializeDateField(getFragmentManager()); contentBinding.caseHospitalizationPatientConditionOnAdmission.initializeSpinner(patientCondition); contentBinding.caseHospitalizationDateFormSentToDistrict.initializeDateField(getFragmentManager()); - + contentBinding.caseHospitalizationTerminationDateHospitalStay.initializeDateField(getFragmentManager()); contentBinding.caseDataOutcome.initializeSpinner(outcomeList); contentBinding.caseHospitalizationSelectInpatientOutpatient.initializeSpinner(inpatientOutpatientList); verifyPrevHospitalizationStatus(); - if (caze.getDisease() != null) { - super.hideFieldsForDisease(caze.getDisease(), contentBinding.mainContent, FormType.HOSPITALIZATION_EDIT); + switch (disease){ + case AHF: + handleAHF(); + case NEW_INFLUENZA: + handleILI(); } } @@ -253,13 +253,37 @@ private void setFieldVisibilitiesAndAccesses(View view) { } - private void handleAHF() { - getContentBinding().caseHospitalizationAdmittedToHealthFacilityNew.addValueChangedListener(field -> { + private void handleHospitalizationVisibility(List viewsToToggle) { + for (View view : viewsToToggle) { + view.setVisibility(GONE); + } + + getContentBinding().caseHospitalizationAdmittedToHealthFacility.addValueChangedListener(field -> { int visibility = (field.getValue() == YesNo.YES ? VISIBLE : GONE); - getContentBinding().caseHospitalizationAdmissionDate.setVisibility(visibility); - getContentBinding().caseHospitalizationDischargeDate.setVisibility(visibility); - getContentBinding().caseHospitalizationDateOfDeath.setVisibility(visibility); + for (View view : viewsToToggle) { + view.setVisibility(visibility); + } }); + } + + private void handleAHF() { + handleHospitalizationVisibility(Arrays.asList( + getContentBinding().caseHospitalizationAdmissionDate, + getContentBinding().caseHospitalizationDischargeDate, + getContentBinding().caseHospitalizationDateOfDeath + )); + } + private void handleILI() { + getContentBinding().caseHospitalizationAdmittedToHealthFacility.setCaption("WAS THE PATIENT ADMITTED AT THE FACILITY (IN-PATIENT)?"); + getContentBinding().caseHospitalizationAdmissionDate.setCaption("DATE OF ADMISSION (IN-PATIENT)"); + getContentBinding().caseHospitalizationDischargeDate.setCaption("DATE PERSON DISCHARGED FROM HOSPITAL"); + handleHospitalizationVisibility(Arrays.asList( + getContentBinding().caseHospitalizationAdmissionDate, + getContentBinding().caseHospitalizationDischargeDate, + getContentBinding().caseHospitalizationTerminationDateHospitalStay, + getContentBinding().caseHospitalizationIntensiveCareUnit + )); } + } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/epidata/EpidemiologicalDataEditFragment.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/epidata/EpidemiologicalDataEditFragment.java index 4fad2bcc981..3acc3be5b9f 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/epidata/EpidemiologicalDataEditFragment.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/epidata/EpidemiologicalDataEditFragment.java @@ -558,6 +558,17 @@ private void updateAddActivitiesAsCaseButtonVisibility() { } private void handleAHF(){ + getContentBinding().epiDataComm1.setVisibility(GONE); + getContentBinding().epiDataHealthCenter1.setVisibility(GONE); + getContentBinding().epiDataCountry1.setVisibility(GONE); + getContentBinding().epiDataComm2.setVisibility(GONE); + getContentBinding().epiDataHealthCenter2.setVisibility(GONE); + getContentBinding().epiDataCountry2.setVisibility(GONE); + + getContentBinding().epiDataIfTravelYesWhere.setVisibility(GONE); + getContentBinding().epiDataIfYesStartDate.setVisibility(GONE); + getContentBinding().epiDataIfYesEndDate.setVisibility(GONE); + List> itemsToRemove = List.of( new Item<>(CaseOutcome.OTHER.toString(), CaseOutcome.OTHER), new Item<>(CaseOutcome.UNKNOWN.toString(), CaseOutcome.UNKNOWN), diff --git a/sormas-app/app/src/main/res/layout/fragment_case_edit_hospitalization_layout.xml b/sormas-app/app/src/main/res/layout/fragment_case_edit_hospitalization_layout.xml index 3ecdeb5612b..1cdd465ff05 100644 --- a/sormas-app/app/src/main/res/layout/fragment_case_edit_hospitalization_layout.xml +++ b/sormas-app/app/src/main/res/layout/fragment_case_edit_hospitalization_layout.xml @@ -46,35 +46,32 @@ + android:layout_height="wrap_content"> - + - - + - + @@ -90,7 +87,7 @@ style="@style/ControlSecondOfTwoColumnsStyle" /> @@ -101,19 +98,12 @@ app:value="@={data.wasPatientAdmitted}" style="@style/ControlSingleColumnStyle" /> - - - - + + @@ -277,9 +266,9 @@ app:dependencyParentField="@{caseHospitalizationHospitalizationReason}" app:dependencyParentValue="@{HospitalizationReasonType.OTHER}" style="@style/ControlSingleColumnStyle" /> - - 1346 - - - - - - - - - - - - - - + + + + + + + + + @@ -338,21 +338,21 @@ android:id="@+id/epiData_comm1" app:dependencyParentField="@{epiDataPatientTravelDuringIllness}" app:dependencyParentValue="@{YesNo.YES}" - style="@style/ControlSingleColumnStyle" + style="@style/ControlFirstOfTwoColumnsStyle" app:value="@={data.comm1}" /> @@ -367,21 +367,21 @@ android:id="@+id/epiData_comm2" app:dependencyParentField="@{epiDataPatientTravelDuringIllness}" app:dependencyParentValue="@{YesNo.YES}" - style="@style/ControlSingleColumnStyle" + style="@style/ControlFirstOfTwoColumnsStyle" app:value="@={data.comm2}" /> @@ -400,7 +400,7 @@ style="@style/ControlSingleColumnStyle"/> @@ -409,21 +409,21 @@ android:id="@+id/epiData_ifYesWhere" app:dependencyParentField="@{epiDataWasPatientHospitalized}" app:dependencyParentValue="@{YesNo.YES}" - style="@style/ControlSingleColumnStyle" + style="@style/ControlFirstOfTwoColumnsStyle" app:value="@={data.ifYesWhere}" /> @@ -435,7 +435,7 @@ style="@style/ControlSingleColumnStyle"/> @@ -444,21 +444,21 @@ android:id="@+id/epiData_ifYesNameHealer" app:dependencyParentField="@{epiDataDidPatientConsultHealer}" app:dependencyParentValue="@{YesNo.YES}" - style="@style/ControlSingleColumnStyle" + style="@style/ControlFirstOfTwoColumnsStyle" app:value="@={data.ifYesNameHealer}" /> @@ -483,14 +483,16 @@ app:enumClass="@{YesNoClass}" style="@style/ControlSingleColumnStyle"/> - + - @@ -512,21 +514,21 @@ android:id="@+id/epiData_ifTravelYesWhere" app:dependencyParentField="@{epiDataPatientTravelAnytimePeriodBeforeIll}" app:dependencyParentValue="@{YesNo.YES}" - style="@style/ControlSingleColumnStyle" + style="@style/ControlFirstOfTwoColumnsStyle" app:value="@={data.ifTravelYesWhere}" /> @@ -538,7 +540,7 @@ style="@style/ControlSingleColumnStyle"/> @@ -547,21 +549,21 @@ android:id="@+id/epiData_suspectLastName" app:dependencyParentField="@{epiDataPatientContactKnownSuspect}" app:dependencyParentValue="@{YesNo.YES}" - style="@style/ControlSingleColumnStyle" + style="@style/ControlFirstOfTwoColumnsStyle" app:value="@={data.suspectLastName}" /> @@ -1017,7 +1019,7 @@ style="@style/ControlSingleColumnStyle"/> - + diff --git a/sormas-app/app/src/main/res/layout/fragment_sample_edit_layout.xml b/sormas-app/app/src/main/res/layout/fragment_sample_edit_layout.xml index 79307ceb0c1..abeca518475 100644 --- a/sormas-app/app/src/main/res/layout/fragment_sample_edit_layout.xml +++ b/sormas-app/app/src/main/res/layout/fragment_sample_edit_layout.xml @@ -346,7 +346,7 @@ + style="@style/ControlFirstOfTwoColumnsStyle" />