Search in sources :

Example 1 with FollowUpStatus

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);
        }
    }
}
Also used : ThemeResource(com.vaadin.server.ThemeResource) FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) Arrays(java.util.Arrays) ConversionException(com.vaadin.v7.data.util.converter.Converter.ConversionException) ValidationUtils(de.symeda.sormas.ui.utils.ValidationUtils) ReinfectionDetailGroup(de.symeda.sormas.api.caze.ReinfectionDetailGroup) AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) InfrastructureFieldsHelper(de.symeda.sormas.ui.utils.InfrastructureFieldsHelper) StringUtils(org.apache.commons.lang3.StringUtils) PersonDto(de.symeda.sormas.api.person.PersonDto) EntityDto(de.symeda.sormas.api.EntityDto) CaseOutcome(de.symeda.sormas.api.caze.CaseOutcome) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) CssStyles(de.symeda.sormas.ui.utils.CssStyles) Map(java.util.Map) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) QuarantineReason(de.symeda.sormas.api.caze.QuarantineReason) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) ValoTheme(com.vaadin.ui.themes.ValoTheme) Property(com.vaadin.v7.data.Property) EnumMap(java.util.EnumMap) Field(com.vaadin.v7.ui.Field) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) CaseLogic(de.symeda.sormas.api.caze.CaseLogic) TextField(com.vaadin.v7.ui.TextField) Descriptions(de.symeda.sormas.api.i18n.Descriptions) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) FollowUpPeriodDto(de.symeda.sormas.api.followup.FollowUpPeriodDto) LABEL_WHITE_SPACE_NORMAL(de.symeda.sormas.ui.utils.CssStyles.LABEL_WHITE_SPACE_NORMAL) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) OutbreakFieldVisibilityChecker(de.symeda.sormas.ui.utils.OutbreakFieldVisibilityChecker) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) OptionGroup(com.vaadin.v7.ui.OptionGroup) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) Image(com.vaadin.ui.Image) LayoutUtil.locCss(de.symeda.sormas.ui.utils.LayoutUtil.locCss) CountryHelper(de.symeda.sormas.api.CountryHelper) ERROR_COLOR_PRIMARY(de.symeda.sormas.ui.utils.CssStyles.ERROR_COLOR_PRIMARY) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) ContentMode(com.vaadin.shared.ui.ContentMode) CssStyles.style(de.symeda.sormas.ui.utils.CssStyles.style) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) Captions(de.symeda.sormas.api.i18n.Captions) ExtendedReduced(de.symeda.sormas.api.utils.ExtendedReduced) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) Button(com.vaadin.ui.Button) Disease(de.symeda.sormas.api.Disease) EndOfIsolationReason(de.symeda.sormas.api.caze.EndOfIsolationReason) TextArea(com.vaadin.v7.ui.TextArea) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) StringToAngularLocationConverter(de.symeda.sormas.ui.utils.StringToAngularLocationConverter) FollowUpLogic(de.symeda.sormas.api.followup.FollowUpLogic) CaseConfirmationBasis(de.symeda.sormas.api.caze.CaseConfirmationBasis) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) DiseaseClassificationCriteriaDto(de.symeda.sormas.api.caze.classification.DiseaseClassificationCriteriaDto) FeatureType(de.symeda.sormas.api.feature.FeatureType) HealthConditionsForm(de.symeda.sormas.ui.clinicalcourse.HealthConditionsForm) CheckBoxTree(de.symeda.sormas.ui.utils.CheckBoxTree) LAYOUT_COL_HIDE_INVSIBLE(de.symeda.sormas.ui.utils.CssStyles.LAYOUT_COL_HIDE_INVSIBLE) LayoutUtil.inlineLocs(de.symeda.sormas.ui.utils.LayoutUtil.inlineLocs) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Date(java.util.Date) CheckBox(com.vaadin.v7.ui.CheckBox) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) CountryFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.CountryFieldVisibilityChecker) Window(com.vaadin.ui.Window) LayoutUtil.locs(de.symeda.sormas.ui.utils.LayoutUtil.locs) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) VaadinIcons(com.vaadin.icons.VaadinIcons) UserRole(de.symeda.sormas.api.user.UserRole) GridLayout(com.vaadin.ui.GridLayout) FORCE_CAPTION(de.symeda.sormas.ui.utils.CssStyles.FORCE_CAPTION) UserProvider(de.symeda.sormas.ui.UserProvider) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) ConfirmationComponent(de.symeda.sormas.ui.utils.ConfirmationComponent) CloseListener(com.vaadin.ui.Window.CloseListener) ViewMode(de.symeda.sormas.ui.utils.ViewMode) ComboBox(com.vaadin.v7.ui.ComboBox) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) Collectors(java.util.stream.Collectors) TypeOfPlace(de.symeda.sormas.api.event.TypeOfPlace) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) List(java.util.List) LayoutUtil.fluidColumnLoc(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc) ContactDto(de.symeda.sormas.api.contact.ContactDto) CaseIdentificationSource(de.symeda.sormas.api.caze.CaseIdentificationSource) UserError(com.vaadin.server.UserError) AbstractSelect(com.vaadin.v7.ui.AbstractSelect) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) LayoutUtil.fluidRowLocsCss(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocsCss) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) HospitalWardType(de.symeda.sormas.api.caze.HospitalWardType) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateHelper(de.symeda.sormas.api.utils.DateHelper) ErrorLevel(com.vaadin.shared.ui.ErrorLevel) ReinfectionDetail(de.symeda.sormas.api.caze.ReinfectionDetail) QuarantineType(de.symeda.sormas.api.contact.QuarantineType) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) CollectionUtils(org.apache.commons.collections.CollectionUtils) Resolution(com.vaadin.v7.shared.ui.datefield.Resolution) PreviousCaseDto(de.symeda.sormas.api.caze.PreviousCaseDto) Label(com.vaadin.ui.Label) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) DateField(com.vaadin.v7.ui.DateField) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) Validations(de.symeda.sormas.api.i18n.Validations) CaseReinfectionCheckBoxTree(de.symeda.sormas.ui.caze.surveillancereport.CaseReinfectionCheckBoxTree) ErrorMessage(com.vaadin.server.ErrorMessage) SOFT_REQUIRED(de.symeda.sormas.ui.utils.CssStyles.SOFT_REQUIRED) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) DateRangeValidator(com.vaadin.v7.data.validator.DateRangeValidator) LayoutUtil.fluidColumnLocCss(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLocCss) LayoutUtil.fluidColumn(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumn) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) DateField(com.vaadin.v7.ui.DateField) FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) Button(com.vaadin.ui.Button)

Example 2 with FollowUpStatus

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));
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) JournalPersonDto(de.symeda.sormas.api.person.JournalPersonDto) UserDto(de.symeda.sormas.api.user.UserDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 3 with FollowUpStatus

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] + ", ");
        }
    }
}
Also used : FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) Date(java.util.Date)

Example 4 with FollowUpStatus

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);
        }
    }
}
Also used : FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) FeatureType(de.symeda.sormas.api.feature.FeatureType) HealthConditionsForm(de.symeda.sormas.ui.clinicalcourse.HealthConditionsForm) AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) LAYOUT_COL_HIDE_INVSIBLE(de.symeda.sormas.ui.utils.CssStyles.LAYOUT_COL_HIDE_INVSIBLE) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) ContactRelation(de.symeda.sormas.api.contact.ContactRelation) ValidationUtils(de.symeda.sormas.ui.utils.ValidationUtils) Date(java.util.Date) CheckBox(com.vaadin.v7.ui.CheckBox) EndOfQuarantineReason(de.symeda.sormas.api.contact.EndOfQuarantineReason) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) TracingApp(de.symeda.sormas.api.contact.TracingApp) ContactProximity(de.symeda.sormas.api.contact.ContactProximity) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) CssStyles(de.symeda.sormas.ui.utils.CssStyles) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) UserRole(de.symeda.sormas.api.user.UserRole) FORCE_CAPTION(de.symeda.sormas.ui.utils.CssStyles.FORCE_CAPTION) UserProvider(de.symeda.sormas.ui.UserProvider) ValoTheme(com.vaadin.ui.themes.ValoTheme) Property(com.vaadin.v7.data.Property) ViewMode(de.symeda.sormas.ui.utils.ViewMode) Validator(com.vaadin.v7.data.Validator) ComboBox(com.vaadin.v7.ui.ComboBox) Link(com.vaadin.ui.Link) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Field(com.vaadin.v7.ui.Field) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) Sets(com.google.common.collect.Sets) List(java.util.List) ContactDto(de.symeda.sormas.api.contact.ContactDto) TextField(com.vaadin.v7.ui.TextField) Descriptions(de.symeda.sormas.api.i18n.Descriptions) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) FollowUpPeriodDto(de.symeda.sormas.api.followup.FollowUpPeriodDto) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) LABEL_WHITE_SPACE_NORMAL(de.symeda.sormas.ui.utils.CssStyles.LABEL_WHITE_SPACE_NORMAL) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateHelper(de.symeda.sormas.api.utils.DateHelper) ErrorLevel(com.vaadin.shared.ui.ErrorLevel) Converter(com.vaadin.v7.data.util.converter.Converter) ArrayList(java.util.ArrayList) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) QuarantineType(de.symeda.sormas.api.contact.QuarantineType) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) LayoutUtil.locCss(de.symeda.sormas.ui.utils.LayoutUtil.locCss) Resolution(com.vaadin.v7.shared.ui.datefield.Resolution) Label(com.vaadin.ui.Label) CountryHelper(de.symeda.sormas.api.CountryHelper) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContactIdentificationSource(de.symeda.sormas.api.contact.ContactIdentificationSource) Validations(de.symeda.sormas.api.i18n.Validations) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) ContactLogic(de.symeda.sormas.api.contact.ContactLogic) ErrorMessage(com.vaadin.server.ErrorMessage) Captions(de.symeda.sormas.api.i18n.Captions) ExtendedReduced(de.symeda.sormas.api.utils.ExtendedReduced) LocalDate(org.joda.time.LocalDate) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) Disease(de.symeda.sormas.api.Disease) DateRangeValidator(com.vaadin.v7.data.validator.DateRangeValidator) TextArea(com.vaadin.v7.ui.TextArea) ContactCategory(de.symeda.sormas.api.contact.ContactCategory) FollowUpLogic(de.symeda.sormas.api.followup.FollowUpLogic) DiseasesConfiguration(de.symeda.sormas.api.utils.Diseases.DiseasesConfiguration) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) DateField(com.vaadin.v7.ui.DateField) FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) Button(com.vaadin.ui.Button)

Example 5 with FollowUpStatus

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]));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) Arrays(java.util.Arrays) VisitStatus(de.symeda.sormas.api.visit.VisitStatus) ExternalDataUpdateException(de.symeda.sormas.api.externaldata.ExternalDataUpdateException) StringUtils(org.apache.commons.lang3.StringUtils) Predicate(javax.persistence.criteria.Predicate) Map(java.util.Map) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) JoinType(javax.persistence.criteria.JoinType) FeatureConfigurationFacadeEjb(de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb) Visit(de.symeda.sormas.backend.visit.Visit) EpiData(de.symeda.sormas.backend.epidata.EpiData) From(javax.persistence.criteria.From) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) EnumMap(java.util.EnumMap) Transactional(javax.transaction.Transactional) Set(java.util.Set) NotNull(javax.validation.constraints.NotNull) DashboardContactDto(de.symeda.sormas.api.dashboard.DashboardContactDto) UserService(de.symeda.sormas.backend.user.UserService) User(de.symeda.sormas.backend.user.User) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) ExternalDataDto(de.symeda.sormas.api.externaldata.ExternalDataDto) JurisdictionHelper(de.symeda.sormas.backend.util.JurisdictionHelper) DeletableAdo(de.symeda.sormas.backend.common.DeletableAdo) SampleService(de.symeda.sormas.backend.sample.SampleService) Sample(de.symeda.sormas.backend.sample.Sample) EventParticipant(de.symeda.sormas.backend.event.EventParticipant) Community(de.symeda.sormas.backend.infrastructure.community.Community) CaseUserFilterCriteria(de.symeda.sormas.backend.caze.CaseUserFilterCriteria) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) Selection(javax.persistence.criteria.Selection) Case(de.symeda.sormas.backend.caze.Case) LocalBean(javax.ejb.LocalBean) ContactListEntryDtoResultTransformer(de.symeda.sormas.backend.contact.transformers.ContactListEntryDtoResultTransformer) EJB(javax.ejb.EJB) Root(javax.persistence.criteria.Root) ChangeDateFilterBuilder(de.symeda.sormas.backend.common.ChangeDateFilterBuilder) TaskCriteria(de.symeda.sormas.api.task.TaskCriteria) DataHelper(de.symeda.sormas.api.utils.DataHelper) Task(de.symeda.sormas.backend.task.Task) ContactLogic(de.symeda.sormas.api.contact.ContactLogic) Disease(de.symeda.sormas.api.Disease) FollowUpLogic(de.symeda.sormas.api.followup.FollowUpLogic) HealthConditions(de.symeda.sormas.backend.clinicalcourse.HealthConditions) Subquery(javax.persistence.criteria.Subquery) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) FeatureType(de.symeda.sormas.api.feature.FeatureType) VisitFacadeEjb(de.symeda.sormas.backend.visit.VisitFacadeEjb) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) Join(javax.persistence.criteria.Join) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) ChangeDateBuilder(de.symeda.sormas.backend.common.ChangeDateBuilder) AbstractCoreAdoService(de.symeda.sormas.backend.common.AbstractCoreAdoService) ContactProximity(de.symeda.sormas.api.contact.ContactProximity) ExposureService(de.symeda.sormas.backend.exposure.ExposureService) UserRole(de.symeda.sormas.api.user.UserRole) VaccinationStatus(de.symeda.sormas.api.caze.VaccinationStatus) Stateless(javax.ejb.Stateless) CaseService(de.symeda.sormas.backend.caze.CaseService) DiseaseConfigurationFacadeEjbLocal(de.symeda.sormas.backend.disease.DiseaseConfigurationFacadeEjb.DiseaseConfigurationFacadeEjbLocal) Person(de.symeda.sormas.backend.person.Person) Timestamp(java.sql.Timestamp) Region(de.symeda.sormas.backend.infrastructure.region.Region) District(de.symeda.sormas.backend.infrastructure.district.District) Collectors(java.util.stream.Collectors) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) List(java.util.List) CoreAdo(de.symeda.sormas.backend.common.CoreAdo) ContactDto(de.symeda.sormas.api.contact.ContactDto) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) Location(de.symeda.sormas.backend.location.Location) SormasToSormasShareInfoService(de.symeda.sormas.backend.sormastosormas.share.shareinfo.SormasToSormasShareInfoService) TaskService(de.symeda.sormas.backend.task.TaskService) DateHelper(de.symeda.sormas.api.utils.DateHelper) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ExternalDataUtil(de.symeda.sormas.backend.util.ExternalDataUtil) HashSet(java.util.HashSet) CriteriaUpdate(javax.persistence.criteria.CriteriaUpdate) CollectionUtils(org.apache.commons.collections.CollectionUtils) IterableHelper(de.symeda.sormas.backend.util.IterableHelper) CaseQueryContext(de.symeda.sormas.backend.caze.CaseQueryContext) Symptoms(de.symeda.sormas.backend.symptoms.Symptoms) SampleJoins(de.symeda.sormas.backend.sample.SampleJoins) LinkedList(java.util.LinkedList) NoSuchElementException(java.util.NoSuchElementException) Expression(javax.persistence.criteria.Expression) CriteriaBuilderHelper(de.symeda.sormas.backend.common.CriteriaBuilderHelper) ModelConstants(de.symeda.sormas.backend.util.ModelConstants) EpiDataService(de.symeda.sormas.backend.epidata.EpiDataService) ContactListEntryDto(de.symeda.sormas.api.contact.ContactListEntryDto) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) Event(de.symeda.sormas.backend.event.Event) SormasToSormasShareInfo(de.symeda.sormas.backend.sormastosormas.share.shareinfo.SormasToSormasShareInfo) ExternalJournalService(de.symeda.sormas.backend.externaljournal.ExternalJournalService) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) Comparator(java.util.Comparator) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) Predicate(javax.persistence.criteria.Predicate)

Aggregations

FollowUpStatus (de.symeda.sormas.api.contact.FollowUpStatus)5 ContactDto (de.symeda.sormas.api.contact.ContactDto)4 Date (java.util.Date)4 Disease (de.symeda.sormas.api.Disease)3 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)3 FeatureType (de.symeda.sormas.api.feature.FeatureType)3 FeatureTypeProperty (de.symeda.sormas.api.feature.FeatureTypeProperty)3 FollowUpLogic (de.symeda.sormas.api.followup.FollowUpLogic)3 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)3 Strings (de.symeda.sormas.api.i18n.Strings)3 UserRole (de.symeda.sormas.api.user.UserRole)3 DateHelper (de.symeda.sormas.api.utils.DateHelper)3 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 List (java.util.List)3 ErrorMessage (com.vaadin.server.ErrorMessage)2 ErrorLevel (com.vaadin.shared.ui.ErrorLevel)2 Button (com.vaadin.ui.Button)2 Label (com.vaadin.ui.Label)2 ValoTheme (com.vaadin.ui.themes.ValoTheme)2