-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
packages/esm-billing-app/src/claims/claims-management/header/summary-header.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { DatePicker, DatePickerInput } from '@carbon/react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import styles from './summary-header.scss'; | ||
|
||
|
||
interface ClaimsSummaryHeaderProps { | ||
filters: { | ||
fromDate: Date | null; | ||
toDate: Date | null; | ||
}; | ||
onFilterChanged: (updateFn: (currentFilters: any) => any) => void; | ||
statusOptions?: string[]; | ||
} | ||
|
||
const ClaimSummaryHeader: React.FC<ClaimsSummaryHeaderProps> = ({ | ||
filters, | ||
onFilterChanged, | ||
}) => { | ||
const { t } = useTranslation(); | ||
|
||
|
||
const today = new Date(); | ||
const oneMonthAgo = new Date(today); | ||
oneMonthAgo.setMonth(today.getMonth() - 1); | ||
|
||
|
||
useEffect(() => { | ||
if (!filters.fromDate && !filters.toDate) { | ||
onFilterChanged(() => ({ | ||
fromDate: oneMonthAgo, | ||
toDate: today, | ||
})); | ||
} | ||
}, [filters, onFilterChanged, oneMonthAgo, today]); | ||
|
||
return ( | ||
<div className={styles.summaryContainer}> | ||
<DatePicker | ||
datePickerType="range" | ||
value={[filters.fromDate, filters.toDate]} | ||
onChange={([fromDate, toDate]) => | ||
onFilterChanged((currentFilters) => ({ ...currentFilters, fromDate, toDate })) | ||
} | ||
aria-label={t('datePicker.rangeLabel', 'Select date range')} | ||
> | ||
<DatePickerInput | ||
id="date-picker-input-id-start" | ||
placeholder={t('datePicker.startPlaceholder', 'mm/dd/yyyy')} | ||
size="md" | ||
labelText={t('datePicker.startLabel', 'Start Date')} | ||
/> | ||
<DatePickerInput | ||
id="date-picker-input-id-finish" | ||
placeholder={t('datePicker.endPlaceholder', 'mm/dd/yyyy')} | ||
size="md" | ||
labelText={t('datePicker.endLabel', 'End Date')} | ||
/> | ||
</DatePicker> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ClaimSummaryHeader; | ||
13 changes: 13 additions & 0 deletions
13
packages/esm-billing-app/src/claims/claims-management/header/summary-header.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@use '@carbon/layout'; | ||
@use '@carbon/type'; | ||
@use '@carbon/colors'; | ||
|
||
.summaryContainer { | ||
display: flex; | ||
margin-top: layout.$spacing-05; | ||
gap: layout.$spacing-01; | ||
} | ||
|
||
.input { | ||
min-width: 300px; | ||
} |
70 changes: 70 additions & 0 deletions
70
...ages/esm-billing-app/src/claims/claims-management/main/claims-summary-chart.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { BarChartOptions, GroupedBarChart, ScaleTypes } from '@carbon/charts-react'; | ||
|
||
const ClaimsSummaryChart = () => { | ||
const [metrics, setMetrics] = useState({ summaryGraph: [] }); | ||
|
||
useEffect(() => { | ||
setTimeout(() => { | ||
// Simulating API data fetch | ||
const data = { | ||
summaryGraph: [ | ||
{ month: 'January', claimsA: 1200, claimsB: 1000 }, | ||
{ month: 'February', claimsA: 1000, claimsB: 1100 }, | ||
{ month: 'March', claimsA: 1400, claimsB: 1300 }, | ||
{ month: 'April', claimsA: 800, claimsB: 700 }, | ||
{ month: 'May', claimsA: 1100, claimsB: 1200 }, | ||
], | ||
}; | ||
|
||
setMetrics(data); | ||
}, 1000); // Simulating async fetch | ||
}, []); | ||
|
||
if (!metrics.summaryGraph.length) { | ||
return <div>Loading data...</div>; | ||
} | ||
|
||
const transformClaimSummaryChartData = (data) => { | ||
return data.map((item) => [ | ||
{ group: item.month, value: item.claimsA }, | ||
{ group: item.month, value: item.claimsB }, | ||
]).flat(); | ||
}; | ||
|
||
const options: BarChartOptions = { | ||
title: 'Claims Comparative Analysis', | ||
legend: { | ||
enabled: true, | ||
}, | ||
axes: { | ||
left: { | ||
title: 'Month', | ||
mapsTo: 'group', | ||
scaleType: ScaleTypes.LABELS, | ||
}, | ||
bottom: { | ||
title: 'Amount (Ksh)', | ||
mapsTo: 'value', | ||
|
||
scaleType: ScaleTypes.LINEAR, | ||
includeZero: true, | ||
}, | ||
}, | ||
height: '400px', | ||
}; | ||
|
||
|
||
const transformedData = transformClaimSummaryChartData(metrics.summaryGraph); | ||
|
||
return ( | ||
<div style={{ padding: '2rem' }}> | ||
<GroupedBarChart | ||
data={transformedData} | ||
options={options} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ClaimsSummaryChart; |
93 changes: 93 additions & 0 deletions
93
packages/esm-billing-app/src/claims/claims-management/main/claims-summary-main.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import styles from '../../metrics/metrics.scss'; | ||
import { ClaimsManagementHeader } from '../header/claims-header.component'; | ||
import ClaimsSummaryHeader from '../header/summary-header.component'; | ||
import { ClaimsSummaryFilter } from '../../../types'; | ||
import ClaimsSummaryChart from './claims-summary-chart.component'; | ||
|
||
|
||
import MetricsHeader from '../../metrics/metrics-header.component'; | ||
import MetricsCard from '../../metrics/metrics-card.component'; | ||
import { convertToCurrency } from '../../../helpers'; | ||
|
||
|
||
const MainMetrics = () => { | ||
|
||
|
||
const [filters, setFilters] = useState({ | ||
fromDate: null, | ||
toDate: null, | ||
}); | ||
const onFilterChanged = (updateFn: (currentFilters: any) => any) => { | ||
setFilters(updateFn(filters)); | ||
}; | ||
|
||
|
||
const fromDate = filters.fromDate || new Date(); | ||
const toDate = filters.toDate || new Date(); | ||
// test data values declaration | ||
const totalAmount = 1150000; | ||
const claimedAmount = 120000; | ||
|
||
const pendingAmount = 56000; | ||
|
||
const preApps = 300; | ||
const preAppsApproved = 188; | ||
|
||
const preAppsPending = 20; | ||
|
||
const t = (key, fallback) => fallback; | ||
|
||
return ( | ||
<div className={`omrs-main-content`}> | ||
<ClaimsManagementHeader title={t('claims', 'Claims Summary')} /> | ||
<ClaimsSummaryHeader | ||
filters={filters} | ||
onFilterChanged={onFilterChanged} | ||
/> <> | ||
<div className={styles.cardContainer} data-testid="claims-metrics"> | ||
<MetricsCard | ||
label={t('ksh', '')} | ||
value={convertToCurrency(totalAmount)} | ||
headerLabel={t('claimsItems', 'Total Claimed')} | ||
/> | ||
<MetricsCard | ||
label={t('ksh', '')} | ||
value={convertToCurrency(claimedAmount)} | ||
headerLabel={t('claimsItems', 'Total Approved')} | ||
/> | ||
<MetricsCard | ||
label={t('ksh', '')} | ||
value={convertToCurrency(pendingAmount)} | ||
headerLabel={t('claimsItems', 'Amount Pending')} | ||
/> | ||
</div> | ||
<div className={styles.cardContainer} data-testid="claims-metrics"> | ||
<MetricsCard | ||
label={t('ksh', '')} | ||
value={preApps} | ||
headerLabel={t('claimsItems', 'Total Preauth')} | ||
/> | ||
<MetricsCard | ||
label={t('ksh', '')} | ||
value={preAppsApproved} | ||
headerLabel={t('claimsItems', 'Approved Preauth')} | ||
/> | ||
<MetricsCard | ||
label={t('ksh', '')} | ||
value={preAppsPending} | ||
headerLabel={t('claimsItems', 'Pending Preauth')} | ||
/> | ||
</div> | ||
<ClaimsSummaryChart /> | ||
|
||
</> | ||
|
||
|
||
</div> | ||
|
||
); | ||
}; | ||
|
||
export default MainMetrics; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters