use of de.symeda.sormas.app.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class CaseEditFragment method setUpFieldVisibilities.
// Instance methods
private void setUpFieldVisibilities(final FragmentCaseEditLayoutBinding contentBinding) {
setFieldVisibilitiesAndAccesses(CaseDataDto.class, contentBinding.mainContent);
InfrastructureDaoHelper.initializeHealthFacilityDetailsFieldVisibility(contentBinding.caseDataHealthFacility, contentBinding.caseDataHealthFacilityDetails);
InfrastructureDaoHelper.initializePointOfEntryDetailsFieldVisibility(contentBinding.caseDataPointOfEntry, contentBinding.caseDataPointOfEntryDetails);
if (!isFieldAccessible(CaseDataDto.class, contentBinding.caseDataCommunity)) {
contentBinding.caseDataRegion.setEnabled(false);
contentBinding.caseDataDistrict.setEnabled(false);
}
// Smallpox vaccination scar image
contentBinding.caseDataSmallpoxVaccinationScar.getViewTreeObserver().addOnGlobalLayoutListener(() -> contentBinding.smallpoxVaccinationScarImg.setVisibility(contentBinding.caseDataSmallpoxVaccinationScar.getVisibility()));
// Port Health fields
if (UserRole.isPortHealthUser(ConfigProvider.getUser().getUserRoles())) {
contentBinding.caseDataCaseOrigin.setVisibility(GONE);
contentBinding.facilityOrHome.setVisibility(GONE);
contentBinding.caseDataCommunity.setVisibility(GONE);
contentBinding.facilityTypeFieldsLayout.setVisibility(GONE);
contentBinding.caseDataHealthFacility.setVisibility(GONE);
contentBinding.caseDataHealthFacilityDetails.setVisibility(GONE);
} else {
if (record.getCaseOrigin() == CaseOrigin.POINT_OF_ENTRY) {
if (record.getHealthFacility() == null) {
contentBinding.facilityOrHome.setVisibility(GONE);
contentBinding.caseDataCommunity.setVisibility(GONE);
contentBinding.facilityTypeFieldsLayout.setVisibility(GONE);
contentBinding.caseDataHealthFacility.setVisibility(GONE);
contentBinding.caseDataHealthFacilityDetails.setVisibility(GONE);
}
} else {
contentBinding.pointOfEntryFieldsLayout.setVisibility(GONE);
}
}
// Button panel
DiseaseClassificationCriteria classificationCriteria = DatabaseHelper.getDiseaseClassificationCriteriaDao().getByDisease(record.getDisease());
if (classificationCriteria == null || !classificationCriteria.hasAnyCriteria()) {
contentBinding.showClassificationRules.setVisibility(GONE);
}
if (!ConfigProvider.hasUserRight(UserRight.CASE_REFER_FROM_POE) || record.getCaseOrigin() != CaseOrigin.POINT_OF_ENTRY || record.getHealthFacility() != null) {
contentBinding.referCaseFromPoe.setVisibility(GONE);
}
if (contentBinding.showClassificationRules.getVisibility() == GONE && contentBinding.referCaseFromPoe.getVisibility() == GONE) {
contentBinding.caseButtonsPanel.setVisibility(GONE);
}
if (!ConfigProvider.isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
contentBinding.caseDataExternalID.setVisibility(GONE);
} else {
contentBinding.caseDataEpidNumber.setVisibility(GONE);
}
updateCaseConfirmationVisibility(contentBinding);
contentBinding.caseDataQuarantineExtended.setVisibility(record.isQuarantineExtended() ? VISIBLE : GONE);
contentBinding.caseDataQuarantineReduced.setVisibility(record.isQuarantineReduced() ? VISIBLE : GONE);
User user = ConfigProvider.getUser();
if (user.hasUserRole(UserRole.HOSPITAL_INFORMANT)) {
// Hospital Informants are not allowed to change place of stay
contentBinding.caseDataDifferentPlaceOfStayJurisdiction.setEnabled(false);
contentBinding.caseDataDifferentPlaceOfStayJurisdiction.setVisibility(GONE);
}
}
use of de.symeda.sormas.app.backend.user.User 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.user.User in project SORMAS-Project by hzi-braunschweig.
the class ContactDtoHelper method fillInnerFromAdo.
@Override
public void fillInnerFromAdo(ContactDto target, Contact source) {
if (source.getPerson() != null) {
Person person = DatabaseHelper.getPersonDao().queryForId(source.getPerson().getId());
target.setPerson(PersonDtoHelper.toReferenceDto(person));
} else {
target.setPerson(null);
}
if (source.getRegion() != null) {
Region region = DatabaseHelper.getRegionDao().queryForId(source.getRegion().getId());
target.setRegion(RegionDtoHelper.toReferenceDto(region));
} else {
target.setRegion(null);
}
if (source.getDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getDistrict().getId());
target.setDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setDistrict(null);
}
if (source.getCommunity() != null) {
Community community = DatabaseHelper.getCommunityDao().queryForId(source.getCommunity().getId());
target.setCommunity(CommunityDtoHelper.toReferenceDto(community));
} else {
target.setCommunity(null);
}
if (source.getCaseUuid() != null) {
target.setCaze(new CaseReferenceDto(source.getCaseUuid()));
} else {
target.setCaze(null);
}
if (source.getResultingCaseUuid() != null) {
target.setResultingCase(new CaseReferenceDto(source.getResultingCaseUuid()));
} else {
target.setResultingCase(null);
}
target.setDisease(source.getDisease());
target.setDiseaseDetails(source.getDiseaseDetails());
if (source.getReportingUser() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
target.setReportingUser(UserDtoHelper.toReferenceDto(user));
} else {
target.setReportingUser(null);
}
target.setReportDateTime(source.getReportDateTime());
target.setMultiDayContact(source.isMultiDayContact());
target.setFirstContactDate(source.getFirstContactDate());
target.setLastContactDate(source.getLastContactDate());
target.setContactIdentificationSource(source.getContactIdentificationSource());
target.setContactIdentificationSourceDetails(source.getContactIdentificationSourceDetails());
target.setTracingApp(source.getTracingApp());
target.setTracingAppDetails(source.getTracingAppDetails());
target.setContactProximity(source.getContactProximity());
target.setContactClassification(source.getContactClassification());
target.setContactStatus(source.getContactStatus());
target.setRelationToCase(source.getRelationToCase());
target.setRelationDescription(source.getRelationDescription());
target.setFollowUpStatus(source.getFollowUpStatus());
target.setFollowUpComment(source.getFollowUpComment());
target.setFollowUpUntil(source.getFollowUpUntil());
if (source.getContactOfficer() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getContactOfficer().getId());
target.setContactOfficer(UserDtoHelper.toReferenceDto(user));
} else {
target.setContactOfficer(null);
}
target.setDescription(source.getDescription());
target.setReportLat(source.getReportLat());
target.setReportLon(source.getReportLon());
target.setReportLatLonAccuracy(source.getReportLatLonAccuracy());
target.setExternalID(source.getExternalID());
target.setExternalToken(source.getExternalToken());
target.setInternalToken(source.getInternalToken());
target.setHighPriority(source.isHighPriority());
target.setImmunosuppressiveTherapyBasicDisease(source.getImmunosuppressiveTherapyBasicDisease());
target.setImmunosuppressiveTherapyBasicDiseaseDetails(source.getImmunosuppressiveTherapyBasicDiseaseDetails());
target.setCareForPeopleOver60(source.getCareForPeopleOver60());
target.setQuarantine(source.getQuarantine());
target.setQuarantineTypeDetails(source.getQuarantineTypeDetails());
target.setQuarantineFrom(source.getQuarantineFrom());
target.setQuarantineTo(source.getQuarantineTo());
target.setCaseIdExternalSystem(source.getCaseIdExternalSystem());
target.setCaseOrEventInformation(source.getCaseOrEventInformation());
target.setQuarantineHelpNeeded(source.getQuarantineHelpNeeded());
target.setQuarantineOrderedVerbally(source.isQuarantineOrderedVerbally());
target.setQuarantineOrderedOfficialDocument(source.isQuarantineOrderedOfficialDocument());
target.setQuarantineOrderedVerballyDate(source.getQuarantineOrderedVerballyDate());
target.setQuarantineOrderedOfficialDocumentDate(source.getQuarantineOrderedOfficialDocumentDate());
target.setQuarantineExtended(source.isQuarantineExtended());
target.setQuarantineReduced(source.isQuarantineReduced());
target.setQuarantineHomePossible(source.getQuarantineHomePossible());
target.setQuarantineHomePossibleComment(source.getQuarantineHomePossibleComment());
target.setQuarantineHomeSupplyEnsured(source.getQuarantineHomeSupplyEnsured());
target.setQuarantineHomeSupplyEnsuredComment(source.getQuarantineHomeSupplyEnsuredComment());
target.setQuarantineOfficialOrderSent(source.isQuarantineOfficialOrderSent());
target.setQuarantineOfficialOrderSentDate(source.getQuarantineOfficialOrderSentDate());
target.setAdditionalDetails(source.getAdditionalDetails());
if (source.getEpiData() != null) {
EpiData epiData = DatabaseHelper.getEpiDataDao().queryForId(source.getEpiData().getId());
target.setEpiData(epiDataDtoHelper.adoToDto(epiData));
} else {
target.setEpiData(null);
}
if (source.getHealthConditions() != null) {
HealthConditions healthConditions = DatabaseHelper.getHealthConditionsDao().queryForId(source.getHealthConditions().getId());
target.setHealthConditions(healthConditionsDtoHelper.adoToDto(healthConditions));
} else {
target.setHealthConditions(null);
}
if (source.getSormasToSormasOriginInfo() != null) {
target.setSormasToSormasOriginInfo(sormasToSormasOriginInfoDtoHelper.adoToDto(source.getSormasToSormasOriginInfo()));
}
target.setEndOfQuarantineReason(source.getEndOfQuarantineReason());
target.setEndOfQuarantineReasonDetails(source.getEndOfQuarantineReasonDetails());
target.setPseudonymized(source.isPseudonymized());
target.setReturningTraveler(source.getReturningTraveler());
target.setProhibitionToWork(source.getProhibitionToWork());
target.setProhibitionToWorkFrom(source.getProhibitionToWorkFrom());
target.setProhibitionToWorkUntil(source.getProhibitionToWorkUntil());
if (source.getReportingDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getReportingDistrict().getId());
target.setReportingDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setReportingDistrict(null);
}
target.setFollowUpStatusChangeDate(source.getFollowUpStatusChangeDate());
target.setFollowUpStatusChangeUser(UserDtoHelper.toReferenceDto(source.getFollowUpStatusChangeUser()));
target.setVaccinationStatus(source.getVaccinationStatus());
}
use of de.symeda.sormas.app.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class ExposureDtoHelper method fillInnerFromAdo.
@Override
protected void fillInnerFromAdo(ExposureDto target, Exposure source) {
if (source.getLocation() != null) {
Location location = DatabaseHelper.getLocationDao().queryForId(source.getLocation().getId());
target.setLocation(locationDtoHelper.adoToDto(location));
} else {
target.setLocation(null);
}
if (source.getContactToCase() != null) {
Contact contactToCase = DatabaseHelper.getContactDao().queryForId(source.getContactToCase().getId());
target.setContactToCase(ContactDtoHelper.toReferenceDto(contactToCase));
} else {
target.setContactToCase(null);
}
if (source.getReportingUser() != null) {
User reportingUser = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
target.setReportingUser(UserDtoHelper.toReferenceDto(reportingUser));
} else {
target.setReportingUser(null);
}
target.setAnimalCondition(source.getAnimalCondition());
target.setTypeOfAnimal(source.getTypeOfAnimal());
target.setTypeOfAnimalDetails(source.getTypeOfAnimalDetails());
target.setExposureRole(source.getExposureRole());
target.setAnimalContactType(source.getAnimalContactType());
target.setAnimalContactTypeDetails(source.getAnimalContactTypeDetails());
target.setAnimalMarket(source.getAnimalMarket());
target.setAnimalVaccinated(source.getAnimalVaccinated());
target.setContactToBodyFluids(source.getContactToBodyFluids());
target.setDeceasedPersonIll(source.getDeceasedPersonIll());
target.setDeceasedPersonName(source.getDeceasedPersonName());
target.setDeceasedPersonRelation(source.getDeceasedPersonRelation());
target.setDescription(source.getDescription());
target.setEatingRawAnimalProducts(source.getEatingRawAnimalProducts());
target.setEndDate(source.getEndDate());
target.setExposureType(source.getExposureType());
target.setExposureTypeDetails(source.getExposureTypeDetails());
target.setGatheringDetails(source.getGatheringDetails());
target.setGatheringType(source.getGatheringType());
target.setHabitationDetails(source.getHabitationDetails());
target.setHabitationType(source.getHabitationType());
target.setHandlingAnimals(source.getHandlingAnimals());
target.setHandlingSamples(source.getHandlingSamples());
target.setIndoors(source.getIndoors());
target.setLongFaceToFaceContact(source.getLongFaceToFaceContact());
target.setOtherProtectiveMeasures(source.getOtherProtectiveMeasures());
target.setProtectiveMeasuresDetails(source.getProtectiveMeasuresDetails());
target.setOutdoors(source.getOutdoors());
target.setPercutaneous(source.getPercutaneous());
target.setPhysicalContactDuringPreparation(source.getPhysicalContactDuringPreparation());
target.setPhysicalContactWithBody(source.getPhysicalContactWithBody());
target.setShortDistance(source.getShortDistance());
target.setProbableInfectionEnvironment(source.isProbableInfectionEnvironment());
target.setStartDate(source.getStartDate());
target.setWearingMask(source.getWearingMask());
target.setWearingPpe(source.getWearingPpe());
target.setTypeOfPlace(source.getTypeOfPlace());
target.setTypeOfPlaceDetails(source.getTypeOfPlaceDetails());
target.setMeansOfTransport(source.getMeansOfTransport());
target.setMeansOfTransportDetails(source.getMeansOfTransportDetails());
target.setConnectionNumber(source.getConnectionNumber());
target.setSeatNumber(source.getSeatNumber());
target.setWorkEnvironment(source.getWorkEnvironment());
target.setBodyOfWater(source.getBodyOfWater());
target.setWaterSource(source.getWaterSource());
target.setWaterSourceDetails(source.getWaterSourceDetails());
target.setProphylaxis(source.getProphylaxis());
target.setProphylaxisDate(source.getProphylaxisDate());
target.setRiskArea(source.getRiskArea());
target.setLargeAttendanceNumber(source.getLargeAttendanceNumber());
}
use of de.symeda.sormas.app.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class ContactEditAuthorization method isContactEditAllowed.
public static boolean isContactEditAllowed(Contact contact) {
if (contact.getSormasToSormasOriginInfo() != null) {
return contact.getSormasToSormasOriginInfo().isOwnershipHandedOver();
}
final User user = ConfigProvider.getUser();
final ContactJurisdictionBooleanValidator contactJurisdictionBooleanValidator = ContactJurisdictionBooleanValidator.of(JurisdictionHelper.createContactJurisdictionDto(contact), JurisdictionHelper.createUserJurisdiction(user));
return !contact.isOwnershipHandedOver() && contactJurisdictionBooleanValidator.inJurisdictionOrOwned();
}
Aggregations