forked from openmrs/openmrs-esm-patient-management
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) O3-3246 - Ward App - open patient record in workspace (openmrs…
- Loading branch information
Showing
11 changed files
with
278 additions
and
117 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
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
18 changes: 18 additions & 0 deletions
18
packages/esm-ward-app/src/ward-patient-workspace/ward-patient-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,18 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { UserAvatarIcon } from '@openmrs/esm-framework'; | ||
import { ActionMenuButton, launchWorkspace } from '@openmrs/esm-framework'; | ||
|
||
export default function WardPatientActionButton() { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<ActionMenuButton | ||
getIcon={(props) => <UserAvatarIcon {...props} />} | ||
label={t('Patient', 'patient')} | ||
iconDescription={t('Patient', 'patient')} | ||
handler={() => launchWorkspace('ward-patient-workspace')} | ||
type={'ward'} | ||
/> | ||
); | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/esm-ward-app/src/ward-patient-workspace/ward-patient.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,11 @@ | ||
@use '@carbon/styles/scss/spacing'; | ||
@use '@carbon/styles/scss/type'; | ||
|
||
.workspaceContainer { | ||
min-height: var(--desktop-workspace-window-height); | ||
} | ||
|
||
.headerPatientDetail { | ||
@include type.type-style('body-compact-02'); | ||
margin: 0 spacing.$spacing-02; | ||
} |
79 changes: 79 additions & 0 deletions
79
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useEffect, useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { InlineNotification } from '@carbon/react'; | ||
import { InlineLoading } from '@carbon/react'; | ||
import { | ||
type DefaultWorkspaceProps, | ||
ExtensionSlot, | ||
attach, | ||
getPatientName, | ||
usePatient, | ||
age, | ||
} from '@openmrs/esm-framework'; | ||
import styles from './ward-patient.style.scss'; | ||
|
||
attach('ward-patient-workspace-header-slot', 'patient-vitals-info'); | ||
|
||
export interface WardPatientWorkspaceProps extends DefaultWorkspaceProps { | ||
patientUuid: string; | ||
} | ||
|
||
export default function WardPatientWorkspace({ patientUuid, setTitle }: WardPatientWorkspaceProps) { | ||
const { t } = useTranslation(); | ||
const { patient, isLoading, error } = usePatient(patientUuid); | ||
|
||
useEffect(() => { | ||
if (isLoading) { | ||
setTitle(t('wardPatientWorkspaceTitle', 'Ward Patient'), <InlineLoading />); | ||
} else if (patient) { | ||
setTitle(getPatientName(patient), <PatientWorkspaceTitle patient={patient} />); | ||
} else if (error) { | ||
setTitle(t('wardPatientWorkspaceTitle', 'Ward Patient')); | ||
} | ||
}, [patient]); | ||
|
||
return ( | ||
<div className={styles.workspaceContainer}> | ||
{isLoading ? ( | ||
<InlineLoading /> | ||
) : patient ? ( | ||
<WardPatientWorkspaceView patient={patient} /> | ||
) : error ? ( | ||
<InlineNotification>{error.message}</InlineNotification> | ||
) : ( | ||
<InlineNotification> | ||
{t('failedToLoadPatientWorkspace', 'Ward patient workspace has failed to load.')} | ||
</InlineNotification> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
interface WardPatientWorkspaceViewProps { | ||
patient: fhir.Patient; | ||
} | ||
|
||
function WardPatientWorkspaceView({ patient }: WardPatientWorkspaceViewProps) { | ||
const extensionSlotState = useMemo(() => ({ patient, patientUuid: patient.id }), [patient]); | ||
|
||
return ( | ||
<> | ||
<div> | ||
<ExtensionSlot name="ward-patient-workspace-header-slot" state={extensionSlotState} /> | ||
</div> | ||
<div> | ||
<ExtensionSlot name="ward-patient-workspace-content-slot" state={extensionSlotState} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
function PatientWorkspaceTitle({ patient }: { patient: fhir.Patient }) { | ||
return ( | ||
<> | ||
<div>{getPatientName(patient)} </div> | ||
<div className={styles.headerPatientDetail}>· {patient.gender}</div> | ||
<div className={styles.headerPatientDetail}>· {age(patient.birthDate)}</div> | ||
</> | ||
); | ||
} |
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
Oops, something went wrong.