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);
}
}
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);
});
}
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);
}
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());
}
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());
}
Aggregations