use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.
the class PersonFacadeEjb method toDto.
public static PersonDto toDto(Person source) {
if (source == null) {
return null;
}
PersonDto target = new PersonDto();
DtoHelper.fillDto(target, source);
target.setFirstName(source.getFirstName());
target.setLastName(source.getLastName());
target.setSalutation(source.getSalutation());
target.setOtherSalutation(source.getOtherSalutation());
target.setSex(source.getSex());
target.setPresentCondition(source.getPresentCondition());
target.setBirthdateDD(source.getBirthdateDD());
target.setBirthdateMM(source.getBirthdateMM());
target.setBirthdateYYYY(source.getBirthdateYYYY());
if (source.getBirthdateYYYY() != null) {
// calculate the approximate age based on the birth date
// still not sure whether this is a good solution
Pair<Integer, ApproximateAgeType> pair = ApproximateAgeHelper.getApproximateAge(source.getBirthdateYYYY(), source.getBirthdateMM(), source.getBirthdateDD(), source.getDeathDate());
target.setApproximateAge(pair.getElement0());
target.setApproximateAgeType(pair.getElement1());
target.setApproximateAgeReferenceDate(source.getDeathDate() != null ? source.getDeathDate() : new Date());
} else {
target.setApproximateAge(source.getApproximateAge());
target.setApproximateAgeType(source.getApproximateAgeType());
target.setApproximateAgeReferenceDate(source.getApproximateAgeReferenceDate());
}
target.setCauseOfDeath(source.getCauseOfDeath());
target.setCauseOfDeathDetails(source.getCauseOfDeathDetails());
target.setCauseOfDeathDisease(source.getCauseOfDeathDisease());
target.setDeathDate(source.getDeathDate());
target.setDeathPlaceType(source.getDeathPlaceType());
target.setDeathPlaceDescription(source.getDeathPlaceDescription());
target.setBurialDate(source.getBurialDate());
target.setBurialPlaceDescription(source.getBurialPlaceDescription());
target.setBurialConductor(source.getBurialConductor());
target.setBirthName(source.getBirthName());
target.setNickname(source.getNickname());
target.setMothersMaidenName(source.getMothersMaidenName());
target.setAddress(LocationFacadeEjb.toDto(source.getAddress()));
List<LocationDto> locations = new ArrayList<>();
for (Location location : source.getAddresses()) {
LocationDto locationDto = LocationFacadeEjb.toDto(location);
locations.add(locationDto);
}
target.setAddresses(locations);
if (!CollectionUtils.isEmpty(source.getPersonContactDetails())) {
target.setPersonContactDetails(source.getPersonContactDetails().stream().map(entity -> {
final PersonContactDetailDto personContactDetailDto = PersonContactDetailDto.build(source.toReference(), entity.isPrimaryContact(), entity.getPersonContactDetailType(), entity.getPhoneNumberType(), entity.getDetails(), entity.getContactInformation(), entity.getAdditionalInformation(), entity.isThirdParty(), entity.getThirdPartyRole(), entity.getThirdPartyName());
DtoHelper.fillDto(personContactDetailDto, entity);
return personContactDetailDto;
}).collect(Collectors.toList()));
}
target.setEducationType(source.getEducationType());
target.setEducationDetails(source.getEducationDetails());
target.setOccupationType(source.getOccupationType());
target.setOccupationDetails(source.getOccupationDetails());
target.setArmedForcesRelationType(source.getArmedForcesRelationType());
target.setMothersName(source.getMothersName());
target.setFathersName(source.getFathersName());
target.setNamesOfGuardians(source.getNamesOfGuardians());
target.setPlaceOfBirthRegion(RegionFacadeEjb.toReferenceDto(source.getPlaceOfBirthRegion()));
target.setPlaceOfBirthDistrict(DistrictFacadeEjb.toReferenceDto(source.getPlaceOfBirthDistrict()));
target.setPlaceOfBirthCommunity(CommunityFacadeEjb.toReferenceDto(source.getPlaceOfBirthCommunity()));
target.setPlaceOfBirthFacility(FacilityFacadeEjb.toReferenceDto(source.getPlaceOfBirthFacility()));
target.setPlaceOfBirthFacilityDetails(source.getPlaceOfBirthFacilityDetails());
target.setGestationAgeAtBirth(source.getGestationAgeAtBirth());
target.setBirthWeight(source.getBirthWeight());
target.setPassportNumber(source.getPassportNumber());
target.setNationalHealthId(source.getNationalHealthId());
target.setPlaceOfBirthFacilityType(source.getPlaceOfBirthFacilityType());
target.setSymptomJournalStatus(source.getSymptomJournalStatus());
target.setHasCovidApp(source.isHasCovidApp());
target.setCovidCodeDelivered(source.isCovidCodeDelivered());
target.setExternalId(source.getExternalId());
target.setExternalToken(source.getExternalToken());
target.setInternalToken(source.getInternalToken());
target.setBirthCountry(CountryFacadeEjb.toReferenceDto(source.getBirthCountry()));
target.setCitizenship(CountryFacadeEjb.toReferenceDto(source.getCitizenship()));
target.setAdditionalDetails(source.getAdditionalDetails());
return target;
}
use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.
the class EntityDtoAccessHelperTest method setup.
@Before
public void setup() {
caseDataDto = new CaseDataDto();
caseDataDto.setDisease(Disease.DENGUE);
caseDataDto.setUuid("ABCDEF");
hospitalizationDto = new HospitalizationDto();
hospitalizationDto.setDischargeDate(new Date(1600387200000L));
hospitalizationDto.setIsolated(YesNoUnknown.NO);
personReferenceDto = new PersonReferenceDto();
personReferenceDto.setUuid("GHIJKL");
personDto = new PersonDto();
personDto.setUuid("GHIJKL");
personDto.setFirstName("Tenzing");
personDto.setLastName("Mike");
personDto.setBirthdateDD(26);
personDto.setBirthdateMM(11);
personDto.setBirthdateYYYY(1973);
personDto.setPhone("+49 681 1234");
LocationDto address = new LocationDto();
address.setStreet("Elm Street");
personDto.setAddress(address);
referenceDtoResolver = new IReferenceDtoResolver() {
@Override
public EntityDto resolve(ReferenceDto referenceDto) {
if (referenceDto != null && "GHIJKL".equals(referenceDto.getUuid())) {
return personDto;
}
return null;
}
};
}
use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.
the class CaseCreateForm method addHomeAddressForm.
private void addHomeAddressForm() {
enterHomeAddressNow = new CheckBox(I18nProperties.getCaption(Captions.caseDataEnterHomeAddressNow));
enterHomeAddressNow.addStyleName(VSPACE_3);
getContent().addComponent(enterHomeAddressNow, ENTER_HOME_ADDRESS_NOW);
Label addressHeader = new Label(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.ADDRESS));
addressHeader.addStyleName(H3);
getContent().addComponent(addressHeader, HOME_ADDRESS_HEADER);
addressHeader.setVisible(false);
homeAddressForm = new LocationEditForm(FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale()), UiFieldAccessCheckers.getNoop());
homeAddressForm.setValue(new LocationDto());
homeAddressForm.setCaption(null);
homeAddressForm.setWidthFull();
homeAddressForm.setDisableFacilityAddressCheck(true);
getContent().addComponent(homeAddressForm, HOME_ADDRESS_LOC);
homeAddressForm.setVisible(false);
enterHomeAddressNow.addValueChangeListener(e -> {
boolean isChecked = (boolean) e.getProperty().getValue();
addressHeader.setVisible(isChecked);
homeAddressForm.setVisible(isChecked);
homeAddressForm.clear();
homeAddressForm.setFacilityFieldsVisible(isChecked, true);
});
}
use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasDtoValidator method validateEpiData.
public void validateEpiData(EpiDataDto epiData, ValidationErrors validationErrors, ValidationDirection direction) {
if (epiData != null) {
epiData.getExposures().forEach(exposure -> {
LocationDto exposureLocation = exposure.getLocation();
if (exposureLocation != null) {
validateLocation(exposureLocation, Captions.EpiData_exposures, validationErrors, direction);
}
});
epiData.getActivitiesAsCase().forEach(activity -> {
LocationDto activityLocation = activity.getLocation();
if (activityLocation != null) {
validateLocation(activityLocation, Captions.EpiData_activitiesAsCase, validationErrors, direction);
}
});
}
}
use of de.symeda.sormas.api.location.LocationDto in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantEditForm method addFields.
@Override
protected void addFields() {
if (event == null) {
// workaround to stop initialization until event is set
return;
}
if (searchPerson) {
searchPersonButton = createPersonSearchButton(PERSON_SEARCH_LOC);
searchPersonButton.setCaption(I18nProperties.getString(Strings.infoSearchPersonOnDependentForm));
getContent().addComponent(searchPersonButton, PERSON_SEARCH_LOC);
}
pef = new PersonEditForm(PersonContext.EVENT_PARTICIPANT, event.getDisease(), event.getDiseaseDetails(), null, isPersonPseudonymized);
pef.setWidth(100, Unit.PERCENTAGE);
pef.setImmediate(true);
getFieldGroup().bind(pef, EventParticipantDto.PERSON);
getContent().addComponent(pef, EventParticipantDto.PERSON);
addField(EventParticipantDto.INVOLVEMENT_DESCRIPTION, TextField.class);
ComboBox region = addInfrastructureField(EventParticipantDto.REGION);
region.setDescription(I18nProperties.getPrefixDescription(EventParticipantDto.I18N_PREFIX, EventParticipantDto.REGION));
ComboBox district = addInfrastructureField(EventParticipantDto.DISTRICT);
district.setDescription(I18nProperties.getPrefixDescription(EventParticipantDto.I18N_PREFIX, EventParticipantDto.DISTRICT));
region.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
region.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
LocationDto locationDto = event.getEventLocation();
boolean shouldBeRequired = locationDto.getRegion() == null || locationDto.getDistrict() == null;
region.setRequired(shouldBeRequired);
district.setRequired(shouldBeRequired);
addField(EventParticipantDto.REPORTING_USER, ComboBox.class);
setReadOnly(true, EventParticipantDto.REPORTING_USER);
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
addField(EventParticipantDto.VACCINATION_STATUS);
}
Aggregations