use of de.symeda.sormas.api.contact.FollowUpStatus in project SORMAS-Project by hzi-braunschweig.
the class CaseDataForm method updateFollowUpStatusComponents.
@SuppressWarnings("unchecked")
private void updateFollowUpStatusComponents() {
if (!caseFollowUpEnabled) {
return;
}
getContent().removeComponent(CANCEL_OR_RESUME_FOLLOW_UP_BTN_LOC);
getContent().removeComponent(LOST_FOLLOW_UP_BTN_LOC);
Field<FollowUpStatus> statusField = (Field<FollowUpStatus>) getField(CaseDataDto.FOLLOW_UP_STATUS);
boolean followUpVisible = getValue() != null && statusField.isVisible();
if (followUpVisible && UserProvider.getCurrent().hasUserRight(UserRight.CASE_EDIT)) {
FollowUpStatus followUpStatus = statusField.getValue();
if (followUpStatus == FollowUpStatus.FOLLOW_UP) {
Button cancelButton = ButtonHelper.createButton(Captions.contactCancelFollowUp, event -> {
Field<FollowUpStatus> statusField1 = (Field<FollowUpStatus>) getField(CaseDataDto.FOLLOW_UP_STATUS);
statusField1.setReadOnly(false);
statusField1.setValue(FollowUpStatus.CANCELED);
statusField1.setReadOnly(true);
updateFollowUpStatusComponents();
});
cancelButton.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(cancelButton, CANCEL_OR_RESUME_FOLLOW_UP_BTN_LOC);
Button lostButton = ButtonHelper.createButton(Captions.contactLostToFollowUp, event -> {
Field<FollowUpStatus> statusField12 = (Field<FollowUpStatus>) getField(CaseDataDto.FOLLOW_UP_STATUS);
statusField12.setReadOnly(false);
statusField12.setValue(FollowUpStatus.LOST);
statusField12.setReadOnly(true);
updateFollowUpStatusComponents();
});
lostButton.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(lostButton, LOST_FOLLOW_UP_BTN_LOC);
} else if (followUpStatus == FollowUpStatus.CANCELED || followUpStatus == FollowUpStatus.LOST) {
Button resumeButton = ButtonHelper.createButton(Captions.contactResumeFollowUp, event -> {
Field<FollowUpStatus> statusField13 = (Field<FollowUpStatus>) getField(CaseDataDto.FOLLOW_UP_STATUS);
statusField13.setReadOnly(false);
statusField13.setValue(FollowUpStatus.FOLLOW_UP);
statusField13.setReadOnly(true);
updateFollowUpStatusComponents();
}, CssStyles.FORCE_CAPTION);
resumeButton.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(resumeButton, CANCEL_OR_RESUME_FOLLOW_UP_BTN_LOC);
}
}
}
use of de.symeda.sormas.api.contact.FollowUpStatus in project SORMAS-Project by hzi-braunschweig.
the class PersonFacadeEjbTest method testGetMostRelevantFollowUpStatusByUuid.
@Test
public void testGetMostRelevantFollowUpStatusByUuid() {
RDCFEntities rdcfEntities = creator.createRDCFEntities();
PersonDto person = creator.createPerson();
UserDto user = creator.createUser(rdcfEntities, UserRole.REST_EXTERNAL_VISITS_USER);
ContactDto contact1 = creator.createContact(user.toReference(), person.toReference());
for (FollowUpStatus status : FollowUpStatus.values()) {
contact1.setFollowUpStatus(status);
getContactFacade().save(contact1);
if (FollowUpStatus.COMPLETED.equals(status) || FollowUpStatus.NO_FOLLOW_UP.equals(status)) {
// In this case the status is automatically updated to FOLLOW_UP, because the end of the follow up period has not yet been reached.
assertThat(getPersonFacade().getMostRelevantFollowUpStatusByUuid(person.getUuid()), is(FollowUpStatus.FOLLOW_UP));
continue;
}
assertThat(getPersonFacade().getMostRelevantFollowUpStatusByUuid(person.getUuid()), is(status));
}
ContactDto contact2 = creator.createContact(user.toReference(), person.toReference());
CaseDataDto case1 = creator.createCase(user.toReference(), person.toReference(), rdcfEntities);
updateFollowUpStatus(contact1, FollowUpStatus.FOLLOW_UP);
for (FollowUpStatus status : FollowUpStatus.values()) {
updateFollowUpStatus(case1, status);
updateFollowUpStatus(contact2, status);
// Other states must not interfere one with ongoing follow up
assertThat(getPersonFacade().getMostRelevantFollowUpStatusByUuid(person.getUuid()), is(FollowUpStatus.FOLLOW_UP));
updateFollowUpStatus(contact1, status);
if (FollowUpStatus.COMPLETED.equals(status) || FollowUpStatus.NO_FOLLOW_UP.equals(status)) {
// In this case the status is automatically updated to FOLLOW_UP, because the end of the follow up period has not yet been reached.
assertThat(getPersonFacade().getMostRelevantFollowUpStatusByUuid(person.getUuid()), is(FollowUpStatus.FOLLOW_UP));
updateFollowUpStatus(contact1, FollowUpStatus.FOLLOW_UP);
continue;
}
// In that case one clear status can be calculated
assertThat(getPersonFacade().getMostRelevantFollowUpStatusByUuid(person.getUuid()), is(status));
updateFollowUpStatus(case1, FollowUpStatus.FOLLOW_UP);
// Also ongoing case follow up must not be overwritten
assertThat(getPersonFacade().getMostRelevantFollowUpStatusByUuid(person.getUuid()), is(FollowUpStatus.FOLLOW_UP));
updateFollowUpStatus(case1, status);
updateFollowUpStatus(contact1, FollowUpStatus.FOLLOW_UP);
}
updateFollowUpStatus(contact1, FollowUpStatus.LOST);
updateFollowUpStatus(contact2, FollowUpStatus.CANCELED);
updateFollowUpStatus(case1, FollowUpStatus.LOST);
assertThat(getPersonFacade().getMostRelevantFollowUpStatusByUuid(person.getUuid()), is(FollowUpStatus.NO_FOLLOW_UP));
}
use of de.symeda.sormas.api.contact.FollowUpStatus in project SORMAS-Project by hzi-braunschweig.
the class FollowUpStatusCurveBuilder method buildEpiCurve.
@Override
public void buildEpiCurve(List<Date> datesGroupedBy, DashboardDataProvider dashboardDataProvider) {
int[] underFollowUpNumbers = new int[datesGroupedBy.size()];
int[] lostToFollowUpNumbers = new int[datesGroupedBy.size()];
int[] completedFollowUpNumbers = new int[datesGroupedBy.size()];
int[] canceledFollowUpNumbers = new int[datesGroupedBy.size()];
int[] convertedNumbers = new int[datesGroupedBy.size()];
for (int i = 0; i < datesGroupedBy.size(); i++) {
Date date = datesGroupedBy.get(i);
ContactCriteria contactCriteria = new ContactCriteria().disease(dashboardDataProvider.getDisease()).region(dashboardDataProvider.getRegion()).district(dashboardDataProvider.getDistrict());
if (epiCurveGrouping == EpiCurveGrouping.DAY) {
contactCriteria.reportDateBetween(DateHelper.getStartOfDay(date), DateHelper.getEndOfDay(date));
} else if (epiCurveGrouping == EpiCurveGrouping.WEEK) {
contactCriteria.reportDateBetween(DateHelper.getStartOfWeek(date), DateHelper.getEndOfWeek(date));
} else {
contactCriteria.reportDateBetween(DateHelper.getStartOfMonth(date), DateHelper.getEndOfMonth(date));
}
Map<FollowUpStatus, Long> contactCounts = FacadeProvider.getContactFacade().getNewContactCountPerFollowUpStatus(contactCriteria);
Map<ContactStatus, Long> contactStatusCounts = FacadeProvider.getContactFacade().getNewContactCountPerStatus(contactCriteria);
Long underFollowUpCount = contactCounts.get(FollowUpStatus.FOLLOW_UP);
Long lostToFollowUpCount = contactCounts.get(FollowUpStatus.LOST);
Long completedFollowUpCount = contactCounts.get(FollowUpStatus.COMPLETED);
Long canceledFollowUpCount = contactCounts.get(FollowUpStatus.CANCELED);
Long convertedCount = contactStatusCounts.get(ContactStatus.CONVERTED);
underFollowUpNumbers[i] = underFollowUpCount != null ? underFollowUpCount.intValue() : 0;
lostToFollowUpNumbers[i] = lostToFollowUpCount != null ? lostToFollowUpCount.intValue() : 0;
completedFollowUpNumbers[i] = completedFollowUpCount != null ? completedFollowUpCount.intValue() : 0;
canceledFollowUpNumbers[i] = canceledFollowUpCount != null ? canceledFollowUpCount.intValue() : 0;
convertedNumbers[i] = convertedCount != null ? convertedCount.intValue() : 0;
}
hcjs.append("series: [");
hcjs.append("{ name: '" + I18nProperties.getCaption(Captions.dashboardUnderFollowUpShort) + "', color: '#005A9C', dataLabels: { allowOverlap: false }, data: [");
for (int i = 0; i < underFollowUpNumbers.length; i++) {
if (i == underFollowUpNumbers.length - 1) {
hcjs.append(underFollowUpNumbers[i] + "]},");
} else {
hcjs.append(underFollowUpNumbers[i] + ", ");
}
}
hcjs.append("{ name: '" + I18nProperties.getCaption(Captions.dashboardLostToFollowUpShort) + "', color: '#FF0000', dataLabels: { allowOverlap: false }, data: [");
for (int i = 0; i < lostToFollowUpNumbers.length; i++) {
if (i == lostToFollowUpNumbers.length - 1) {
hcjs.append(lostToFollowUpNumbers[i] + "]},");
} else {
hcjs.append(lostToFollowUpNumbers[i] + ", ");
}
}
hcjs.append("{ name: '" + I18nProperties.getCaption(Captions.dashboardCompletedFollowUpShort) + "', color: '#32CD32', dataLabels: { allowOverlap: false }, data: [");
for (int i = 0; i < completedFollowUpNumbers.length; i++) {
if (i == completedFollowUpNumbers.length - 1) {
hcjs.append(completedFollowUpNumbers[i] + "]},");
} else {
hcjs.append(completedFollowUpNumbers[i] + ", ");
}
}
hcjs.append("{ name: '" + I18nProperties.getCaption(Captions.dashboardCanceledFollowUpShort) + "', color: '#FF8C00', dataLabels: { allowOverlap: false }, data: [");
for (int i = 0; i < canceledFollowUpNumbers.length; i++) {
if (i == canceledFollowUpNumbers.length - 1) {
hcjs.append(canceledFollowUpNumbers[i] + "]},");
} else {
hcjs.append(canceledFollowUpNumbers[i] + ", ");
}
}
hcjs.append("{ name: '" + I18nProperties.getCaption(Captions.dashboardConvertedToCase) + "', color: '#00BFFF', dataLabels: { allowOverlap: false }, data: [");
for (int i = 0; i < convertedNumbers.length; i++) {
if (i == convertedNumbers.length - 1) {
hcjs.append(convertedNumbers[i] + "]}],");
} else {
hcjs.append(convertedNumbers[i] + ", ");
}
}
}
use of de.symeda.sormas.api.contact.FollowUpStatus in project SORMAS-Project by hzi-braunschweig.
the class ContactDataForm method updateFollowUpStatusComponents.
@SuppressWarnings("unchecked")
private void updateFollowUpStatusComponents() {
getContent().removeComponent(CANCEL_OR_RESUME_FOLLOW_UP_BTN_LOC);
getContent().removeComponent(LOST_FOLLOW_UP_BTN_LOC);
Field<FollowUpStatus> statusField = (Field<FollowUpStatus>) getField(ContactDto.FOLLOW_UP_STATUS);
boolean followUpVisible = getValue() != null && statusField.isVisible();
if (followUpVisible && UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EDIT)) {
FollowUpStatus followUpStatus = statusField.getValue();
tfExpectedFollowUpUntilDate.setVisible(followUpStatus != FollowUpStatus.NO_FOLLOW_UP);
boolean followUpCanceledOrLost = followUpStatus == FollowUpStatus.CANCELED || followUpStatus == FollowUpStatus.LOST;
cbOverwriteFollowUpUntil.setReadOnly(followUpCanceledOrLost);
dfFollowUpUntil.setReadOnly(followUpCanceledOrLost || Boolean.TRUE != cbOverwriteFollowUpUntil.getValue());
if (followUpStatus == FollowUpStatus.FOLLOW_UP) {
Button cancelButton = ButtonHelper.createButton(Captions.contactCancelFollowUp, event -> {
setFollowUpStatus(FollowUpStatus.CANCELED);
});
cancelButton.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(cancelButton, CANCEL_OR_RESUME_FOLLOW_UP_BTN_LOC);
Button lostButton = ButtonHelper.createButton(Captions.contactLostToFollowUp, event -> {
setFollowUpStatus(FollowUpStatus.LOST);
});
lostButton.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(lostButton, LOST_FOLLOW_UP_BTN_LOC);
} else if (followUpStatus == FollowUpStatus.CANCELED || followUpStatus == FollowUpStatus.LOST) {
Button resumeButton = ButtonHelper.createButton(Captions.contactResumeFollowUp, event -> {
setFollowUpStatus(FollowUpStatus.FOLLOW_UP);
}, CssStyles.FORCE_CAPTION);
resumeButton.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(resumeButton, CANCEL_OR_RESUME_FOLLOW_UP_BTN_LOC);
}
}
}
use of de.symeda.sormas.api.contact.FollowUpStatus in project SORMAS-Project by hzi-braunschweig.
the class ContactService method getNewContactCountPerFollowUpStatus.
public Map<FollowUpStatus, Long> getNewContactCountPerFollowUpStatus(ContactCriteria contactCriteria, User user) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
Root<Contact> contact = cq.from(getElementClass());
final ContactQueryContext contactQueryContext = new ContactQueryContext(cb, cq, contact);
Predicate filter = createUserFilter(cb, cq, contact);
Predicate criteriaFilter = buildCriteriaFilter(contactCriteria, contactQueryContext);
Predicate notDeleted = cb.isFalse(contact.get(Contact.DELETED));
if (filter != null) {
filter = cb.and(filter, criteriaFilter, notDeleted);
} else {
filter = cb.and(criteriaFilter, notDeleted);
}
if (filter != null) {
cq.where(filter);
}
cq.groupBy(contact.get(Contact.FOLLOW_UP_STATUS));
cq.multiselect(contact.get(Contact.FOLLOW_UP_STATUS), cb.count(contact));
List<Object[]> results = em.createQuery(cq).getResultList();
return results.stream().collect(Collectors.toMap(e -> (FollowUpStatus) e[0], e -> (Long) e[1]));
}
Aggregations