Search in sources :

Example 1 with LocationDto

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;
}
Also used : PersonContactDetailDto(de.symeda.sormas.api.person.PersonContactDetailDto) ApproximateAgeType(de.symeda.sormas.api.person.ApproximateAgeType) PersonDto(de.symeda.sormas.api.person.PersonDto) SimilarPersonDto(de.symeda.sormas.api.person.SimilarPersonDto) JournalPersonDto(de.symeda.sormas.api.person.JournalPersonDto) ArrayList(java.util.ArrayList) Date(java.util.Date) LocationDto(de.symeda.sormas.api.location.LocationDto) Location(de.symeda.sormas.backend.location.Location)

Example 2 with LocationDto

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;
        }
    };
}
Also used : PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) IReferenceDtoResolver(de.symeda.sormas.api.EntityDtoAccessHelper.IReferenceDtoResolver) Date(java.util.Date) LocationDto(de.symeda.sormas.api.location.LocationDto) Before(org.junit.Before)

Example 3 with LocationDto

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);
    });
}
Also used : CheckBox(com.vaadin.v7.ui.CheckBox) Label(com.vaadin.ui.Label) LocationEditForm(de.symeda.sormas.ui.location.LocationEditForm) LocationDto(de.symeda.sormas.api.location.LocationDto)

Example 4 with LocationDto

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);
            }
        });
    }
}
Also used : LocationDto(de.symeda.sormas.api.location.LocationDto)

Example 5 with LocationDto

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);
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ComboBox(com.vaadin.v7.ui.ComboBox) PersonEditForm(de.symeda.sormas.ui.person.PersonEditForm) LocationDto(de.symeda.sormas.api.location.LocationDto)

Aggregations

LocationDto (de.symeda.sormas.api.location.LocationDto)31 PersonDto (de.symeda.sormas.api.person.PersonDto)9 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)7 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 Test (org.junit.Test)7 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)6 UserDto (de.symeda.sormas.api.user.UserDto)4 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)4 ContactDto (de.symeda.sormas.api.contact.ContactDto)3 EpiDataDto (de.symeda.sormas.api.epidata.EpiDataDto)3 EventDto (de.symeda.sormas.api.event.EventDto)3 PersonContactDetailDto (de.symeda.sormas.api.person.PersonContactDetailDto)3 SampleDto (de.symeda.sormas.api.sample.SampleDto)3 Disease (de.symeda.sormas.api.Disease)2 BirthDateDto (de.symeda.sormas.api.caze.BirthDateDto)2 CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)2 ContactCriteria (de.symeda.sormas.api.contact.ContactCriteria)2 ExposureDto (de.symeda.sormas.api.exposure.ExposureDto)2 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)2