Skip to content

Commit

Permalink
#178: Added terminationDateHospitalStay field to hospitalization. Upd…
Browse files Browse the repository at this point in the history
…ated EpidemiologicalDataEditFragment by setting fields visibility to gone. Updated layout style of sample_shipped.
  • Loading branch information
Flava177 committed Nov 15, 2024
1 parent 0524240 commit 901b05c
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import androidx.databinding.ObservableArrayList;

import java.util.Arrays;
import java.util.List;

import de.symeda.sormas.api.Disease;
Expand All @@ -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;
Expand All @@ -66,6 +66,7 @@ public class CaseEditHospitalizationFragment extends BaseEditFragment<FragmentCa
private IEntryItemOnClickListener onPrevHosItemClickListener;
private List<Item> outcomeList;
private List<Item> inpatientOutpatientList;
private Disease disease;


// Static methods
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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();
}
}

Expand All @@ -253,13 +253,37 @@ private void setFieldVisibilitiesAndAccesses(View view) {

}

private void handleAHF() {
getContentBinding().caseHospitalizationAdmittedToHealthFacilityNew.addValueChangedListener(field -> {
private void handleHospitalizationVisibility(List<View> 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
));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item<CaseOutcome>> itemsToRemove = List.of(
new Item<>(CaseOutcome.OTHER.toString(), CaseOutcome.OTHER),
new Item<>(CaseOutcome.UNKNOWN.toString(), CaseOutcome.UNKNOWN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,32 @@

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/fragment_padding"
android:focusable="true"
android:focusableInTouchMode="true"
android:id="@+id/main_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/fragment_padding"
android:id="@+id/main_content"
style="@style/LayoutSingleContentSpaceBelowStyle">

<requestFocus/>
<!--app:goneIfVariable="@{caze.facilityType}"
app:goneIfNotValue="@{FacilityType.HOSPITAL}">-->
<requestFocus/>

<TextView
android:id="@+id/heading_most_recent_hospitalization"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/heading_most_recent_hospitalization"
style="@style/SubHeadingStyle" />
<TextView
android:id="@+id/heading_most_recent_hospitalization"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/heading_most_recent_hospitalization"
style="@style/SubHeadingStyle" />

<LinearLayout
android:id="@+id/facility_type_fields_layout"
android:id="@+id/caseHospitalizationFacility_type_fields_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
Expand All @@ -90,7 +87,7 @@
style="@style/ControlSecondOfTwoColumnsStyle" />

<de.symeda.sormas.app.component.controls.ControlTextReadField
android:id="@+id/caseHospitalization_healthFacilityRecordNumber"
android:id="@+id/healthFacilityRecordNumber"
app:value="@{data.healthFacilityRecordNumber}"
style="@style/ControlSecondOfTwoColumnsStyle" />

Expand All @@ -101,19 +98,12 @@
app:value="@={data.wasPatientAdmitted}"
style="@style/ControlSingleColumnStyle" />


<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/caseHospitalization_admittedToHealthFacility"
app:enumClass="@{YesNoClass}"
app:value="@={data.admittedToHealthFacility}"
style="@style/ControlSingleColumnStyle" />

<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/caseHospitalization_admittedToHealthFacilityNew"
app:value="@={data.admittedToHealthFacilityNew}"
app:enumClass="@{YesNoClass}"
style="@style/ControlSingleColumnStyle" />

<LinearLayout
android:id="@+id/caseHospitalization_memberFamilyHelpingPatient_deathDate"
android:layout_width="match_parent"
Expand Down Expand Up @@ -141,28 +131,26 @@
<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseHospitalization_hospitalRecordNumber"
app:value="@={data.hospitalRecordNumber}"
app:dependencyParentField="@{caseHospitalizationAdmittedToHealthFacility}"
app:dependencyParentValue="@{YesNo.YES}"
style="@style/ControlFirstOfTwoColumnsStyle" />

<de.symeda.sormas.app.component.controls.ControlDateField
android:id="@+id/caseHospitalization_admissionDate"
app:value="@={data.admissionDate}"
app:dependencyParentField="@{caseHospitalizationAdmittedToHealthFacility}"
app:dependencyParentValue="@{YesNo.YES}"
style="@style/ControlSecondOfTwoColumnsStyle" />

<de.symeda.sormas.app.component.controls.ControlDateField
android:id="@+id/caseHospitalization_dischargeDate"
app:value="@={data.dischargeDate}"
app:allowedDaysInFuture="7"
app:dependencyParentField="@{caseHospitalizationAdmittedToHealthFacility}"
app:dependencyParentValue="@{YesNo.YES}"
style="@style/ControlSecondOfTwoColumnsStyle" />


</LinearLayout>

<de.symeda.sormas.app.component.controls.ControlDateField
android:id="@+id/caseHospitalization_terminationDateHospitalStay"
app:value="@={data.terminationDateHospitalStay}"
style="@style/ControlSingleColumnStyle" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -194,6 +182,7 @@
style="@style/ControlSingleColumnStyle" />

<LinearLayout
android:id="@+id/caseHospitalization_intensiveCareUnitStartEndLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
Expand Down Expand Up @@ -277,9 +266,9 @@
app:dependencyParentField="@{caseHospitalizationHospitalizationReason}"
app:dependencyParentValue="@{HospitalizationReasonType.OTHER}"
style="@style/ControlSingleColumnStyle" />
</LinearLayout>

<LinearLayout
android:id="@+id/caseHospitalization_notifyDistrictFormSentToDistrictDate_Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
Expand All @@ -295,47 +284,30 @@
app:value="@={data.dateFormSentToDistrict}"
style="@style/ControlSecondOfTwoColumnsStyle" />

</LinearLayout>1346

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/fragment_padding">

<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/caseHospitalization_hospitalizedPreviously"
app:value="@={data.hospitalizedPreviously}"
app:enumClass="@{YesNoClass}"
style="@style/ControlSingleColumnStyle" />

</LinearLayout>

<LinearLayout
android:id="@+id/caseHospitalization_patientDetailsHeading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/fragment_padding">

<de.symeda.sormas.app.component.controls.ControlSpinnerField
android:id="@+id/caseHospitalization_selectInpatientOutpatient"
app:value="@={data.selectInpatientOutpatient}"
style="@style/ControlSingleColumnStyle" />

<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/caseHospitalization_seenAtAHealthFacility"
app:value="@={data.seenAtAHealthFacility}"
style="@style/ControlSingleColumnStyle" />

<de.symeda.sormas.app.component.controls.ControlDateField
android:id="@+id/caseHospitalization_dateFirstSeen"
app:value="@={data.dateFirstSeen}"
app:dependencyParentField="@{caseHospitalizationSeenAtAHealthFacility}"
app:dependencyParentValue="@{YesNoUnknown.YES}"
style="@style/ControlSingleColumnStyle" />

</LinearLayout>
<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/caseHospitalization_hospitalizedPreviously"
app:value="@={data.hospitalizedPreviously}"
app:enumClass="@{YesNoClass}"
style="@style/ControlSingleColumnStyle" />

<de.symeda.sormas.app.component.controls.ControlSpinnerField
android:id="@+id/caseHospitalization_selectInpatientOutpatient"
app:value="@={data.selectInpatientOutpatient}"
style="@style/ControlSingleColumnStyle" />

<de.symeda.sormas.app.component.controls.ControlDateField
android:id="@+id/caseHospitalization_dateFirstSeen"
app:value="@={data.dateFirstSeen}"
app:dependencyParentField="@{caseHospitalizationSeenAtAHealthFacility}"
app:dependencyParentValue="@{YesNoUnknown.YES}"
style="@style/ControlSingleColumnStyle" />

<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/caseHospitalization_seenAtAHealthFacility"
app:value="@={data.seenAtAHealthFacility}"
style="@style/ControlSingleColumnStyle" />

<LinearLayout
android:id="@+id/prev_hospitalizations_layout"
Expand Down Expand Up @@ -381,6 +353,8 @@
style="@style/FullHorizontalDividerStyle"
app:goneIfEmpty="@{previousHospitalizationList}"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
Loading

0 comments on commit 901b05c

Please sign in to comment.