From fd7e87b0fef374eda3e361e698bf27bc688b42c0 Mon Sep 17 00:00:00 2001 From: pirupius Date: Wed, 19 Apr 2023 13:09:00 +0300 Subject: [PATCH] type refactors --- packages/esm-commons-lib/src/api/types.ts | 59 +++++++++++++++++++ packages/esm-covid-app/src/dashboard.meta.tsx | 8 +-- packages/esm-hiv-app/src/dashboard.meta.tsx | 19 +++++- .../esm-ohri-pmtct-app/src/dashboard.meta.tsx | 2 +- 4 files changed, 81 insertions(+), 7 deletions(-) diff --git a/packages/esm-commons-lib/src/api/types.ts b/packages/esm-commons-lib/src/api/types.ts index 6f495f9d0..c9b20ec4d 100644 --- a/packages/esm-commons-lib/src/api/types.ts +++ b/packages/esm-commons-lib/src/api/types.ts @@ -219,3 +219,62 @@ export interface PatientListRow { lastVisit?: string; actions?: React.ReactNode; } + +export interface PatientChartMeta { + /** + * Defines the slot name in slug case e.g. "covid-chart-summary" + */ + slot: string; + columns: number; + title: string; +} + +// OHRI Dashboard Types +export interface OhriDashboardMeta { + /** + * Used to generate the menu title displayed on the sidenav + * @example "Covid Cases" + */ + menuTitle: string; + slot: string; + config: { + columns?: number; + type: string; + /** + * Conditionally rendor icon on menu item + */ + icon?: React.Component; + }; + /** + * Determines if the dashboard is a folder + */ + isFolder?: boolean; +} + +export interface OhriDashboardLinkMeta { + /** + * Used to generate route and slot names + * @example "covid-cases" + */ + name: string; + slot: string; + /** + * Used to generate the menu title displayed on the sidenav + * @example "Covid Cases" + */ + title: string; + config: { + columns?: number; + type?: string; + programme: string; + /** + * Title displayed on the welcome section of the dashboard + */ + dashboardTitle?: string; + /** + * Conditionally rendor icon on menu item + */ + icon?: React.Component; + }; + isLink?: boolean; +} diff --git a/packages/esm-covid-app/src/dashboard.meta.tsx b/packages/esm-covid-app/src/dashboard.meta.tsx index 769a7e59c..c2e2861a4 100644 --- a/packages/esm-covid-app/src/dashboard.meta.tsx +++ b/packages/esm-covid-app/src/dashboard.meta.tsx @@ -1,4 +1,5 @@ import { Coronavirus } from '@carbon/react/icons'; +import { OhriDashboardLinkMeta, OhriDashboardMeta } from '@ohri/openmrs-esm-ohri-commons-lib'; // Patient Chart Dashboards export const covidPatientChartMeta = { @@ -32,17 +33,16 @@ export const covidVaccinationsDashboardMeta = { }; // Clinical Dashboards -export const covidClinicalViewDashboardMeta = { +export const covidClinicalViewDashboardMeta: OhriDashboardMeta = { + menuTitle: 'COVID', slot: 'ohri-covid-dashboard-slot', config: { columns: 1, type: 'grid', icon: Coronavirus }, isFolder: true, - title: 'COVID', }; -export const covid19CasesDashboardMeta = { +export const covid19CasesDashboardMeta: OhriDashboardLinkMeta = { name: 'covid-cases', slot: 'covid-cases-dashboard-slot', config: { columns: 1, type: 'grid', programme: 'covid', icon: Coronavirus }, title: 'COVID-19 Cases', - dashboardIcon: Coronavirus, }; diff --git a/packages/esm-hiv-app/src/dashboard.meta.tsx b/packages/esm-hiv-app/src/dashboard.meta.tsx index cdbf0abc8..7ed9404ab 100644 --- a/packages/esm-hiv-app/src/dashboard.meta.tsx +++ b/packages/esm-hiv-app/src/dashboard.meta.tsx @@ -1,4 +1,5 @@ import { Home, Pills } from '@carbon/react/icons'; +import { OhriDashboardLinkMeta, OhriDashboardMeta } from '@ohri/openmrs-esm-ohri-commons-lib'; // Patient Chart Dashboards export const hivPreventionDashboardMeta = { @@ -92,16 +93,30 @@ export const hivPreventionFolderDashboardMeta = { title: 'HIV Prevention', }; -export const htsDashboardMeta = { +export const hivFolderDashboardMeta: OhriDashboardMeta = { + slot: 'ohri-hiv-dashboard-slot', + config: { columns: 1, type: 'grid', icon: Home }, + isFolder: true, + menuTitle: 'HIV', +}; + +export const htsDashboardMeta: OhriDashboardLinkMeta = { name: 'hts', slot: 'hts-dashboard-slot', config: { columns: 1, type: 'grid', programme: 'hts', dashboardTitle: 'HTS Home Page' }, title: 'HIV Testing Services', }; -export const careAndTreatmentDashboardMeta = { +export const careAndTreatmentDashboardMeta: OhriDashboardLinkMeta = { name: 'care-and-treatment', slot: 'ct-dashboard-slot', config: { columns: 1, type: 'grid', programme: 'ct', dashboardTitle: 'C&T Home Page' }, title: 'Care and Treatment', }; + +export const labResultsDashboardMeta: OhriDashboardLinkMeta = { + name: 'lab-results', + slot: 'lab-results-dashboard-slot', + config: { columns: 1, type: 'grid', programme: 'lab-results', dashboardTitle: 'Lab Results Home Page' }, + title: 'Lab Results', +}; diff --git a/packages/esm-ohri-pmtct-app/src/dashboard.meta.tsx b/packages/esm-ohri-pmtct-app/src/dashboard.meta.tsx index a324ee6e3..d29b8fbf8 100644 --- a/packages/esm-ohri-pmtct-app/src/dashboard.meta.tsx +++ b/packages/esm-ohri-pmtct-app/src/dashboard.meta.tsx @@ -37,6 +37,7 @@ export const childVisitsDashboardMeta = { export const motherChildDashboardMeta = { name: 'mother-child-health', slot: 'mother-child-health-dashboard-slot', + menuTitle: 'Maternal & Child Health', config: { columns: 1, type: 'grid', @@ -45,5 +46,4 @@ export const motherChildDashboardMeta = { icon: PedestrianChild, }, isLink: true, - title: 'Maternal & Child Health', };