use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitController method editVisit.
public void editVisit(String visitUuid, ContactReferenceDto contactRef, CaseReferenceDto caseRef, Consumer<VisitReferenceDto> doneConsumer) {
VisitDto visit = FacadeProvider.getVisitFacade().getVisitByUuid(visitUuid);
VisitEditForm editForm;
if (contactRef != null) {
ContactDto contact = FacadeProvider.getContactFacade().getByUuid(contactRef.getUuid());
PersonDto visitPerson = FacadeProvider.getPersonFacade().getPersonByUuid(visit.getPerson().getUuid());
editForm = new VisitEditForm(visit.getDisease(), contact, visitPerson, false, !contact.isPseudonymized());
} else if (caseRef != null) {
CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseRef.getUuid());
PersonDto visitPerson = FacadeProvider.getPersonFacade().getPersonByUuid(visit.getPerson().getUuid());
editForm = new VisitEditForm(visit.getDisease(), caze, visitPerson, false, !caze.isPseudonymized());
} else {
throw new IllegalArgumentException("Cannot edit a visit without contact nor case");
}
editForm.setValue(visit);
boolean canEdit = VisitOrigin.USER.equals(visit.getOrigin());
editVisit(editForm, visit.toReference(), doneConsumer, canEdit);
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class TestDataCreator method createVisit.
public VisitDto createVisit(Disease disease, PersonReferenceDto contactPerson, Date visitDateTime, VisitStatus visitStatus) {
VisitDto visit = VisitDto.build(contactPerson, disease, VisitOrigin.USER);
visit.setVisitDateTime(visitDateTime);
visit.setVisitStatus(visitStatus);
visit = FacadeProvider.getVisitFacade().saveVisit(visit);
return visit;
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjb method convertToDto.
public VisitDto convertToDto(Visit source, Pseudonymizer pseudonymizer) {
VisitDto visitDto = toDto(source);
pseudonymizeDto(source, visitDto, pseudonymizer);
return visitDto;
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjb method saveExternalVisit.
@Override
public ExternalVisitDto saveExternalVisit(@Valid final ExternalVisitDto dto) {
final String personUuid = dto.getPersonUuid();
final UserReferenceDto currentUser = new UserReferenceDto(userService.getCurrentUser().getUuid());
final VisitDto visitDto = VisitDto.build(new PersonReferenceDto(personUuid), dto.getDisease(), dto.getVisitDateTime(), currentUser, dto.getVisitStatus(), dto.getVisitRemarks(), dto.getSymptoms(), dto.getReportLat(), dto.getReportLon(), dto.getReportLatLonAccuracy(), VisitOrigin.EXTERNAL_JOURNAL);
saveVisit(visitDto);
return ExternalVisitDto.build(personUuid, visitDto.getDisease(), visitDto.getVisitDateTime(), visitDto.getVisitStatus(), visitDto.getVisitRemarks(), visitDto.getSymptoms(), visitDto.getReportLat(), visitDto.getReportLon(), visitDto.getReportLatLonAccuracy());
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testContactDeletion.
@Test
public void testContactDeletion() {
Date since = new Date();
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
UserDto admin = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Another", "Admin", UserRole.ADMIN);
String adminUuid = admin.getUuid();
PersonDto cazePerson = creator.createPerson("Case", "Person");
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
PersonDto contactPerson = creator.createPerson("Contact", "Person");
ContactDto contact = creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
VisitDto visit = creator.createVisit(caze.getDisease(), contactPerson.toReference(), DateUtils.addDays(new Date(), 21), VisitStatus.UNAVAILABLE, VisitOrigin.USER);
TaskDto task = creator.createTask(TaskContext.CONTACT, TaskType.CONTACT_INVESTIGATION, TaskStatus.PENDING, null, contact.toReference(), null, new Date(), user.toReference());
SampleDto sample = creator.createSample(contact.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
SampleDto sample2 = creator.createSample(contact.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
sample2.setAssociatedCase(new CaseReferenceDto(caze.getUuid()));
getSampleFacade().saveSample(sample2);
// Database should contain the created contact, visit and task
assertNotNull(getContactFacade().getByUuid(contact.getUuid()));
assertNotNull(getTaskFacade().getByUuid(task.getUuid()));
assertNotNull(getVisitFacade().getVisitByUuid(visit.getUuid()));
assertNotNull(getSampleFacade().getSampleByUuid(sample.getUuid()));
getContactFacade().deleteContact(contact.getUuid());
// Deleted flag should be set for contact; Task should be deleted
assertTrue(getContactFacade().getDeletedUuidsSince(since).contains(contact.getUuid()));
// Can't delete visit because it might be associated with other contacts as well
// assertNull(getVisitFacade().getVisitByUuid(visit.getUuid()));
assertNull(getTaskFacade().getByUuid(task.getUuid()));
assertTrue(getSampleFacade().getDeletedUuidsSince(since).contains(sample.getUuid()));
assertFalse(getSampleFacade().getDeletedUuidsSince(since).contains(sample2.getUuid()));
}
Aggregations