-
-
Notifications
You must be signed in to change notification settings - Fork 0
Rebrand to Open Health and add Dashboard metrics view #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dependabot/npm_and_yarn/eslint-plugin-react-7.31.11
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,92 @@ | ||
| import React, { useEffect } from 'react' | ||
| import { Alert, Card, Col, Container, Row, Spinner } from 'react-bootstrap' | ||
| import { useQuery } from 'react-query' | ||
|
|
||
| import { useUpdateTitle } from '../page-header/title/TitleContext' | ||
| import AppointmentRepository from '../shared/db/AppointmentRepository' | ||
| import ImagingRepository from '../shared/db/ImagingRepository' | ||
| import IncidentRepository from '../shared/db/IncidentRepository' | ||
| import LabRepository from '../shared/db/LabRepository' | ||
| import MedicationRepository from '../shared/db/MedicationRepository' | ||
| import PatientRepository from '../shared/db/PatientRepository' | ||
| import useTranslator from '../shared/hooks/useTranslator' | ||
|
|
||
| type DataDomain = 'patients' | 'appointments' | 'labs' | 'medications' | 'imagings' | 'incidents' | ||
|
|
||
| type DataMetric = { | ||
| domain: DataDomain | ||
| value: number | ||
| } | ||
|
|
||
| const fetchPlatformMetrics = async (): Promise<DataMetric[]> => { | ||
| const [patients, appointments, labs, medications, imagings, incidents] = await Promise.all([ | ||
| PatientRepository.count(), | ||
| AppointmentRepository.count(), | ||
| LabRepository.count(), | ||
| MedicationRepository.count(), | ||
| ImagingRepository.count(), | ||
| IncidentRepository.count(), | ||
| ]) | ||
|
|
||
| return [ | ||
| { domain: 'patients', value: patients }, | ||
| { domain: 'appointments', value: appointments }, | ||
| { domain: 'labs', value: labs }, | ||
| { domain: 'medications', value: medications }, | ||
| { domain: 'imagings', value: imagings }, | ||
| { domain: 'incidents', value: incidents }, | ||
| ] | ||
| } | ||
|
|
||
| const Dashboard: React.FC = () => { | ||
| const { t } = useTranslator() | ||
| const updateTitle = useUpdateTitle() | ||
| const { data: metrics = [], isLoading, isError } = useQuery('dashboard-metrics', fetchPlatformMetrics) | ||
|
|
||
| useEffect(() => { | ||
| updateTitle(t('dashboard.label')) | ||
| }) | ||
| return <h3>Example</h3> | ||
| }, [t, updateTitle]) | ||
|
|
||
| const totalRecords = metrics.reduce((runningTotal, metric) => runningTotal + metric.value, 0) | ||
|
|
||
| return ( | ||
| <Container fluid> | ||
| <Row className="mb-4"> | ||
| <Col> | ||
| <h3>{t('dashboard.centralHubTitle')}</h3> | ||
| <p className="text-muted mb-0">{t('dashboard.centralHubDescription')}</p> | ||
| </Col> | ||
| </Row> | ||
| {isError && <Alert variant="danger">{t('dashboard.metricsLoadError')}</Alert>} | ||
| {isLoading && <Spinner animation="border" role="status" />} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: The loading spinner could be made more accessible and visually integrated with the layout. Consider wrapping the spinner in a <Spinner animation="border" role="status">
<span className="visually-hidden">Loading...</span>
</Spinner>This will make the loading state clearer and more accessible. Suggested implementation: {isError && <Alert variant="danger">{t('dashboard.metricsLoadError')}</Alert>}
{isLoading && (
<Row className="justify-content-center my-4">
<Col xs="auto" className="text-center">
<Spinner animation="border" role="status">
<span className="visually-hidden">{t('dashboard.loading')}</span>
</Spinner>
</Col>
</Row>
)}
{!isLoading && !isError && (
|
||
| {!isLoading && !isError && ( | ||
| <> | ||
| <Row className="mb-4"> | ||
| <Col md={6} lg={4}> | ||
| <Card> | ||
| <Card.Body> | ||
| <Card.Title>{t('dashboard.totalRecordsLabel')}</Card.Title> | ||
| <h2 className="mb-0">{totalRecords}</h2> | ||
| </Card.Body> | ||
| </Card> | ||
| </Col> | ||
| </Row> | ||
| <Row> | ||
| {metrics.map((metric) => ( | ||
| <Col key={metric.domain} sm={6} lg={4} className="mb-3"> | ||
| <Card className="h-100"> | ||
| <Card.Body> | ||
| <Card.Title>{t(`dashboard.metrics.${metric.domain}`)}</Card.Title> | ||
| <h4 className="mb-0">{metric.value}</h4> | ||
| </Card.Body> | ||
| </Card> | ||
| </Col> | ||
| ))} | ||
| </Row> | ||
| </> | ||
| )} | ||
| </Container> | ||
| ) | ||
| } | ||
|
|
||
| export default Dashboard | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'لوحة القيادة', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
|
Comment on lines
+4
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: New dashboard strings are left in English across non-English locale files. These new keys ( |
||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Dashboard', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Dashboard', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Panel', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Tableau de bord', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Dasbor', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Dashboard', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'ダッシュボード', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Painel de controle', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Панель приборов', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: 'Panel', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| export default { | ||
| dashboard: { | ||
| label: '仪表板', | ||
| centralHubTitle: 'Digital Health Command Center', | ||
| centralHubDescription: 'Centralize your care data across patients, appointments, labs, medications, imaging, and incidents.', | ||
| totalRecordsLabel: 'Total clinical records', | ||
| metricsLoadError: 'Unable to load centralized healthcare metrics. Please try again.', | ||
| metrics: { | ||
| patients: 'Patients', | ||
| appointments: 'Appointments', | ||
| labs: 'Lab requests', | ||
| medications: 'Medication requests', | ||
| imagings: 'Imaging requests', | ||
| incidents: 'Incidents', | ||
| }, | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchPlatformMetricsalways queries counts for patients, appointments, labs, medications, imaging, and incidents before rendering, but this component does not checkstate.user.permissionsfirst. Users who are denied module access are redirected to/byPrivateRoute, so they can still see record counts for domains they are not authorized to read, which leaks restricted operational data. Filter metric queries/rendering by the corresponding read permissions (or skip unauthorized repositories entirely) before requesting these counts.Useful? React with 👍 / 👎.