use of de.symeda.sormas.api.vaccination.VaccinationDto in project SORMAS-Project by hzi-braunschweig.
the class VaccinationFacadeEjb method save.
public VaccinationDto save(@Valid VaccinationDto dto) {
Vaccination existingVaccination = dto.getUuid() != null ? vaccinationService.getByUuid(dto.getUuid()) : null;
VaccinationDto existingDto = toDto(existingVaccination);
Date oldVaccinationDate = existingVaccination != null ? existingVaccination.getVaccinationDate() : null;
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
restorePseudonymizedDto(dto, existingDto, existingVaccination, pseudonymizer);
validate(dto, false);
existingVaccination = fillOrBuildEntity(dto, existingVaccination, true);
vaccinationService.ensurePersisted(existingVaccination);
updateVaccinationStatuses(existingVaccination.getVaccinationDate(), oldVaccinationDate, existingVaccination.getImmunization().getPerson().getId(), existingVaccination.getImmunization().getDisease());
return convertToDto(existingVaccination, pseudonymizer);
}
use of de.symeda.sormas.api.vaccination.VaccinationDto in project SORMAS-Project by hzi-braunschweig.
the class VaccinationFacadeEjb method toDto.
public VaccinationDto toDto(Vaccination entity) {
if (entity == null) {
return null;
}
VaccinationDto dto = new VaccinationDto();
DtoHelper.fillDto(dto, entity);
dto.setImmunization(ImmunizationFacadeEjb.toReferenceDto(entity.getImmunization()));
dto.setHealthConditions(healthConditionsMapper.toDto(entity.getHealthConditions()));
dto.setReportDate(entity.getReportDate());
dto.setReportingUser(UserFacadeEjb.toReferenceDto(entity.getReportingUser()));
dto.setVaccinationDate(entity.getVaccinationDate());
dto.setVaccineName(entity.getVaccineName());
dto.setOtherVaccineName(entity.getOtherVaccineName());
dto.setVaccineManufacturer(entity.getVaccineManufacturer());
dto.setOtherVaccineManufacturer(entity.getOtherVaccineManufacturer());
dto.setVaccineType(entity.getVaccineType());
dto.setVaccineDose(entity.getVaccineDose());
dto.setVaccineInn(entity.getVaccineInn());
dto.setVaccineBatchNumber(entity.getVaccineBatchNumber());
dto.setVaccineUniiCode(entity.getVaccineUniiCode());
dto.setVaccineAtcCode(entity.getVaccineAtcCode());
dto.setVaccinationInfoSource(entity.getVaccinationInfoSource());
dto.setPregnant(entity.getPregnant());
dto.setTrimester(entity.getTrimester());
return dto;
}
use of de.symeda.sormas.api.vaccination.VaccinationDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testGetExportList.
@Test
public void testGetExportList() {
TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = useSurveillanceOfficerLogin(rdcf);
PersonDto cazePerson = creator.createPerson("Case", "Person");
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
ContactDto contact = creator.createContact(user.toReference(), user.toReference(), creator.createPerson("Contact", "Person").toReference(), caze, new Date(), new Date(), null, rdcf);
PersonDto contactPerson = getPersonFacade().getPersonByUuid(contact.getPerson().getUuid());
VisitDto visit = creator.createVisit(caze.getDisease(), contactPerson.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
EpiDataDto epiData = contact.getEpiData();
epiData.setExposureDetailsKnown(YesNoUnknown.YES);
List<ExposureDto> travels = new ArrayList<>();
ExposureDto exposure = ExposureDto.build(ExposureType.TRAVEL);
exposure.getLocation().setDetails("Mallorca");
exposure.setStartDate(DateHelper.subtractDays(new Date(), 15));
exposure.setEndDate(DateHelper.subtractDays(new Date(), 7));
caze.getEpiData().getExposures().add(exposure);
travels.add(exposure);
epiData.setExposures(travels);
contact.setEpiData(epiData);
getContactFacade().save(contact);
contactPerson.getAddress().setRegion(new RegionReferenceDto(rdcf.region.getUuid(), null, null));
contactPerson.getAddress().setDistrict(new DistrictReferenceDto(rdcf.district.getUuid(), null, null));
contactPerson.getAddress().setCity("City");
contactPerson.getAddress().setStreet("Test street");
contactPerson.getAddress().setHouseNumber("Test number");
contactPerson.getAddress().setAdditionalInformation("Test information");
contactPerson.getAddress().setPostalCode("1234");
getPersonFacade().savePerson(contactPerson);
visit.getSymptoms().setAbdominalPain(SymptomState.YES);
getVisitFacade().saveVisit(visit);
ImmunizationDto immunization = creator.createImmunization(contact.getDisease(), contact.getPerson(), contact.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(contact.getDisease(), contact.getPerson(), contact.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 8), DateHelper.subtractDays(new Date(), 7), null, null);
VaccinationDto firstVaccination = creator.createVaccination(contact.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 7), Vaccine.OXFORD_ASTRA_ZENECA, VaccineManufacturer.ASTRA_ZENECA);
creator.createVaccination(contact.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 4), Vaccine.MRNA_1273, VaccineManufacturer.MODERNA);
VaccinationDto thirdVaccination = creator.createVaccination(contact.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), new Date(), Vaccine.COMIRNATY, VaccineManufacturer.BIONTECH_PFIZER);
List<ContactExportDto> results;
results = getContactFacade().getExportList(null, Collections.emptySet(), 0, 100, null, Language.EN);
// Database should contain one contact, associated visit and task
assertEquals(1, results.size());
// Make sure that everything that is added retrospectively (address, last cooperative visit date and symptoms) is present
ContactExportDto exportDto = results.get(0);
assertEquals(rdcf.region.getCaption(), exportDto.getAddressRegion());
assertEquals(rdcf.district.getCaption(), exportDto.getAddressDistrict());
assertEquals("City", exportDto.getCity());
assertEquals("Test street", exportDto.getStreet());
assertEquals("Test number", exportDto.getHouseNumber());
assertEquals("Test information", exportDto.getAdditionalInformation());
assertEquals("1234", exportDto.getPostalCode());
assertEquals(VaccinationStatus.VACCINATED, exportDto.getVaccinationStatus());
assertEquals(thirdVaccination.getVaccineName(), exportDto.getVaccineName());
assertEquals(firstVaccination.getVaccinationDate(), exportDto.getFirstVaccinationDate());
assertEquals(thirdVaccination.getVaccinationDate(), exportDto.getLastVaccinationDate());
assertNotNull(exportDto.getLastCooperativeVisitDate());
assertTrue(StringUtils.isNotEmpty(exportDto.getLastCooperativeVisitSymptoms()));
assertEquals(YesNoUnknown.YES, exportDto.getLastCooperativeVisitSymptomatic());
assertNotNull(exportDto.getEpiDataId());
assertTrue(exportDto.isTraveled());
assertEquals(EpiDataHelper.buildDetailedTravelString(exposure.getLocation().toString(), exposure.getDescription(), exposure.getStartDate(), exposure.getEndDate(), Language.EN), exportDto.getTravelHistory());
assertThat(exportDto.getEventCount(), equalTo(0L));
// one Contact with 2 Events
UserReferenceDto reportingUser = new UserReferenceDto(user.getUuid());
EventDto event1 = creator.createEvent(reportingUser, DateHelper.subtractDays(new Date(), 1));
EventDto event2 = creator.createEvent(reportingUser, new Date());
creator.createEventParticipant(new EventReferenceDto(event2.getUuid()), contactPerson, reportingUser);
creator.createEventParticipant(new EventReferenceDto(event1.getUuid()), contactPerson, reportingUser);
results = getContactFacade().getExportList(null, Collections.emptySet(), 0, 100, null, Language.EN);
assertThat(results, hasSize(1));
{
ContactExportDto dto = results.get(0);
assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
assertThat(dto.getEventCount(), equalTo(2L));
}
}
use of de.symeda.sormas.api.vaccination.VaccinationDto in project SORMAS-Project by hzi-braunschweig.
the class CaseImportFacadeEjb method buildEntities.
private ImportLineResultDto<CaseImportEntities> buildEntities(String[] values, String[] entityClasses, String[][] entityPropertyPaths, boolean ignoreEmptyEntries, CaseImportEntities entities) {
final UserReferenceDto currentUserRef = userService.getCurrentUser().toReference();
final List<SampleDto> samples = entities.getSamples();
final List<PathogenTestDto> pathogenTests = entities.getPathogenTests();
final List<VaccinationDto> vaccinations = entities.getVaccinations();
ImportRelatedObjectsMapper.Builder relatedObjectsMapperBuilder = new ImportRelatedObjectsMapper.Builder().addMapper(SampleDto.class, samples, () -> SampleDto.build(currentUserRef, new CaseReferenceDto(entities.getCaze().getUuid())), this::insertColumnEntryIntoRelatedObject).addMapper(PathogenTestDto.class, pathogenTests, () -> {
if (samples.isEmpty()) {
return null;
}
SampleDto referenceSample = samples.get(samples.size() - 1);
return PathogenTestDto.build(new SampleReferenceDto(referenceSample.getUuid()), currentUserRef);
}, this::insertColumnEntryIntoRelatedObject);
if (featureConfigurationFacade.isPropertyValueTrue(FeatureType.IMMUNIZATION_MANAGEMENT, FeatureTypeProperty.REDUCED)) {
relatedObjectsMapperBuilder.addMapper(VaccinationDto.class, vaccinations, () -> VaccinationDto.build(currentUserRef), this::insertColumnEntryIntoRelatedObject);
}
ImportRelatedObjectsMapper relatedMapper = relatedObjectsMapperBuilder.build();
final ImportLineResultDto<CaseImportEntities> result = insertRowIntoData(values, entityClasses, entityPropertyPaths, ignoreEmptyEntries, (cellData) -> {
try {
CaseDataDto caze = entities.getCaze();
if (!relatedMapper.map(cellData)) {
if (StringUtils.isNotEmpty(cellData.getValue())) {
// If the cell entry is not empty, try to insert it into the current case or its person
insertColumnEntryIntoData(caze, entities.getPerson(), cellData.getValue(), cellData.getEntityPropertyPath());
}
}
} catch (ImportErrorException | InvalidColumnException e) {
return e;
}
return null;
});
// Sanitize non-HOME address
PersonHelper.sanitizeNonHomeAddress(entities.getPerson());
return result;
}
use of de.symeda.sormas.api.vaccination.VaccinationDto in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationFacadeEjb method save.
public ImmunizationDto save(@Valid @NotNull ImmunizationDto dto, boolean checkChangeDate, boolean internal) {
Immunization existingImmunization = service.getByUuid(dto.getUuid());
if (internal && existingImmunization != null && !service.isImmunizationEditAllowed(existingImmunization)) {
throw new AccessDeniedException(I18nProperties.getString(Strings.errorImmunizationNotEditable));
}
ImmunizationDto existingDto = toDto(existingImmunization);
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
restorePseudonymizedDto(dto, existingDto, existingImmunization, pseudonymizer);
validate(dto);
Immunization immunization = fillOrBuildEntity(dto, existingImmunization, checkChangeDate);
service.updateImmunizationStatusBasedOnVaccinations(immunization);
immunization.getVaccinations().forEach(vaccination -> {
VaccinationDto existingVaccination = null;
if (existingDto != null) {
existingVaccination = existingDto.getVaccinations().stream().filter(vaccinationDto -> vaccination.getUuid().equals(vaccinationDto.getUuid())).findAny().orElse(null);
}
Date oldVaccinationDate = existingVaccination != null ? existingVaccination.getVaccinationDate() : null;
vaccinationFacade.updateVaccinationStatuses(vaccination.getVaccinationDate(), oldVaccinationDate, immunization.getPersonId(), immunization.getDisease());
});
service.ensurePersisted(immunization);
if (existingImmunization != null && internal && sormasToSormasFacade.isFeatureConfigured()) {
syncSharesAsync(existingImmunization);
}
return convertToDto(immunization, pseudonymizer);
}
Aggregations