Search in sources :

Example 1 with VaccinationDto

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

the class CaseImportFacadeEjb method saveImportedEntities.

@Override
public ImportLineResultDto<CaseImportEntities> saveImportedEntities(@Valid CaseImportEntities entities, boolean skipPersonValidation) {
    CaseDataDto caze = entities.getCaze();
    PersonDto person = entities.getPerson();
    List<SampleDto> samples = entities.getSamples();
    List<PathogenTestDto> pathogenTests = entities.getPathogenTests();
    List<VaccinationDto> vaccinations = entities.getVaccinations();
    try {
        // Necessary to make sure that the follow-up information is retained
        if (featureConfigurationFacade.isFeatureEnabled(FeatureType.CASE_FOLLOWUP) && caze.getFollowUpStatus() == null) {
            caze.setFollowUpStatus(FollowUpStatus.FOLLOW_UP);
        }
        if (caze.getEpidNumber() != null && caseFacade.doesEpidNumberExist(caze.getEpidNumber(), caze.getUuid(), caze.getDisease())) {
            return ImportLineResultDto.errorResult(I18nProperties.getString(Strings.messageEpidNumberWarning));
        }
        // PersonDto savedPerson = personFacade.savePerson(person);
        final PersonDto savedPerson = personFacade.savePerson(person, skipPersonValidation);
        caze.setPerson(savedPerson.toReference());
        // Workaround: Reset the change date to avoid OutdatedEntityExceptions
        // Should be changed when doing #2265
        caze.setChangeDate(new Date());
        caseFacade.save(caze);
        for (SampleDto sample : samples) {
            sampleFacade.saveSample(sample);
        }
        for (PathogenTestDto pathogenTest : pathogenTests) {
            pathogenTestFacade.savePathogenTest(pathogenTest);
        }
        for (VaccinationDto vaccination : vaccinations) {
            vaccinationFacade.createWithImmunization(vaccination, caze.getResponsibleRegion(), caze.getResponsibleDistrict(), caze.getPerson(), caze.getDisease());
        }
        return ImportLineResultDto.successResult();
    } catch (ValidationRuntimeException e) {
        return ImportLineResultDto.errorResult(e.getMessage());
    }
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Date(java.util.Date)

Example 2 with VaccinationDto

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

the class ImmunizationFacadeEjb method fillOrBuildEntity.

protected Immunization fillOrBuildEntity(@NotNull ImmunizationDto source, Immunization target, boolean checkChangeDate) {
    target = DtoHelper.fillOrBuildEntity(source, target, Immunization::new, checkChangeDate);
    target.setDisease(source.getDisease());
    target.setDiseaseDetails(source.getDiseaseDetails());
    target.setPerson(personService.getByReferenceDto(source.getPerson()));
    target.setReportDate(source.getReportDate());
    target.setReportingUser(userService.getByReferenceDto(source.getReportingUser()));
    target.setArchived(source.isArchived());
    target.setImmunizationStatus(source.getImmunizationStatus());
    target.setMeansOfImmunization(source.getMeansOfImmunization());
    target.setMeansOfImmunizationDetails(source.getMeansOfImmunizationDetails());
    target.setImmunizationManagementStatus(source.getImmunizationManagementStatus());
    target.setExternalId(source.getExternalId());
    target.setResponsibleRegion(regionService.getByReferenceDto(source.getResponsibleRegion()));
    target.setResponsibleDistrict(districtService.getByReferenceDto(source.getResponsibleDistrict()));
    target.setResponsibleCommunity(communityService.getByReferenceDto(source.getResponsibleCommunity()));
    target.setCountry(countryService.getByReferenceDto(source.getCountry()));
    target.setFacilityType(source.getFacilityType());
    target.setHealthFacility(facilityService.getByReferenceDto(source.getHealthFacility()));
    target.setHealthFacilityDetails(source.getHealthFacilityDetails());
    target.setStartDate(source.getStartDate());
    target.setEndDate(source.getEndDate());
    target.setNumberOfDoses(source.getNumberOfDoses());
    target.setNumberOfDosesDetails(source.getNumberOfDosesDetails());
    target.setPreviousInfection(source.getPreviousInfection());
    target.setLastInfectionDate(source.getLastInfectionDate());
    target.setAdditionalDetails(source.getAdditionalDetails());
    target.setPositiveTestResultDate(source.getPositiveTestResultDate());
    target.setRecoveryDate(source.getRecoveryDate());
    target.setValidFrom(source.getValidFrom());
    target.setValidUntil(source.getValidUntil());
    target.setRelatedCase(caseService.getByReferenceDto(source.getRelatedCase()));
    List<Vaccination> vaccinationEntities = new ArrayList<>();
    for (VaccinationDto vaccinationDto : source.getVaccinations()) {
        Vaccination vaccination = vaccinationFacade.fromDto(vaccinationDto, checkChangeDate);
        vaccination.setImmunization(target);
        vaccinationEntities.add(vaccination);
    }
    target.getVaccinations().clear();
    target.getVaccinations().addAll(vaccinationEntities);
    if (source.getSormasToSormasOriginInfo() != null) {
        target.setSormasToSormasOriginInfo(originInfoFacade.fromDto(source.getSormasToSormasOriginInfo(), checkChangeDate));
    }
    return target;
}
Also used : Vaccination(de.symeda.sormas.backend.vaccination.Vaccination) ArrayList(java.util.ArrayList) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto)

Example 3 with VaccinationDto

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

the class VaccinationFacadeEjb method convertToDto.

public VaccinationDto convertToDto(Vaccination source, Pseudonymizer pseudonymizer) {
    VaccinationDto dto = toDto(source);
    pseudonymizeDto(source, dto, pseudonymizer);
    return dto;
}
Also used : VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto)

Example 4 with VaccinationDto

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

the class VaccinationFacadeEjbTest method testSave.

@Test
public void testSave() {
    loginWith(nationalUser);
    PersonDto person = creator.createPerson("John", "Doe");
    ImmunizationDto immunizationDto = creator.createImmunization(Disease.CORONAVIRUS, person.toReference(), nationalUser.toReference(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf1);
    HealthConditionsDto healthConditions = new HealthConditionsDto();
    healthConditions.setOtherConditions("PEBMAC");
    VaccinationDto vaccinationDto = creator.createVaccination(nationalUser.toReference(), new ImmunizationReferenceDto(immunizationDto.getUuid(), immunizationDto.toString(), immunizationDto.getExternalId()), healthConditions);
    Vaccination actualVaccination = getVaccinationService().getByUuid(vaccinationDto.getUuid());
    assertThat(actualVaccination.getUuid(), equalTo(vaccinationDto.getUuid()));
    assertThat(vaccinationDto.getHealthConditions().getOtherConditions(), equalTo("PEBMAC"));
    ImmunizationDto actualImmunization = getImmunizationFacade().getByUuid(immunizationDto.getUuid());
    assertThat(actualImmunization.getVaccinations(), hasSize(1));
    assertThat(actualImmunization.getVaccinations().get(0).getUuid(), equalTo(vaccinationDto.getUuid()));
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) PersonDto(de.symeda.sormas.api.person.PersonDto) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) ImmunizationReferenceDto(de.symeda.sormas.api.immunization.ImmunizationReferenceDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 5 with VaccinationDto

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

the class VaccinationFacadeEjbTest method testGetEntriesList.

@Test
public void testGetEntriesList() {
    loginWith(nationalUser);
    PersonDto person1 = creator.createPerson("John", "Doe");
    PersonDto person2 = creator.createPerson("Jane", "Doe");
    Disease disease1 = Disease.CORONAVIRUS;
    Disease disease2 = Disease.CHOLERA;
    ImmunizationDto immunization11 = creator.createImmunization(disease1, person1.toReference(), nationalUser.toReference(), rdcf1);
    ImmunizationDto immunization12 = creator.createImmunization(disease1, person1.toReference(), nationalUser.toReference(), rdcf1);
    ImmunizationDto immunization13 = creator.createImmunization(disease2, person1.toReference(), nationalUser.toReference(), rdcf1);
    ImmunizationDto immunization21 = creator.createImmunization(disease1, person2.toReference(), nationalUser.toReference(), rdcf1);
    creator.createImmunization(disease2, person2.toReference(), nationalUser.toReference(), rdcf1);
    VaccinationDto vaccination111 = creator.createVaccination(nationalUser.toReference(), immunization11.toReference());
    VaccinationDto vaccination112 = creator.createVaccination(nationalUser.toReference(), immunization11.toReference());
    VaccinationDto vaccination121 = creator.createVaccination(nationalUser.toReference(), immunization12.toReference());
    VaccinationDto vaccination131 = creator.createVaccination(nationalUser.toReference(), immunization13.toReference());
    VaccinationDto vaccination211 = creator.createVaccination(nationalUser.toReference(), immunization21.toReference());
    VaccinationDto vaccination212 = creator.createVaccination(nationalUser.toReference(), immunization21.toReference());
    List<VaccinationListEntryDto> vaccinations = getVaccinationFacade().getEntriesList(new VaccinationListCriteria.Builder(person1.toReference()).withDisease(disease1).build(), null, null, null);
    assertThat(vaccinations, hasSize(3));
    assertThat(vaccinations, hasItems(hasProperty(EntityDto.UUID, is(vaccination111.getUuid())), hasProperty(EntityDto.UUID, is(vaccination112.getUuid())), hasProperty(EntityDto.UUID, is(vaccination121.getUuid()))));
    vaccinations = getVaccinationFacade().getEntriesList(new VaccinationListCriteria.Builder(person1.toReference()).withDisease(disease2).build(), null, null, null);
    assertThat(vaccinations, hasSize(1));
    assertThat(vaccinations, hasItem(hasProperty(EntityDto.UUID, is(vaccination131.getUuid()))));
    vaccinations = getVaccinationFacade().getEntriesList(new VaccinationListCriteria.Builder(person2.toReference()).withDisease(disease1).build(), null, null, null);
    assertThat(vaccinations, hasSize(2));
    assertThat(vaccinations, hasItems(hasProperty(EntityDto.UUID, is(vaccination211.getUuid())), hasProperty(EntityDto.UUID, is(vaccination212.getUuid()))));
    vaccinations = getVaccinationFacade().getEntriesList(new VaccinationListCriteria.Builder(person2.toReference()).withDisease(disease2).build(), null, null, null);
    assertThat(vaccinations, hasSize(0));
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) Disease(de.symeda.sormas.api.Disease) PersonDto(de.symeda.sormas.api.person.PersonDto) VaccinationListEntryDto(de.symeda.sormas.api.vaccination.VaccinationListEntryDto) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) VaccinationListCriteria(de.symeda.sormas.api.vaccination.VaccinationListCriteria) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

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