Skip to content

Commit

Permalink
#180: Added field: check if child is neonate and rendered logic visib…
Browse files Browse the repository at this point in the history
…ility on other fields at person fragment for IDSR
  • Loading branch information
Flava177 committed Oct 14, 2024
1 parent 2db6073 commit bcbc8e4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,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 = 368;
public static final int DATABASE_VERSION = 369;

private static DatabaseHelper instance = null;

Expand Down Expand Up @@ -3462,6 +3462,9 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int
default:
throw new IllegalStateException("onUpgrade() with unknown oldVersion " + oldVersion);

case 368:
currentVersion = 368;
getDao(Person.class).executeRaw("ALTER TABLE person ADD COLUMN applicable varchar(255);");
// 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 @@ -104,6 +104,9 @@ public class Person extends PseudonymizableAdo {
private String mothersName;
@Column(length = CHARACTER_LIMIT_DEFAULT)
private String fathersName;
@Enumerated(EnumType.STRING)
private YesNo applicable;

@Column(length = CHARACTER_LIMIT_DEFAULT)
private String namesOfGuardians;
@Column
Expand Down Expand Up @@ -536,6 +539,14 @@ public void setFathersName(String fathersName) {
this.fathersName = fathersName;
}

public YesNo getApplicable() {
return applicable;
}

public void setApplicable(YesNo applicable) {
this.applicable = applicable;
}

public String getNamesOfGuardians() {
return namesOfGuardians;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void fillInnerFromDto(Person target, PersonDto source) {
target.setCauseOfDeathDetails(source.getCauseOfDeathDetails());
target.setMothersName(source.getMothersName());
target.setFathersName(source.getFathersName());
target.setApplicable(source.getApplicable());
target.setNamesOfGuardians(source.getNamesOfGuardians());
target.setPlaceOfBirthRegion(DatabaseHelper.getRegionDao().getByReferenceDto(source.getPlaceOfBirthRegion()));
target.setPlaceOfBirthDistrict(DatabaseHelper.getDistrictDao().getByReferenceDto(source.getPlaceOfBirthDistrict()));
Expand Down Expand Up @@ -206,6 +207,7 @@ public void fillInnerFromAdo(PersonDto target, Person source) {

target.setMothersName(source.getMothersName());
target.setFathersName(source.getFathersName());
target.setApplicable(source.getApplicable());
target.setNamesOfGuardians(source.getNamesOfGuardians());

if (source.getPlaceOfBirthRegion() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ private void setUpLayoutBinding(final BaseEditFragment fragment, final Person re
List<Item> approximateAgeTypeList = DataUtils.getEnumItems(ApproximateAgeType.class, true);
List<Item> sexList = DataUtils.getEnumItems(Sex.class, true);
List<Item> marriageList = DataUtils.getEnumItems(MaritalStatus.class, true);
List<Item> yesNoList = DataUtils.getEnumItems(YesNo.class, true);
List<Item> causeOfDeathList = DataUtils.getEnumItems(CauseOfDeath.class, true);
List<Item> diseaseList = DataUtils.toItems(DiseaseConfigurationCache.getInstance().getAllDiseases(true, true, true));
if (record.getCauseOfDeathDisease() != null && !diseaseList.contains(record.getCauseOfDeathDisease())) {
Expand Down Expand Up @@ -244,6 +245,7 @@ private void setUpLayoutBinding(final BaseEditFragment fragment, final Person re
contentBinding.personBurialConductor.initializeSpinner(burialConductorList);
contentBinding.personOccupationType.initializeSpinner(occupationTypeList);
contentBinding.personArmedForcesRelationType.initializeSpinner(DataUtils.getEnumItems(ArmedForcesRelationType.class, true));
contentBinding.personApplicable.initializeSpinner(yesNoList);
contentBinding.personEducationType.initializeSpinner(DataUtils.getEnumItems(EducationType.class, true));
// Determine which values should show as personPresentCondition (the person may have a value that by default is not shown for the current disease)
List<Item> items = DataUtils.getEnumItems(PresentCondition.class, true, getFieldVisibilityCheckers());
Expand Down Expand Up @@ -620,11 +622,15 @@ public void onAfterLayoutBinding(final FragmentPersonEditLayoutBinding contentBi
contentBinding.personCitizenship.setVisibility(GONE);
contentBinding.personBirthCountry.setVisibility(GONE);

if (caseDisease != null) {
super.hideFieldsForDisease(caseDisease, contentBinding.mainContent, FormType.PERSON_EDIT);
}

handlePersonResidenceSinceWhenInMonths(contentBinding);
contentBinding.personApplicable.addValueChangedListener(event -> {
YesNo applicableValue = (YesNo) contentBinding.personApplicable.getValue();
int visibility = YesNo.YES.equals(applicableValue) ? View.VISIBLE : View.GONE;

contentBinding.personMothersName.setVisibility(visibility);
contentBinding.personFathersName.setVisibility(visibility);
});

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<import type="de.symeda.sormas.api.person.CauseOfDeath" />
<import type="de.symeda.sormas.api.person.Salutation" />
<import type="de.symeda.sormas.api.utils.YesNoUnknown" />
<import type="de.symeda.sormas.api.utils.YesNo" />
<import type="de.symeda.sormas.api.i18n.I18nProperties" />
<import type="de.symeda.sormas.api.i18n.Strings" />
<import type="de.symeda.sormas.app.component.controls.ControlButtonType" />
Expand Down Expand Up @@ -585,6 +586,11 @@

</LinearLayout>

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

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

0 comments on commit bcbc8e4

Please sign in to comment.