-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20499f9
commit f4522e8
Showing
12 changed files
with
231 additions
and
39 deletions.
There are no files selected for viewing
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
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,18 @@ | ||
import { createGlobalStore, getGlobalStore } from '@openmrs/esm-framework'; | ||
import { type WardPatientCardProps } from './types'; | ||
|
||
type ActiveBedSelection = WardPatientCardProps; | ||
|
||
interface WardStoreState { | ||
activeBedSelection: ActiveBedSelection | null; | ||
} | ||
|
||
const initialState: WardStoreState = { | ||
activeBedSelection: null, | ||
}; | ||
|
||
export const wardStore = createGlobalStore('ward', initialState); | ||
|
||
export function getWardStore() { | ||
return getGlobalStore<WardStoreState>('ward', initialState); | ||
} |
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
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
24 changes: 14 additions & 10 deletions
24
packages/esm-ward-app/src/ward-patient-workspace/ward-patient.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
42 changes: 42 additions & 0 deletions
42
packages/esm-ward-app/src/ward-workspace/patient-banner/patient-banner.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,42 @@ | ||
import React, { useMemo } from 'react'; | ||
import { useConfig } from '@openmrs/esm-framework'; | ||
import { defaultPatientCardElementConfig, type WardConfigObject } from '../../config-schema'; | ||
import { useParams } from 'react-router-dom'; | ||
import { getPatientCardElementFromDefinition } from '../../ward-patient-card/ward-patient-card-row.resources'; | ||
import type { PatientCardElementType, WardPatientCardProps } from '../../types'; | ||
import styles from './style.scss'; | ||
|
||
const WardPatientWorkspaceBanner = ({ bed, patient, visit }: WardPatientCardProps) => { | ||
const { locationUuid } = useParams(); | ||
const { wardPatientCards } = useConfig<WardConfigObject>(); | ||
const { cardDefinitions } = wardPatientCards; | ||
|
||
// extract configured elements for the patient card header to use for the banner section | ||
const bannerElements = useMemo(() => { | ||
const cardDefinition = cardDefinitions.find((cardDef) => { | ||
const appliedTo = cardDef.appliedTo; | ||
|
||
return appliedTo == null || appliedTo.some((criteria) => criteria.location == locationUuid); | ||
}); | ||
|
||
const headerRow = cardDefinition.rows.find((cardDef) => cardDef.rowType === 'header'); | ||
|
||
return headerRow.elements.map((elementType: PatientCardElementType) => | ||
getPatientCardElementFromDefinition({ | ||
id: elementType, | ||
elementType, | ||
config: defaultPatientCardElementConfig, | ||
}), | ||
); | ||
}, [cardDefinitions]); | ||
|
||
return ( | ||
<div className={styles.patientBanner}> | ||
{bannerElements.map((BannerElement) => ( | ||
<BannerElement patient={patient} visit={visit} bed={bed} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default WardPatientWorkspaceBanner; |
23 changes: 23 additions & 0 deletions
23
packages/esm-ward-app/src/ward-workspace/patient-banner/style.scss
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 @@ | ||
@use '@carbon/styles/scss/spacing'; | ||
@import '~@openmrs/esm-styleguide/src/vars'; | ||
|
||
.patientBanner { | ||
@extend .dotSeparatedChildren; | ||
display: flex; | ||
flex-wrap: wrap; | ||
width: 100%; | ||
padding: spacing.$spacing-04; | ||
background: $ui-01; | ||
} | ||
|
||
.dotSeparatedChildren { | ||
> div:not(div:first-of-type) { | ||
display: flex; | ||
align-items: center; | ||
|
||
&::before { | ||
content: '·'; | ||
padding: 0 spacing.$spacing-02; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ages/esm-ward-app/src/ward-workspace/ward-patient-notes/notes-action-button.extension.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,17 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ActionMenuButton, launchWorkspace, StickyNoteAddIcon } from '@openmrs/esm-framework'; | ||
|
||
export default function WardPatientNotesActionButton({ workspaceProps }: { workspaceProps: any }) { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<ActionMenuButton | ||
getIcon={(props) => <StickyNoteAddIcon {...props} size={16} />} | ||
label={t('PatientNote', 'Patient Note')} | ||
iconDescription={t('PatientNote', 'Patient Note')} | ||
handler={() => launchWorkspace('ward-patient-notes-workspace')} | ||
type={'ward-patient-notes'} | ||
/> | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/esm-ward-app/src/ward-workspace/ward-patient-notes/notes.style.scss
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,6 @@ | ||
@import '~@openmrs/esm-styleguide/src/vars'; | ||
|
||
.workspaceContainer { | ||
width: calc(100% - 2rem); | ||
min-height: var(--desktop-workspace-window-height); | ||
} |
39 changes: 39 additions & 0 deletions
39
packages/esm-ward-app/src/ward-workspace/ward-patient-notes/notes.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,39 @@ | ||
import React, { useMemo } from 'react'; | ||
import styles from './notes.style.scss'; | ||
import { type DefaultWorkspaceProps, ExtensionSlot } from '@openmrs/esm-framework'; | ||
import { getWardStore } from '../../store'; | ||
import WardPatientWorkspaceBanner from '../patient-banner/patient-banner.component'; | ||
|
||
const WardPatientNotesWorkspace = ({ | ||
promptBeforeClosing, | ||
closeWorkspace, | ||
closeWorkspaceWithSavedChanges, | ||
setOnCloseCallback, | ||
}: DefaultWorkspaceProps) => { | ||
const wardStore = getWardStore(); | ||
const { patient, visit, bed } = wardStore.getState().activeBedSelection; | ||
|
||
setOnCloseCallback(() => { | ||
wardStore.setState({ activeBedSelection: null }); | ||
}); | ||
|
||
const notesFormExtensionState = useMemo( | ||
() => ({ | ||
patient, | ||
patientUuid: patient.uuid, | ||
promptBeforeClosing, | ||
closeWorkspace, | ||
closeWorkspaceWithSavedChanges, | ||
}), | ||
[patient, closeWorkspace, closeWorkspaceWithSavedChanges, promptBeforeClosing], | ||
); | ||
|
||
return ( | ||
<div className={styles.workspaceContainer}> | ||
<WardPatientWorkspaceBanner patient={patient} bed={bed} visit={visit} /> | ||
<ExtensionSlot name="ward-patient-notes-workspace-slot" state={notesFormExtensionState} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WardPatientNotesWorkspace; |