Search in sources :

Example 21 with VaccinationDto

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

the class ImmunizationFacadeEjb method toDto.

public ImmunizationDto toDto(Immunization entity) {
    if (entity == null) {
        return null;
    }
    ImmunizationDto dto = new ImmunizationDto();
    DtoHelper.fillDto(dto, entity);
    dto.setDisease(entity.getDisease());
    dto.setDiseaseDetails(entity.getDiseaseDetails());
    dto.setPerson(PersonFacadeEjb.toReferenceDto(entity.getPerson()));
    dto.setReportDate(entity.getReportDate());
    dto.setReportingUser(UserFacadeEjb.toReferenceDto(entity.getReportingUser()));
    dto.setArchived(entity.isArchived());
    dto.setImmunizationStatus(entity.getImmunizationStatus());
    dto.setMeansOfImmunization(entity.getMeansOfImmunization());
    dto.setMeansOfImmunizationDetails(entity.getMeansOfImmunizationDetails());
    dto.setImmunizationManagementStatus(entity.getImmunizationManagementStatus());
    dto.setExternalId(entity.getExternalId());
    dto.setResponsibleRegion(RegionFacadeEjb.toReferenceDto(entity.getResponsibleRegion()));
    dto.setResponsibleDistrict(DistrictFacadeEjb.toReferenceDto(entity.getResponsibleDistrict()));
    dto.setResponsibleCommunity(CommunityFacadeEjb.toReferenceDto(entity.getResponsibleCommunity()));
    dto.setCountry(CountryFacadeEjb.toReferenceDto(entity.getCountry()));
    dto.setFacilityType(entity.getFacilityType());
    dto.setHealthFacility(FacilityFacadeEjb.toReferenceDto(entity.getHealthFacility()));
    dto.setHealthFacilityDetails(entity.getHealthFacilityDetails());
    dto.setStartDate(entity.getStartDate());
    dto.setEndDate(entity.getEndDate());
    dto.setNumberOfDoses(entity.getNumberOfDoses());
    dto.setNumberOfDosesDetails(entity.getNumberOfDosesDetails());
    dto.setPreviousInfection(entity.getPreviousInfection());
    dto.setLastInfectionDate(entity.getLastInfectionDate());
    dto.setAdditionalDetails(entity.getAdditionalDetails());
    dto.setPositiveTestResultDate(entity.getPositiveTestResultDate());
    dto.setRecoveryDate(entity.getRecoveryDate());
    dto.setValidFrom(entity.getValidFrom());
    dto.setValidUntil(entity.getValidUntil());
    dto.setRelatedCase(CaseFacadeEjb.toReferenceDto(entity.getRelatedCase()));
    List<VaccinationDto> vaccinationDtos = new ArrayList<>();
    for (Vaccination vaccination : entity.getVaccinations()) {
        VaccinationDto vaccinationDto = vaccinationFacade.toDto(vaccination);
        vaccinationDtos.add(vaccinationDto);
    }
    dto.setVaccinations(vaccinationDtos);
    dto.setSormasToSormasOriginInfo(SormasToSormasOriginInfoFacadeEjb.toDto(entity.getSormasToSormasOriginInfo()));
    dto.setOwnershipHandedOver(entity.getSormasToSormasShares().stream().anyMatch(ShareInfoHelper::isOwnerShipHandedOver));
    return dto;
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) Vaccination(de.symeda.sormas.backend.vaccination.Vaccination) ArrayList(java.util.ArrayList) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto)

Example 22 with VaccinationDto

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

the class VaccinationFacadeEjb method copyExistingVaccinationsToNewImmunization.

public void copyExistingVaccinationsToNewImmunization(ImmunizationDto immunizationDto, Immunization newImmunization) {
    List<Vaccination> vaccinationEntities = new ArrayList<>();
    for (VaccinationDto vaccinationDto : immunizationDto.getVaccinations()) {
        Vaccination vaccination = new Vaccination();
        vaccination.setUuid(DataHelper.createUuid());
        vaccination = fillOrBuildEntity(vaccinationDto, vaccination, false);
        vaccination.setImmunization(newImmunization);
        vaccinationEntities.add(vaccination);
    }
    newImmunization.getVaccinations().clear();
    newImmunization.getVaccinations().addAll(vaccinationEntities);
}
Also used : ArrayList(java.util.ArrayList) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto)

Example 23 with VaccinationDto

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

the class CaseFacadeEjbTest method testGetExportList.

@Test
public void testGetExportList() {
    RDCFEntities rdcfEntities = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    RDCF rdcf = new RDCF(rdcfEntities);
    UserDto user = creator.createUser(rdcfEntities.region.getUuid(), rdcfEntities.district.getUuid(), rdcfEntities.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcfEntities);
    cazePerson.getAddress().setCity("City");
    getPersonFacade().savePerson(cazePerson);
    ExposureDto exposure = ExposureDto.build(ExposureType.TRAVEL);
    exposure.getLocation().setDetails("Ghana");
    exposure.setStartDate(new Date());
    exposure.setEndDate(new Date());
    caze.getEpiData().getExposures().add(exposure);
    caze.getSymptoms().setAbdominalPain(SymptomState.YES);
    caze = getCaseFacade().save(caze);
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -1);
    creator.createSample(caze.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcfEntities.facility);
    creator.createSample(caze.toReference(), cal.getTime(), cal.getTime(), user.toReference(), SampleMaterial.CRUST, rdcfEntities.facility);
    creator.createPathogenTest(caze, PathogenTestType.ANTIGEN_DETECTION, PathogenTestResultType.POSITIVE);
    creator.createPrescription(caze);
    ImmunizationDto immunization = creator.createImmunization(caze.getDisease(), caze.getPerson(), caze.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 10), DateHelper.subtractDays(new Date(), 5), DateHelper.subtractDays(new Date(), 1), null);
    creator.createImmunization(caze.getDisease(), caze.getPerson(), caze.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 8), DateHelper.subtractDays(new Date(), 7), null, null);
    VaccinationDto firstVaccination = creator.createVaccination(caze.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 7), Vaccine.OXFORD_ASTRA_ZENECA, VaccineManufacturer.ASTRA_ZENECA);
    creator.createVaccination(caze.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 4), Vaccine.MRNA_1273, VaccineManufacturer.MODERNA);
    VaccinationDto thirdVaccination = creator.createVaccination(caze.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), new Date(), Vaccine.COMIRNATY, VaccineManufacturer.BIONTECH_PFIZER);
    final String primaryPhone = "0000444888";
    final String primaryEmail = "primary@email.com";
    cazePerson = getPersonFacade().getPersonByUuid(cazePerson.getUuid());
    cazePerson.setPhone(primaryPhone);
    cazePerson.setEmailAddress(primaryEmail);
    cazePerson.getPersonContactDetails().add(PersonContactDetailDto.build(cazePerson.toReference(), false, PersonContactDetailType.PHONE, PhoneNumberType.LANDLINE, "", "0265590500", "", false, "", ""));
    cazePerson.getPersonContactDetails().add(PersonContactDetailDto.build(cazePerson.toReference(), false, PersonContactDetailType.EMAIL, null, "", "secondary@email.com", "", false, "", ""));
    cazePerson.getPersonContactDetails().add(PersonContactDetailDto.build(cazePerson.toReference(), false, PersonContactDetailType.OTHER, null, "SkypeID", "personSkype", "", false, "", ""));
    getPersonFacade().savePerson(cazePerson);
    List<CaseExportDto> results = getCaseFacade().getExportList(new CaseCriteria(), Collections.emptySet(), CaseExportType.CASE_SURVEILLANCE, 0, 100, null, Language.EN);
    // List should have one entry
    assertEquals(1, results.size());
    assertTrue(results.get(0).getSampleDateTime2().after(results.get(0).getSampleDateTime3()));
    // Make sure that everything that is added retrospectively (symptoms, sample
    // dates, lab results, address, travel history) is present
    CaseExportDto exportDto = results.get(0);
    assertNotNull(exportDto.getSymptoms());
    // assertNotNull(exportDto.getSampleDateTime1());
    // assertNotNull(exportDto.getSampleLab1());
    // assertTrue(StringUtils.isNotEmpty(exportDto.getAddress()));
    // assertTrue(StringUtils.isNotEmpty(exportDto.getTravelHistory()));
    assertEquals(primaryPhone, exportDto.getPhone());
    assertEquals(primaryEmail, exportDto.getEmailAddress());
    final String otherContactDetails = exportDto.getOtherContactDetails();
    assertTrue(otherContactDetails.contains("0265590500 (PHONE)"));
    assertTrue(otherContactDetails.contains("secondary@email.com (EMAIL)"));
    assertTrue(otherContactDetails.contains("personSkype (SkypeID)"));
    assertEquals(VaccinationStatus.VACCINATED, exportDto.getVaccinationStatus());
    assertEquals(thirdVaccination.getVaccineName(), exportDto.getVaccineName());
    assertEquals(firstVaccination.getVaccinationDate(), exportDto.getFirstVaccinationDate());
    assertEquals(thirdVaccination.getVaccinationDate(), exportDto.getLastVaccinationDate());
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) Calendar(java.util.Calendar) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Date(java.util.Date) LocalDate(java.time.LocalDate) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) CaseExportDto(de.symeda.sormas.api.caze.CaseExportDto) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 24 with VaccinationDto

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

the class TestDataCreator method createVaccination.

public VaccinationDto createVaccination(UserReferenceDto reportingUser, ImmunizationReferenceDto immunization, HealthConditionsDto healthConditions, Date vaccinationDate, Vaccine vaccine, VaccineManufacturer vaccineManufacturer) {
    VaccinationDto vaccination = new VaccinationDto();
    vaccination.setUuid(DataHelper.createUuid());
    vaccination.setReportingUser(reportingUser);
    vaccination.setReportDate(new Date());
    vaccination.setVaccinationDate(new Date());
    vaccination.setVaccineName(vaccine);
    vaccination.setVaccineManufacturer(vaccineManufacturer);
    vaccination.setVaccinationDate(vaccinationDate);
    vaccination.setImmunization(immunization);
    vaccination.setHealthConditions(healthConditions);
    return beanTest.getVaccinationFacade().save(vaccination);
}
Also used : VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) Date(java.util.Date)

Example 25 with VaccinationDto

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

the class VaccinationFacadeEjbTest method testCreate.

@Test
public void testCreate() {
    loginWith(nationalUser);
    PersonDto person1 = creator.createPerson("John", "Doe");
    PersonDto person2 = creator.createPerson("Jane", "Doe");
    Disease disease1 = Disease.CORONAVIRUS;
    Disease disease2 = Disease.CHOLERA;
    // Immunization association case 1 covered
    VaccinationDto vaccination11 = VaccinationDto.build(nationalUser.toReference());
    vaccination11 = getVaccinationFacade().createWithImmunization(vaccination11, rdcf1.region, rdcf1.district, person1.toReference(), disease1);
    ImmunizationReferenceDto immunization11 = vaccination11.getImmunization();
    assertNotNull(immunization11);
    VaccinationDto vaccination12 = VaccinationDto.build(nationalUser.toReference());
    vaccination12 = getVaccinationFacade().createWithImmunization(vaccination12, rdcf1.region, rdcf1.district, person1.toReference(), disease1);
    ImmunizationReferenceDto immunization12 = vaccination12.getImmunization();
    assertEquals(immunization11, immunization12);
    VaccinationDto vaccination13 = VaccinationDto.build(nationalUser.toReference());
    vaccination13 = getVaccinationFacade().createWithImmunization(vaccination13, rdcf1.region, rdcf1.district, person1.toReference(), disease2);
    ImmunizationReferenceDto immunization13 = vaccination13.getImmunization();
    assertNotEquals(immunization11, immunization13);
    VaccinationDto vaccination21 = VaccinationDto.build(nationalUser.toReference());
    vaccination21 = getVaccinationFacade().createWithImmunization(vaccination21, rdcf1.region, rdcf1.district, person2.toReference(), disease1);
    ImmunizationReferenceDto immunization21 = vaccination21.getImmunization();
    assertNotEquals(immunization11, immunization21);
    VaccinationDto vaccination22 = VaccinationDto.build(nationalUser.toReference());
    vaccination22 = getVaccinationFacade().createWithImmunization(vaccination22, rdcf1.region, rdcf1.district, person2.toReference(), disease2);
    ImmunizationReferenceDto immunization22 = vaccination22.getImmunization();
    assertNotEquals(immunization21, immunization22);
    // Test correct association based on dates
    PersonDto person3 = creator.createPerson("James", "Doe");
    Date referenceDate = new Date();
    ImmunizationDto immunizationStartEnd = creator.createImmunization(disease1, person3.toReference(), nationalUser.toReference(), rdcf1, i -> {
        i.setStartDate(DateHelper.subtractDays(referenceDate, 400));
        i.setEndDate(DateHelper.subtractDays(referenceDate, 380));
    });
    ImmunizationDto immunizationStart = creator.createImmunization(disease1, person3.toReference(), nationalUser.toReference(), rdcf1, i -> {
        i.setStartDate(DateHelper.subtractDays(referenceDate, 420));
    });
    creator.createImmunization(disease1, person3.toReference(), nationalUser.toReference(), rdcf1, i -> {
        i.setEndDate(DateHelper.subtractDays(referenceDate, 390));
    });
    ImmunizationDto immunizationReport = creator.createImmunization(disease1, person3.toReference(), nationalUser.toReference(), rdcf1);
    ImmunizationDto immunizationReport2 = creator.createImmunization(disease2, person3.toReference(), nationalUser.toReference(), rdcf1);
    // Immunization association case 2 covered
    VaccinationDto vaccination31 = VaccinationDto.build(nationalUser.toReference());
    vaccination31.setVaccinationDate(DateHelper.subtractDays(referenceDate, 390));
    vaccination31 = getVaccinationFacade().createWithImmunization(vaccination31, rdcf1.region, rdcf1.district, person3.toReference(), disease1);
    assertEquals(vaccination31.getImmunization(), immunizationStartEnd.toReference());
    // Immunization association case 3 covered
    VaccinationDto vaccination32 = VaccinationDto.build(nationalUser.toReference());
    vaccination32.setVaccinationDate(DateHelper.subtractDays(referenceDate, 415));
    vaccination32 = getVaccinationFacade().createWithImmunization(vaccination32, rdcf1.region, rdcf1.district, person3.toReference(), disease1);
    assertEquals(vaccination32.getImmunization(), immunizationStart.toReference());
    // Immunization association case 3 covered
    VaccinationDto vaccination33 = VaccinationDto.build(nationalUser.toReference());
    vaccination33.setVaccinationDate(DateHelper.subtractDays(referenceDate, 0));
    vaccination33 = getVaccinationFacade().createWithImmunization(vaccination33, rdcf1.region, rdcf1.district, person3.toReference(), disease1);
    assertEquals(vaccination33.getImmunization(), immunizationStartEnd.toReference());
    // Immunization association case 4 covered
    VaccinationDto vaccination34 = VaccinationDto.build(nationalUser.toReference());
    vaccination34.setVaccinationDate(DateHelper.subtractDays(referenceDate, 100));
    vaccination34 = getVaccinationFacade().createWithImmunization(vaccination34, rdcf1.region, rdcf1.district, person3.toReference(), disease2);
    assertEquals(vaccination34.getImmunization(), immunizationReport2.toReference());
    // Immunization association case 4 covered
    VaccinationDto vaccination35 = VaccinationDto.build(nationalUser.toReference());
    vaccination35 = getVaccinationFacade().createWithImmunization(vaccination35, rdcf1.region, rdcf1.district, person3.toReference(), disease1);
    assertThat(vaccination35.getImmunization(), anyOf(is(immunizationReport.toReference()), is(immunizationReport2.toReference())));
    // Ignore immunizations with a means of immunization that does not include vaccination
    PersonDto person4 = creator.createPerson("Johanna", "Doe");
    ImmunizationDto recoveryImmunization = creator.createImmunization(disease1, person4.toReference(), nationalUser.toReference(), rdcf1, i -> i.setMeansOfImmunization(MeansOfImmunization.RECOVERY));
    VaccinationDto vaccination41 = VaccinationDto.build(nationalUser.toReference());
    vaccination41 = getVaccinationFacade().createWithImmunization(vaccination41, rdcf1.region, rdcf1.district, person4.toReference(), disease1);
    assertNotEquals(vaccination41.getImmunization(), recoveryImmunization.toReference());
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) Disease(de.symeda.sormas.api.Disease) PersonDto(de.symeda.sormas.api.person.PersonDto) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) ImmunizationReferenceDto(de.symeda.sormas.api.immunization.ImmunizationReferenceDto) Date(java.util.Date) LocalDate(java.time.LocalDate) 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