Search in sources :

Example 1 with WeeklyReport

use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportBackendTest method shouldCreateReportWithCases.

@Test
public void shouldCreateReportWithCases() {
    TestEntityCreator.createCase();
    WeeklyReport report = TestEntityCreator.createWeeklyReport(DateHelper.getEpiWeek(new Date()));
    // Assure that the weekly report has an entry
    assertThat(report.getTotalNumberOfCases(), is(1));
}
Also used : WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) Date(java.util.Date) Test(org.junit.Test)

Example 2 with WeeklyReport

use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.

the class TestEntityCreator method createWeeklyReport.

public static WeeklyReport createWeeklyReport(EpiWeek epiWeek) {
    WeeklyReport weeklyReport;
    try {
        weeklyReport = DatabaseHelper.getWeeklyReportDao().build(epiWeek);
        DatabaseHelper.getWeeklyReportDao().saveAndSnapshot(weeklyReport);
    } catch (DaoException e) {
        throw new RuntimeException(e);
    }
    return DatabaseHelper.getWeeklyReportDao().queryForIdWithEmbedded(weeklyReport.getId());
}
Also used : WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) DaoException(de.symeda.sormas.app.backend.common.DaoException)

Example 3 with WeeklyReport

use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.

the class TaskNotificationService method doWeeklyReportNotification.

private static void doWeeklyReportNotification(Context context, Date notificationRangeStart, Date notificationRangeEnd) {
    if (ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE) && !DatabaseHelper.getFeatureConfigurationDao().isFeatureDisabled(FeatureType.WEEKLY_REPORTING)) {
        // notify at 6:00
        Date notificationPoint = DateHelper.addSeconds(DateHelper.getStartOfDay(new Date()), 60 * 60 * 6);
        if (DateHelper.isBetween(notificationPoint, notificationRangeStart, notificationRangeEnd)) {
            WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().queryByEpiWeekAndUser(DateHelper.getPreviousEpiWeek(notificationPoint), ConfigProvider.getUser());
            if (weeklyReport == null) {
                int notificationId = (int) notificationPoint.getTime();
                Intent notificationIntent = new Intent(context, ReportActivity.class);
                PendingIntent pi = PendingIntent.getActivity(context, notificationId, notificationIntent, 0);
                String title = context.getResources().getString(R.string.action_submit_report);
                NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, NotificationHelper.NOTIFICATION_CHANNEL_TASKS_ID).setTicker(title).setSmallIcon(R.mipmap.ic_launcher_foreground).setContentTitle(title).setContentText(context.getResources().getString(R.string.hint_weekly_report_confirmation_required)).setContentIntent(pi).setAutoCancel(true).setContentIntent(pi);
                NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
                notificationManager.notify(notificationId, notificationBuilder.build());
            }
        }
    }
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(androidx.core.app.NotificationCompat) WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Date(java.util.Date)

Example 4 with WeeklyReport

use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.

the class ReportFragment method showSubmitReportConfirmationDialog.

private void showSubmitReportConfirmationDialog() {
    final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_add_cases_before_report_submit, R.string.action_submit_report, R.string.action_cancel);
    confirmationDialog.setPositiveCallback(() -> {
        confirmReportTask = new DefaultAsyncTask(getContext()) {

            @Override
            public void onPreExecute() {
                getBaseActivity().showPreloader();
            }

            @Override
            public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
                WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().build(getEpiWeek());
                DatabaseHelper.getWeeklyReportDao().saveAndSnapshot(weeklyReport);
            }

            @Override
            protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
                super.onPostExecute(taskResult);
                getBaseActivity().hidePreloader();
                Intent intent = new Intent(getContext(), ReportActivity.class);
                getContext().startActivity(intent);
                if (!taskResult.getResultStatus().isSuccess()) {
                    NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.ERROR, taskResult.getResultStatus().getMessage());
                    return;
                }
                NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.SUCCESS, R.string.message_weekly_report_submitted);
            }
        }.executeOnThreadPool();
    });
    confirmationDialog.show();
}
Also used : DefaultAsyncTask(de.symeda.sormas.app.core.async.DefaultAsyncTask) TaskResultHolder(de.symeda.sormas.app.core.async.TaskResultHolder) AsyncTaskResult(de.symeda.sormas.app.core.async.AsyncTaskResult) WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) Intent(android.content.Intent) ConfirmationDialog(de.symeda.sormas.app.component.dialog.ConfirmationDialog)

Example 5 with WeeklyReport

use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.

the class ReportFragment method showReportData.

protected void showReportData() {
    User user = ConfigProvider.getUser();
    EpiWeek epiWeek = getEpiWeek();
    EpiWeekFilterOption filterOption = getEpiWeekFilterOption();
    if (epiWeek == null || !ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE)) {
        setVisibilityForNoData();
    } else {
        WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().queryByEpiWeekAndUser(epiWeek, user);
        if (EpiWeekFilterOption.THIS_WEEK.equals(filterOption)) {
            // table is shown if the report for the last week has been confirmed; no buttons
            reportDate = getResources().getString(R.string.hint_report_not_submitted);
            setVisibilityForTable(false);
            showPendingReport();
        } else if (EpiWeekFilterOption.LAST_WEEK.equals(filterOption)) {
            // table is shown, buttons are shown if the report has not been confirmed yet
            if (weeklyReport == null) {
                setVisibilityForTable(true);
                reportDate = getResources().getString(R.string.hint_report_not_submitted);
                showPendingReport();
            } else {
                setVisibilityForTable(false);
                reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
                showWeeklyReport(weeklyReport);
            }
        } else {
            // any other week;
            if (weeklyReport == null) {
                if (DateHelper.isEpiWeekAfter(DateHelper.getEpiWeek(new Date()), epiWeek)) {
                    // 'no data' hint is shown for dates in the future
                    setVisibilityForNoData();
                    reportDate = "";
                    showNoReport();
                } else {
                    // table is shown for dates in the past
                    setVisibilityForTable(true);
                    reportDate = getResources().getString(R.string.hint_report_not_submitted);
                    showPendingReport();
                }
            } else {
                setVisibilityForTable(false);
                reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
                showWeeklyReport(weeklyReport);
            }
        }
    }
}
Also used : User(de.symeda.sormas.app.backend.user.User) WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Aggregations

WeeklyReport (de.symeda.sormas.app.backend.report.WeeklyReport)10 WeeklyReportEntry (de.symeda.sormas.app.backend.report.WeeklyReportEntry)4 User (de.symeda.sormas.app.backend.user.User)4 Date (java.util.Date)3 Intent (android.content.Intent)2 MeansOfImmunization (de.symeda.sormas.api.immunization.MeansOfImmunization)2 ActivityAsCase (de.symeda.sormas.app.backend.activityascase.ActivityAsCase)2 Campaign (de.symeda.sormas.app.backend.campaign.Campaign)2 CampaignFormData (de.symeda.sormas.app.backend.campaign.data.CampaignFormData)2 CampaignFormMeta (de.symeda.sormas.app.backend.campaign.form.CampaignFormMeta)2 Case (de.symeda.sormas.app.backend.caze.Case)2 MaternalHistory (de.symeda.sormas.app.backend.caze.maternalhistory.MaternalHistory)2 PortHealthInfo (de.symeda.sormas.app.backend.caze.porthealthinfo.PortHealthInfo)2 DiseaseClassificationCriteria (de.symeda.sormas.app.backend.classification.DiseaseClassificationCriteria)2 ClinicalCourse (de.symeda.sormas.app.backend.clinicalcourse.ClinicalCourse)2 ClinicalVisit (de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit)2 HealthConditions (de.symeda.sormas.app.backend.clinicalcourse.HealthConditions)2 Contact (de.symeda.sormas.app.backend.contact.Contact)2 CustomizableEnumValue (de.symeda.sormas.app.backend.customizableenum.CustomizableEnumValue)2 DiseaseConfiguration (de.symeda.sormas.app.backend.disease.DiseaseConfiguration)2