From 553db70d1123ff762b54db693005f587c718bc7f Mon Sep 17 00:00:00 2001 From: arodidev <51090527+arodidev@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:57:43 +0300 Subject: [PATCH 1/8] introducing metrics extension slot --- .../home-metrics-widget.component.tsx | 11 +++++++++++ .../src/home-metrics-widgets/home-metrics-widget.scss | 3 +++ packages/esm-home-app/src/index.ts | 3 +++ packages/esm-home-app/src/routes.json | 7 +++++++ 4 files changed, 24 insertions(+) create mode 100644 packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.component.tsx create mode 100644 packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.scss diff --git a/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.component.tsx b/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.component.tsx new file mode 100644 index 000000000..b95535dd0 --- /dev/null +++ b/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.component.tsx @@ -0,0 +1,11 @@ +import { ExtensionSlot } from '@openmrs/esm-framework'; +import React from 'react'; +import styles from './home-metrics-widget.scss'; + +interface HomeMetricsWidgetProps {} + +const HomeMetricsWidgets: React.FC = () => { + return ; +}; + +export default HomeMetricsWidgets; diff --git a/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.scss b/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.scss new file mode 100644 index 000000000..865d3456a --- /dev/null +++ b/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.scss @@ -0,0 +1,3 @@ +@use '@carbon/styles/scss/spacing'; + +.homeMetricsWidget {} \ No newline at end of file diff --git a/packages/esm-home-app/src/index.ts b/packages/esm-home-app/src/index.ts index 3b79dc733..9d319cf06 100644 --- a/packages/esm-home-app/src/index.ts +++ b/packages/esm-home-app/src/index.ts @@ -5,6 +5,7 @@ import { esmHomeSchema } from './openmrs-esm-home-schema'; import rootComponent from './root.component'; import homeNavMenuComponent from './side-menu/side-menu.component'; import homeWidgetDashboardComponent from './home-page-widgets/home-page-widgets.component'; +import HomeMetricsWidgetsComponent from './home-metrics-widgets/home-metrics-widget.component'; const moduleName = '@openmrs/esm-home-app'; const pageName = 'home'; @@ -24,6 +25,8 @@ export const homeWidgetDbLink = getSyncLifecycle(createDashboardLink(dashboardMe export const homeWidgetDashboard = getSyncLifecycle(homeWidgetDashboardComponent, options); +export const homeMetricsWidgetDashboard = getSyncLifecycle(HomeMetricsWidgetsComponent, options); + export function startupApp() { defineConfigSchema(moduleName, esmHomeSchema); // t('Home', 'Home'); diff --git a/packages/esm-home-app/src/routes.json b/packages/esm-home-app/src/routes.json index c131cc1fc..7a64cf690 100644 --- a/packages/esm-home-app/src/routes.json +++ b/packages/esm-home-app/src/routes.json @@ -32,6 +32,13 @@ "online": true, "offline": true }, + { + "name": "home-metrics-widget-dashboard", + "slot": "home-dashboard-slot", + "component": "homeMetricsWidgetDashboard", + "online": true, + "offline": true + }, { "name": "home-widget-dashboard", "slot": "home-dashboard-slot", From 58d28a22c96262a921cb72d1ead2e4f55dadf170 Mon Sep 17 00:00:00 2001 From: arodidev <51090527+arodidev@users.noreply.github.com> Date: Thu, 29 Feb 2024 08:30:29 +0300 Subject: [PATCH 2/8] Added test summary tile --- .../home-metrics-widget.scss | 3 --- .../TestDataTile.component.tsx | 23 +++++++++++++++++++ .../homepage-metrics/home-metrics-widget.scss | 5 ++++ .../home-metrics-widgets.component.tsx} | 0 .../esm-home-app/src/hooks/useTestData.ts | 0 packages/esm-home-app/src/index.ts | 5 +++- packages/esm-home-app/src/routes.json | 7 ++++++ 7 files changed, 39 insertions(+), 4 deletions(-) delete mode 100644 packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.scss create mode 100644 packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx create mode 100644 packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss rename packages/esm-home-app/src/{home-metrics-widgets/home-metrics-widget.component.tsx => homepage-metrics/home-metrics-widgets.component.tsx} (100%) create mode 100644 packages/esm-home-app/src/hooks/useTestData.ts diff --git a/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.scss b/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.scss deleted file mode 100644 index 865d3456a..000000000 --- a/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.scss +++ /dev/null @@ -1,3 +0,0 @@ -@use '@carbon/styles/scss/spacing'; - -.homeMetricsWidget {} \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx b/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx new file mode 100644 index 000000000..482e29741 --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { Tile, Layer } from '@carbon/react'; +import styles from './home-metrics-widget.scss'; +import { ArrowRight } from '@carbon/react/icons'; + +interface DataTileProps {} + +const DataTile = () => { + const dataValue = 'default'; + return ( + + + +
+

Data to display: {dataValue}

+
+
+
+
+ ); +}; + +export default DataTile; diff --git a/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss b/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss new file mode 100644 index 000000000..fef831c2c --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss @@ -0,0 +1,5 @@ +@use '@carbon/styles/scss/spacing'; + +.homeMetricsWidget { + padding: spacing.$spacing-05 +} \ No newline at end of file diff --git a/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.component.tsx b/packages/esm-home-app/src/homepage-metrics/home-metrics-widgets.component.tsx similarity index 100% rename from packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.component.tsx rename to packages/esm-home-app/src/homepage-metrics/home-metrics-widgets.component.tsx diff --git a/packages/esm-home-app/src/hooks/useTestData.ts b/packages/esm-home-app/src/hooks/useTestData.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/esm-home-app/src/index.ts b/packages/esm-home-app/src/index.ts index 9d319cf06..2ef8c1379 100644 --- a/packages/esm-home-app/src/index.ts +++ b/packages/esm-home-app/src/index.ts @@ -5,7 +5,8 @@ import { esmHomeSchema } from './openmrs-esm-home-schema'; import rootComponent from './root.component'; import homeNavMenuComponent from './side-menu/side-menu.component'; import homeWidgetDashboardComponent from './home-page-widgets/home-page-widgets.component'; -import HomeMetricsWidgetsComponent from './home-metrics-widgets/home-metrics-widget.component'; +import HomeMetricsWidgetsComponent from './homepage-metrics/home-metrics-widgets.component'; +import DataTile from './homepage-metrics/TestDataTile.component'; const moduleName = '@openmrs/esm-home-app'; const pageName = 'home'; @@ -27,6 +28,8 @@ export const homeWidgetDashboard = getSyncLifecycle(homeWidgetDashboardComponent export const homeMetricsWidgetDashboard = getSyncLifecycle(HomeMetricsWidgetsComponent, options); +export const metricTile = getSyncLifecycle(DataTile, options); + export function startupApp() { defineConfigSchema(moduleName, esmHomeSchema); // t('Home', 'Home'); diff --git a/packages/esm-home-app/src/routes.json b/packages/esm-home-app/src/routes.json index 7a64cf690..267a10f0d 100644 --- a/packages/esm-home-app/src/routes.json +++ b/packages/esm-home-app/src/routes.json @@ -45,6 +45,13 @@ "component": "homeWidgetDashboard", "online": true, "offline": true + }, + { + "name": "matric-tile", + "slot": "home-metrics-widgets-slot", + "component": "metricTile", + "online": true, + "offline": true } ] } \ No newline at end of file From 8e0786a12cb378805731b5463bfc41923d566051 Mon Sep 17 00:00:00 2001 From: arodidev <51090527+arodidev@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:31:05 +0300 Subject: [PATCH 3/8] removing miscellaneous additions --- .../home-metrics-widgets.component.tsx} | 0 packages/esm-home-app/src/index.ts | 3 --- 2 files changed, 3 deletions(-) rename packages/esm-home-app/src/{home-metrics-widgets/home-metrics-widget.component.tsx => homepage-metrics/home-metrics-widgets.component.tsx} (100%) diff --git a/packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.component.tsx b/packages/esm-home-app/src/homepage-metrics/home-metrics-widgets.component.tsx similarity index 100% rename from packages/esm-home-app/src/home-metrics-widgets/home-metrics-widget.component.tsx rename to packages/esm-home-app/src/homepage-metrics/home-metrics-widgets.component.tsx diff --git a/packages/esm-home-app/src/index.ts b/packages/esm-home-app/src/index.ts index 9d319cf06..3b79dc733 100644 --- a/packages/esm-home-app/src/index.ts +++ b/packages/esm-home-app/src/index.ts @@ -5,7 +5,6 @@ import { esmHomeSchema } from './openmrs-esm-home-schema'; import rootComponent from './root.component'; import homeNavMenuComponent from './side-menu/side-menu.component'; import homeWidgetDashboardComponent from './home-page-widgets/home-page-widgets.component'; -import HomeMetricsWidgetsComponent from './home-metrics-widgets/home-metrics-widget.component'; const moduleName = '@openmrs/esm-home-app'; const pageName = 'home'; @@ -25,8 +24,6 @@ export const homeWidgetDbLink = getSyncLifecycle(createDashboardLink(dashboardMe export const homeWidgetDashboard = getSyncLifecycle(homeWidgetDashboardComponent, options); -export const homeMetricsWidgetDashboard = getSyncLifecycle(HomeMetricsWidgetsComponent, options); - export function startupApp() { defineConfigSchema(moduleName, esmHomeSchema); // t('Home', 'Home'); From 985a3dc8200cc5235c8b8870b92da5a89c9ae3f5 Mon Sep 17 00:00:00 2001 From: arodidev <51090527+arodidev@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:36:09 +0300 Subject: [PATCH 4/8] fetch appointments data --- .../TestDataTile.component.tsx | 17 ++++++++++----- .../homepage-metrics/home-metrics-widget.scss | 21 ++++++++++++++++++- .../esm-home-app/src/hooks/useTestData.ts | 18 ++++++++++++++++ .../src/openmrs-esm-home-schema.ts | 6 ++++++ packages/esm-home-app/src/routes.json | 2 +- 5 files changed, 57 insertions(+), 7 deletions(-) diff --git a/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx b/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx index 482e29741..2cf2d0999 100644 --- a/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx +++ b/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx @@ -1,18 +1,25 @@ import React from 'react'; -import { Tile, Layer } from '@carbon/react'; +import { Tile, Layer, InlineLoading } from '@carbon/react'; import styles from './home-metrics-widget.scss'; import { ArrowRight } from '@carbon/react/icons'; +import { useTestdata } from '../hooks/useTestData'; interface DataTileProps {} const DataTile = () => { - const dataValue = 'default'; - return ( + const { responseData: data, error, isLoading } = useTestdata(); + + // console.log(data, isLoading); + return isLoading ? ( +
+ +
+ ) : ( -
-

Data to display: {dataValue}

+
+
Data to display: {data?.length}
diff --git a/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss b/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss index fef831c2c..622728e02 100644 --- a/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss +++ b/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss @@ -1,5 +1,24 @@ @use '@carbon/styles/scss/spacing'; +@use '@carbon/styles/scss/type'; +@use '@carbon/colors'; +@import '~@openmrs/esm-styleguide/src/vars'; .homeMetricsWidget { - padding: spacing.$spacing-05 + padding: spacing.$spacing-05; +} + +.tileContainer { + border: 0.0625rem solid $ui-03; + height: 7.875rem; + padding: spacing.$spacing-05; + margin: spacing.$spacing-03 spacing.$spacing-03; + max-width: 20rem; +} + +.tileHeader { + font-size: 0.875rem; + font-weight: 600; + line-height: 1.28572; + letter-spacing: 0.16px; + color: #525252; } \ No newline at end of file diff --git a/packages/esm-home-app/src/hooks/useTestData.ts b/packages/esm-home-app/src/hooks/useTestData.ts index e69de29bb..74a64b78a 100644 --- a/packages/esm-home-app/src/hooks/useTestData.ts +++ b/packages/esm-home-app/src/hooks/useTestData.ts @@ -0,0 +1,18 @@ +import React from 'react'; +import { useConfig, FetchResponse, openmrsFetch, toOmrsIsoString, getGlobalStore } from '@openmrs/esm-framework'; +import useSWR from 'swr'; +import dayjs from 'dayjs'; + +interface TestDataProps {} + +export const useTestdata = () => { + const omrsDateFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZZ'; + const appointmentDate = dayjs(new Date().setHours(0, 0, 0, 0)).format(omrsDateFormat); + + const url = `ws/rest/v1/appointment/all?forDate=${appointmentDate}`; + + const { data, error, isLoading } = useSWR<{ data: Array }>(url, openmrsFetch); + + const responseData = data?.data; + return { responseData, error, isLoading }; +}; diff --git a/packages/esm-home-app/src/openmrs-esm-home-schema.ts b/packages/esm-home-app/src/openmrs-esm-home-schema.ts index fad80e60d..df6e42da2 100644 --- a/packages/esm-home-app/src/openmrs-esm-home-schema.ts +++ b/packages/esm-home-app/src/openmrs-esm-home-schema.ts @@ -35,4 +35,10 @@ export const esmHomeSchema = { _validators: [validators.isUrlWithTemplateParameters(['patientUuid'])], }, }, + + // reportingUrl:{ + // _type: Type.String, + // __description: "URL to the reporting tools to be used for this esm", + // _default: "Path to mamba ETL", + // } }; diff --git a/packages/esm-home-app/src/routes.json b/packages/esm-home-app/src/routes.json index 267a10f0d..27fe39f85 100644 --- a/packages/esm-home-app/src/routes.json +++ b/packages/esm-home-app/src/routes.json @@ -47,7 +47,7 @@ "offline": true }, { - "name": "matric-tile", + "name": "metric-tile", "slot": "home-metrics-widgets-slot", "component": "metricTile", "online": true, From 66e4225638c0d9a3a791e717ce79da9231727381 Mon Sep 17 00:00:00 2001 From: arodidev <51090527+arodidev@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:15:42 +0300 Subject: [PATCH 5/8] populate tiles with relevant data --- .../dashboard/home-dashboard.component.tsx | 1 + .../src/dashboard/home-dashboard.scss | 7 +++- .../TestDataTile.component.tsx | 30 ---------------- .../appointments-tile.component.tsx | 28 +++++++++++++++ .../appointments-tile.scss | 20 +++++++++++ .../homepage-metrics/home-metrics-widget.scss | 20 ++--------- .../home-metrics-widgets.component.tsx | 11 ------ .../metrics-container.component.tsx | 17 +++++++++ .../visit-summary.component.tsx | 32 +++++++++++++++++ .../visit-summary-tile/visit-summary.scss | 26 ++++++++++++++ .../visits-tile/visits-tile.component.tsx | 28 +++++++++++++++ .../visits-tile/visits-tile.scss | 20 +++++++++++ .../esm-home-app/src/hooks/useActiveVisits.ts | 35 +++++++++++++++++++ ...{useTestData.ts => useAppointmentsData.ts} | 9 ++--- .../esm-home-app/src/hooks/useVisitSummary.ts | 21 +++++++++++ packages/esm-home-app/src/index.ts | 9 +++-- packages/esm-home-app/src/routes.json | 4 +-- 17 files changed, 245 insertions(+), 73 deletions(-) delete mode 100644 packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx create mode 100644 packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.component.tsx create mode 100644 packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.scss delete mode 100644 packages/esm-home-app/src/homepage-metrics/home-metrics-widgets.component.tsx create mode 100644 packages/esm-home-app/src/homepage-metrics/metrics-container.component.tsx create mode 100644 packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.component.tsx create mode 100644 packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.scss create mode 100644 packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.component.tsx create mode 100644 packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.scss create mode 100644 packages/esm-home-app/src/hooks/useActiveVisits.ts rename packages/esm-home-app/src/hooks/{useTestData.ts => useAppointmentsData.ts} (54%) create mode 100644 packages/esm-home-app/src/hooks/useVisitSummary.ts diff --git a/packages/esm-home-app/src/dashboard/home-dashboard.component.tsx b/packages/esm-home-app/src/dashboard/home-dashboard.component.tsx index 22b89d7cb..d9264ac30 100644 --- a/packages/esm-home-app/src/dashboard/home-dashboard.component.tsx +++ b/packages/esm-home-app/src/dashboard/home-dashboard.component.tsx @@ -19,6 +19,7 @@ export default function HomeDashboard() { return (
{isDesktop(layout) && } +
); diff --git a/packages/esm-home-app/src/dashboard/home-dashboard.scss b/packages/esm-home-app/src/dashboard/home-dashboard.scss index 3b65ae19d..3ac9b32f9 100644 --- a/packages/esm-home-app/src/dashboard/home-dashboard.scss +++ b/packages/esm-home-app/src/dashboard/home-dashboard.scss @@ -14,8 +14,9 @@ width: 100%; } } + /*TO BE REMOVED ONCE WE IMPROVE LEFT SIDE NAVIGATION*/ -li::marker{ +li::marker { font-size: 0px; } @@ -23,3 +24,7 @@ li::marker{ display: flex; justify-content: center; } + +.homeMetricsWidgets { + padding: spacing.$spacing-05; +} \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx b/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx deleted file mode 100644 index 2cf2d0999..000000000 --- a/packages/esm-home-app/src/homepage-metrics/TestDataTile.component.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import { Tile, Layer, InlineLoading } from '@carbon/react'; -import styles from './home-metrics-widget.scss'; -import { ArrowRight } from '@carbon/react/icons'; -import { useTestdata } from '../hooks/useTestData'; - -interface DataTileProps {} - -const DataTile = () => { - const { responseData: data, error, isLoading } = useTestdata(); - - // console.log(data, isLoading); - return isLoading ? ( -
- -
- ) : ( - - - -
-
Data to display: {data?.length}
-
-
-
-
- ); -}; - -export default DataTile; diff --git a/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.component.tsx b/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.component.tsx new file mode 100644 index 000000000..9401e7cef --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.component.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { Tile, Layer, InlineLoading } from '@carbon/react'; +import { useAppointmentsData } from '../../hooks/useAppointmentsData'; +import styles from '../appointments-metric-tile/appointments-tile.scss'; + +const AppointmentsTile: React.FC = () => { + const { responseData: data, error, isLoading } = useAppointmentsData(); + + return ( + + + +
+ {isLoading ? ( +
+ +
+ ) : ( +
Scheduled for Today: {data?.length}
+ )} +
+
+
+
+ ); +}; + +export default AppointmentsTile; diff --git a/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.scss b/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.scss new file mode 100644 index 000000000..fb93c65df --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.scss @@ -0,0 +1,20 @@ +@use '@carbon/styles/scss/spacing'; +@use '@carbon/styles/scss/type'; +@use '@carbon/colors'; +@import '~@openmrs/esm-styleguide/src/vars'; + +.tileContainer { + border: 0.0625rem solid $ui-03; + height: 7.875rem; + padding: spacing.$spacing-05; + margin: spacing.$spacing-03 spacing.$spacing-03; + min-width: 20rem; +} + +.tileHeader { + font-size: 0.875rem; + font-weight: 600; + line-height: 1.28572; + letter-spacing: 0.16px; + color: #525252; +} \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss b/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss index 622728e02..3b8dcb069 100644 --- a/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss +++ b/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss @@ -3,22 +3,6 @@ @use '@carbon/colors'; @import '~@openmrs/esm-styleguide/src/vars'; -.homeMetricsWidget { - padding: spacing.$spacing-05; -} - -.tileContainer { - border: 0.0625rem solid $ui-03; - height: 7.875rem; - padding: spacing.$spacing-05; - margin: spacing.$spacing-03 spacing.$spacing-03; - max-width: 20rem; -} - -.tileHeader { - font-size: 0.875rem; - font-weight: 600; - line-height: 1.28572; - letter-spacing: 0.16px; - color: #525252; +.container { + display: flex; } \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/home-metrics-widgets.component.tsx b/packages/esm-home-app/src/homepage-metrics/home-metrics-widgets.component.tsx deleted file mode 100644 index b95535dd0..000000000 --- a/packages/esm-home-app/src/homepage-metrics/home-metrics-widgets.component.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { ExtensionSlot } from '@openmrs/esm-framework'; -import React from 'react'; -import styles from './home-metrics-widget.scss'; - -interface HomeMetricsWidgetProps {} - -const HomeMetricsWidgets: React.FC = () => { - return ; -}; - -export default HomeMetricsWidgets; diff --git a/packages/esm-home-app/src/homepage-metrics/metrics-container.component.tsx b/packages/esm-home-app/src/homepage-metrics/metrics-container.component.tsx new file mode 100644 index 000000000..a84777781 --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/metrics-container.component.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import AppointmentsTile from './appointments-metric-tile/appointments-tile.component'; +import ActiveVisitTile from './visits-tile/visits-tile.component'; +import styles from '../homepage-metrics/home-metrics-widget.scss'; +import VisitSummary from './visit-summary-tile/visit-summary.component'; + +const MetricsContainer: React.FC = () => { + return ( +
+ + + +
+ ); +}; + +export default MetricsContainer; diff --git a/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.component.tsx b/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.component.tsx new file mode 100644 index 000000000..ebea53900 --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.component.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import styles from '../visits-tile/visits-tile.scss'; +import { useTranslation } from 'react-i18next'; +import { Tile, Layer, InlineLoading } from '@carbon/react'; +import useActiveVisits from '../../hooks/useActiveVisits'; + +const VisitSummary: React.FC = () => { + const { data, isLoading } = useActiveVisits(); + const { t } = useTranslation(); + + return ( + + + +
+ {isLoading ? ( +
+ +
+ ) : ( +
+ {t('totalVisitsToday', 'Total Visits Today')} : {data?.results.length ?? 0} +
+ )} +
+
+
+
+ ); +}; + +export default VisitSummary; diff --git a/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.scss b/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.scss new file mode 100644 index 000000000..42d07978b --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.scss @@ -0,0 +1,26 @@ +@use '@carbon/styles/scss/spacing'; +@use '@carbon/styles/scss/type'; +@use '@carbon/colors'; +@import '~@openmrs/esm-styleguide/src/vars'; + +.tileContainer { + border: 0.0625rem solid $ui-03; + height: 7.875rem; + padding: spacing.$spacing-05; + margin: spacing.$spacing-03 spacing.$spacing-03; + min-width: 20rem; +} + +.tileHeader { + font-size: 0.875rem; + font-weight: 600; + line-height: 1.28572; + letter-spacing: 0.16px; + color: #525252; +} + +.loadingSpinner { + display: flex; + align-items: center; + justify-content: center; +} \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.component.tsx b/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.component.tsx new file mode 100644 index 000000000..9222789d3 --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.component.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import useVisitSummary from '../../hooks/useVisitSummary'; +import { Tile, Layer, InlineLoading } from '@carbon/react'; +import styles from '../visits-tile/visits-tile.scss'; + +const VisitTile: React.FC = () => { + const { data, isLoading } = useVisitSummary(); + + return ( + + + +
+ {isLoading ? ( +
+ +
+ ) : ( +
Active Visits: {data?.results.length ?? 0}
+ )} +
+
+
+
+ ); +}; + +export default VisitTile; diff --git a/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.scss b/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.scss new file mode 100644 index 000000000..fb93c65df --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.scss @@ -0,0 +1,20 @@ +@use '@carbon/styles/scss/spacing'; +@use '@carbon/styles/scss/type'; +@use '@carbon/colors'; +@import '~@openmrs/esm-styleguide/src/vars'; + +.tileContainer { + border: 0.0625rem solid $ui-03; + height: 7.875rem; + padding: spacing.$spacing-05; + margin: spacing.$spacing-03 spacing.$spacing-03; + min-width: 20rem; +} + +.tileHeader { + font-size: 0.875rem; + font-weight: 600; + line-height: 1.28572; + letter-spacing: 0.16px; + color: #525252; +} \ No newline at end of file diff --git a/packages/esm-home-app/src/hooks/useActiveVisits.ts b/packages/esm-home-app/src/hooks/useActiveVisits.ts new file mode 100644 index 000000000..87c4d3280 --- /dev/null +++ b/packages/esm-home-app/src/hooks/useActiveVisits.ts @@ -0,0 +1,35 @@ +import { openmrsFetch, useConfig, useSession, Visit } from '@openmrs/esm-framework'; +import useSWR from 'swr'; +import dayjs from 'dayjs'; + +export function useActiveVisits() { + const session = useSession(); + const sessionLocation = session?.sessionLocation?.uuid; + + const customRepresentation = + 'custom:(uuid,patient:(uuid,identifiers:(identifier,uuid,identifierType:(name,uuid)),person:(age,display,gender,uuid,attributes:(value,attributeType:(uuid,display)))),' + + 'visitType:(uuid,name,display),location:(uuid,name,display),startDatetime,stopDatetime)'; + + const getUrl = () => { + let url = `/ws/rest/v1/visit?v=${customRepresentation}&`; + let urlSearchParams = new URLSearchParams(); + + urlSearchParams.append('includeInactive', 'false'); + urlSearchParams.append('totalCount', 'true'); + urlSearchParams.append('location', `${sessionLocation}`); + + return url + urlSearchParams.toString(); + }; + + const { data, error, isLoading } = useSWR<{ data: { results: any[]; totalCount: number } }>(getUrl, openmrsFetch); + + const reponseData = data?.data; + + return { + data: reponseData, + error, + isLoading, + }; +} + +export default useActiveVisits; diff --git a/packages/esm-home-app/src/hooks/useTestData.ts b/packages/esm-home-app/src/hooks/useAppointmentsData.ts similarity index 54% rename from packages/esm-home-app/src/hooks/useTestData.ts rename to packages/esm-home-app/src/hooks/useAppointmentsData.ts index 74a64b78a..8c0de61de 100644 --- a/packages/esm-home-app/src/hooks/useTestData.ts +++ b/packages/esm-home-app/src/hooks/useAppointmentsData.ts @@ -1,17 +1,14 @@ -import React from 'react'; -import { useConfig, FetchResponse, openmrsFetch, toOmrsIsoString, getGlobalStore } from '@openmrs/esm-framework'; +import { openmrsFetch } from '@openmrs/esm-framework'; import useSWR from 'swr'; import dayjs from 'dayjs'; -interface TestDataProps {} - -export const useTestdata = () => { +export const useAppointmentsData = () => { const omrsDateFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZZ'; const appointmentDate = dayjs(new Date().setHours(0, 0, 0, 0)).format(omrsDateFormat); const url = `ws/rest/v1/appointment/all?forDate=${appointmentDate}`; - const { data, error, isLoading } = useSWR<{ data: Array }>(url, openmrsFetch); + const { data, error, isLoading } = useSWR<{ data: Array }>(url, openmrsFetch); const responseData = data?.data; return { responseData, error, isLoading }; diff --git a/packages/esm-home-app/src/hooks/useVisitSummary.ts b/packages/esm-home-app/src/hooks/useVisitSummary.ts new file mode 100644 index 000000000..29f319125 --- /dev/null +++ b/packages/esm-home-app/src/hooks/useVisitSummary.ts @@ -0,0 +1,21 @@ +import { openmrsFetch, useSession, Visit } from '@openmrs/esm-framework'; +import useSWR from 'swr'; +import dayjs from 'dayjs'; + +const useVisitSummary = () => { + const omrsDateFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZZ'; + const currentVisitDate = dayjs(new Date().setHours(0, 0, 0, 0)).format(omrsDateFormat); + + const visitsUrl = `/ws/rest/v1/visit?includeInactive=true&v=custom:(uuid,patient:(uuid,identifiers:(identifier,uuid),person:(age,display,gender,uuid)),visitType:(uuid,name,display),location:(uuid,name,display),startDatetime,stopDatetime)&fromStartDate=${dayjs( + currentVisitDate, + ).format('YYYY-MM-DD')}`; + // &location=${session?.sessionLocation?.uuid} : to add location filtering + + const { data, error, isLoading } = useSWR<{ data: { results: Visit[] } }>(visitsUrl, openmrsFetch); + + const responseData = data?.data; + + return { data: responseData, error, isLoading }; +}; + +export default useVisitSummary; diff --git a/packages/esm-home-app/src/index.ts b/packages/esm-home-app/src/index.ts index 2ef8c1379..32d6d7f1e 100644 --- a/packages/esm-home-app/src/index.ts +++ b/packages/esm-home-app/src/index.ts @@ -5,8 +5,6 @@ import { esmHomeSchema } from './openmrs-esm-home-schema'; import rootComponent from './root.component'; import homeNavMenuComponent from './side-menu/side-menu.component'; import homeWidgetDashboardComponent from './home-page-widgets/home-page-widgets.component'; -import HomeMetricsWidgetsComponent from './homepage-metrics/home-metrics-widgets.component'; -import DataTile from './homepage-metrics/TestDataTile.component'; const moduleName = '@openmrs/esm-home-app'; const pageName = 'home'; @@ -26,9 +24,10 @@ export const homeWidgetDbLink = getSyncLifecycle(createDashboardLink(dashboardMe export const homeWidgetDashboard = getSyncLifecycle(homeWidgetDashboardComponent, options); -export const homeMetricsWidgetDashboard = getSyncLifecycle(HomeMetricsWidgetsComponent, options); - -export const metricTile = getSyncLifecycle(DataTile, options); +export const metricContainer = getAsyncLifecycle( + () => import('./homepage-metrics/metrics-container.component'), + options, +); export function startupApp() { defineConfigSchema(moduleName, esmHomeSchema); diff --git a/packages/esm-home-app/src/routes.json b/packages/esm-home-app/src/routes.json index 27fe39f85..29cc9f9a1 100644 --- a/packages/esm-home-app/src/routes.json +++ b/packages/esm-home-app/src/routes.json @@ -47,9 +47,9 @@ "offline": true }, { - "name": "metric-tile", + "name": "metric-container", "slot": "home-metrics-widgets-slot", - "component": "metricTile", + "component": "metricContainer", "online": true, "offline": true } From 8b825d8d4ba916529c80ffa8cc069c43deab6bc1 Mon Sep 17 00:00:00 2001 From: arodidev <51090527+arodidev@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:55:00 +0300 Subject: [PATCH 6/8] refactor --- .../src/dashboard/home-dashboard.scss | 4 -- .../appointments-tile.component.tsx | 28 ------------- .../appointments-tile.scss | 20 ---------- .../homepage-metrics/home-metrics-widget.scss | 4 ++ .../metrics-container.component.tsx | 17 +++++--- .../metrics-tile/metrics-tile.component.tsx | 32 +++++++++++++++ .../metrics-tile/metrics-tile.scss | 39 +++++++++++++++++++ .../visit-summary.component.tsx | 32 --------------- .../visit-summary-tile/visit-summary.scss | 26 ------------- .../visits-tile/visits-tile.component.tsx | 28 ------------- .../visits-tile/visits-tile.scss | 20 ---------- .../esm-home-app/src/hooks/useActiveVisits.ts | 8 ++-- .../src/hooks/useAppointmentsData.ts | 7 +++- .../esm-home-app/src/hooks/useVisitSummary.ts | 6 +-- packages/esm-home-app/translations/en.json | 3 +- 15 files changed, 99 insertions(+), 175 deletions(-) delete mode 100644 packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.component.tsx delete mode 100644 packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.scss create mode 100644 packages/esm-home-app/src/homepage-metrics/metrics-tile/metrics-tile.component.tsx create mode 100644 packages/esm-home-app/src/homepage-metrics/metrics-tile/metrics-tile.scss delete mode 100644 packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.component.tsx delete mode 100644 packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.scss delete mode 100644 packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.component.tsx delete mode 100644 packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.scss diff --git a/packages/esm-home-app/src/dashboard/home-dashboard.scss b/packages/esm-home-app/src/dashboard/home-dashboard.scss index 3ac9b32f9..52204848f 100644 --- a/packages/esm-home-app/src/dashboard/home-dashboard.scss +++ b/packages/esm-home-app/src/dashboard/home-dashboard.scss @@ -23,8 +23,4 @@ li::marker { .logoSection { display: flex; justify-content: center; -} - -.homeMetricsWidgets { - padding: spacing.$spacing-05; } \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.component.tsx b/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.component.tsx deleted file mode 100644 index 9401e7cef..000000000 --- a/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.component.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import { Tile, Layer, InlineLoading } from '@carbon/react'; -import { useAppointmentsData } from '../../hooks/useAppointmentsData'; -import styles from '../appointments-metric-tile/appointments-tile.scss'; - -const AppointmentsTile: React.FC = () => { - const { responseData: data, error, isLoading } = useAppointmentsData(); - - return ( - - - -
- {isLoading ? ( -
- -
- ) : ( -
Scheduled for Today: {data?.length}
- )} -
-
-
-
- ); -}; - -export default AppointmentsTile; diff --git a/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.scss b/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.scss deleted file mode 100644 index fb93c65df..000000000 --- a/packages/esm-home-app/src/homepage-metrics/appointments-metric-tile/appointments-tile.scss +++ /dev/null @@ -1,20 +0,0 @@ -@use '@carbon/styles/scss/spacing'; -@use '@carbon/styles/scss/type'; -@use '@carbon/colors'; -@import '~@openmrs/esm-styleguide/src/vars'; - -.tileContainer { - border: 0.0625rem solid $ui-03; - height: 7.875rem; - padding: spacing.$spacing-05; - margin: spacing.$spacing-03 spacing.$spacing-03; - min-width: 20rem; -} - -.tileHeader { - font-size: 0.875rem; - font-weight: 600; - line-height: 1.28572; - letter-spacing: 0.16px; - color: #525252; -} \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss b/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss index 3b8dcb069..bb8772f54 100644 --- a/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss +++ b/packages/esm-home-app/src/homepage-metrics/home-metrics-widget.scss @@ -4,5 +4,9 @@ @import '~@openmrs/esm-styleguide/src/vars'; .container { + background-color: $ui-02; display: flex; + justify-content: space-between; + flex-flow: row wrap; + padding: 0.5rem 0.5rem 0 0.5rem } \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/metrics-container.component.tsx b/packages/esm-home-app/src/homepage-metrics/metrics-container.component.tsx index a84777781..5910f6fde 100644 --- a/packages/esm-home-app/src/homepage-metrics/metrics-container.component.tsx +++ b/packages/esm-home-app/src/homepage-metrics/metrics-container.component.tsx @@ -1,15 +1,20 @@ import React from 'react'; -import AppointmentsTile from './appointments-metric-tile/appointments-tile.component'; -import ActiveVisitTile from './visits-tile/visits-tile.component'; +import MetricTile from './metrics-tile/metrics-tile.component'; import styles from '../homepage-metrics/home-metrics-widget.scss'; -import VisitSummary from './visit-summary-tile/visit-summary.component'; +import useAppointmentsData from '../hooks/useAppointmentsData'; +import useActiveVisits from '../hooks/useActiveVisits'; +import useVisitSummary from '../hooks/useVisitSummary'; const MetricsContainer: React.FC = () => { + const { data: appointmentsData } = useAppointmentsData(); + const { data: activeVisitsData } = useActiveVisits(); + const { data: visitSummaryData } = useVisitSummary(); + return (
- - - + + +
); }; diff --git a/packages/esm-home-app/src/homepage-metrics/metrics-tile/metrics-tile.component.tsx b/packages/esm-home-app/src/homepage-metrics/metrics-tile/metrics-tile.component.tsx new file mode 100644 index 000000000..48a98b930 --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/metrics-tile/metrics-tile.component.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import { Tile, InlineLoading } from '@carbon/react'; +import styles from './metrics-tile.scss'; +import { useTranslation } from 'react-i18next'; + +interface MetricTileProps { + data: any[] | undefined; + header: string; +} + +const VisitTile: React.FC = ({ data, header }) => { + const { t } = useTranslation(); + return ( + + +
+
+
+
{t('tileHeader', header)}
+
+
+
Patients
+
{data?.length}
+
+
+
+
+
+ ); +}; + +export default VisitTile; diff --git a/packages/esm-home-app/src/homepage-metrics/metrics-tile/metrics-tile.scss b/packages/esm-home-app/src/homepage-metrics/metrics-tile/metrics-tile.scss new file mode 100644 index 000000000..39c13b8da --- /dev/null +++ b/packages/esm-home-app/src/homepage-metrics/metrics-tile/metrics-tile.scss @@ -0,0 +1,39 @@ +@use '@carbon/styles/scss/spacing'; +@use '@carbon/styles/scss/type'; +@use '@carbon/colors'; +@import '~@openmrs/esm-styleguide/src/vars'; + +.tileContent { + display: flex; + flex-direction: column; + align-items: space-between; +} + +.tileContainer { + background-color: white; + border: 0.0625rem solid #e0e0e0; + height: 7.875rem; + padding: 1rem; + margin: 0.5rem 0.5rem; + flex-grow: 1; +} + +.tileHeader { + font-size: 0.875rem; + font-weight: 600; + line-height: 1.28572; + letter-spacing: 0.16px; + color: #525252; +} + +.displayDetails { + margin-top: 1.5rem; +} + +.displayData { + font-size: 1.75rem; + font-weight: 400; + line-height: 1.28572; + letter-spacing: 0; + color: #161616; +} \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.component.tsx b/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.component.tsx deleted file mode 100644 index ebea53900..000000000 --- a/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.component.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import React from 'react'; -import styles from '../visits-tile/visits-tile.scss'; -import { useTranslation } from 'react-i18next'; -import { Tile, Layer, InlineLoading } from '@carbon/react'; -import useActiveVisits from '../../hooks/useActiveVisits'; - -const VisitSummary: React.FC = () => { - const { data, isLoading } = useActiveVisits(); - const { t } = useTranslation(); - - return ( - - - -
- {isLoading ? ( -
- -
- ) : ( -
- {t('totalVisitsToday', 'Total Visits Today')} : {data?.results.length ?? 0} -
- )} -
-
-
-
- ); -}; - -export default VisitSummary; diff --git a/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.scss b/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.scss deleted file mode 100644 index 42d07978b..000000000 --- a/packages/esm-home-app/src/homepage-metrics/visit-summary-tile/visit-summary.scss +++ /dev/null @@ -1,26 +0,0 @@ -@use '@carbon/styles/scss/spacing'; -@use '@carbon/styles/scss/type'; -@use '@carbon/colors'; -@import '~@openmrs/esm-styleguide/src/vars'; - -.tileContainer { - border: 0.0625rem solid $ui-03; - height: 7.875rem; - padding: spacing.$spacing-05; - margin: spacing.$spacing-03 spacing.$spacing-03; - min-width: 20rem; -} - -.tileHeader { - font-size: 0.875rem; - font-weight: 600; - line-height: 1.28572; - letter-spacing: 0.16px; - color: #525252; -} - -.loadingSpinner { - display: flex; - align-items: center; - justify-content: center; -} \ No newline at end of file diff --git a/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.component.tsx b/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.component.tsx deleted file mode 100644 index 9222789d3..000000000 --- a/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.component.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import useVisitSummary from '../../hooks/useVisitSummary'; -import { Tile, Layer, InlineLoading } from '@carbon/react'; -import styles from '../visits-tile/visits-tile.scss'; - -const VisitTile: React.FC = () => { - const { data, isLoading } = useVisitSummary(); - - return ( - - - -
- {isLoading ? ( -
- -
- ) : ( -
Active Visits: {data?.results.length ?? 0}
- )} -
-
-
-
- ); -}; - -export default VisitTile; diff --git a/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.scss b/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.scss deleted file mode 100644 index fb93c65df..000000000 --- a/packages/esm-home-app/src/homepage-metrics/visits-tile/visits-tile.scss +++ /dev/null @@ -1,20 +0,0 @@ -@use '@carbon/styles/scss/spacing'; -@use '@carbon/styles/scss/type'; -@use '@carbon/colors'; -@import '~@openmrs/esm-styleguide/src/vars'; - -.tileContainer { - border: 0.0625rem solid $ui-03; - height: 7.875rem; - padding: spacing.$spacing-05; - margin: spacing.$spacing-03 spacing.$spacing-03; - min-width: 20rem; -} - -.tileHeader { - font-size: 0.875rem; - font-weight: 600; - line-height: 1.28572; - letter-spacing: 0.16px; - color: #525252; -} \ No newline at end of file diff --git a/packages/esm-home-app/src/hooks/useActiveVisits.ts b/packages/esm-home-app/src/hooks/useActiveVisits.ts index 87c4d3280..81f28a10b 100644 --- a/packages/esm-home-app/src/hooks/useActiveVisits.ts +++ b/packages/esm-home-app/src/hooks/useActiveVisits.ts @@ -6,9 +6,7 @@ export function useActiveVisits() { const session = useSession(); const sessionLocation = session?.sessionLocation?.uuid; - const customRepresentation = - 'custom:(uuid,patient:(uuid,identifiers:(identifier,uuid,identifierType:(name,uuid)),person:(age,display,gender,uuid,attributes:(value,attributeType:(uuid,display)))),' + - 'visitType:(uuid,name,display),location:(uuid,name,display),startDatetime,stopDatetime)'; + const customRepresentation = 'custom:(uuid,startDatetime,stopDatetime)'; const getUrl = () => { let url = `/ws/rest/v1/visit?v=${customRepresentation}&`; @@ -23,10 +21,10 @@ export function useActiveVisits() { const { data, error, isLoading } = useSWR<{ data: { results: any[]; totalCount: number } }>(getUrl, openmrsFetch); - const reponseData = data?.data; + const responseData = data?.data.results; return { - data: reponseData, + data: responseData, error, isLoading, }; diff --git a/packages/esm-home-app/src/hooks/useAppointmentsData.ts b/packages/esm-home-app/src/hooks/useAppointmentsData.ts index 8c0de61de..63c313271 100644 --- a/packages/esm-home-app/src/hooks/useAppointmentsData.ts +++ b/packages/esm-home-app/src/hooks/useAppointmentsData.ts @@ -2,7 +2,7 @@ import { openmrsFetch } from '@openmrs/esm-framework'; import useSWR from 'swr'; import dayjs from 'dayjs'; -export const useAppointmentsData = () => { +const useAppointmentsData = () => { const omrsDateFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZZ'; const appointmentDate = dayjs(new Date().setHours(0, 0, 0, 0)).format(omrsDateFormat); @@ -11,5 +11,8 @@ export const useAppointmentsData = () => { const { data, error, isLoading } = useSWR<{ data: Array }>(url, openmrsFetch); const responseData = data?.data; - return { responseData, error, isLoading }; + + return { data: responseData, error, isLoading }; }; + +export default useAppointmentsData; diff --git a/packages/esm-home-app/src/hooks/useVisitSummary.ts b/packages/esm-home-app/src/hooks/useVisitSummary.ts index 29f319125..86ab6f224 100644 --- a/packages/esm-home-app/src/hooks/useVisitSummary.ts +++ b/packages/esm-home-app/src/hooks/useVisitSummary.ts @@ -5,15 +5,15 @@ import dayjs from 'dayjs'; const useVisitSummary = () => { const omrsDateFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZZ'; const currentVisitDate = dayjs(new Date().setHours(0, 0, 0, 0)).format(omrsDateFormat); + const customRepresentation = 'custom:(uuid,startDatetime,stopDatetime)'; - const visitsUrl = `/ws/rest/v1/visit?includeInactive=true&v=custom:(uuid,patient:(uuid,identifiers:(identifier,uuid),person:(age,display,gender,uuid)),visitType:(uuid,name,display),location:(uuid,name,display),startDatetime,stopDatetime)&fromStartDate=${dayjs( + const visitsUrl = `/ws/rest/v1/visit?includeInactive=true&v=${customRepresentation}&fromStartDate=${dayjs( currentVisitDate, ).format('YYYY-MM-DD')}`; - // &location=${session?.sessionLocation?.uuid} : to add location filtering const { data, error, isLoading } = useSWR<{ data: { results: Visit[] } }>(visitsUrl, openmrsFetch); - const responseData = data?.data; + const responseData = data?.data.results; return { data: responseData, error, isLoading }; }; diff --git a/packages/esm-home-app/translations/en.json b/packages/esm-home-app/translations/en.json index a5ff8c612..12729694e 100644 --- a/packages/esm-home-app/translations/en.json +++ b/packages/esm-home-app/translations/en.json @@ -1,3 +1,4 @@ { - "Home": "Home" + "Home": "Home", + "totalVisitsToday": "Total Visits Today" } From dff9a8ad4c338a675456b3e4b6fa3544e8d05bd5 Mon Sep 17 00:00:00 2001 From: arodidev <51090527+arodidev@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:55:25 +0300 Subject: [PATCH 7/8] translations --- packages/esm-home-app/translations/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/esm-home-app/translations/en.json b/packages/esm-home-app/translations/en.json index 12729694e..b01fbb107 100644 --- a/packages/esm-home-app/translations/en.json +++ b/packages/esm-home-app/translations/en.json @@ -1,4 +1,4 @@ { "Home": "Home", - "totalVisitsToday": "Total Visits Today" + "tileHeader": "" } From a08da1f5d2bd4cbe1c03a50136774415c7608696 Mon Sep 17 00:00:00 2001 From: arodidev <51090527+arodidev@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:05:05 +0300 Subject: [PATCH 8/8] cleanup --- packages/esm-home-app/src/openmrs-esm-home-schema.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/esm-home-app/src/openmrs-esm-home-schema.ts b/packages/esm-home-app/src/openmrs-esm-home-schema.ts index df6e42da2..fad80e60d 100644 --- a/packages/esm-home-app/src/openmrs-esm-home-schema.ts +++ b/packages/esm-home-app/src/openmrs-esm-home-schema.ts @@ -35,10 +35,4 @@ export const esmHomeSchema = { _validators: [validators.isUrlWithTemplateParameters(['patientUuid'])], }, }, - - // reportingUrl:{ - // _type: Type.String, - // __description: "URL to the reporting tools to be used for this esm", - // _default: "Path to mamba ETL", - // } };