Search in sources :

Example 31 with VaccinationDto

use of de.symeda.sormas.api.vaccination.VaccinationDto in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationDtoHelper method fillInnerFromAdo.

@Override
protected void fillInnerFromAdo(ImmunizationDto target, Immunization source) {
    target.setDisease(source.getDisease());
    target.setDiseaseDetails(source.getDiseaseDetails());
    if (source.getPerson() != null) {
        Person person = DatabaseHelper.getPersonDao().queryForId(source.getPerson().getId());
        target.setPerson(PersonDtoHelper.toReferenceDto(person));
    }
    target.setReportDate(source.getReportDate());
    if (source.getReportingUser() != null) {
        User user = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
        target.setReportingUser(UserDtoHelper.toReferenceDto(user));
    }
    target.setArchived(source.isArchived());
    target.setImmunizationStatus(source.getImmunizationStatus());
    target.setMeansOfImmunization(source.getMeansOfImmunization());
    target.setMeansOfImmunizationDetails(source.getMeansOfImmunizationDetails());
    target.setImmunizationManagementStatus(source.getImmunizationManagementStatus());
    target.setExternalId(source.getExternalId());
    if (source.getResponsibleRegion() != null) {
        Region region = DatabaseHelper.getRegionDao().queryForId(source.getResponsibleRegion().getId());
        target.setResponsibleRegion(RegionDtoHelper.toReferenceDto(region));
    }
    if (source.getResponsibleDistrict() != null) {
        District district = DatabaseHelper.getDistrictDao().queryForId(source.getResponsibleDistrict().getId());
        target.setResponsibleDistrict(DistrictDtoHelper.toReferenceDto(district));
    }
    if (source.getResponsibleCommunity() != null) {
        Community community = DatabaseHelper.getCommunityDao().queryForId(source.getResponsibleCommunity().getId());
        target.setResponsibleCommunity(CommunityDtoHelper.toReferenceDto(community));
    }
    if (source.getCountry() != null) {
        Country country = DatabaseHelper.getCountryDao().queryForId(source.getCountry().getId());
        target.setCountry(CountryDtoHelper.toReferenceDto(country));
    }
    target.setFacilityType(source.getFacilityType());
    if (source.getHealthFacility() != null) {
        Facility facility = DatabaseHelper.getFacilityDao().queryForId(source.getHealthFacility().getId());
        target.setHealthFacility(FacilityDtoHelper.toReferenceDto(facility));
    } else {
        target.setHealthFacility(null);
    }
    target.setHealthFacilityDetails(source.getHealthFacilityDetails());
    target.setStartDate(source.getStartDate());
    target.setEndDate(source.getEndDate());
    target.setValidFrom(source.getValidFrom());
    target.setValidUntil(source.getValidUntil());
    target.setNumberOfDoses(source.getNumberOfDoses());
    target.setPreviousInfection(source.getPreviousInfection());
    target.setLastInfectionDate(source.getLastInfectionDate());
    target.setAdditionalDetails(source.getAdditionalDetails());
    target.setPositiveTestResultDate(source.getPositiveTestResultDate());
    target.setRecoveryDate(source.getRecoveryDate());
    if (source.getRelatedCase() != null) {
        Case caze = DatabaseHelper.getCaseDao().queryForId(source.getRelatedCase().getId());
        target.setRelatedCase(CaseDtoHelper.toReferenceDto(caze));
    }
    List<VaccinationDto> vaccinationDtos = new ArrayList<>();
    DatabaseHelper.getImmunizationDao().initVaccinations(source);
    if (!source.getVaccinations().isEmpty()) {
        for (Vaccination vaccination : source.getVaccinations()) {
            VaccinationDto vaccinationDto = vaccinationDtoHelper.adoToDto(vaccination);
            vaccinationDtos.add(vaccinationDto);
        }
    }
    target.setVaccinations(vaccinationDtos);
    if (source.getSormasToSormasOriginInfo() != null) {
        target.setSormasToSormasOriginInfo(sormasToSormasOriginInfoDtoHelper.adoToDto(source.getSormasToSormasOriginInfo()));
    }
    target.setPseudonymized(source.isPseudonymized());
}
Also used : User(de.symeda.sormas.app.backend.user.User) Vaccination(de.symeda.sormas.app.backend.vaccination.Vaccination) ArrayList(java.util.ArrayList) Region(de.symeda.sormas.app.backend.region.Region) Country(de.symeda.sormas.app.backend.region.Country) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) Facility(de.symeda.sormas.app.backend.facility.Facility) Person(de.symeda.sormas.app.backend.person.Person) District(de.symeda.sormas.app.backend.region.District) Community(de.symeda.sormas.app.backend.region.Community) Case(de.symeda.sormas.app.backend.caze.Case)

Aggregations

VaccinationDto (de.symeda.sormas.api.vaccination.VaccinationDto)31 Date (java.util.Date)13 PersonDto (de.symeda.sormas.api.person.PersonDto)12 Test (org.junit.Test)11 ImmunizationDto (de.symeda.sormas.api.immunization.ImmunizationDto)10 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)9 ArrayList (java.util.ArrayList)9 UserDto (de.symeda.sormas.api.user.UserDto)8 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)8 Disease (de.symeda.sormas.api.Disease)5 ContactDto (de.symeda.sormas.api.contact.ContactDto)5 EventDto (de.symeda.sormas.api.event.EventDto)4 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)4 PathogenTestDto (de.symeda.sormas.api.sample.PathogenTestDto)4 ValidationRuntimeException (de.symeda.sormas.api.utils.ValidationRuntimeException)4 LocalDate (java.time.LocalDate)4 EntityDto (de.symeda.sormas.api.EntityDto)3 Captions (de.symeda.sormas.api.i18n.Captions)3 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)3 ImmunizationReferenceDto (de.symeda.sormas.api.immunization.ImmunizationReferenceDto)3