-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) O3-3818: Add clinical forms workspace to Ward app sidebar (#1319)
* feat: add clinical forms to ward app * feat: add formentryworkspace name to props * feat: add clinical forms * (feat) add related workspace names props on clinical forms dashboard workspace * (fix) package.json
- Loading branch information
1 parent
93e37ad
commit a18801b
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...ages/esm-ward-app/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<WardPatientWorkspaceProps>('ward-patient-clinical-forms-workspace'); | ||
} | ||
}; | ||
|
||
return ( | ||
<ActionMenuButton | ||
getIcon={(props) => <Document {...props} />} | ||
label={t('clinicalForms', 'Clinical forms')} | ||
iconDescription={t('clinicalForms', 'Clinical forms')} | ||
handler={launchPatientWorkspaceCb} | ||
type="ward-patient-clinical-form" | ||
/> | ||
); | ||
}; | ||
|
||
export default ClinicalFormsWorkspaceSideRailIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useMemo } from 'react'; | ||
import { ExtensionSlot } from '@openmrs/esm-framework'; | ||
import type { WardPatientWorkspaceProps } from '../../types'; | ||
|
||
const WardPatientClinicalFormsWorkspace: React.FC<WardPatientWorkspaceProps> = (props) => { | ||
const { wardPatient, ...restWorkspaceProps } = props; | ||
const patientUuid = wardPatient?.patient?.uuid; | ||
|
||
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], | ||
); | ||
|
||
return <ExtensionSlot name="ward-patient-clinical-forms-workspace-slot" state={clinicalFormsExtensionState} />; | ||
}; | ||
|
||
export default WardPatientClinicalFormsWorkspace; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters