diff --git a/packages/esm-patient-chart-app/src/patient-summary/patient-hiv-encounter-summary.component.tsx b/packages/esm-patient-chart-app/src/clinical-views/components/patient-program-summary.component.tsx similarity index 59% rename from packages/esm-patient-chart-app/src/patient-summary/patient-hiv-encounter-summary.component.tsx rename to packages/esm-patient-chart-app/src/clinical-views/components/patient-program-summary.component.tsx index 5fd8fbc80c..701baa3bcf 100644 --- a/packages/esm-patient-chart-app/src/patient-summary/patient-hiv-encounter-summary.component.tsx +++ b/packages/esm-patient-chart-app/src/clinical-views/components/patient-program-summary.component.tsx @@ -1,9 +1,7 @@ import React from 'react'; import { useConfig } from '@openmrs/esm-framework'; -import serviceSummaryConfig from './service-summary-config.json'; - -import { EncounterTile, type EncounterTileColumn } from '../encounter-tile/encounter-tile.component'; -import { getEncounterTileColumns } from '../encounter-list/encounter-tile-config-builder'; +import { getEncounterTileColumns } from '../../encounter-tile/utils/encounter-tile-config-builder'; +import { EncounterTile, type EncounterTileColumn } from '../../encounter-tile/components/encounter-tile.component'; interface OverviewListProps { patientUuid: string; @@ -16,13 +14,12 @@ interface TileDefinition { const HIVSummaryOverviewList: React.FC = ({ patientUuid }) => { const config = useConfig(); - //console.log(config) - const tilesDefinitions = serviceSummaryConfig['encounter-tiles-group'].tilesDefinitions; + const tilesDefinitions = config.tilesDefinitions; const tilesData: Array = tilesDefinitions.map((tile: any) => ({ - title: tile.title, - columns: getEncounterTileColumns(tile, config), + title: tile.tileHeader, + columns: getEncounterTileColumns(tile), })); return ( diff --git a/packages/esm-patient-chart-app/src/dashboard.meta.ts b/packages/esm-patient-chart-app/src/dashboard.meta.ts index 4eb02555e4..dc827279a1 100644 --- a/packages/esm-patient-chart-app/src/dashboard.meta.ts +++ b/packages/esm-patient-chart-app/src/dashboard.meta.ts @@ -9,16 +9,3 @@ export const encountersDashboardMeta = { path: 'Visits', title: 'Visits', }; - -//clinical views -export const hivPatientSummaryDashboardMeta = { - slot: 'hiv-care-and-treatment-group-slot', - path: 'hiv-patient-summary', - title: 'HIV Patient Summary', -}; - -export const programManagementDashboardMeta = { - slot: 'hiv-care-and-treatment-group-slot', - path: 'hiv-program-management', - title: 'HIV Program Management', -}; diff --git a/packages/esm-patient-chart-app/src/encounter-list/api.resource.ts b/packages/esm-patient-chart-app/src/encounter-list/api.resource.ts deleted file mode 100644 index 413a130c70..0000000000 --- a/packages/esm-patient-chart-app/src/encounter-list/api.resource.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; -import dayjs from 'dayjs'; - -export function fetchPatientRelationships(patientUuid: string) { - return openmrsFetch(`${restBaseUrl}/relationship?person=${patientUuid}&v=full`).then(({ data }) => { - if (data.results.length) { - return data.results; - } - return null; - }); -} diff --git a/packages/esm-patient-chart-app/src/encounter-list/shema-manipulation.ts b/packages/esm-patient-chart-app/src/encounter-list/shema-manipulation.ts deleted file mode 100644 index 25d6b5ac3d..0000000000 --- a/packages/esm-patient-chart-app/src/encounter-list/shema-manipulation.ts +++ /dev/null @@ -1,52 +0,0 @@ -export function extractSchemaValues(schema) { - const result = {}; - function traverse(obj) { - if (obj === null || obj === undefined || typeof obj !== 'object') { - return; - } - Object.entries(obj).forEach(([key, value]) => { - if (value !== undefined && value !== null) { - if (typeof value === 'object' && !Array.isArray(value)) { - traverse(value); - } else { - result[key] = value; - } - } - }); - } - - traverse(schema); - return result; -} - -export function replaceWithConfigDefaults(obj, configDefaults) { - if (Array.isArray(obj)) { - return obj.map((item) => { - if (typeof item === 'string' && configDefaults.hasOwnProperty(item)) { - return configDefaults[item]; - } else { - return replaceWithConfigDefaults(item, configDefaults); - } - }); - } else if (typeof obj === 'object' && obj !== null) { - const newObj = {}; - for (const key in obj) { - if (typeof obj[key] === 'string') { - if (configDefaults.hasOwnProperty(key)) { - // Case where UUID is the value - newObj[configDefaults[key]] = obj[key]; - } else if (configDefaults.hasOwnProperty(obj[key])) { - // Case where UUID is the key - newObj[key] = configDefaults[obj[key]]; - } else { - newObj[key] = obj[key]; - } - } else { - newObj[key] = replaceWithConfigDefaults(obj[key], configDefaults); - } - } - return newObj; - } else { - return obj; - } -} diff --git a/packages/esm-patient-chart-app/src/encounter-tile/encounter-tile.component.tsx b/packages/esm-patient-chart-app/src/encounter-tile/components/encounter-tile.component.tsx similarity index 97% rename from packages/esm-patient-chart-app/src/encounter-tile/encounter-tile.component.tsx rename to packages/esm-patient-chart-app/src/encounter-tile/components/encounter-tile.component.tsx index 70d6e3c47e..fb318625bc 100644 --- a/packages/esm-patient-chart-app/src/encounter-tile/encounter-tile.component.tsx +++ b/packages/esm-patient-chart-app/src/encounter-tile/components/encounter-tile.component.tsx @@ -1,7 +1,7 @@ import { CodeSnippetSkeleton, Tile, Column } from '@carbon/react'; import React from 'react'; import styles from './tile.scss'; -import { LazyCell } from '../lazy-cell/lazy-cell.component'; +import { LazyCell } from '../../lazy-cell/lazy-cell.component'; import { useLastEncounter } from '../hooks/useLastEncounter'; export interface EncounterTileColumn { diff --git a/packages/esm-patient-chart-app/src/encounter-tile/tile.scss b/packages/esm-patient-chart-app/src/encounter-tile/components/tile.scss similarity index 96% rename from packages/esm-patient-chart-app/src/encounter-tile/tile.scss rename to packages/esm-patient-chart-app/src/encounter-tile/components/tile.scss index 4a8bc2995d..36a1ab3c1f 100644 --- a/packages/esm-patient-chart-app/src/encounter-tile/tile.scss +++ b/packages/esm-patient-chart-app/src/encounter-tile/components/tile.scss @@ -3,7 +3,7 @@ @use '@openmrs/esm-styleguide/src/vars' as *; .title { - @include type.productiveHeading03; + @include type.type-style('productive-heading-03'); } .title:after { @@ -21,7 +21,7 @@ } .tile { - height: 100%; + height: 35%; padding: layout.$spacing-01 0 layout.$spacing-05 layout.$spacing-05; margin: layout.$spacing-03; border: solid 1px #e0e0e0; diff --git a/packages/esm-patient-chart-app/src/hooks/useLastEncounter.ts b/packages/esm-patient-chart-app/src/encounter-tile/hooks/useLastEncounter.ts similarity index 92% rename from packages/esm-patient-chart-app/src/hooks/useLastEncounter.ts rename to packages/esm-patient-chart-app/src/encounter-tile/hooks/useLastEncounter.ts index 43a983b7b5..71aab27749 100644 --- a/packages/esm-patient-chart-app/src/hooks/useLastEncounter.ts +++ b/packages/esm-patient-chart-app/src/encounter-tile/hooks/useLastEncounter.ts @@ -1,5 +1,5 @@ import { openmrsFetch } from '@openmrs/esm-framework'; -import { type OpenmrsEncounter } from '../../../esm-patient-common-lib/src/types'; +import { type OpenmrsEncounter } from '@openmrs/esm-patient-common-lib'; import useSWR from 'swr'; diff --git a/packages/esm-patient-chart-app/src/encounter-tile/summary-card.component.tsx b/packages/esm-patient-chart-app/src/encounter-tile/summary-card.component.tsx deleted file mode 100644 index 699846e567..0000000000 --- a/packages/esm-patient-chart-app/src/encounter-tile/summary-card.component.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React, { useMemo } from 'react'; -import { Tile, Column } from '@carbon/react'; -import styles from './tile.scss'; - -export interface SummaryCardProps { - columns: Array; - headerTitle: string; - maxRowItems?: number; -} - -export interface SummaryCardColumn { - header: string; - value: string; - summary?: string; -} - -export const SummaryCard = ({ columns, headerTitle, maxRowItems }: SummaryCardProps) => { - const groupedColumns = useMemo(() => { - if (maxRowItems && columns.length > maxRowItems) { - let groups: SummaryCardColumn[][] = []; - for (let i = 0; i < columns.length; i += maxRowItems) { - groups.push(columns.slice(i, i + maxRowItems)); - } - return groups; - } - return [columns]; - }, [columns, maxRowItems]); - - return ( - -
-

{headerTitle}

-
- {maxRowItems ? ( - groupedColumns.map((group) => ( - - {group.map((column, index) => ( - - ))} - - )) - ) : ( - - {columns.map((column, index) => ( - - ))} - - )} -
- ); -}; - -function SummaryItem({ column }: { column: SummaryCardColumn }) { - return ( -
-
- {column.header} - {column.value} - {column.summary && {column.summary}} -
-
- ); -} diff --git a/packages/esm-patient-chart-app/src/encounter-list/encounter-tile-config-builder.ts b/packages/esm-patient-chart-app/src/encounter-tile/utils/encounter-tile-config-builder.ts similarity index 80% rename from packages/esm-patient-chart-app/src/encounter-list/encounter-tile-config-builder.ts rename to packages/esm-patient-chart-app/src/encounter-tile/utils/encounter-tile-config-builder.ts index 61fcf8b6ab..3c4c82800f 100644 --- a/packages/esm-patient-chart-app/src/encounter-list/encounter-tile-config-builder.ts +++ b/packages/esm-patient-chart-app/src/encounter-tile/utils/encounter-tile-config-builder.ts @@ -1,5 +1,4 @@ -import { getConceptFromMappings, getObsFromEncounter } from './encounter-list-utils'; -import { extractSchemaValues, replaceWithConfigDefaults } from './shema-manipulation'; +import { getConceptFromMappings, getObsFromEncounter } from './helpers'; interface MenuCardProps { title: string; @@ -21,6 +20,9 @@ interface ColumnDefinition { hasSummary?: boolean; conceptMappings?: Array; summaryConcept?: SummaryConcept; + isTrueFalseConcept?: boolean; + type: string; + fallbackConcepts?: Array; } interface FormattedCardColumn { @@ -39,11 +41,8 @@ const calculateDateDifferenceInDate = (givenDate: string): string => { return `${totalDays} days`; }; -export const getEncounterTileColumns = (schemaConfig: MenuCardProps, config = null) => { - const configDefaults = extractSchemaValues(config); - const transformedSchemaConfig = replaceWithConfigDefaults(schemaConfig, configDefaults); - - const columns: Array = transformedSchemaConfig.columns?.map((column) => ({ +export const getEncounterTileColumns = (tileDefinition: MenuCardProps) => { + const columns: Array = tileDefinition.columns?.map((column) => ({ key: column.id, header: column.title, concept: column.concept, @@ -78,7 +77,7 @@ export const getEncounterTileColumns = (schemaConfig: MenuCardProps, config = nu const primaryDate = getObsFromEncounter( encounter, column.summaryConcept.primaryConcept, - column.summaryConcept.hasDate, + column.summaryConcept.isDate, ); if (primaryDate !== '--') { @@ -88,7 +87,7 @@ export const getEncounterTileColumns = (schemaConfig: MenuCardProps, config = nu } } - return getObsFromEncounter(encounter, column.summaryConcept.primaryConcept, column.summaryConcept.hasDate); + return getObsFromEncounter(encounter, column.summaryConcept.primaryConcept, column.summaryConcept.isDate); } : null, })); diff --git a/packages/esm-patient-chart-app/src/encounter-list/encounter-list-utils.ts b/packages/esm-patient-chart-app/src/encounter-tile/utils/helpers.ts similarity index 100% rename from packages/esm-patient-chart-app/src/encounter-list/encounter-list-utils.ts rename to packages/esm-patient-chart-app/src/encounter-tile/utils/helpers.ts diff --git a/packages/esm-patient-chart-app/src/index.ts b/packages/esm-patient-chart-app/src/index.ts index 5258407139..475d0fb1c3 100644 --- a/packages/esm-patient-chart-app/src/index.ts +++ b/packages/esm-patient-chart-app/src/index.ts @@ -12,12 +12,7 @@ import { genericDashboardConfigSchema } from './side-nav/generic-dashboard.compo import { genericNavGroupConfigSchema } from './side-nav/generic-nav-group.component'; import { moduleName } from './constants'; import { setupOfflineVisitsSync, setupCacheableRoutes } from './offline'; -import { - summaryDashboardMeta, - encountersDashboardMeta, - hivPatientSummaryDashboardMeta, - programManagementDashboardMeta, -} from './dashboard.meta'; +import { summaryDashboardMeta, encountersDashboardMeta } from './dashboard.meta'; import addPastVisitActionButtonComponent from './actions-buttons/add-past-visit.component'; import cancelVisitActionButtonComponent from './actions-buttons/cancel-visit.component'; import currentVisitSummaryComponent from './visit/visits-widget/current-visit-summary.component'; @@ -35,9 +30,7 @@ import startVisitActionButtonOnPatientSearch from './visit/start-visit-button.co import startVisitFormComponent from './visit/visit-form/visit-form.component'; import stopVisitActionButtonComponent from './actions-buttons/stop-visit.component'; import visitAttributeTagsComponent from './patient-banner-tags/visit-attribute-tags.component'; -import { PatientSummaryCardContainer } from './patient-summary/patient-summary.component'; -import { ProgramManagement } from './patient-summary/program-management.component'; -import HIVSummaryOverviewList from './patient-summary/patient-hiv-encounter-summary.component'; +import HIVSummaryOverviewList from './clinical-views/components/patient-program-summary.component'; // This allows @openmrs/esm-patient-common-lib to be accessed by modules that are not // using webpack. This is used for ngx-formentry. @@ -119,17 +112,9 @@ export const stopVisitPatientSearchActionButton = getSyncLifecycle(stopVisitActi featureName: 'patient-actions-slot', moduleName, }); -// export const patientSummaryCardContainer = getSyncLifecycle(PatientSummaryCardContainer, { -// featureName: 'encounter-tiles-group', -// moduleName, -// }); -export const patientSummaryCardContainer = getSyncLifecycle(HIVSummaryOverviewList, { - featureName: 'encounter-tiles-group', - moduleName, -}); -export const programManagementComponent = getSyncLifecycle(ProgramManagement, { - featureName: 'encounter-list-table-tabs', +export const patientProgramSummary = getSyncLifecycle(HIVSummaryOverviewList, { + featureName: 'program-summary', moduleName, }); @@ -153,22 +138,6 @@ export const encountersSummaryDashboardLink = { featureName: 'encounter', moduleName }, ); -export const hivPatientSummaryDashboardLink = getSyncLifecycle( - createDashboardLink({ - ...hivPatientSummaryDashboardMeta, - moduleName, - }), - { featureName: 'hiv-patient-summary', moduleName }, -); - -export const hivPatientManagementDashboardLink = getSyncLifecycle( - createDashboardLink({ - ...programManagementDashboardMeta, - moduleName, - }), - { featureName: 'hiv-patient-summary', moduleName }, -); - export const currentVisitSummary = getSyncLifecycle(currentVisitSummaryComponent, { featureName: 'current-visit-summary', moduleName, diff --git a/packages/esm-patient-chart-app/src/patient-summary/patient-summary.component.tsx b/packages/esm-patient-chart-app/src/patient-summary/patient-summary.component.tsx deleted file mode 100644 index 077ef1bd63..0000000000 --- a/packages/esm-patient-chart-app/src/patient-summary/patient-summary.component.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -//import { SummaryCard } from "@openmrs/esm-patient-common-lib"; -import { useConfig } from '@openmrs/esm-framework'; -import { SummaryCard } from '../encounter-tile/summary-card.component'; - -export function PatientSummaryCardContainer() { - const config = useConfig(); - const testColumns = [ - { - header: 'Age', - value: '34', - summary: 'No country for old men', - }, - { - header: 'Marital Status', - value: 'Married', - }, - { - header: 'Number of Children', - value: '10', - }, - { - header: 'DOB', - value: '10/04/1990', - }, - ]; - - return ; -} diff --git a/packages/esm-patient-chart-app/src/patient-summary/program-management.component.tsx b/packages/esm-patient-chart-app/src/patient-summary/program-management.component.tsx deleted file mode 100644 index 4f08cd8832..0000000000 --- a/packages/esm-patient-chart-app/src/patient-summary/program-management.component.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react'; -import { EmptyState } from '@openmrs/esm-patient-common-lib'; - -export function ProgramManagement() { - return ; -} diff --git a/packages/esm-patient-chart-app/src/patient-summary/service-summary-config.json b/packages/esm-patient-chart-app/src/patient-summary/service-summary-config.json deleted file mode 100644 index f6c81443dd..0000000000 --- a/packages/esm-patient-chart-app/src/patient-summary/service-summary-config.json +++ /dev/null @@ -1,137 +0,0 @@ -{ - "encounter-tiles-group" : { - "tilesDefinitions" : [ - { - "title": "Characteristics", - "columns": [ - { - "id": "artCohort", - "title": "ART Cohort", - "encounterType": "art_Therapy_EncounterUUID", - "concept": "artTherapyDateTime_UUID", - "isDate": true, - "conceptMappings": [ - "artTherapyDateTime_UUID", - "artStopDateUUID", - "switchDateUUID", - "substitutionDateUUID", - "dateRestartedUUID" - ] - }, - { - "id": "currentRegimen", - "hasSummary": true, - "title": "Current Regimen", - "encounterType": "art_Therapy_EncounterUUID", - "concept": "regimenConcept", - "summaryConcept": { - "primaryConcept": "regimenLine_UUID" - } - }, - { - "id": "dsdModel", - "title": "DSD Model", - "hasSummary": true, - "encounterType": "ServiceDeliveryEncounterType_UUID", - "concept": "CommunityDSDModel_UUID", - "summaryConcept": { - "primaryConcept": "CommunityDSDModel_UUID" - } - }, - { - "id": "populationType", - "title": "Population Type", - "encounterType": "careAndTreatmentEncounterType", - "concept": "populationCategoryConcept", - "hasSummary": true, - "summaryConcept": { - "primaryConcept": "keyPopulationTypeConcept", - "secondaryConcept": "priorityPopulationTypeConcept" - } - } - ] - }, - { - "title": "HIV Monitoring", - "columns": [ - { - "id": "viralLoad", - "title": "Current Viral Load", - "encounterType": "ViralLoadResultsEncounter_UUID", - "concept": "ViralLoadResult_UUID", - "hasSummary": true, - "summaryConcept": { - "primaryConcept": "ViralLoadResultDate_UUID", - "isDate": true - } - }, - { - "id": "currentVLReason", - "title": "Reason For Current VL", - "encounterType": "art_Therapy_EncounterUUID", - "concept": "ReasonForViralLoad_UUID", - "hasSummary": true, - "summaryConcept": { - "primaryConcept": "ViralLoadResultDate_UUID", - "isDate": true, - "hasCalculatedDate": true - } - }, - { - "id": "lastCD4Count", - "title": "Last CD4 Count", - "hasSummary": true, - "encounterType": "CD4LabResultsEncounter_UUID", - "concept": "hivCD4Count_UUID", - "summaryConcept": { - "primaryConcept": "Cd4LabResultDate_UUID", - "isDate": true - } - } - ] - }, - { - "title": "Last Visit Details", - "columns": [ - { - "id": "tbScreening", - "title": "TB Screening", - "encounterType": "clinicalVisitEncounterType", - "concept": "tbScreeningOutcome", - "hasSummary": true, - "summaryConcept": { - "primaryConcept": "regimenLine_UUID", - "isDate": true - } - }, - { - "id": "oIs", - "title": "OIs", - "encounterType": "clinicalVisitEncounterType", - "concept": "opportunisticInfectionConcept" - }, - { - "id": "nextAppointmentDate", - "title": "Next Appointment Date", - "hasSummary": true, - "encounterType": "clinicalVisitEncounterType", - "concept": "returnVisitDateConcept", - "summaryConcept": { - "primaryConcept": "returnVisitDateConcept", - "isDate": true, - "hasCalculatedDate": true - } - }, - { - "id": "programStatus", - "title": "Program Status", - "encounterType": "hivProgramStatusEncounterType", - "concept": "generalTreatmentStatusConcept" - } - ] - } - ] - } -} - - diff --git a/packages/esm-patient-chart-app/src/routes.json b/packages/esm-patient-chart-app/src/routes.json index 33ce936146..b4fca3d397 100644 --- a/packages/esm-patient-chart-app/src/routes.json +++ b/packages/esm-patient-chart-app/src/routes.json @@ -21,41 +21,11 @@ "offline": true }, { - "name": "hiv-patient-summary-widget", - "component": "patientSummaryCardContainer", - "slot": "encounter-tiles-group", + "name": "program-summary", + "component": "patientProgramSummary", "online": true, "offline": true }, - { - "name": "hiv-patient-summary-dashboard", - "component": "hivPatientSummaryDashboardLink", - "online": true, - "offline": true, - "order": 6, - "meta": { - "slot": "encounter-tiles-group", - "path": "hiv-patient-summary" - } - }, - { - "name": "hiv-program-management-widget", - "component": "programManagementComponent", - "slot": "encounter-list-table-tabs", - "online": true, - "offline": true - }, - { - "name": "hiv-program-management-dashboard", - "component": "hivPatientManagementDashboardLink", - "online": true, - "offline": true, - "order": 6, - "meta": { - "slot": "encounter-list-table-tabs", - "path": "hiv-program-management" - } - }, { "name": "stop-visit-button", "component": "stopVisitActionButton", diff --git a/packages/esm-patient-common-lib/tsconfig.json b/packages/esm-patient-common-lib/tsconfig.json index 3ebfc0be81..973ff45f44 100644 --- a/packages/esm-patient-common-lib/tsconfig.json +++ b/packages/esm-patient-common-lib/tsconfig.json @@ -1,4 +1,4 @@ { "extends": "../../tsconfig.json", - "include": ["src/**/*", "../../tools/setup-tests.ts", "../esm-patient-chart-app/src/hooks", "../esm-patient-chart-app/src/lazy-cell", "../esm-patient-chart-app/src/encounter-list/encounter-list-utils.ts", "../esm-patient-chart-app/src/encounter-list/api.resource.ts", "../esm-patient-chart-app/src/encounter-list/encounter-tile-config-builder.ts", "../esm-patient-chart-app/src/encounter-list/index.ts", "../esm-patient-chart-app/src/encounter-list/shema-manipulation.ts"], + "include": ["src/**/*", "../../tools/setup-tests.ts", "../esm-patient-chart-app/src/hooks", "../esm-patient-chart-app/src/lazy-cell", "../esm-patient-chart-app/src/encounter-tile/utils/helpers.ts", "../esm-patient-chart-app/src/encounter-tile/utils/shema-manipulation.ts"], }