Skip to content

Commit

Permalink
(feat) O3-3245: Add workspace to create transfer request for patients…
Browse files Browse the repository at this point in the history
… in the admission queue (#1289)
  • Loading branch information
vasharma05 authored Aug 23, 2024
1 parent 10a4a9e commit fd9f27d
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/esm-ward-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ export interface WardPatientCardDefinition {
*/
location: string;
}>;
}
}
6 changes: 6 additions & 0 deletions packages/esm-ward-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export const patientTransferAndSwapWorkspaceSiderailIcon = getAsyncLifecycle(
options,
);

// t('transferRequest', 'Transfer request')
export const patientTransferRequestWorkspace = getAsyncLifecycle(
() => import('./ward-workspace/patient-transfer-request-workspace/patient-transfer-request.workspace'),
options,
);

export const patientDischargeWorkspaceSideRailIcon = getAsyncLifecycle(
() => import('./action-menu-buttons/discharge-workspace-siderail.component'),
options,
Expand Down
6 changes: 6 additions & 0 deletions packages/esm-ward-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
"hasOwnSidebar": true,
"sidebarFamily": "ward-patient"
},
{
"name": "patient-transfer-request-workspace",
"component": "patientTransferRequestWorkspace",
"title": "transferRequest",
"type": "transfer-request-form"
},
{
"name": "patient-discharge-workspace",
"component": "patientDischargeWorkspace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ const WardPatientCodedObsTags: React.FC<WardPatientCodedObsTagsProps> = ({ confi
return matchVisit || visit == null; // TODO: remove visit == null hack when server API supports returning visit
});

const summaryLabelToDisplay =
summaryLabel != null
? t(summaryLabel)
: obsToDisplay?.[0]?.concept?.display;
const summaryLabelToDisplay = summaryLabel != null ? t(summaryLabel) : obsToDisplay?.[0]?.concept?.display;

const obsNodes = obsToDisplay?.map((o) => {
const { display, uuid } = o.value as OpenmrsResource;
Expand Down Expand Up @@ -78,4 +75,4 @@ const WardPatientCodedObsTags: React.FC<WardPatientCodedObsTagsProps> = ({ confi
}
};

export default WardPatientCodedObsTags;
export default WardPatientCodedObsTags;
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ const WardPatientIdentifier: React.FC<WardPatientIdentifierProps> = ({ config: c
);
patientIdentifiers.sort(identifierCompareFunction);
const patientIdentifier = patientIdentifiers[0];
const labelToDisplay =
label != null ? t(label) : patientIdentifier?.identifierType?.name;
const labelToDisplay = label != null ? t(label) : patientIdentifier?.identifierType?.name;
return (
<div>
{labelToDisplay ? <Tag>{t('identifierTypelabel', '{{label}}:', { label: labelToDisplay })}</Tag> : <></>}
Expand All @@ -50,4 +49,4 @@ const WardPatientIdentifier: React.FC<WardPatientIdentifierProps> = ({ config: c
);
};

export default WardPatientIdentifier;
export default WardPatientIdentifier;
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ const WardPatientObs: React.FC<WardPatientObsProps> = ({ config, patient, visit
})
?.slice(0, limit == 0 ? Number.MAX_VALUE : limit);

const labelToDisplay =
label != null ? t(label) : obsToDisplay?.[0]?.concept?.display;
const labelToDisplay = label != null ? t(label) : obsToDisplay?.[0]?.concept?.display;

const obsNodes = obsToDisplay?.map((o) => {
const { value } = o;
Expand All @@ -56,4 +55,4 @@ const WardPatientObs: React.FC<WardPatientObsProps> = ({ config, patient, visit
}
};

export default WardPatientObs;
export default WardPatientObs;
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@ import { Button } from '@carbon/react';
import { ArrowRightIcon, launchWorkspace, useLayoutType } from '@openmrs/esm-framework';
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import type { WardPatientCard } from '../../types';
import type { WardPatientWorkspaceProps, WardPatientCard } from '../../types';
import type { AdmitPatientFormWorkspaceProps } from '../admit-patient-form-workspace/types';
import styles from './admission-request-card.scss';

const AdmissionRequestCardActions: WardPatientCard = ({ patient, inpatientRequest }) => {
const AdmissionRequestCardActions: WardPatientCard = (wardPatient) => {
const { patient, inpatientRequest } = wardPatient;
const { dispositionType } = inpatientRequest;
const { t } = useTranslation();
const responsiveSize = useLayoutType() === 'tablet' ? 'lg' : 'md';
const launchPatientAdmissionForm = useCallback(
() => launchWorkspace<AdmitPatientFormWorkspaceProps>('admit-patient-form-workspace', { patient, dispositionType }),
[],
);

const launchPatientTransferForm = useCallback(() => {
launchWorkspace<WardPatientWorkspaceProps>('patient-transfer-request-workspace', {
wardPatient,
});
}, [wardPatient]);

return (
<div className={styles.admissionRequestActionBar}>
<Button kind="ghost" size={responsiveSize}>
<Button kind="ghost" size={responsiveSize} onClick={launchPatientTransferForm}>
{t('transferElsewhere', 'Transfer elsewhere')}
</Button>
<Button kind="ghost" renderIcon={ArrowRightIcon} size={responsiveSize} onClick={launchPatientAdmissionForm}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
RadioButtonGroup,
RadioButtonSkeleton,
} from '@carbon/react';
import classNames from 'classnames';

export default function PatientBedSwapForm({
promptBeforeClosing,
Expand Down Expand Up @@ -148,7 +149,9 @@ export default function PatientBedSwapForm({
}, []);

return (
<Form onSubmit={handleSubmit(onSubmit, onError)} className={styles.formContainer}>
<Form
onSubmit={handleSubmit(onSubmit, onError)}
className={classNames(styles.formContainer, styles.workspaceContent)}>
<div>
{errorFetchingEmrConfiguration && (
<div className={styles.formError}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createEncounter } from '../../ward.resource';
import useWardLocation from '../../hooks/useWardLocation';
import type { ObsPayload, WardPatientWorkspaceProps } from '../../types';
import { useInpatientRequest } from '../../hooks/useInpatientRequest';
import classNames from 'classnames';
import { Button, ButtonSet, Form, InlineNotification, RadioButton, RadioButtonGroup, TextArea } from '@carbon/react';

export default function PatientTransferForm({
Expand Down Expand Up @@ -154,7 +155,9 @@ export default function PatientTransferForm({
}, []);

return (
<Form onSubmit={handleSubmit(onSubmit, onError)} className={styles.formContainer}>
<Form
onSubmit={handleSubmit(onSubmit, onError)}
className={classNames(styles.formContainer, styles.workspaceContent)}>
<div>
{errorFetchingEmrConfiguration && (
<div className={styles.formError}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
@use '@carbon/layout';
@use '@openmrs/esm-styleguide/src/vars' as *;

.flexWrapper {
height: 100%;
display: flex;
flex-direction: column;
color: #393939;
}

.workspaceContent {
padding: layout.$spacing-05;
height: 100%;
Expand All @@ -10,8 +17,12 @@
color: #393939;
}

.contentSwitcherWrapper {
padding: 0 layout.$spacing-05;
}

.patientWorkspaceBanner {
margin: (-(layout.$spacing-05)) (-(layout.$spacing-05)) layout.$spacing-05 (-(layout.$spacing-05));
margin-bottom: layout.$spacing-05;
}

.field {
Expand All @@ -26,7 +37,6 @@
}

.workspaceForm {
margin-top: layout.$spacing-05;
flex: 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export default function PatientTransferAndSwapWorkspace(props: WardPatientWorksp
const isBedManagementModuleInstalled = useFeatureFlag('bedmanagement-module');

return (
<div className={styles.workspaceContent}>
<div className={styles.flexWrapper}>
<div className={styles.patientWorkspaceBanner}>
<WardPatientWorkspaceBanner {...props?.wardPatient} />
</div>
{isBedManagementModuleInstalled && (
<div>
<div className={styles.contentSwitcherWrapper}>
<h2 className={styles.productiveHeading02}>{t('typeOfTransfer', 'Type of transfer')}</h2>
<div className={styles.contentSwitcher}>
<ContentSwitcher onChange={({ name }) => setSelectedSection(name)}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import PatientTransferForm from '../patient-transfer-bed-swap/patient-transfer-request-form.component';
import { type WardPatientWorkspaceProps } from '../../types';

interface PatientTransferRequestFormProps extends WardPatientWorkspaceProps {}

const PatientTransferRequestForm: React.FC<PatientTransferRequestFormProps> = (props) => {
return <PatientTransferForm {...props} />;
};

export default PatientTransferRequestForm;
1 change: 1 addition & 0 deletions packages/esm-ward-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"somePartsOfTheFormDidntLoad": "Some parts of the form didn't load",
"transfer": "Transfer",
"transferElsewhere": "Transfer elsewhere",
"transferRequest": "Transfer request",
"transfers": "Transfers",
"transferType": "Transfer type",
"typeOfTransfer": "Type of transfer",
Expand Down

0 comments on commit fd9f27d

Please sign in to comment.