Search in sources :

Example 1 with Bundler

use of de.symeda.sormas.app.util.Bundler 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);
    }
}
Also used : PlagueType(de.symeda.sormas.api.caze.PlagueType) DataUtils(de.symeda.sormas.app.util.DataUtils) PersonValidator(de.symeda.sormas.app.person.edit.PersonValidator) DateHelper(de.symeda.sormas.api.utils.DateHelper) Facility(de.symeda.sormas.app.backend.facility.Facility) ArrayList(java.util.ArrayList) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) User(de.symeda.sormas.app.backend.user.User) Calendar(java.util.Calendar) ConfigProvider(de.symeda.sormas.app.backend.config.ConfigProvider) VISIBLE(android.view.View.VISIBLE) CountryHelper(de.symeda.sormas.api.CountryHelper) Item(de.symeda.sormas.app.component.Item) UserRole(de.symeda.sormas.api.user.UserRole) InfrastructureFieldsDependencyHandler(de.symeda.sormas.app.util.InfrastructureFieldsDependencyHandler) Bundler(de.symeda.sormas.app.util.Bundler) Case(de.symeda.sormas.app.backend.caze.Case) FragmentCaseNewLayoutBinding(de.symeda.sormas.app.databinding.FragmentCaseNewLayoutBinding) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Sex(de.symeda.sormas.api.person.Sex) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) DengueFeverType(de.symeda.sormas.api.caze.DengueFeverType) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) TypeOfPlace(de.symeda.sormas.api.event.TypeOfPlace) R(de.symeda.sormas.app.R) InfrastructureDaoHelper(de.symeda.sormas.app.util.InfrastructureDaoHelper) PresentCondition(de.symeda.sormas.api.person.PresentCondition) List(java.util.List) Disease(de.symeda.sormas.api.Disease) DiseaseConfigurationCache(de.symeda.sormas.app.util.DiseaseConfigurationCache) GONE(android.view.View.GONE) RabiesType(de.symeda.sormas.api.caze.RabiesType) DatabaseHelper(de.symeda.sormas.app.backend.common.DatabaseHelper) BaseEditFragment(de.symeda.sormas.app.BaseEditFragment) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) User(de.symeda.sormas.app.backend.user.User) Bundler(de.symeda.sormas.app.util.Bundler)

Example 2 with Bundler

use of de.symeda.sormas.app.util.Bundler in project SORMAS-Project by hzi-braunschweig.

the class ClinicalVisitEditActivity method onSaveInstanceState.

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
    super.onSaveInstanceState(outState);
    new Bundler(outState).setCaseUuid(caseUuid);
}
Also used : Bundler(de.symeda.sormas.app.util.Bundler)

Example 3 with Bundler

use of de.symeda.sormas.app.util.Bundler in project SORMAS-Project by hzi-braunschweig.

the class ClinicalVisitReadActivity method onSaveInstanceState.

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
    super.onSaveInstanceState(outState);
    new Bundler(outState).setCaseUuid(caseUuid);
}
Also used : Bundler(de.symeda.sormas.app.util.Bundler)

Example 4 with Bundler

use of de.symeda.sormas.app.util.Bundler in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationNewFragment method onAfterLayoutBinding.

@Override
protected void onAfterLayoutBinding(FragmentImmunizationNewLayoutBinding contentBinding) {
    InfrastructureDaoHelper.initializeHealthFacilityDetailsFieldVisibility(contentBinding.immunizationHealthFacility, contentBinding.immunizationHealthFacilityDetails);
    contentBinding.immunizationMeansOfImmunization.addValueChangedListener(e -> {
        if (!Boolean.TRUE.equals(contentBinding.overwriteImmunizationManagementStatusCheckBox.getValue())) {
            if (e.getValue() == MeansOfImmunization.OTHER || e.getValue() == MeansOfImmunization.RECOVERY) {
                contentBinding.immunizationImmunizationManagementStatus.setValue(ImmunizationManagementStatus.COMPLETED);
            } else {
                contentBinding.immunizationImmunizationManagementStatus.setValue(ImmunizationManagementStatus.SCHEDULED);
            }
        }
        boolean isVaccination = MeansOfImmunization.isVaccination((MeansOfImmunization) e.getValue());
        contentBinding.immunizationNumberOfDoses.setVisibility(isVaccination ? View.VISIBLE : View.GONE);
        contentBinding.immunizationNumberOfDoses.setEnabled(isVaccination);
    });
    contentBinding.overwriteImmunizationManagementStatusCheckBox.addValueChangedListener(e -> contentBinding.immunizationImmunizationManagementStatus.setEnabled(Boolean.TRUE.equals(e.getValue())));
    contentBinding.immunizationImmunizationManagementStatus.addValueChangedListener(e -> {
        if (e.getValue() == ImmunizationManagementStatus.SCHEDULED || e.getValue() == ImmunizationManagementStatus.ONGOING) {
            contentBinding.immunizationImmunizationStatus.setValue(ImmunizationStatus.PENDING);
        }
        if (e.getValue() == ImmunizationManagementStatus.COMPLETED) {
            contentBinding.immunizationImmunizationStatus.setValue(ImmunizationStatus.ACQUIRED);
        }
        if (e.getValue() == ImmunizationManagementStatus.CANCELED) {
            contentBinding.immunizationImmunizationStatus.setValue(ImmunizationStatus.NOT_ACQUIRED);
        }
    });
    contentBinding.immunizationImmunizationManagementStatus.setValue(ImmunizationManagementStatus.SCHEDULED);
    contentBinding.immunizationImmunizationManagementStatus.setEnabled(false);
    contentBinding.immunizationNumberOfDoses.setVisibility(View.GONE);
    if (!(record.getHealthFacility() == null || (record.getHealthFacility() != null && FacilityDto.NONE_FACILITY_UUID.equals(record.getHealthFacility().getUuid())))) {
        final FacilityType facilityType = record.getFacilityType();
        if (facilityType != null) {
            contentBinding.facilityTypeGroup.setValue(facilityType.getFacilityTypeGroup());
        }
    }
    // Disable personal details fields when immunization is created from case, contact or event participant
    Bundler bundler = new Bundler(getArguments());
    if (bundler.getCaseUuid() != null || bundler.getContactUuid() != null || bundler.getEventParticipantUuid() != null) {
        contentBinding.personFirstName.setEnabled(false);
        contentBinding.personLastName.setEnabled(false);
        contentBinding.personSex.setEnabled(false);
        contentBinding.personBirthdateYYYY.setEnabled(false);
        contentBinding.personBirthdateMM.setEnabled(false);
        contentBinding.personBirthdateDD.setEnabled(false);
    }
}
Also used : FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Bundler(de.symeda.sormas.app.util.Bundler)

Example 5 with Bundler

use of de.symeda.sormas.app.util.Bundler in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationNewFragment method onLayoutBinding.

@Override
protected void onLayoutBinding(FragmentImmunizationNewLayoutBinding contentBinding) {
    contentBinding.setData(record);
    contentBinding.setYesNoUnknownClass(YesNoUnknown.class);
    InfrastructureFieldsDependencyHandler.instance.initializeFacilityFields(record, contentBinding.immunizationResponsibleRegion, initialResponsibleRegions, record.getResponsibleRegion(), contentBinding.immunizationResponsibleDistrict, initialResponsibleDistricts, record.getResponsibleDistrict(), contentBinding.immunizationResponsibleCommunity, initialResponsibleCommunities, record.getResponsibleCommunity(), null, null, contentBinding.facilityTypeGroup, facilityTypeGroupList, contentBinding.immunizationFacilityType, facilityTypeList, contentBinding.immunizationHealthFacility, initialFacilities, record.getHealthFacility(), contentBinding.immunizationHealthFacilityDetails, true);
    // Initialize ControlSpinnerFields
    contentBinding.immunizationDisease.initializeSpinner(diseaseList);
    contentBinding.immunizationImmunizationStatus.initializeSpinner(immunizationStatusList);
    contentBinding.immunizationImmunizationStatus.setEnabled(false);
    contentBinding.immunizationImmunizationManagementStatus.initializeSpinner(immunizationManagementStatusList);
    contentBinding.immunizationMeansOfImmunization.initializeSpinner(meansOfImmunizationList);
    contentBinding.personBirthdateDD.initializeSpinner(new ArrayList<>());
    contentBinding.personBirthdateMM.initializeSpinner(monthList, field -> DataUtils.updateListOfDays(contentBinding.personBirthdateDD, (Integer) contentBinding.personBirthdateYYYY.getValue(), (Integer) field.getValue()));
    contentBinding.personBirthdateYYYY.initializeSpinner(yearList, field -> DataUtils.updateListOfDays(contentBinding.personBirthdateDD, (Integer) field.getValue(), (Integer) contentBinding.personBirthdateMM.getValue()));
    int year = Calendar.getInstance().get(Calendar.YEAR);
    contentBinding.personBirthdateYYYY.setSelectionOnOpen(year - 35);
    contentBinding.personSex.initializeSpinner(sexList);
    if (record.getDisease() != null && new Bundler(getArguments()).getEventParticipantUuid() != null) {
        contentBinding.immunizationDisease.setEnabled(false);
    }
    // Initialize ControlDateFields
    contentBinding.immunizationReportDate.initializeDateField(getFragmentManager());
    contentBinding.immunizationStartDate.initializeDateField(getFragmentManager());
    contentBinding.immunizationEndDate.initializeDateField(getFragmentManager());
    ValidationHelper.initDateIntervalValidator(contentBinding.immunizationStartDate, contentBinding.immunizationEndDate);
    contentBinding.immunizationValidFrom.initializeDateField(getFragmentManager());
    contentBinding.immunizationValidUntil.initializeDateField(getFragmentManager());
    ValidationHelper.initDateIntervalValidator(contentBinding.immunizationValidFrom, contentBinding.immunizationValidUntil);
    ValidationHelper.initIntegerValidator(contentBinding.immunizationNumberOfDoses, I18nProperties.getValidationError(Validations.vaccineDosesFormat), 1, 10);
}
Also used : Bundler(de.symeda.sormas.app.util.Bundler)

Aggregations

Bundler (de.symeda.sormas.app.util.Bundler)36 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)2 Case (de.symeda.sormas.app.backend.caze.Case)2 Intent (android.content.Intent)1 Drawable (android.graphics.drawable.Drawable)1 GONE (android.view.View.GONE)1 VISIBLE (android.view.View.VISIBLE)1 Toolbar (androidx.appcompat.widget.Toolbar)1 CountryHelper (de.symeda.sormas.api.CountryHelper)1 Disease (de.symeda.sormas.api.Disease)1 CaseOrigin (de.symeda.sormas.api.caze.CaseOrigin)1 DengueFeverType (de.symeda.sormas.api.caze.DengueFeverType)1 PlagueType (de.symeda.sormas.api.caze.PlagueType)1 RabiesType (de.symeda.sormas.api.caze.RabiesType)1 CustomizableEnumType (de.symeda.sormas.api.customizableenum.CustomizableEnumType)1 DiseaseVariant (de.symeda.sormas.api.disease.DiseaseVariant)1 TypeOfPlace (de.symeda.sormas.api.event.TypeOfPlace)1 FacilityTypeGroup (de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup)1 PresentCondition (de.symeda.sormas.api.person.PresentCondition)1 Sex (de.symeda.sormas.api.person.Sex)1