From d1da9d0fdf621392871f9ca74825edc494daf024 Mon Sep 17 00:00:00 2001 From: Thibault Dethier <84660492+tdethier@users.noreply.github.com> Date: Thu, 20 Apr 2023 10:06:56 +0200 Subject: [PATCH] OMT-313: Added claim percentage referrals report (#89) --- src/index.js | 18 ++++++ src/reports/ClaimPercentageReferralsReport.js | 64 +++++++++++++++++++ src/translations/en.json | 6 +- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src/reports/ClaimPercentageReferralsReport.js diff --git a/src/index.js b/src/index.js index 26ad23d2..3b5cd0f8 100644 --- a/src/index.js +++ b/src/index.js @@ -15,6 +15,9 @@ import ClaimMasterPanelExt from "./components/ClaimMasterPanelExt"; import AttachmentsDialog from "./components/AttachmentsDialog"; import messages_en from "./translations/en.json"; import reducer from "./reducer"; +import { decodeId } from "@openimis/fe-core"; +import ClaimPercentageReferralsReport from "./reports/ClaimPercentageReferralsReport"; + const ROUTE_HEALTH_FACILITIES = "claim/healthFacilities"; const ROUTE_CLAIM_EDIT = "claim/healthFacilities/claim"; @@ -25,6 +28,21 @@ const ROUTE_CLAIM_FEEDBACK = "claim/feedback"; const DEFAULT_CONFIG = { "translations": [{ key: "en", messages: messages_en }], "reducers": [{ key: "claim", reducer }], + "reports": [ + { + key: "claim_percentage_referrals", + component: ClaimPercentageReferralsReport, + isValid: (values) => values.region && values.district && values.dateStart && values.dateEnd, + getParams: (values) => { + const params = {} + params.region_id = decodeId(values.region.id); + params.district_id = decodeId(values.district.id); + params.date_start = values.dateStart; + params.date_end = values.dateEnd; + return params; + }, + }, + ], "refs": [ { key: "claim.route.healthFacilities", ref: ROUTE_HEALTH_FACILITIES }, { key: "claim.route.claimEdit", ref: ROUTE_CLAIM_EDIT }, diff --git a/src/reports/ClaimPercentageReferralsReport.js b/src/reports/ClaimPercentageReferralsReport.js new file mode 100644 index 00000000..299e6dd2 --- /dev/null +++ b/src/reports/ClaimPercentageReferralsReport.js @@ -0,0 +1,64 @@ +import { Grid } from "@material-ui/core"; +import { PublishedComponent, useModulesManager, useTranslations } from "@openimis/fe-core"; +import React from "react"; + +const ClaimPercentageReferralsReport = (props) => { + const { values, setValues } = props; + const modulesManager = useModulesManager(); + const { formatMessage } = useTranslations("claim", modulesManager); + + return ( + + + + setValues({ + ...values, + region, + }) + } + required + value={values.region} + /> + + + + setValues({ + ...values, + district, + }) + } + required + value={values.district} + /> + + + setValues({ ...values, dateStart })} + /> + + + setValues({ ...values, dateEnd })} + /> + + + ); +}; + +export default ClaimPercentageReferralsReport; diff --git a/src/translations/en.json b/src/translations/en.json index b4234253..81c89919 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -230,5 +230,9 @@ "claim.ClaimFilter.processedDateTo": "Processed To", "claim.claimSummaries.processedDate": "Processed On", "claim.edit.items.pricevaluated": "Valuated", - "claim.edit.services.pricevaluated": "Valuated" + "claim.edit.services.pricevaluated": "Valuated", + "claim.ClaimPercentageReferralsReport.region": "Region", + "claim.ClaimPercentageReferralsReport.district": "District", + "claim.ClaimPercentageReferralsReport.dateStart": "Date From", + "claim.ClaimPercentageReferralsReport.dateEnd": "Date To" }