use of de.symeda.sormas.api.exposure.ExposureDto in project SORMAS-Project by hzi-braunschweig.
the class ExposuresField method addGeneratedColumns.
private void addGeneratedColumns(Table table) {
table.addGeneratedColumn(COLUMN_EXPOSURE_TYPE, (Table.ColumnGenerator) (source, itemId, columnId) -> {
ExposureDto exposure = (ExposureDto) itemId;
String exposureString = ExposureType.OTHER != exposure.getExposureType() ? exposure.getExposureType().toString() : exposure.getExposureTypeDetails();
// if possible, always display "lowest-level" activity type (e.g. show type of gathering instead of just "gathering")
if (exposure.getExposureType() == ExposureType.GATHERING && exposure.getGatheringType() != null) {
exposureString += " - " + (exposure.getGatheringType() != GatheringType.OTHER ? exposure.getGatheringType().toString() : (StringUtils.isNotEmpty(exposure.getGatheringDetails()) ? exposure.getGatheringDetails() : GatheringType.OTHER.toString()));
}
if (exposure.getExposureType() == ExposureType.HABITATION && exposure.getHabitationType() != null) {
exposureString += " - " + (exposure.getHabitationType() != HabitationType.OTHER ? exposure.getHabitationType().toString() : (StringUtils.isNotEmpty(exposure.getHabitationDetails()) ? exposure.getHabitationDetails() : HabitationType.OTHER.toString()));
}
if (exposure.getExposureType() == ExposureType.ANIMAL_CONTACT && exposure.getTypeOfAnimal() != null) {
exposureString += " (" + (exposure.getTypeOfAnimal() != TypeOfAnimal.OTHER ? exposure.getTypeOfAnimal().toString() : (exposure.getTypeOfAnimalDetails() != null ? exposure.getTypeOfAnimalDetails() : TypeOfAnimal.OTHER.toString())) + ")";
}
if (exposure.getRiskArea() == YesNoUnknown.YES || exposure.isProbableInfectionEnvironment())
exposureString = "<b>" + exposureString + "</b>";
if (exposure.getRiskArea() == YesNoUnknown.YES) {
exposureString = VaadinIcons.INFO_CIRCLE.getHtml() + " " + exposureString;
}
if (exposure.isProbableInfectionEnvironment()) {
exposureString = VaadinIcons.CHECK_CIRCLE.getHtml() + " " + exposureString;
}
Label exposureTypeLabel = new Label(exposureString, ContentMode.HTML);
if (exposure.getRiskArea() == YesNoUnknown.YES) {
exposureTypeLabel.setDescription(I18nProperties.getString(Strings.infoExposuresRiskAreaHint) + " ");
}
if (exposure.isProbableInfectionEnvironment()) {
exposureTypeLabel.setDescription(exposureTypeLabel.getDescription() + I18nProperties.getString(Strings.infoExposuresInfectionEnvironmentHint));
}
return exposureTypeLabel;
});
table.addGeneratedColumn(COLUMN_TYPE_OF_PLACE, (Table.ColumnGenerator) (source, itemId, columnId) -> {
ExposureDto exposure = (ExposureDto) itemId;
String typeOfPlaceString;
if (exposure.getTypeOfPlace() == null) {
return "";
} else if (exposure.getTypeOfPlace() == TypeOfPlace.FACILITY && exposure.getLocation().getFacilityType() != null) {
typeOfPlaceString = exposure.getLocation().getFacilityType().toString();
if (StringUtils.isNotEmpty(exposure.getLocation().getFacilityDetails())) {
typeOfPlaceString += " - " + exposure.getLocation().getFacilityDetails();
} else if (exposure.getLocation().getFacility() != null) {
typeOfPlaceString += " - " + exposure.getLocation().getFacility().toString();
}
} else if (exposure.getTypeOfPlace() == TypeOfPlace.MEANS_OF_TRANSPORT) {
typeOfPlaceString = exposure.getMeansOfTransport() == null ? TypeOfPlace.MEANS_OF_TRANSPORT.toString() : (exposure.getMeansOfTransport() != MeansOfTransport.OTHER ? exposure.getMeansOfTransport().toString() : ((StringUtils.isNotEmpty(exposure.getMeansOfTransportDetails())) ? exposure.getMeansOfTransportDetails() : TypeOfPlace.MEANS_OF_TRANSPORT.toString()));
} else {
typeOfPlaceString = exposure.getTypeOfPlace() != TypeOfPlace.OTHER ? exposure.getTypeOfPlace().toString() : (StringUtils.isNotEmpty(exposure.getTypeOfPlaceDetails()) ? exposure.getTypeOfPlaceDetails() : TypeOfPlace.OTHER.toString());
}
return typeOfPlaceString;
});
table.addGeneratedColumn(COLUMN_DATE, (Table.ColumnGenerator) (source, itemId, columnId) -> {
ExposureDto exposure = (ExposureDto) itemId;
return DateFormatHelper.buildPeriodDateTimeString(exposure.getStartDate(), exposure.getEndDate());
});
table.addGeneratedColumn(COLUMN_ADDRESS, (Table.ColumnGenerator) (source, itemId, columnId) -> LocationHelper.buildLocationString(((ExposureDto) itemId).getLocation()));
table.addGeneratedColumn(COLUMN_DESCRIPTION, (Table.ColumnGenerator) (source, itemId, columnId) -> {
ExposureDto exposure = (ExposureDto) itemId;
Label descriptionLabel = new Label(StringUtils.abbreviate(exposure.getDescription(), 75));
if (StringUtils.isNotBlank(exposure.getDescription())) {
descriptionLabel.setDescription(exposure.getDescription());
}
return descriptionLabel;
});
table.addGeneratedColumn(COLUMN_SOURCE_CASE_NAME, (Table.ColumnGenerator) (source, itemId, columnId) -> {
ExposureDto exposure = (ExposureDto) itemId;
return !isPseudonymized ? DataHelper.toStringNullable(exposure.getContactToCase() != null ? exposure.getContactToCase().getCaseName() : "") : I18nProperties.getCaption(Captions.inaccessibleValue);
});
}
use of de.symeda.sormas.api.exposure.ExposureDto in project SORMAS-Project by hzi-braunschweig.
the class ExposuresField method createEntry.
@Override
protected ExposureDto createEntry() {
UserDto user = UserProvider.getCurrent().getUser();
ExposureDto exposure = ExposureDto.build(null);
exposure.getLocation().setRegion(user.getRegion());
exposure.getLocation().setDistrict(user.getDistrict());
exposure.getLocation().setCommunity(user.getCommunity());
exposure.setReportingUser(user.toReference());
return exposure;
}
use of de.symeda.sormas.api.exposure.ExposureDto in project SORMAS-Project by hzi-braunschweig.
the class ExposuresField method showMultipleInfectionEnvironmentsPopup.
private void showMultipleInfectionEnvironmentsPopup(ExposureDto entry) {
VerticalLayout warningLayout = VaadinUiUtil.createWarningLayout();
Window popupWindow = VaadinUiUtil.showPopupWindow(warningLayout);
com.vaadin.ui.Label infoLabel = new com.vaadin.ui.Label(I18nProperties.getValidationError(Validations.caseMultipleInfectionEnvironments));
CssStyles.style(infoLabel, CssStyles.LABEL_LARGE, CssStyles.LABEL_WHITE_SPACE_NORMAL);
warningLayout.addComponent(infoLabel);
ConfirmationComponent yesNo = VaadinUiUtil.buildYesNoConfirmationComponent();
yesNo.getConfirmButton().addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(Button.ClickEvent event) {
popupWindow.close();
for (ExposureDto exposure : getValue()) {
if (exposure.isProbableInfectionEnvironment() && !exposure.getUuid().equals(entry.getUuid())) {
exposure.setProbableInfectionEnvironment(false);
}
}
getTable().refreshRowCache();
}
});
yesNo.getCancelButton().addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(Button.ClickEvent event) {
popupWindow.close();
entry.setProbableInfectionEnvironment(false);
getTable().refreshRowCache();
}
});
warningLayout.addComponent(yesNo);
popupWindow.setWidth(800, Sizeable.Unit.PIXELS);
popupWindow.setClosable(false);
}
use of de.symeda.sormas.api.exposure.ExposureDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjb method restorePseudonymizedDto.
public void restorePseudonymizedDto(CaseDataDto dto, CaseDataDto existingCaseDto, Case caze, Pseudonymizer pseudonymizer) {
if (existingCaseDto != null) {
boolean inJurisdiction = service.inJurisdictionOrOwned(caze);
User currentUser = userService.getCurrentUser();
pseudonymizer.restoreUser(caze.getReportingUser(), currentUser, dto, dto::setReportingUser);
pseudonymizer.restoreUser(caze.getClassificationUser(), currentUser, dto, dto::setClassificationUser);
pseudonymizer.restorePseudonymizedValues(CaseDataDto.class, dto, existingCaseDto, inJurisdiction);
EpiDataDto epiData = dto.getEpiData();
EpiDataDto existingEpiData = existingCaseDto.getEpiData();
pseudonymizer.restorePseudonymizedValues(EpiDataDto.class, epiData, existingEpiData, inJurisdiction);
epiData.getExposures().forEach(exposure -> {
ExposureDto existingExposure = existingEpiData.getExposures().stream().filter(exp -> DataHelper.isSame(exposure, exp)).findFirst().orElse(null);
if (existingExposure != null) {
pseudonymizer.restorePseudonymizedValues(ExposureDto.class, exposure, existingExposure, inJurisdiction);
pseudonymizer.restorePseudonymizedValues(LocationDto.class, exposure.getLocation(), existingExposure.getLocation(), inJurisdiction);
}
});
pseudonymizer.restorePseudonymizedValues(HealthConditionsDto.class, dto.getHealthConditions(), existingCaseDto.getHealthConditions(), inJurisdiction);
dto.getHospitalization().getPreviousHospitalizations().forEach(previousHospitalization -> existingCaseDto.getHospitalization().getPreviousHospitalizations().stream().filter(eh -> DataHelper.isSame(previousHospitalization, eh)).findFirst().ifPresent(existingPreviousHospitalization -> pseudonymizer.restorePseudonymizedValues(PreviousHospitalizationDto.class, previousHospitalization, existingPreviousHospitalization, inJurisdiction)));
pseudonymizer.restorePseudonymizedValues(SymptomsDto.class, dto.getSymptoms(), existingCaseDto.getSymptoms(), inJurisdiction);
pseudonymizer.restorePseudonymizedValues(MaternalHistoryDto.class, dto.getMaternalHistory(), existingCaseDto.getMaternalHistory(), inJurisdiction);
}
}
use of de.symeda.sormas.api.exposure.ExposureDto in project SORMAS-Project by hzi-braunschweig.
the class EpiDataDtoHelper method fillInnerFromAdo.
@Override
public void fillInnerFromAdo(EpiDataDto target, EpiData source) {
target.setExposureDetailsKnown(source.getExposureDetailsKnown());
target.setActivityAsCaseDetailsKnown(source.getActivityAsCaseDetailsKnown());
target.setContactWithSourceCaseKnown(source.getContactWithSourceCaseKnown());
target.setHighTransmissionRiskArea(source.getHighTransmissionRiskArea());
target.setLargeOutbreaksArea(source.getLargeOutbreaksArea());
target.setAreaInfectedAnimals(source.getAreaInfectedAnimals());
List<ExposureDto> exposureDtos = new ArrayList<>();
if (!source.getExposures().isEmpty()) {
for (Exposure exposure : source.getExposures()) {
ExposureDto exposureDto = exposureDtoHelper.adoToDto(exposure);
exposureDtos.add(exposureDto);
}
}
target.setExposures(exposureDtos);
List<ActivityAsCaseDto> activityAsCaseDtos = new ArrayList<>();
if (!source.getActivitiesAsCase().isEmpty()) {
for (ActivityAsCase activityAsCase : source.getActivitiesAsCase()) {
ActivityAsCaseDto exposureDto = activityAsCaseDtoHelper.adoToDto(activityAsCase);
activityAsCaseDtos.add(exposureDto);
}
}
target.setActivitiesAsCase(activityAsCaseDtos);
target.setPseudonymized(source.isPseudonymized());
}
Aggregations