Skip to content

Commit

Permalink
#170: implemented case new features(fields) and logic for Mpox.
Browse files Browse the repository at this point in the history
  • Loading branch information
Flava177 committed Dec 12, 2024
1 parent 603e983 commit 587452c
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import de.symeda.sormas.api.Disease;
Expand Down Expand Up @@ -545,6 +547,22 @@ public class Case extends PseudonymizableAdo {
private String familyLinkWithPatient;
@Column(length = CHARACTER_LIMIT_DEFAULT)
private String nameOfVillagePersonGotIll;
@Column(length = CHARACTER_LIMIT_DEFAULT)
private String addressMpox;
@Column(length = CHARACTER_LIMIT_DEFAULT)
private String village;
@Column(length = CHARACTER_LIMIT_DEFAULT)
private String city;
@Column(length = CHARACTER_LIMIT_DEFAULT)
private String nationality;
@Column(length = CHARACTER_LIMIT_DEFAULT)
private String ethnicity;
@Column(length = CHARACTER_LIMIT_DEFAULT)
private String occupation;
@DatabaseField(foreign = true, foreignAutoRefresh = true)
private Region regionOfResidence;
@DatabaseField(foreign = true, foreignAutoRefresh = true)
private District districtOfResidence;

public boolean isUnreferredPortHealthCase() {
return caseOrigin == CaseOrigin.POINT_OF_ENTRY && healthFacility == null;
Expand Down Expand Up @@ -1927,4 +1945,71 @@ public String getNameOfVillagePersonGotIll() {
public void setNameOfVillagePersonGotIll(String nameOfVillagePersonGotIll) {
this.nameOfVillagePersonGotIll = nameOfVillagePersonGotIll;
}

public String getAddressMpox() {
return addressMpox;
}

public void setAddressMpox(String addressMpox) {
this.addressMpox = addressMpox;
}

public String getVillage() {
return village;
}

public void setVillage(String village) {
this.village = village;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public String getNationality() {
return nationality;
}

public void setNationality(String nationality) {
this.nationality = nationality;
}

public String getEthnicity() {
return ethnicity;
}

public void setEthnicity(String ethnicity) {
this.ethnicity = ethnicity;
}

public String getOccupation() {
return occupation;
}

public void setOccupation(String occupation) {
this.occupation = occupation;
}

@ManyToOne(fetch = FetchType.LAZY)
public Region getRegionOfResidence() {
return regionOfResidence;
}

public void setRegionOfResidence(Region regionOfResidence) {
this.regionOfResidence = regionOfResidence;
}

@ManyToOne(fetch = FetchType.LAZY)
public District getDistrictOfResidence() {
return districtOfResidence;
}

public void setDistrictOfResidence(District districtOfResidence) {
this.districtOfResidence = districtOfResidence;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

import java.util.List;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.PostResponse;
import de.symeda.sormas.api.caze.CaseDataDto;
import de.symeda.sormas.api.caze.CaseReferenceDto;
import de.symeda.sormas.api.foodhistory.FoodHistoryDto;
import de.symeda.sormas.api.location.LocationDto;
import de.symeda.sormas.api.person.PersonReferenceDto;
import de.symeda.sormas.api.symptoms.SymptomsDto;
import de.symeda.sormas.app.backend.afpimmunization.AfpImmunizationDtoHelper;
Expand Down Expand Up @@ -302,6 +304,31 @@ public void fillInnerFromDto(Case target, CaseDataDto source) {
target.setInformationGivenBy(source.getInformationGivenBy());
target.setFamilyLinkWithPatient(source.getFamilyLinkWithPatient());
target.setNameOfVillagePersonGotIll(source.getNameOfVillagePersonGotIll());
target.setAddressMpox(source.getAddressMpox());
target.setVillage(source.getVillage());
target.setCity(source.getCity());
target.setNationality(source.getNationality());
target.setEthnicity(source.getEthnicity());
target.setOccupation(source.getOccupation());
target.setRegionOfResidence(DatabaseHelper.getRegionDao().getByReferenceDto(source.getRegionOfResidence()));
target.setDistrictOfResidence(DatabaseHelper.getDistrictDao().getByReferenceDto(source.getDistrictOfResidence()));

if (source.getDisease() == Disease.MONKEYPOX) {
if (source.getHospitalization() != null) {
if (source.getHospitalization().getLocationType() == null) {
source.getHospitalization().setLocationType(new LocationDto());
}

LocationDto locationType = source.getHospitalization().getLocationType();
if (locationType.getRegion() == null) {
locationType.setRegion(source.getResponsibleRegion());
locationType.setDistrict(source.getResponsibleDistrict());
locationType.setCommunity(source.getResponsibleCommunity());
}

source.getHospitalization().setNameOfFacility(source.getHealthFacility());
}
}
}

@Override
Expand Down Expand Up @@ -644,6 +671,26 @@ public void fillInnerFromAdo(CaseDataDto target, Case source) {
target.setInformationGivenBy(source.getInformationGivenBy());
target.setFamilyLinkWithPatient(source.getFamilyLinkWithPatient());
target.setNameOfVillagePersonGotIll(source.getNameOfVillagePersonGotIll());
target.setAddressMpox(source.getAddressMpox());
target.setVillage(source.getVillage());
target.setCity(source.getCity());
target.setNationality(source.getNationality());
target.setEthnicity(source.getEthnicity());
target.setOccupation(source.getOccupation());

if (source.getRegionOfResidence() != null) {
Region regionOfResidence = DatabaseHelper.getRegionDao().queryForId(source.getRegionOfResidence().getId());
target.setRegionOfResidence(RegionDtoHelper.toReferenceDto(regionOfResidence));
} else {
target.setRegionOfResidence(null);
}

if (source.getDistrictOfResidence() != null) {
District districtOfResidence = DatabaseHelper.getDistrictDao().queryForId(source.getDistrictOfResidence().getId());
target.setDistrictOfResidence(DistrictDtoHelper.toReferenceDto(districtOfResidence));
} else {
target.setDistrictOfResidence(null);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 418;
public static final int DATABASE_VERSION = 419;

private static DatabaseHelper instance = null;

Expand Down Expand Up @@ -4296,6 +4296,18 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int
case 417:
currentVersion = 417;
getDao(Person.class).executeRaw("ALTER TABLE person ADD COLUMN telNumber varchar(255);");

case 418:
currentVersion = 418;
getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN addressMpox varchar(255);");
getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN village varchar(255);");
getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN city varchar(255);");
getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN nationality varchar(255);");
getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN ethnicity varchar(255);");
getDao(Case.class).executeRaw("ALTER TABLE cases ADD COLUMN occupation varchar(255);");
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);");

// ATTENTION: break should only be done after last version
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,20 @@ public void onLayoutBinding(FragmentCaseNewLayoutBinding contentBinding) {
}
}
});

InfrastructureFieldsDependencyHandler.instance.initializeRegionFields(
contentBinding.caseDataRegionOfResidence,
initialRegions,
record.getRegion(),
contentBinding.caseDataDistrictOfResidence,
initialDistricts,
record.getDistrict(),
null,
null,
null
);


contentBinding.caseDataDisease.addValueChangedListener(e -> {
contentBinding.rapidCaseEntryCheckBox.setVisibility(
e.getValue() != null && ((CaseNewActivity) getActivity()).getLineListingDiseases().contains(e.getValue()) ? VISIBLE : GONE);
Expand Down
112 changes: 112 additions & 0 deletions sormas-app/app/src/main/res/layout/fragment_case_new_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<import type="de.symeda.sormas.api.event.TypeOfPlace" />
<import type="de.symeda.sormas.api.i18n.I18nProperties" />
<import type="de.symeda.sormas.api.i18n.Strings" />
<import type="de.symeda.sormas.api.i18n.Captions" />
<import type="de.symeda.sormas.api.disease.DiseaseVariant" />

<variable name="data" type="de.symeda.sormas.app.backend.caze.Case" />
Expand Down Expand Up @@ -414,6 +415,117 @@
app:value="@={data.person.phone}"
style="@style/ControlSingleColumnStyle" />

<LinearLayout
android:id="@+id/age_fields_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/person_approximateAge"
app:value="@={data.person.approximateAge}"
app:inputType="number"
app:maxLength="3"
style="@style/ControlFirstOfTwoColumnsStyle" />

<de.symeda.sormas.app.component.controls.ControlSpinnerField
android:id="@+id/person_approximateAgeType"
app:value="@={data.person.approximateAgeType}"
style="@style/ControlSecondOfTwoColumnsStyle" />

</LinearLayout>

<LinearLayout
android:id="@+id/addressVillageCity_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseData_addressMpox"
style="@style/ControlFirstOfTwoColumnsStyle"
app:value="@={data.addressMpox}" />

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseData_village"
style="@style/ControlSecondOfTwoColumnsStyle"
app:value="@={data.village}" />

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseData_city"
style="@style/ControlSecondOfTwoColumnsStyle"
app:value="@={data.city}" />

</LinearLayout>

<TextView
android:id="@+id/caseData_coorLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{I18nProperties.getCaption(Captions.coorLabel)}"
style="@style/SubHeadingStyle" />

<LinearLayout
android:id="@+id/gps_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseData_reportLon"
style="@style/ControlFirstOfTwoColumnsStyle"
app:inputType="number"
app:value="@={data.reportLon}" />

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseData_reportLat"
style="@style/ControlSecondOfTwoColumnsStyle"
app:inputType="number"
app:value="@={data.reportLat}" />

</LinearLayout>

<LinearLayout
android:id="@+id/nationalityEthnicty_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseData_nationality"
style="@style/ControlFirstOfTwoColumnsStyle"
app:value="@={data.nationality}" />

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseData_ethnicity"
style="@style/ControlSecondOfTwoColumnsStyle"
app:value="@={data.ethnicity}" />

</LinearLayout>

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/caseData_occupation"
style="@style/ControlSingleColumnStyle"
app:value="@={data.occupation}" />

<LinearLayout
android:id="@+id/mpoxRegionDistrict_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlSpinnerField
android:id="@+id/caseData_regionOfResidence"
app:value="@={data.regionOfResidence}"
style="@style/ControlFirstOfTwoColumnsStyle" />

<de.symeda.sormas.app.component.controls.ControlSpinnerField
android:id="@+id/caseData_districtOfResidence"
app:value="@={data.districtOfResidence}"
style="@style/ControlSecondOfTwoColumnsStyle" />

</LinearLayout>

</LinearLayout>

</ScrollView>
Expand Down

0 comments on commit 587452c

Please sign in to comment.