From ab363e662e30f69cdb8d1ec2d1f66dea416a11ef Mon Sep 17 00:00:00 2001 From: Usama Idriss Kakumba Date: Fri, 6 Sep 2024 21:20:35 +0300 Subject: [PATCH 1/5] feat: add clinical forms to ward app --- ...cal-forms-workspace-siderail.component.tsx | 37 +++++++++++++++++++ packages/esm-ward-app/src/index.ts | 15 ++++++++ packages/esm-ward-app/src/routes.json | 25 +++++++++++++ .../patient-clinical-forms.workspace.tsx | 20 ++++++++++ .../patient-form-entry.workspace.tsx | 26 +++++++++++++ .../patient-clinical-forms-workspace/types.ts | 9 +++++ 6 files changed, 132 insertions(+) create mode 100644 packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx create mode 100644 packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx create mode 100644 packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx create mode 100644 packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/types.ts diff --git a/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx b/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx new file mode 100644 index 000000000..d5faca5b7 --- /dev/null +++ b/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { Document } from '@carbon/react/icons'; +import { useTranslation } from 'react-i18next'; +import { ActionMenuButton, launchWorkspace, useWorkspaces } from '@openmrs/esm-framework'; +import type { WardPatientWorkspaceProps } from '../types'; + +const ClinicalFormsWorkspaceSideRailIcon: React.FC = () => { + const { t } = useTranslation(); + const { workspaces } = useWorkspaces(); + + const formEntryWorkspaces = workspaces.filter((w) => w.name === 'ward-patient-form-entry-workspace'); + const recentlyOpenedForm = formEntryWorkspaces[0]; + + const isClinicalFormOpen = formEntryWorkspaces?.length >= 1; + + const launchPatientWorkspaceCb = () => { + if (isClinicalFormOpen) { + launchWorkspace('ward-patient-form-entry-workspace', { + workspaceTitle: recentlyOpenedForm?.additionalProps?.['workspaceTitle'], + }); + } else { + launchWorkspace('ward-patient-clinical-forms-workspace'); + } + }; + + return ( + } + label={t('clinicalForms', 'Clinical forms')} + iconDescription={t('clinicalForms', 'Clinical forms')} + handler={launchPatientWorkspaceCb} + type="ward-patient-clinical-form" + /> + ); +}; + +export default ClinicalFormsWorkspaceSideRailIcon; diff --git a/packages/esm-ward-app/src/index.ts b/packages/esm-ward-app/src/index.ts index 06a6a344d..33ae86a57 100644 --- a/packages/esm-ward-app/src/index.ts +++ b/packages/esm-ward-app/src/index.ts @@ -107,6 +107,21 @@ export const patientDischargeWorkspaceSideRailIcon = getAsyncLifecycle( options, ); +export const patientClinicalFormsWorkspace = getAsyncLifecycle( + () => import('./ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace'), + options, +); + +export const patientFormEntryWorkspace = getAsyncLifecycle( + () => import('./ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace'), + options, +); + +export const clinicalFormWorkspaceSideRailIcon = getAsyncLifecycle( + () => import('./action-menu-buttons/clinical-forms-workspace-siderail.component'), + options, +); + export function startupApp() { registerBreadcrumbs([]); defineConfigSchema(moduleName, configSchema); diff --git a/packages/esm-ward-app/src/routes.json b/packages/esm-ward-app/src/routes.json index 9b5690071..40a77e341 100644 --- a/packages/esm-ward-app/src/routes.json +++ b/packages/esm-ward-app/src/routes.json @@ -55,6 +55,11 @@ "slot": "action-menu-ward-patient-items-slot", "component": "patientDischargeWorkspaceSideRailIcon" }, + { + "name": "clinical-forms-workspace-siderail-button", + "component": "clinicalFormWorkspaceSideRailIcon", + "slot": "action-menu-ward-patient-items-slot" + }, { "component": "admissionRequestNoteRowExtension", "name": "admission-request-note-card-row", @@ -122,6 +127,26 @@ "type": "ward-patient-discharge", "hasOwnSidebar": true, "sidebarFamily": "ward-patient" + }, + { + "name": "ward-patient-clinical-forms-workspace", + "component": "patientClinicalFormsWorkspace", + "title": "clinicalForms", + "type": "ward-patient-clinical-forms", + "hasOwnSidebar": true, + "sidebarFamily": "ward-patient", + "width": "wider" + }, + { + "name": "ward-patient-form-entry-workspace", + "title": "clinicalForm", + "component": "patientFormEntryWorkspace", + "type": "ward-patient-clinical-form", + "canMaximize": true, + "canHide": true, + "width": "wider", + "hasOwnSidebar": true, + "sidebarFamily": "ward-patient" } ] } diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx new file mode 100644 index 000000000..469c5bd42 --- /dev/null +++ b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import { ExtensionSlot } from '@openmrs/esm-framework'; +import type { WardPatientWorkspaceProps } from '../../types'; + +const WardPatientClinicalFormsWorkspace: React.FC = (props) => { + const { wardPatient, ...restWorkspaceProps } = props; + const patientUuid = wardPatient?.patient?.uuid; + + return ( + + ); +}; + +export default WardPatientClinicalFormsWorkspace; diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx new file mode 100644 index 000000000..f174cf1b5 --- /dev/null +++ b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { ExtensionSlot } from '@openmrs/esm-framework'; +// import { useCheckAndPromptForVisit } from '@openmrs/esm-patient-common-lib'; +import type { WardPatientWorkspaceProps } from '../../types'; + +const WardPatientFormEntryWorkspace: React.FC = (props) => { + const { wardPatient, ...restWorkspaceProps } = props; + const patientUuid = wardPatient?.patient?.uuid; + // const { hasCurrentVisit } = useCheckAndPromptForVisit(patientUuid); + // + // if (!hasCurrentVisit) { + // return null; + // } + + return ( + + ); +}; + +export default WardPatientFormEntryWorkspace; diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/types.ts b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/types.ts new file mode 100644 index 000000000..57e3e6225 --- /dev/null +++ b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/types.ts @@ -0,0 +1,9 @@ +import type { DefaultWorkspaceProps, Patient } from '@openmrs/esm-framework'; + +export interface WardPatientClinicalFormsWorkspaceProps extends DefaultWorkspaceProps { + patient: Patient; +} + +export interface WardPatientFormEntryWorkspaceProps extends DefaultWorkspaceProps { + patient: Patient; +} From 2d245280c4ce81ebb4e04825f910c1161799bbe9 Mon Sep 17 00:00:00 2001 From: Usama Idriss Kakumba Date: Fri, 6 Sep 2024 22:18:57 +0300 Subject: [PATCH 2/5] feat: add formentryworkspace name to props --- ...cal-forms-workspace-siderail.component.tsx | 2 +- .../patient-clinical-forms.workspace.tsx | 19 +++++++++-------- .../patient-form-entry.workspace.tsx | 21 ++++++++++--------- .../patient-clinical-forms-workspace/types.ts | 9 -------- packages/esm-ward-app/translations/en.json | 1 + 5 files changed, 23 insertions(+), 29 deletions(-) delete mode 100644 packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/types.ts diff --git a/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx b/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx index d5faca5b7..349084992 100644 --- a/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx +++ b/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx @@ -29,7 +29,7 @@ const ClinicalFormsWorkspaceSideRailIcon: React.FC = () => { label={t('clinicalForms', 'Clinical forms')} iconDescription={t('clinicalForms', 'Clinical forms')} handler={launchPatientWorkspaceCb} - type="ward-patient-clinical-form" + type={'ward-patient-clinical-form' || 'ward-patient-clinical-forms'} /> ); }; diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx index 469c5bd42..666565bbe 100644 --- a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx +++ b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { ExtensionSlot } from '@openmrs/esm-framework'; import type { WardPatientWorkspaceProps } from '../../types'; @@ -6,15 +6,16 @@ const WardPatientClinicalFormsWorkspace: React.FC = ( const { wardPatient, ...restWorkspaceProps } = props; const patientUuid = wardPatient?.patient?.uuid; - return ( - + const clinicalFormsExtensionState = useMemo( + () => ({ + patientUuid, + formEntryWorkspaceName: 'ward-patient-form-entry-workspace', + ...restWorkspaceProps, + }), + [patientUuid, restWorkspaceProps], ); + + return ; }; export default WardPatientClinicalFormsWorkspace; diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx index f174cf1b5..4dc7584d6 100644 --- a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx +++ b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { ExtensionSlot } from '@openmrs/esm-framework'; // import { useCheckAndPromptForVisit } from '@openmrs/esm-patient-common-lib'; import type { WardPatientWorkspaceProps } from '../../types'; @@ -6,21 +6,22 @@ import type { WardPatientWorkspaceProps } from '../../types'; const WardPatientFormEntryWorkspace: React.FC = (props) => { const { wardPatient, ...restWorkspaceProps } = props; const patientUuid = wardPatient?.patient?.uuid; + + const formEntryExtensionState = useMemo( + () => ({ + patientUuid, + ...restWorkspaceProps, + }), + [patientUuid, restWorkspaceProps], + ); + // const { hasCurrentVisit } = useCheckAndPromptForVisit(patientUuid); // // if (!hasCurrentVisit) { // return null; // } - return ( - - ); + return ; }; export default WardPatientFormEntryWorkspace; diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/types.ts b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/types.ts deleted file mode 100644 index 57e3e6225..000000000 --- a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { DefaultWorkspaceProps, Patient } from '@openmrs/esm-framework'; - -export interface WardPatientClinicalFormsWorkspaceProps extends DefaultWorkspaceProps { - patient: Patient; -} - -export interface WardPatientFormEntryWorkspaceProps extends DefaultWorkspaceProps { - patient: Patient; -} diff --git a/packages/esm-ward-app/translations/en.json b/packages/esm-ward-app/translations/en.json index 0b23feefe..57c35745a 100644 --- a/packages/esm-ward-app/translations/en.json +++ b/packages/esm-ward-app/translations/en.json @@ -10,6 +10,7 @@ "bedSwap": "Bed swap", "cancel": "Cancel", "chooseAnOption": "Choose an option", + "clinicalForms": "Clinical forms", "clinicalNoteLabel": "Write your notes", "discharge": "Discharge", "empty": "Empty", From 3df40699fa453c515293f501733f39242c975a51 Mon Sep 17 00:00:00 2001 From: Usama Idriss Kakumba Date: Wed, 18 Sep 2024 11:06:57 +0300 Subject: [PATCH 3/5] feat: add clinical forms --- package.json | 4 ++-- ...inical-forms-workspace-siderail.component.tsx | 2 +- .../patient-form-entry.workspace.tsx | 16 ++++------------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index b4f900fb8..21201d781 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "devDependencies": { "@babel/core": "^7.11.6", "@carbon/react": "~1.37.0", - "@openmrs/esm-framework": "next", + "@openmrs/esm-framework": "^5.8.1-pre.2296", "@openmrs/esm-patient-common-lib": "next", "@playwright/test": "1.45.2", "@swc/core": "^1.2.165", @@ -64,7 +64,7 @@ "jest-cli": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "lint-staged": "^15.2.1", - "openmrs": "next", + "openmrs": "^5.8.1-pre.2296", "prettier": "^3.1.1", "react": "^18.1.0", "react-dom": "^18.1.0", diff --git a/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx b/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx index 349084992..d5faca5b7 100644 --- a/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx +++ b/packages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx @@ -29,7 +29,7 @@ const ClinicalFormsWorkspaceSideRailIcon: React.FC = () => { label={t('clinicalForms', 'Clinical forms')} iconDescription={t('clinicalForms', 'Clinical forms')} handler={launchPatientWorkspaceCb} - type={'ward-patient-clinical-form' || 'ward-patient-clinical-forms'} + type="ward-patient-clinical-form" /> ); }; diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx index 4dc7584d6..fbfa18893 100644 --- a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx +++ b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx @@ -3,17 +3,9 @@ import { ExtensionSlot } from '@openmrs/esm-framework'; // import { useCheckAndPromptForVisit } from '@openmrs/esm-patient-common-lib'; import type { WardPatientWorkspaceProps } from '../../types'; -const WardPatientFormEntryWorkspace: React.FC = (props) => { - const { wardPatient, ...restWorkspaceProps } = props; - const patientUuid = wardPatient?.patient?.uuid; - - const formEntryExtensionState = useMemo( - () => ({ - patientUuid, - ...restWorkspaceProps, - }), - [patientUuid, restWorkspaceProps], - ); +const WardPatientFormEntryWorkspace: React.FC = () => { + // const { wardPatient, ...restWorkspaceProps } = props; + // const patientUuid = wardPatient?.patient?.uuid; // const { hasCurrentVisit } = useCheckAndPromptForVisit(patientUuid); // @@ -21,7 +13,7 @@ const WardPatientFormEntryWorkspace: React.FC = (prop // return null; // } - return ; + return ; }; export default WardPatientFormEntryWorkspace; From e7b67c89b2c391eb5f7933b09a00e8fc655efb27 Mon Sep 17 00:00:00 2001 From: Usama Idriss Kakumba Date: Wed, 18 Sep 2024 14:56:45 +0300 Subject: [PATCH 4/5] (feat) add related workspace names props on clinical forms dashboard workspace --- packages/esm-ward-app/src/index.ts | 5 ----- packages/esm-ward-app/src/routes.json | 11 ----------- .../patient-clinical-forms.workspace.tsx | 2 ++ .../patient-form-entry.workspace.tsx | 19 ------------------- 4 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx diff --git a/packages/esm-ward-app/src/index.ts b/packages/esm-ward-app/src/index.ts index 33ae86a57..4f262d69e 100644 --- a/packages/esm-ward-app/src/index.ts +++ b/packages/esm-ward-app/src/index.ts @@ -112,11 +112,6 @@ export const patientClinicalFormsWorkspace = getAsyncLifecycle( options, ); -export const patientFormEntryWorkspace = getAsyncLifecycle( - () => import('./ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace'), - options, -); - export const clinicalFormWorkspaceSideRailIcon = getAsyncLifecycle( () => import('./action-menu-buttons/clinical-forms-workspace-siderail.component'), options, diff --git a/packages/esm-ward-app/src/routes.json b/packages/esm-ward-app/src/routes.json index 40a77e341..5a134c232 100644 --- a/packages/esm-ward-app/src/routes.json +++ b/packages/esm-ward-app/src/routes.json @@ -136,17 +136,6 @@ "hasOwnSidebar": true, "sidebarFamily": "ward-patient", "width": "wider" - }, - { - "name": "ward-patient-form-entry-workspace", - "title": "clinicalForm", - "component": "patientFormEntryWorkspace", - "type": "ward-patient-clinical-form", - "canMaximize": true, - "canHide": true, - "width": "wider", - "hasOwnSidebar": true, - "sidebarFamily": "ward-patient" } ] } diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx index 666565bbe..9d76e742a 100644 --- a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx +++ b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx @@ -9,7 +9,9 @@ const WardPatientClinicalFormsWorkspace: React.FC = ( const clinicalFormsExtensionState = useMemo( () => ({ patientUuid, + clinicalFormsWorkspaceName: 'ward-patient-clinical-forms-workspace', formEntryWorkspaceName: 'ward-patient-form-entry-workspace', + htmlFormEntryWorkspaceName: 'ward-patient-html-form-entry-workspace', ...restWorkspaceProps, }), [patientUuid, restWorkspaceProps], diff --git a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx b/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx deleted file mode 100644 index fbfa18893..000000000 --- a/packages/esm-ward-app/src/ward-workspace/patient-clinical-forms-workspace/patient-form-entry.workspace.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React, { useMemo } from 'react'; -import { ExtensionSlot } from '@openmrs/esm-framework'; -// import { useCheckAndPromptForVisit } from '@openmrs/esm-patient-common-lib'; -import type { WardPatientWorkspaceProps } from '../../types'; - -const WardPatientFormEntryWorkspace: React.FC = () => { - // const { wardPatient, ...restWorkspaceProps } = props; - // const patientUuid = wardPatient?.patient?.uuid; - - // const { hasCurrentVisit } = useCheckAndPromptForVisit(patientUuid); - // - // if (!hasCurrentVisit) { - // return null; - // } - - return ; -}; - -export default WardPatientFormEntryWorkspace; From c9da785c50f8000a0c9fcb784948410cf43e86a5 Mon Sep 17 00:00:00 2001 From: Usama Idriss Kakumba Date: Wed, 18 Sep 2024 15:04:22 +0300 Subject: [PATCH 5/5] (fix) package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 21201d781..b4f900fb8 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "devDependencies": { "@babel/core": "^7.11.6", "@carbon/react": "~1.37.0", - "@openmrs/esm-framework": "^5.8.1-pre.2296", + "@openmrs/esm-framework": "next", "@openmrs/esm-patient-common-lib": "next", "@playwright/test": "1.45.2", "@swc/core": "^1.2.165", @@ -64,7 +64,7 @@ "jest-cli": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "lint-staged": "^15.2.1", - "openmrs": "^5.8.1-pre.2296", + "openmrs": "next", "prettier": "^3.1.1", "react": "^18.1.0", "react-dom": "^18.1.0",