Search in sources :

Example 1 with Facility

use of de.symeda.sormas.app.backend.facility.Facility 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 Facility

use of de.symeda.sormas.app.backend.facility.Facility in project SORMAS-Project by hzi-braunschweig.

the class LocationDialog method configureAsPersonAddressDialog.

public void configureAsPersonAddressDialog(boolean showDeleteButton) {
    if (showDeleteButton) {
        getDeleteButton().setVisibility(View.VISIBLE);
    }
    contentBinding.locationAddressType.setVisibility(View.VISIBLE);
    if (!ConfigProvider.isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
        contentBinding.locationAddressType.initializeSpinner(DataUtils.toItems(Arrays.asList(PersonAddressType.getValues(ConfigProvider.getServerCountryCode()))));
    } else {
        contentBinding.locationAddressType.initializeSpinner(DataUtils.getEnumItems(PersonAddressType.class));
    }
    contentBinding.locationAddressType.setValidationCallback(() -> contentBinding.locationAddressType.getValue() != null);
    contentBinding.locationAddressType.addValueChangedListener(e -> {
        Object locationAddressTypeValue = contentBinding.locationAddressType.getValue();
        if (locationAddressTypeValue == null || PersonAddressType.HOME.equals(locationAddressTypeValue)) {
            contentBinding.locationAddressTypeDetails.setVisibility(GONE);
        } else {
            contentBinding.locationAddressTypeDetails.setVisibility(View.VISIBLE);
        }
        FacilityTypeGroup oldGroup = (FacilityTypeGroup) contentBinding.facilityTypeGroup.getValue();
        FacilityType oldType = (FacilityType) contentBinding.locationFacilityType.getValue();
        Facility oldFacility = (Facility) contentBinding.locationFacility.getValue();
        String oldDetails = contentBinding.locationFacilityDetails.getValue();
        contentBinding.facilityTypeGroup.setSpinnerData(null);
        if (PersonAddressType.HOME.equals(locationAddressTypeValue)) {
            contentBinding.facilityTypeGroup.setSpinnerData(DataUtils.toItems(FacilityTypeGroup.getAccomodationGroups()));
        } else {
            contentBinding.facilityTypeGroup.setSpinnerData(DataUtils.getEnumItems(FacilityTypeGroup.class));
        }
        contentBinding.facilityTypeGroup.setValue(oldGroup);
        contentBinding.locationFacilityType.setValue(oldType);
        contentBinding.locationFacility.setValue(oldFacility);
        contentBinding.locationFacilityDetails.setValue(oldDetails);
    });
}
Also used : PersonAddressType(de.symeda.sormas.api.person.PersonAddressType) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) Facility(de.symeda.sormas.app.backend.facility.Facility) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType)

Example 3 with Facility

use of de.symeda.sormas.app.backend.facility.Facility in project SORMAS-Project by hzi-braunschweig.

the class LocationDialog method initializeContentView.

@Override
protected void initializeContentView(ViewDataBinding rootBinding, ViewDataBinding buttonPanelBinding) {
    List<Item> initialContinents = InfrastructureDaoHelper.loadContinents();
    List<Item> initialSubcontinents = InfrastructureDaoHelper.loadSubcontinents();
    List<Item> initialCountries = InfrastructureDaoHelper.loadCountries();
    List<Item> initialRegions = InfrastructureDaoHelper.loadRegionsByServerCountry();
    List<Item> initialDistricts = InfrastructureDaoHelper.loadDistricts(data.getRegion());
    List<Item> initialCommunities = InfrastructureDaoHelper.loadCommunities(data.getDistrict());
    List<Item> initialFacilities = InfrastructureDaoHelper.loadFacilities(data.getDistrict(), data.getCommunity(), data.getFacilityType());
    List<Item> facilityTypeGroupList = DataUtils.toItems(Arrays.asList(FacilityTypeGroup.values()), true);
    List<Item> facilityTypeList = data.getFacilityType() != null ? DataUtils.toItems(FacilityType.getTypes(data.getFacilityType().getFacilityTypeGroup())) : null;
    InfrastructureDaoHelper.initializeHealthFacilityDetailsFieldVisibility(contentBinding.locationFacility, contentBinding.locationFacilityDetails);
    if (data.getCountry() == null) {
        String serverCountryName = ConfigProvider.getServerCountryName();
        for (Item countryItem : initialCountries) {
            Country country = (Country) countryItem.getValue();
            if (country != null && serverCountryName != null && serverCountryName.equalsIgnoreCase(country.getName())) {
                data.setCountry(country);
                break;
            }
        }
    }
    InfrastructureFieldsDependencyHandler.instance.initializeFacilityFields(data, this.contentBinding.locationContinent, initialContinents, data.getContinent(), this.contentBinding.locationSubcontinent, initialSubcontinents, data.getSubcontinent(), this.contentBinding.locationCountry, initialCountries, data.getCountry(), this.contentBinding.locationRegion, initialRegions, data.getRegion(), this.contentBinding.locationDistrict, initialDistricts, data.getDistrict(), this.contentBinding.locationCommunity, initialCommunities, data.getCommunity(), null, null, this.contentBinding.facilityTypeGroup, facilityTypeGroupList, this.contentBinding.locationFacilityType, facilityTypeList, this.contentBinding.locationFacility, initialFacilities, data.getFacility(), this.contentBinding.locationFacilityDetails, true);
    setFieldVisibilitiesAndAccesses(LocationDto.class, contentBinding.mainContent);
    if (!isFieldAccessible(LocationDto.class, LocationDto.COMMUNITY)) {
        this.contentBinding.locationRegion.setEnabled(false);
        this.contentBinding.locationDistrict.setEnabled(false);
    }
    contentBinding.locationAreaType.initializeSpinner(DataUtils.getEnumItems(AreaType.class));
    // "Pick GPS Coordinates" confirmation dialog
    this.contentBinding.pickGpsCoordinates.setOnClickListener(v -> {
        final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.confirmation_pick_gps, R.string.yes, R.string.no);
        confirmationDialog.setPositiveCallback(() -> {
            android.location.Location phoneLocation = LocationService.instance().getLocation(getActivity());
            if (phoneLocation != null) {
                contentBinding.locationLatitude.setDoubleValue(phoneLocation.getLatitude());
                contentBinding.locationLongitude.setDoubleValue(phoneLocation.getLongitude());
                contentBinding.locationLatLonAccuracy.setFloatValue(phoneLocation.getAccuracy());
            } else {
                NotificationHelper.showDialogNotification(LocationDialog.this, NotificationType.WARNING, R.string.message_gps_problem);
            }
        });
        confirmationDialog.show();
    });
    if (data.getId() == null) {
        setLiveValidationDisabled(true);
    }
    if (data.getFacility() == null) {
        contentBinding.locationFacilityDetails.setVisibility(GONE);
    } else {
        contentBinding.facilityTypeGroup.setValue(data.getFacilityType().getFacilityTypeGroup());
    }
    if (data.getFacilityType() != null) {
        contentBinding.locationFacilityType.setValue(data.getFacilityType());
        contentBinding.facilityTypeGroup.setValue(data.getFacilityType().getFacilityTypeGroup());
    } else {
        setFacilityContactPersonFieldsVisible(false, true);
    }
    contentBinding.locationFacilityType.addValueChangedListener(field -> {
        if (field.getValue() == null) {
            setFacilityContactPersonFieldsVisible(false, true);
        } else {
            setFacilityContactPersonFieldsVisible(true, true);
        }
    });
    contentBinding.locationFacility.addValueChangedListener(field -> {
        final Facility facility = (Facility) field.getValue();
        // field.isDirty() always return true making it not usable in our case
        if (this.previousFacility != null && this.previousFacility.equals(facility)) {
            // The field didn't changed
            return;
        }
        this.previousFacility = facility;
        if (facility != null && (StringUtils.isNotEmpty(facility.getCity()) || StringUtils.isNotEmpty(facility.getPostalCode()) || StringUtils.isNotEmpty(facility.getStreet()) || StringUtils.isNotEmpty(facility.getHouseNumber()) || StringUtils.isNotEmpty(facility.getAdditionalInformation()) || facility.getAreaType() != null || facility.getLatitude() != null || facility.getLongitude() != null || (StringUtils.isNotEmpty(facility.getContactPersonFirstName()) && StringUtils.isNotEmpty(facility.getContactPersonLastName())))) {
            if ((StringUtils.isNotEmpty(contentBinding.locationCity.getValue()) && !contentBinding.locationCity.getValue().equals(facility.getCity())) || (StringUtils.isNotEmpty(contentBinding.locationPostalCode.getValue()) && !contentBinding.locationPostalCode.getValue().equals(facility.getPostalCode())) || (StringUtils.isNotEmpty(contentBinding.locationStreet.getValue()) && !contentBinding.locationStreet.getValue().equals(facility.getStreet())) || (StringUtils.isNotEmpty(contentBinding.locationHouseNumber.getValue()) && !contentBinding.locationHouseNumber.getValue().equals(facility.getHouseNumber())) || (StringUtils.isNotEmpty(contentBinding.locationAdditionalInformation.getValue()) && !contentBinding.locationAdditionalInformation.getValue().equals(facility.getAdditionalInformation())) || (contentBinding.locationAreaType.getValue() != null && contentBinding.locationAreaType.getValue() != facility.getAreaType()) || (StringUtils.isNotEmpty(contentBinding.locationContactPersonFirstName.getValue()) && StringUtils.isNotEmpty(contentBinding.locationContactPersonLastName.getValue())) || (StringUtils.isNotEmpty(contentBinding.locationLatitude.getValue()) && !Double.valueOf(contentBinding.locationLatitude.getValue()).equals(facility.getLatitude())) || (StringUtils.isNotEmpty(contentBinding.locationLongitude.getValue()) && !Double.valueOf(contentBinding.locationLongitude.getValue()).equals(facility.getLongitude()))) {
                ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_location, -1, R.string.yes, R.string.no);
                confirmationDialog.getConfig().setSubHeading(I18nProperties.getString(Strings.confirmationLocationFacilityAddressOverride));
                confirmationDialog.setPositiveCallback(() -> overrideLocationDetailsWithFacilityOnes(facility));
                confirmationDialog.show();
            } else {
                overrideLocationDetailsWithFacilityOnes(facility);
            }
        }
    });
    ValidationHelper.initEmailValidator(contentBinding.locationContactPersonEmail);
    ValidationHelper.initPhoneNumberValidator(contentBinding.locationContactPersonPhone);
}
Also used : Item(de.symeda.sormas.app.component.Item) Country(de.symeda.sormas.app.backend.region.Country) Facility(de.symeda.sormas.app.backend.facility.Facility) AreaType(de.symeda.sormas.api.infrastructure.area.AreaType) LocationDto(de.symeda.sormas.api.location.LocationDto)

Example 4 with Facility

use of de.symeda.sormas.app.backend.facility.Facility in project SORMAS-Project by hzi-braunschweig.

the class TestEntityCreator method createCase.

public static Case createCase(Person person) {
    Disease disease = Disease.EVD;
    Region region = DatabaseHelper.getRegionDao().queryUuid(TestHelper.REGION_UUID);
    District district = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.DISTRICT_UUID);
    Community community = DatabaseHelper.getCommunityDao().queryUuid(TestHelper.COMMUNITY_UUID);
    Facility facility = DatabaseHelper.getFacilityDao().queryUuid(TestHelper.FACILITY_UUID);
    CaseClassification caseClassification = CaseClassification.SUSPECT;
    InvestigationStatus investigationStatus = InvestigationStatus.PENDING;
    Case caze = DatabaseHelper.getCaseDao().build(person);
    caze.setDisease(disease);
    caze.setResponsibleRegion(region);
    caze.setResponsibleDistrict(district);
    caze.setResponsibleCommunity(community);
    caze.setHealthFacility(facility);
    caze.setFacilityType(FacilityType.HOSPITAL);
    caze.setCaseClassification(caseClassification);
    caze.setInvestigationStatus(investigationStatus);
    caze.setReportDate(new Date());
    try {
        DatabaseHelper.getCaseDao().saveAndSnapshot(caze);
        DatabaseHelper.getCaseDao().accept(caze);
    } catch (DaoException e) {
        throw new RuntimeException(e);
    }
    return DatabaseHelper.getCaseDao().queryForIdWithEmbedded(caze.getId());
}
Also used : Disease(de.symeda.sormas.api.Disease) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) Region(de.symeda.sormas.app.backend.region.Region) Facility(de.symeda.sormas.app.backend.facility.Facility) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) DaoException(de.symeda.sormas.app.backend.common.DaoException) District(de.symeda.sormas.app.backend.region.District) Community(de.symeda.sormas.app.backend.region.Community) Date(java.util.Date) Case(de.symeda.sormas.app.backend.caze.Case)

Example 5 with Facility

use of de.symeda.sormas.app.backend.facility.Facility in project SORMAS-Project by hzi-braunschweig.

the class TestEntityCreator method createSample.

public static Sample createSample(Case caze) {
    if (caze == null) {
        caze = createCase();
    }
    Date sampleDateTime = DateHelper.subtractDays(new Date(), 1);
    Facility lab = DatabaseHelper.getFacilityDao().queryForAll().get(0);
    SampleMaterial material = SampleMaterial.BLOOD;
    Sample sample = DatabaseHelper.getSampleDao().build(caze);
    sample.setSampleDateTime(sampleDateTime);
    sample.setLab(lab);
    sample.setSampleMaterial(material);
    try {
        DatabaseHelper.getSampleDao().saveAndSnapshot(sample);
        DatabaseHelper.getSampleDao().accept(sample);
    } catch (DaoException e) {
        throw new RuntimeException(e);
    }
    return DatabaseHelper.getSampleDao().queryForIdWithEmbedded(sample.getId());
}
Also used : Sample(de.symeda.sormas.app.backend.sample.Sample) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) Facility(de.symeda.sormas.app.backend.facility.Facility) DaoException(de.symeda.sormas.app.backend.common.DaoException) Date(java.util.Date)

Aggregations

Facility (de.symeda.sormas.app.backend.facility.Facility)26 District (de.symeda.sormas.app.backend.region.District)12 Community (de.symeda.sormas.app.backend.region.Community)10 User (de.symeda.sormas.app.backend.user.User)10 Case (de.symeda.sormas.app.backend.caze.Case)9 Region (de.symeda.sormas.app.backend.region.Region)9 Item (de.symeda.sormas.app.component.Item)6 ArrayList (java.util.ArrayList)6 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)5 Country (de.symeda.sormas.app.backend.region.Country)5 Disease (de.symeda.sormas.api.Disease)4 PointOfEntry (de.symeda.sormas.app.backend.infrastructure.PointOfEntry)4 FacilityTypeGroup (de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup)3 ClinicalCourse (de.symeda.sormas.app.backend.clinicalcourse.ClinicalCourse)3 Person (de.symeda.sormas.app.backend.person.Person)3 Continent (de.symeda.sormas.app.backend.region.Continent)3 Subcontinent (de.symeda.sormas.app.backend.region.Subcontinent)3 Vaccination (de.symeda.sormas.app.backend.vaccination.Vaccination)3 ControlPropertyField (de.symeda.sormas.app.component.controls.ControlPropertyField)3 ValueChangeListener (de.symeda.sormas.app.component.controls.ValueChangeListener)3