use of de.symeda.sormas.app.databinding.FragmentCaseNewLayoutBinding in project SORMAS-Project by hzi-braunschweig.
the class CaseNewFragment method onAfterLayoutBinding.
@Override
public void onAfterLayoutBinding(final FragmentCaseNewLayoutBinding contentBinding) {
InfrastructureDaoHelper.initializeHealthFacilityDetailsFieldVisibility(contentBinding.caseDataHealthFacility, contentBinding.caseDataHealthFacilityDetails);
InfrastructureDaoHelper.initializePointOfEntryDetailsFieldVisibility(contentBinding.caseDataPointOfEntry, contentBinding.caseDataPointOfEntryDetails);
if (!ConfigProvider.isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) && !ConfigProvider.isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
contentBinding.caseDataExternalID.setVisibility(GONE);
contentBinding.caseDataExternalToken.setVisibility(GONE);
} else {
contentBinding.caseDataEpidNumber.setVisibility(GONE);
}
contentBinding.caseDataResponsibleRegion.setEnabled(false);
contentBinding.caseDataResponsibleRegion.setRequired(false);
contentBinding.caseDataResponsibleDistrict.setEnabled(false);
contentBinding.caseDataResponsibleDistrict.setRequired(false);
User user = ConfigProvider.getUser();
if (user.getPointOfEntry() == null) {
contentBinding.facilityOrHome.setValue(TypeOfPlace.FACILITY);
}
if (user.hasUserRole(UserRole.HOSPITAL_INFORMANT) && user.getHealthFacility() != null) {
// Hospital Informants are not allowed to create cases in another health facility
contentBinding.caseDataCommunity.setEnabled(false);
contentBinding.caseDataCommunity.setRequired(false);
contentBinding.caseDataHealthFacility.setEnabled(false);
contentBinding.caseDataHealthFacility.setRequired(false);
contentBinding.facilityOrHome.setEnabled(false);
contentBinding.facilityTypeGroup.setEnabled(false);
contentBinding.caseDataFacilityType.setEnabled(false);
contentBinding.caseDataDifferentPlaceOfStayJurisdiction.setEnabled(false);
contentBinding.caseDataDifferentPlaceOfStayJurisdiction.setVisibility(GONE);
}
if (user.hasUserRole(UserRole.POE_INFORMANT) && user.getPointOfEntry() != null) {
contentBinding.caseDataPointOfEntry.setEnabled(false);
contentBinding.caseDataPointOfEntry.setRequired(false);
}
if (user.hasUserRole(UserRole.COMMUNITY_INFORMANT) && user.getCommunity() != null) {
// Community Informants are not allowed to create cases in another community
contentBinding.caseDataCommunity.setEnabled(false);
contentBinding.caseDataCommunity.setRequired(false);
}
// Disable personal details and disease fields when case is created from contact
// or event person
Bundler bundler = new Bundler(getArguments());
if (bundler.getContactUuid() != null || bundler.getEventParticipantUuid() != null) {
contentBinding.caseDataFirstName.setEnabled(false);
contentBinding.caseDataLastName.setEnabled(false);
contentBinding.personSex.setEnabled(false);
contentBinding.personBirthdateYYYY.setEnabled(false);
contentBinding.personBirthdateMM.setEnabled(false);
contentBinding.personBirthdateDD.setEnabled(false);
contentBinding.caseDataDisease.setEnabled(false);
contentBinding.caseDataDiseaseDetails.setEnabled(false);
contentBinding.caseDataPlagueType.setEnabled(false);
contentBinding.caseDataDengueFeverType.setEnabled(false);
contentBinding.caseDataHumanRabiesType.setEnabled(false);
}
// Set up port health visibilities
if (UserRole.isPortHealthUser(ConfigProvider.getUser().getUserRoles())) {
contentBinding.caseDataCaseOrigin.setVisibility(GONE);
contentBinding.caseDataDisease.setVisibility(GONE);
contentBinding.facilityOrHome.setVisibility(GONE);
contentBinding.caseDataCommunity.setVisibility(GONE);
contentBinding.facilityTypeFieldsLayout.setVisibility(GONE);
contentBinding.caseDataHealthFacility.setVisibility(GONE);
contentBinding.facilityTypeGroup.setRequired(false);
contentBinding.caseDataFacilityType.setRequired(false);
contentBinding.caseDataHealthFacility.setRequired(false);
contentBinding.caseDataHealthFacilityDetails.setRequired(false);
} else if (DatabaseHelper.getPointOfEntryDao().hasActiveEntriesInDistrict()) {
if (record.getCaseOrigin() == CaseOrigin.IN_COUNTRY) {
contentBinding.caseDataPointOfEntry.setRequired(false);
contentBinding.caseDataPointOfEntry.setVisibility(GONE);
} else {
contentBinding.caseDataHealthFacility.setRequired(false);
}
contentBinding.caseDataCaseOrigin.addValueChangedListener(e -> {
if (e.getValue() == CaseOrigin.IN_COUNTRY) {
contentBinding.caseDataPointOfEntry.setVisibility(GONE);
contentBinding.caseDataPointOfEntry.setRequired(false);
contentBinding.caseDataPointOfEntry.setValue(null);
contentBinding.caseDataHealthFacility.setRequired(true);
} else {
contentBinding.caseDataPointOfEntry.setVisibility(VISIBLE);
contentBinding.caseDataHealthFacility.setRequired(false);
contentBinding.caseDataPointOfEntry.setRequired(true);
}
});
} else {
contentBinding.caseDataCaseOrigin.setVisibility(GONE);
contentBinding.caseDataPointOfEntry.setVisibility(GONE);
}
}
Aggregations