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());
}
}
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;
}
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;
}
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()));
}
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));
}
Aggregations