use of de.symeda.sormas.api.person.PersonDto in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationController method getImmunizationViewTitleLayout.
public TitleLayout getImmunizationViewTitleLayout(String uuid) {
ImmunizationDto immunizationDto = findImmunization(uuid);
TitleLayout titleLayout = new TitleLayout();
String shortUuid = DataHelper.getShortUuid(immunizationDto.getUuid());
PersonDto person = FacadeProvider.getPersonFacade().getPersonByUuid(immunizationDto.getPerson().getUuid());
StringBuilder mainRowText = TitleLayoutHelper.buildPersonString(person);
mainRowText.append(mainRowText.length() > 0 ? " (" + shortUuid + ")" : shortUuid);
titleLayout.addMainRow(mainRowText.toString());
return titleLayout;
}
use of de.symeda.sormas.api.person.PersonDto in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationCreationForm method getPerson.
public PersonDto getPerson() {
PersonDto person = PersonDto.build();
person.setFirstName((String) getField(PersonDto.FIRST_NAME).getValue());
person.setLastName((String) getField(PersonDto.LAST_NAME).getValue());
person.setBirthdateDD((Integer) getField(PersonDto.BIRTH_DATE_DD).getValue());
person.setBirthdateMM((Integer) getField(PersonDto.BIRTH_DATE_MM).getValue());
person.setBirthdateYYYY((Integer) getField(PersonDto.BIRTH_DATE_YYYY).getValue());
person.setSex((Sex) getField(PersonDto.SEX).getValue());
person.setPresentCondition((PresentCondition) getField(PersonDto.PRESENT_CONDITION).getValue());
String phone = (String) getField(PersonDto.PHONE).getValue();
if (StringUtils.isNotEmpty(phone)) {
person.setPhone(phone);
}
String emailAddress = (String) getField(PersonDto.EMAIL_ADDRESS).getValue();
if (StringUtils.isNotEmpty(emailAddress)) {
person.setEmailAddress(emailAddress);
}
person.setNationalHealthId((String) getField(PersonDto.NATIONAL_HEALTH_ID).getValue());
person.setPassportNumber((String) getField(PersonDto.PASSPORT_NUMBER).getValue());
return person;
}
use of de.symeda.sormas.api.person.PersonDto in project SORMAS-Project by hzi-braunschweig.
the class EntityDtoAccessHelperTest method setup.
@Before
public void setup() {
caseDataDto = new CaseDataDto();
caseDataDto.setDisease(Disease.DENGUE);
caseDataDto.setUuid("ABCDEF");
hospitalizationDto = new HospitalizationDto();
hospitalizationDto.setDischargeDate(new Date(1600387200000L));
hospitalizationDto.setIsolated(YesNoUnknown.NO);
personReferenceDto = new PersonReferenceDto();
personReferenceDto.setUuid("GHIJKL");
personDto = new PersonDto();
personDto.setUuid("GHIJKL");
personDto.setFirstName("Tenzing");
personDto.setLastName("Mike");
personDto.setBirthdateDD(26);
personDto.setBirthdateMM(11);
personDto.setBirthdateYYYY(1973);
personDto.setPhone("+49 681 1234");
LocationDto address = new LocationDto();
address.setStreet("Elm Street");
personDto.setAddress(address);
referenceDtoResolver = new IReferenceDtoResolver() {
@Override
public EntityDto resolve(ReferenceDto referenceDto) {
if (referenceDto != null && "GHIJKL".equals(referenceDto.getUuid())) {
return personDto;
}
return null;
}
};
}
use of de.symeda.sormas.api.person.PersonDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjb method mergeCase.
private void mergeCase(CaseDataDto leadCaseData, CaseDataDto otherCaseData, boolean cloning) {
// 1 Merge Dtos
// 1.1 Case
copyDtoValues(leadCaseData, otherCaseData, cloning);
save(leadCaseData, !cloning, true, true, false);
// 1.2 Person - Only merge when the persons have different UUIDs
if (!cloning && !DataHelper.equal(leadCaseData.getPerson().getUuid(), otherCaseData.getPerson().getUuid())) {
PersonDto leadPerson = personFacade.getPersonByUuid(leadCaseData.getPerson().getUuid());
PersonDto otherPerson = personFacade.getPersonByUuid(otherCaseData.getPerson().getUuid());
personFacade.mergePerson(leadPerson, otherPerson);
} else {
assert (DataHelper.equal(leadCaseData.getPerson().getUuid(), otherCaseData.getPerson().getUuid()));
}
// 2 Change CaseReference
Case leadCase = service.getByUuid(leadCaseData.getUuid());
Case otherCase = service.getByUuid(otherCaseData.getUuid());
// 2.1 Contacts
List<Contact> contacts = contactService.findBy(new ContactCriteria().caze(otherCase.toReference()), null);
for (Contact contact : contacts) {
if (cloning) {
ContactDto newContact = ContactDto.build(leadCase.toReference(), leadCase.getDisease(), leadCase.getDiseaseDetails(), leadCase.getDiseaseVariant());
newContact.setPerson(new PersonReferenceDto(contact.getPerson().getUuid()));
DtoHelper.copyDtoValues(newContact, contactFacade.toDto(contact), cloning);
contactFacade.save(newContact, false, false);
} else {
// simply move existing entities to the merge target
contact.setCaze(leadCase);
contactService.ensurePersisted(contact);
}
}
// 2.2 Samples
List<Sample> samples = sampleService.findBy(new SampleCriteria().caze(otherCase.toReference()), null);
for (Sample sample : samples) {
if (cloning) {
SampleDto newSample = SampleDto.build(sample.getReportingUser().toReference(), leadCase.toReference());
DtoHelper.copyDtoValues(newSample, SampleFacadeEjb.toDto(sample), cloning);
sampleFacade.saveSample(newSample, false, true, true);
// 2.2.1 Pathogen Tests
for (PathogenTest pathogenTest : sample.getPathogenTests()) {
PathogenTestDto newPathogenTest = PathogenTestDto.build(newSample.toReference(), pathogenTest.getLabUser().toReference());
DtoHelper.copyDtoValues(newPathogenTest, PathogenTestFacadeEjbLocal.toDto(pathogenTest), cloning);
sampleTestFacade.savePathogenTest(newPathogenTest);
}
for (AdditionalTest additionalTest : sample.getAdditionalTests()) {
AdditionalTestDto newAdditionalTest = AdditionalTestDto.build(newSample.toReference());
DtoHelper.copyDtoValues(newAdditionalTest, AdditionalTestFacadeEjbLocal.toDto(additionalTest), cloning);
additionalTestFacade.saveAdditionalTest(newAdditionalTest);
}
} else {
// simply move existing entities to the merge target
sample.setAssociatedCase(leadCase);
sampleService.ensurePersisted(sample);
}
}
// 2.3 Tasks
if (!cloning) {
// simply move existing entities to the merge target
List<Task> tasks = taskService.findBy(new TaskCriteria().caze(new CaseReferenceDto(otherCase.getUuid())), true);
for (Task task : tasks) {
task.setCaze(leadCase);
taskService.ensurePersisted(task);
}
}
// 3 Change Therapy Reference
// 3.1 Treatments
List<Treatment> treatments = treatmentService.findBy(new TreatmentCriteria().therapy(new TherapyReferenceDto(otherCase.getTherapy().getUuid())));
TherapyReferenceDto leadCaseTherapyReference = new TherapyReferenceDto(leadCase.getTherapy().getUuid());
for (Treatment treatment : treatments) {
if (cloning) {
TreatmentDto newTreatment = TreatmentDto.build(leadCaseTherapyReference);
DtoHelper.copyDtoValues(newTreatment, TreatmentFacadeEjb.toDto(treatment), cloning);
treatmentFacade.saveTreatment(newTreatment);
} else {
// simply move existing entities to the merge target
treatment.setTherapy(leadCase.getTherapy());
treatmentService.ensurePersisted(treatment);
}
}
// 3.2 Prescriptions
List<Prescription> prescriptions = prescriptionService.findBy(new PrescriptionCriteria().therapy(new TherapyReferenceDto(otherCase.getTherapy().getUuid())));
for (Prescription prescription : prescriptions) {
if (cloning) {
PrescriptionDto newPrescription = PrescriptionDto.buildPrescription(leadCaseTherapyReference);
DtoHelper.copyDtoValues(newPrescription, PrescriptionFacadeEjb.toDto(prescription), cloning);
prescriptionFacade.savePrescription(newPrescription);
} else {
// simply move existing entities to the merge target
prescription.setTherapy(leadCase.getTherapy());
prescriptionService.ensurePersisted(prescription);
}
}
// 4 Change Clinical Course Reference
// 4.1 Clinical Visits
List<ClinicalVisit> clinicalVisits = clinicalVisitService.findBy(new ClinicalVisitCriteria().clinicalCourse(new ClinicalCourseReferenceDto(otherCase.getClinicalCourse().getUuid())));
for (ClinicalVisit clinicalVisit : clinicalVisits) {
if (cloning) {
ClinicalVisitDto newClinicalVisit = ClinicalVisitDto.build(leadCaseData.getClinicalCourse().toReference(), leadCase.getDisease());
DtoHelper.copyDtoValues(newClinicalVisit, ClinicalVisitFacadeEjb.toDto(clinicalVisit), cloning);
clinicalVisitFacade.saveClinicalVisit(newClinicalVisit, leadCase.getUuid(), false);
} else {
// simply move existing entities to the merge target
clinicalVisit.setClinicalCourse(leadCase.getClinicalCourse());
clinicalVisitService.ensurePersisted(clinicalVisit);
}
}
// (set the person and the disease of the visit, saveVisit does the rest)
for (VisitDto otherVisit : otherCase.getVisits().stream().map(VisitFacadeEjb::toDto).collect(Collectors.toList())) {
otherVisit.setPerson(leadCaseData.getPerson());
otherVisit.setDisease(leadCaseData.getDisease());
visitFacade.saveVisit(otherVisit);
}
// 6 Documents
List<Document> documents = documentService.getRelatedToEntity(DocumentRelatedEntityType.CASE, otherCase.getUuid());
for (Document document : documents) {
document.setRelatedEntityUuid(leadCaseData.getUuid());
documentService.ensurePersisted(document);
}
// 7 Persist Event links through eventparticipants
Set<EventParticipant> eventParticipants = otherCase.getEventParticipants();
for (EventParticipant eventParticipant : eventParticipants) {
eventParticipant.setResultingCase(leadCase);
eventParticipantService.ensurePersisted(eventParticipant);
}
otherCase.getEventParticipants().clear();
// 8 Exposures - Make sure there are no two probable infection environments
// if there are more than 2 exposures marked as probable infection environment, find the one that originates from the otherCase and set it to false
// the one originating from the otherCase should always be found at the higher index
List<Exposure> probableExposuresList = leadCase.getEpiData().getExposures().stream().filter(Exposure::isProbableInfectionEnvironment).collect(Collectors.toList());
while (probableExposuresList.size() >= 2) {
// should never be > 2, but still make sure to set all but one exposures to false
probableExposuresList.get(probableExposuresList.size() - 1).setProbableInfectionEnvironment(false);
exposureService.ensurePersisted(probableExposuresList.get(probableExposuresList.size() - 1));
probableExposuresList.remove(probableExposuresList.size() - 1);
}
// 9 Reports
List<SurveillanceReport> surveillanceReports = surveillanceReportService.getByCaseUuids(Collections.singletonList(otherCase.getUuid()));
surveillanceReports.forEach(surveillanceReport -> {
SurveillanceReportDto surveillanceReportDto = SurveillanceReportFacadeEjb.toDto(surveillanceReport);
surveillanceReportDto.setCaze(leadCase.toReference());
surveillanceReportFacade.saveSurveillanceReport(surveillanceReportDto);
});
// 10 Activity as case
final EpiData otherEpiData = otherCase.getEpiData();
if (otherEpiData != null && YesNoUnknown.YES == otherEpiData.getActivityAsCaseDetailsKnown() && CollectionUtils.isNotEmpty(otherEpiData.getActivitiesAsCase())) {
final EpiData leadEpiData = leadCase.getEpiData();
leadEpiData.setActivityAsCaseDetailsKnown(YesNoUnknown.YES);
epiDataService.ensurePersisted(leadEpiData);
}
// Travel entries reference
List<TravelEntry> travelEntries = travelEntryService.getAllByResultingCase(otherCase);
travelEntries.forEach(t -> {
t.setResultingCase(leadCase);
travelEntryService.ensurePersisted(t);
});
}
use of de.symeda.sormas.api.person.PersonDto 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());
}
}
Aggregations