use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjb method getVisitsByContactAndPeriod.
@Override
public List<VisitDto> getVisitsByContactAndPeriod(ContactReferenceDto contactRef, Date begin, Date end) {
Contact contact = contactService.getByReferenceDto(contactRef);
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
return contact.getVisits().stream().filter(visit -> visit.getVisitDateTime().after(begin) && visit.getVisitDateTime().before(end)).map(visit -> convertToDto(visit, pseudonymizer)).collect(Collectors.toList());
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitFacadeEjb method onVisitChanged.
private void onVisitChanged(VisitDto existingVisit, Visit newVisit) {
updateContactVisitAssociations(existingVisit, newVisit);
updateCaseVisitAssociations(existingVisit, newVisit);
// Send an email to all responsible supervisors when the contact has become
// symptomatic
boolean previousSymptomaticStatus = existingVisit != null && Boolean.TRUE.equals(existingVisit.getSymptoms().getSymptomatic());
if (newVisit.getContacts() != null && previousSymptomaticStatus == false && Boolean.TRUE.equals(newVisit.getSymptoms().getSymptomatic())) {
for (Contact contact : newVisit.getContacts()) {
// Skip if there is already a symptomatic visit for this contact
if (contact.getVisits().stream().filter(v -> !v.equals(newVisit)).filter(v -> Boolean.TRUE.equals(v.getSymptoms().getSymptomatic())).count() > 0) {
continue;
}
Case contactCase = contact.getCaze();
try {
String messageContent;
if (contactCase != null) {
messageContent = String.format(I18nProperties.getString(MessageContents.CONTENT_CONTACT_SYMPTOMATIC), DataHelper.getShortUuid(contact.getUuid()), DataHelper.getShortUuid(contactCase.getUuid()));
} else {
messageContent = String.format(I18nProperties.getString(MessageContents.CONTENT_CONTACT_WITHOUT_CASE_SYMPTOMATIC), DataHelper.getShortUuid(contact.getUuid()));
}
notificationService.sendNotifications(NotificationType.CONTACT_SYMPTOMATIC, JurisdictionHelper.getContactRegions(contact), null, MessageSubject.CONTACT_SYMPTOMATIC, messageContent);
} catch (NotificationDeliveryFailedException e) {
logger.error("EmailDeliveryFailedException when trying to notify supervisors about a contact that has become symptomatic.");
}
}
}
if (newVisit.getContacts() != null) {
for (Contact contact : newVisit.getContacts()) {
contactService.updateFollowUpDetails(contact, false);
}
}
if (newVisit.getCaze() != null) {
// Update case symptoms
CaseDataDto caze = caseFacade.toDto(newVisit.getCaze());
SymptomsDto caseSymptoms = caze.getSymptoms();
SymptomsHelper.updateSymptoms(toDto(newVisit).getSymptoms(), caseSymptoms);
caseFacade.save(caze, true);
}
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitController method createVisit.
private void createVisit(VisitEditForm createForm, Consumer<VisitReferenceDto> doneConsumer) {
final CommitDiscardWrapperComponent<VisitEditForm> editView = new CommitDiscardWrapperComponent<VisitEditForm>(createForm, UserProvider.getCurrent().hasUserRight(UserRight.VISIT_CREATE), createForm.getFieldGroup());
editView.addCommitListener(() -> {
if (!createForm.getFieldGroup().isModified()) {
VisitDto dto = createForm.getValue();
dto = FacadeProvider.getVisitFacade().saveVisit(dto);
if (doneConsumer != null) {
doneConsumer.accept(dto.toReference());
}
}
});
Window window = VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getString(Strings.headingCreateNewVisit));
// visit form is too big for typical screens
window.setWidth(createForm.getWidth() + 64 + 24, Unit.PIXELS);
window.setHeight(80, Unit.PERCENTAGE);
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitController method createNewVisit.
private VisitDto createNewVisit(PersonReferenceDto personRef, Disease disease) {
VisitDto visit = VisitDto.build(personRef, disease, VisitOrigin.USER);
UserReferenceDto userReference = UserProvider.getCurrent().getUserReference();
visit.setVisitUser(userReference);
return visit;
}
use of de.symeda.sormas.api.visit.VisitDto in project SORMAS-Project by hzi-braunschweig.
the class VisitController method createVisit.
public void createVisit(CaseReferenceDto caseRef, Consumer<VisitReferenceDto> doneConsumer) {
VisitDto visit = createNewVisit(caseRef);
CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseRef.getUuid());
PersonDto person = FacadeProvider.getPersonFacade().getPersonByUuid(caze.getPerson().getUuid());
VisitEditForm createForm = new VisitEditForm(visit.getDisease(), caze, person, true, true);
createForm.setValue(visit);
createVisit(createForm, doneConsumer);
}
Aggregations