Search in sources :

Example 1 with CaseIndexDetailedDto

use of de.symeda.sormas.api.caze.CaseIndexDetailedDto in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjb method getIndexDetailedList.

@Override
public List<CaseIndexDetailedDto> getIndexDetailedList(CaseCriteria caseCriteria, Integer first, Integer max, List<SortProperty> sortProperties) {
    CriteriaQuery<CaseIndexDetailedDto> cq = listQueryBuilder.buildIndexDetailedCriteria(caseCriteria, sortProperties);
    List<CaseIndexDetailedDto> cases = QueryHelper.getResultList(em, cq, first, max);
    // Load latest events info
    // Adding a second query here is not perfect, but selecting the last event with a criteria query
    // doesn't seem to be possible and using a native query is not an option because of user filters
    List<EventSummaryDetails> eventSummaries = eventService.getEventSummaryDetailsByCases(cases.stream().map(CaseIndexDetailedDto::getId).collect(Collectors.toList()));
    Map<String, ExternalShareInfoCountAndLatestDate> survToolShareCountAndDates = null;
    if (externalSurveillanceToolGatewayFacade.isFeatureEnabled()) {
        survToolShareCountAndDates = externalShareInfoService.getCaseShareCountAndLatestDate(cases.stream().map(CaseIndexDto::getId).collect(Collectors.toList())).stream().collect(Collectors.toMap(ExternalShareInfoCountAndLatestDate::getAssociatedObjectUuid, Function.identity()));
    }
    Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
    for (CaseIndexDetailedDto caze : cases) {
        if (survToolShareCountAndDates != null) {
            ExternalShareInfoCountAndLatestDate survToolShareCountAndDate = survToolShareCountAndDates.get(caze.getUuid());
            if (survToolShareCountAndDate != null) {
                caze.setSurveillanceToolShareCount(survToolShareCountAndDate.getCount());
                caze.setSurveillanceToolLastShareDate(survToolShareCountAndDate.getLatestDate());
                caze.setSurveillanceToolStatus(survToolShareCountAndDate.getLatestStatus());
            }
        }
        if (caze.getEventCount() > 0) {
            eventSummaries.stream().filter(v -> v.getCaseId() == caze.getId()).max(Comparator.comparing(EventSummaryDetails::getEventDate)).ifPresent(eventSummary -> {
                caze.setLatestEventId(eventSummary.getEventUuid());
                caze.setLatestEventStatus(eventSummary.getEventStatus());
                caze.setLatestEventTitle(eventSummary.getEventTitle());
            });
        }
        Boolean isInJurisdiction = caze.getInJurisdiction();
        pseudonymizer.pseudonymizeDto(CaseIndexDetailedDto.class, caze, isInJurisdiction, c -> {
            pseudonymizer.pseudonymizeDto(AgeAndBirthDateDto.class, caze.getAgeAndBirthDate(), isInJurisdiction, null);
            pseudonymizer.pseudonymizeUser(userService.getByUuid(caze.getReportingUser().getUuid()), userService.getCurrentUser(), caze::setReportingUser);
        });
    }
    return cases;
}
Also used : Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) EventSummaryDetails(de.symeda.sormas.backend.event.EventSummaryDetails) CaseIndexDetailedDto(de.symeda.sormas.api.caze.CaseIndexDetailedDto) ExternalShareInfoCountAndLatestDate(de.symeda.sormas.backend.share.ExternalShareInfoCountAndLatestDate)

Example 2 with CaseIndexDetailedDto

use of de.symeda.sormas.api.caze.CaseIndexDetailedDto in project SORMAS-Project by hzi-braunschweig.

the class CaseGridDetailed method initColumns.

@SuppressWarnings("unchecked")
@Override
protected void initColumns() {
    addColumn(caze -> {
        if (caze.getLatestSampleDateTime() != null) {
            return DateFormatHelper.formatLocalDateTime(caze.getLatestSampleDateTime()) + " [" + caze.getSampleCount() + "]";
        } else {
            return null;
        }
    }).setCaption(I18nProperties.getPrefixCaption(CaseIndexDetailedDto.I18N_PREFIX, CaseIndexDetailedDto.LATEST_SAMPLE_DATE_TIME)).setId(LATEST_SAMPLE_DATE_TIME_AND_SAMPLE_COUNT).setSortable(false).setWidth(150);
    super.initColumns();
    if (!FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY)) {
        getColumn(CaseIndexDetailedDto.RE_INFECTION).setHidden(true);
    }
    getColumn(CaseIndexDetailedDto.SEX).setWidth(80);
    getColumn(CaseIndexDetailedDto.AGE_AND_BIRTH_DATE).setWidth(100);
    getColumn(CaseIndexDetailedDto.POSTAL_CODE).setWidth(100);
    getColumn(CaseIndexDetailedDto.CITY).setWidth(150);
    getColumn(CaseIndexDetailedDto.STREET).setWidth(150);
    getColumn(CaseIndexDetailedDto.HOUSE_NUMBER).setWidth(50);
    getColumn(CaseIndexDetailedDto.ADDITIONAL_INFORMATION).setWidth(200);
    getColumn(CaseIndexDetailedDto.PHONE).setWidth(100);
    getColumn(CaseIndexDetailedDto.EVENT_COUNT).setWidth(80).setSortable(false);
    getColumn(CaseIndexDetailedDto.LATEST_EVENT_ID).setWidth(80).setSortable(false);
    getColumn(CaseIndexDetailedDto.LATEST_EVENT_STATUS).setWidth(80).setSortable(false);
    getColumn(CaseIndexDetailedDto.LATEST_EVENT_TITLE).setWidth(150).setSortable(false);
    ((Column<CaseIndexDetailedDto, String>) getColumn(CaseIndexDetailedDto.LATEST_EVENT_ID)).setRenderer(new UuidRenderer());
    addItemClickListener(new ShowDetailsListener<>(CaseIndexDetailedDto.LATEST_EVENT_ID, c -> ControllerProvider.getEventController().navigateToData(c.getLatestEventId())));
    ((Column<CaseIndexDetailedDto, AgeAndBirthDateDto>) getColumn(CaseIndexDetailedDto.AGE_AND_BIRTH_DATE)).setRenderer(value -> value == null ? "" : PersonHelper.getAgeAndBirthdateString(value.getAge(), value.getAgeType(), value.getDateOfBirthDD(), value.getDateOfBirthMM(), value.getDateOfBirthYYYY()), new TextRenderer());
    ((Column<CaseIndexDetailedDto, Date>) getColumn(CaseIndexDetailedDto.SYMPTOM_ONSET_DATE)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat())).setCaption(I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE)).setWidth(80);
}
Also used : TextRenderer(com.vaadin.ui.renderers.TextRenderer) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) PersonHelper(de.symeda.sormas.api.person.PersonHelper) AgeAndBirthDateDto(de.symeda.sormas.api.caze.AgeAndBirthDateDto) CaseIndexDetailedDto(de.symeda.sormas.api.caze.CaseIndexDetailedDto) SortProperty(de.symeda.sormas.api.utils.SortProperty) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) ShowDetailsListener(de.symeda.sormas.ui.utils.ShowDetailsListener) List(java.util.List) Stream(java.util.stream.Stream) CountryHelper(de.symeda.sormas.api.CountryHelper) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) DateRenderer(com.vaadin.ui.renderers.DateRenderer) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) DateRenderer(com.vaadin.ui.renderers.DateRenderer) TextRenderer(com.vaadin.ui.renderers.TextRenderer)

Aggregations

CaseIndexDetailedDto (de.symeda.sormas.api.caze.CaseIndexDetailedDto)2 DateRenderer (com.vaadin.ui.renderers.DateRenderer)1 TextRenderer (com.vaadin.ui.renderers.TextRenderer)1 CountryHelper (de.symeda.sormas.api.CountryHelper)1 FacadeProvider (de.symeda.sormas.api.FacadeProvider)1 AgeAndBirthDateDto (de.symeda.sormas.api.caze.AgeAndBirthDateDto)1 CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)1 CaseIndexDto (de.symeda.sormas.api.caze.CaseIndexDto)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1 PersonHelper (de.symeda.sormas.api.person.PersonHelper)1 SymptomsDto (de.symeda.sormas.api.symptoms.SymptomsDto)1 SortProperty (de.symeda.sormas.api.utils.SortProperty)1 EventSummaryDetails (de.symeda.sormas.backend.event.EventSummaryDetails)1 ExternalShareInfoCountAndLatestDate (de.symeda.sormas.backend.share.ExternalShareInfoCountAndLatestDate)1 Pseudonymizer (de.symeda.sormas.backend.util.Pseudonymizer)1 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)1 DateFormatHelper (de.symeda.sormas.ui.utils.DateFormatHelper)1 ShowDetailsListener (de.symeda.sormas.ui.utils.ShowDetailsListener)1 UuidRenderer (de.symeda.sormas.ui.utils.UuidRenderer)1 Date (java.util.Date)1