@kenyaemr/esm-ward-app 8.0.1-pre.99 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +20 -24
- package/dist/109.js +1 -0
- package/dist/109.js.map +1 -0
- package/dist/124.js +1 -0
- package/dist/124.js.map +1 -0
- package/dist/125.js +1 -0
- package/dist/125.js.map +1 -0
- package/dist/130.js +1 -1
- package/dist/130.js.LICENSE.txt +2 -0
- package/dist/130.js.map +1 -1
- package/dist/146.js +1 -0
- package/dist/146.js.map +1 -0
- package/dist/15.js +1 -0
- package/dist/15.js.map +1 -0
- package/dist/153.js +1 -0
- package/dist/153.js.map +1 -0
- package/dist/303.js +2 -1
- package/dist/303.js.map +1 -1
- package/dist/325.js +1 -0
- package/dist/325.js.map +1 -0
- package/dist/372.js +2 -0
- package/dist/372.js.map +1 -0
- package/dist/471.js +1 -0
- package/dist/471.js.map +1 -0
- package/dist/481.js +1 -0
- package/dist/481.js.map +1 -0
- package/dist/53.js +1 -0
- package/dist/53.js.map +1 -0
- package/dist/{960.js → 559.js} +1 -1
- package/dist/559.js.map +1 -0
- package/dist/574.js +1 -1
- package/dist/576.js +1 -0
- package/dist/576.js.map +1 -0
- package/dist/577.js +1 -1
- package/dist/577.js.map +1 -1
- package/dist/{255.js → 649.js} +2 -2
- package/dist/649.js.LICENSE.txt +9 -0
- package/dist/649.js.map +1 -0
- package/dist/{659.js → 662.js} +1 -1
- package/dist/662.js.map +1 -0
- package/dist/920.js +1 -0
- package/dist/920.js.map +1 -0
- package/dist/921.js +1 -0
- package/dist/921.js.map +1 -0
- package/dist/922.js +1 -0
- package/dist/922.js.map +1 -0
- package/dist/969.js +1 -0
- package/dist/969.js.map +1 -0
- package/dist/kenyaemr-esm-ward-app.js +1 -1
- package/dist/kenyaemr-esm-ward-app.js.buildmanifest.json +304 -128
- package/dist/kenyaemr-esm-ward-app.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.LICENSE.txt +0 -10
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/mock.tsx +62 -0
- package/package-lock.json +5001 -0
- package/package.json +2 -3
- package/src/action-menu-buttons/clinical-forms-workspace-siderail.component.tsx +37 -0
- package/src/action-menu-buttons/discharge-workspace-siderail.component.tsx +20 -0
- package/src/beds/empty-bed-skeleton.tsx +4 -3
- package/src/beds/empty-bed.component.tsx +3 -3
- package/src/beds/ward-bed.component.tsx +41 -0
- package/src/beds/ward-bed.scss +45 -0
- package/src/beds/{occupied-bed.test.tsx → ward-bed.test.tsx} +42 -20
- package/src/config-schema.ts +203 -84
- package/src/constant.ts +1 -1
- package/src/hooks/useAdmissionLocation.ts +22 -4
- package/src/hooks/useAssignedBedByPatient.ts +9 -0
- package/src/hooks/useBeds.ts +3 -4
- package/src/hooks/useConcept.ts +3 -4
- package/src/hooks/useEmrConfiguration.ts +5 -0
- package/src/hooks/useInpatientAdmission.ts +9 -14
- package/src/hooks/useInpatientRequest.ts +4 -15
- package/src/hooks/useLocations.ts +8 -51
- package/src/hooks/useMotherAndChildren.ts +46 -0
- package/src/hooks/useObs.ts +3 -7
- package/src/hooks/usePatientPendingOrders.ts +16 -0
- package/src/hooks/useWardPatientGrouping.ts +32 -0
- package/src/index.ts +45 -17
- package/src/location-selector/location-selector.component.tsx +18 -21
- package/src/root.component.tsx +3 -0
- package/src/routes.json +41 -3
- package/src/types/index.ts +50 -1
- package/src/ward-patient-card/card-rows/admission-request-note-row.component.tsx +38 -0
- package/src/ward-patient-card/card-rows/coded-obs-tags-row.component.tsx +108 -0
- package/src/ward-patient-card/card-rows/mother-child-row.component.tsx +84 -0
- package/src/ward-patient-card/card-rows/mother-child-row.scss +22 -0
- package/src/ward-patient-card/card-rows/pending-items-row.component.tsx +54 -0
- package/src/ward-patient-card/row-elements/ward-patient-age.tsx +1 -1
- package/src/ward-patient-card/row-elements/ward-patient-coded-obs-tags.tsx +62 -39
- package/src/ward-patient-card/row-elements/ward-patient-header-address.tsx +5 -5
- package/src/ward-patient-card/row-elements/ward-patient-identifier.tsx +18 -41
- package/src/ward-patient-card/row-elements/ward-patient-location.tsx +19 -0
- package/src/ward-patient-card/row-elements/ward-patient-obs.resource.ts +38 -34
- package/src/ward-patient-card/row-elements/ward-patient-obs.tsx +26 -13
- package/src/ward-patient-card/row-elements/ward-patient-pending-order.component.tsx +45 -0
- package/src/ward-patient-card/row-elements/ward-patient-pending-transfer.tsx +38 -0
- package/src/ward-patient-card/row-elements/ward-patient-responsive-tooltip.tsx +32 -0
- package/src/ward-patient-card/row-elements/ward-patient-skeleton-text.tsx +9 -0
- package/src/ward-patient-card/ward-patient-card.component.tsx +14 -45
- package/src/ward-patient-card/ward-patient-card.scss +68 -9
- package/src/ward-view/default-ward/default-ward-beds.component.tsx +42 -0
- package/src/ward-view/default-ward/default-ward-patient-card-header.component.tsx +32 -0
- package/src/ward-view/default-ward/default-ward-patient-card.component.tsx +31 -0
- package/src/ward-view/default-ward/default-ward-pending-patients.component.tsx +52 -0
- package/src/ward-view/default-ward/default-ward-unassigned-patients.component.tsx +32 -0
- package/src/ward-view/default-ward/default-ward-view.component.tsx +31 -0
- package/src/ward-view/materal-ward/maternal-ward-beds.component.tsx +65 -0
- package/src/ward-view/materal-ward/maternal-ward-patient-card-header.component.tsx +30 -0
- package/src/ward-view/materal-ward/maternal-ward-patient-card.component.tsx +93 -0
- package/src/{beds/occupied-bed.scss → ward-view/materal-ward/maternal-ward-patient-card.scss} +4 -9
- package/src/ward-view/materal-ward/maternal-ward-patient-card.test.tsx +58 -0
- package/src/ward-view/materal-ward/maternal-ward-pending-patients.component.tsx +48 -0
- package/src/ward-view/materal-ward/maternal-ward-unassigned-patients.component.tsx +33 -0
- package/src/ward-view/materal-ward/maternal-ward-view.component.tsx +38 -0
- package/src/ward-view/materal-ward/maternal-ward-view.resource.ts +89 -0
- package/src/ward-view/ward-view.component.tsx +15 -163
- package/src/ward-view/ward-view.resource.ts +193 -1
- package/src/ward-view/ward-view.scss +17 -6
- package/src/ward-view/ward-view.test.tsx +43 -48
- package/src/ward-view/ward.component.tsx +106 -0
- package/src/ward-view-header/admission-requests-bar.component.tsx +14 -9
- package/src/ward-view-header/admission-requests-bar.test.tsx +11 -23
- package/src/ward-view-header/admission-requests.scss +1 -1
- package/src/ward-view-header/ward-metric.component.tsx +24 -0
- package/src/ward-view-header/ward-metric.scss +25 -0
- package/src/ward-view-header/ward-metrics.component.tsx +78 -0
- package/src/ward-view-header/ward-metrics.scss +7 -0
- package/src/ward-view-header/ward-metrics.test.tsx +37 -0
- package/src/ward-view-header/ward-view-header.component.tsx +9 -4
- package/src/ward-view-header/ward-view-header.scss +0 -1
- package/src/ward-workspace/admission-request-card/admission-request-card-actions.component.tsx +70 -6
- package/src/ward-workspace/admission-request-card/admission-request-card-header.component.tsx +10 -23
- package/src/ward-workspace/admission-request-card/admission-request-card.component.tsx +9 -3
- package/src/ward-workspace/admission-request-card/admission-request-card.scss +13 -4
- package/src/ward-workspace/admission-request-workspace/admission-requests-workspace.test.tsx +55 -33
- package/src/ward-workspace/admission-request-workspace/admission-requests.workspace.tsx +30 -37
- package/src/ward-workspace/admit-patient-form-workspace/admit-patient-form.test.tsx +98 -203
- package/src/ward-workspace/admit-patient-form-workspace/admit-patient-form.workspace.tsx +116 -180
- package/src/ward-workspace/bed-selector.component.tsx +119 -0
- package/src/ward-workspace/bed-selector.scss +15 -0
- package/src/ward-workspace/patient-banner/patient-banner.component.tsx +7 -14
- package/src/ward-workspace/patient-clinical-forms-workspace/patient-clinical-forms.workspace.tsx +23 -0
- package/src/{ward-patient-workspace → ward-workspace/patient-details}/ward-patient-action-button.extension.tsx +2 -1
- package/src/{ward-patient-workspace → ward-workspace/patient-details}/ward-patient.workspace.tsx +18 -9
- package/src/ward-workspace/patient-discharge/patient-discharge.scss +41 -0
- package/src/ward-workspace/patient-discharge/patient-discharge.workspace.tsx +113 -0
- package/src/ward-workspace/patient-transfer-bed-swap/patient-bed-swap-form.component.tsx +68 -79
- package/src/ward-workspace/patient-transfer-bed-swap/patient-transfer-request-form.component.tsx +24 -24
- package/src/ward-workspace/patient-transfer-bed-swap/patient-transfer-swap.scss +12 -2
- package/src/ward-workspace/patient-transfer-bed-swap/patient-transfer-swap.workspace.tsx +12 -8
- package/src/ward-workspace/patient-transfer-request-workspace/patient-transfer-request.workspace.tsx +11 -0
- package/src/ward-workspace/ward-patient-notes/form/notes-form.component.tsx +1 -1
- package/src/ward-workspace/ward-patient-notes/form/notes-form.test.tsx +1 -1
- package/src/ward-workspace/ward-patient-notes/history/notes-container.component.tsx +2 -2
- package/src/ward-workspace/ward-patient-notes/notes.resource.ts +5 -7
- package/src/ward-workspace/ward-patient-notes/notes.workspace.tsx +1 -1
- package/src/ward-workspace/ward-patient-notes/types.ts +0 -4
- package/src/ward.resource.ts +38 -2
- package/translations/en.json +31 -7
- package/dist/152.js +0 -1
- package/dist/152.js.map +0 -1
- package/dist/255.js.map +0 -1
- package/dist/269.js +0 -1
- package/dist/269.js.map +0 -1
- package/dist/346.js +0 -1
- package/dist/346.js.map +0 -1
- package/dist/466.js +0 -1
- package/dist/466.js.map +0 -1
- package/dist/659.js.map +0 -1
- package/dist/729.js +0 -1
- package/dist/729.js.map +0 -1
- package/dist/749.js +0 -1
- package/dist/749.js.map +0 -1
- package/dist/76.js +0 -1
- package/dist/76.js.map +0 -1
- package/dist/793.js +0 -2
- package/dist/793.js.map +0 -1
- package/dist/803.js +0 -1
- package/dist/803.js.map +0 -1
- package/dist/960.js.map +0 -1
- package/src/beds/empty-bed.scss +0 -28
- package/src/beds/occupied-bed.component.tsx +0 -35
- package/src/beds/unassigned-patient.component.tsx +0 -20
- package/src/beds/unassigned-patient.scss +0 -6
- package/src/config-schema-admission-request-note.ts +0 -9
- package/src/config-schema-extension-colored-obs-tags.ts +0 -91
- package/src/hooks/useCurrentWardCardConfig.ts +0 -32
- package/src/ward-patient-card/card-rows/admission-request-note.extension.tsx +0 -27
- package/src/ward-patient-card/card-rows/colored-obs-tags-card-row.extension.tsx +0 -13
- package/src/ward-patient-card/ward-patient-card-element.component.tsx +0 -65
- package/src/ward-view/ward-bed.component.tsx +0 -14
- /package/dist/{793.js.LICENSE.txt → 303.js.LICENSE.txt} +0 -0
- /package/dist/{255.js.LICENSE.txt → 372.js.LICENSE.txt} +0 -0
- /package/src/{ward-patient-workspace → ward-workspace/patient-details}/ward-patient.style.scss +0 -0
package/src/ward-workspace/admission-request-card/admission-request-card-actions.component.tsx
CHANGED
|
@@ -1,25 +1,89 @@
|
|
|
1
1
|
import { Button } from '@carbon/react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
ArrowRightIcon,
|
|
4
|
+
launchWorkspace,
|
|
5
|
+
showSnackbar,
|
|
6
|
+
useAppContext,
|
|
7
|
+
useFeatureFlag,
|
|
8
|
+
useLayoutType,
|
|
9
|
+
} from '@openmrs/esm-framework';
|
|
10
|
+
import React, { useCallback, useContext } from 'react';
|
|
4
11
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import
|
|
12
|
+
import useWardLocation from '../../hooks/useWardLocation';
|
|
13
|
+
import type { WardPatientCardType, WardPatientWorkspaceProps, WardViewContext } from '../../types';
|
|
14
|
+
import { useAdmitPatient } from '../../ward.resource';
|
|
15
|
+
import { AdmissionRequestsWorkspaceContext } from '../admission-request-workspace/admission-requests.workspace';
|
|
6
16
|
import type { AdmitPatientFormWorkspaceProps } from '../admit-patient-form-workspace/types';
|
|
7
17
|
import styles from './admission-request-card.scss';
|
|
8
18
|
|
|
9
|
-
const AdmissionRequestCardActions:
|
|
19
|
+
const AdmissionRequestCardActions: WardPatientCardType = (wardPatient) => {
|
|
20
|
+
const { patient, inpatientRequest } = wardPatient;
|
|
10
21
|
const { dispositionType } = inpatientRequest;
|
|
11
22
|
const { t } = useTranslation();
|
|
23
|
+
const { location } = useWardLocation();
|
|
12
24
|
const responsiveSize = useLayoutType() === 'tablet' ? 'lg' : 'md';
|
|
25
|
+
const { WardPatientHeader, wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {};
|
|
26
|
+
const { admitPatient, isLoadingEmrConfiguration, errorFetchingEmrConfiguration } = useAdmitPatient();
|
|
27
|
+
|
|
13
28
|
const launchPatientAdmissionForm = useCallback(
|
|
14
29
|
() => launchWorkspace<AdmitPatientFormWorkspaceProps>('admit-patient-form-workspace', { patient, dispositionType }),
|
|
15
30
|
[],
|
|
16
31
|
);
|
|
32
|
+
|
|
33
|
+
const launchPatientTransferForm = useCallback(() => {
|
|
34
|
+
launchWorkspace<WardPatientWorkspaceProps>('patient-transfer-request-workspace', {
|
|
35
|
+
wardPatient,
|
|
36
|
+
WardPatientHeader,
|
|
37
|
+
});
|
|
38
|
+
}, [wardPatient, WardPatientHeader]);
|
|
39
|
+
const isBedManagementModuleInstalled = useFeatureFlag('bedmanagement-module');
|
|
40
|
+
const { closeWorkspaceWithSavedChanges } = useContext(AdmissionRequestsWorkspaceContext);
|
|
41
|
+
|
|
42
|
+
// If bed management module is installed, open the next form
|
|
43
|
+
// for bed selection. If not, admit patient directly
|
|
44
|
+
const onAdmit = () => {
|
|
45
|
+
if (isBedManagementModuleInstalled) {
|
|
46
|
+
launchPatientAdmissionForm();
|
|
47
|
+
} else {
|
|
48
|
+
admitPatient(patient, dispositionType)
|
|
49
|
+
.then(
|
|
50
|
+
(response) => {
|
|
51
|
+
if (response && response?.ok) {
|
|
52
|
+
showSnackbar({
|
|
53
|
+
kind: 'success',
|
|
54
|
+
title: t('patientAdmittedSuccessfully', 'Patient admitted successfully'),
|
|
55
|
+
subtitle: t('patientAdmittedWoBed', 'Patient admitted successfully to {{location}}', {
|
|
56
|
+
location: location?.display,
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
(err: Error) => {
|
|
62
|
+
showSnackbar({
|
|
63
|
+
kind: 'error',
|
|
64
|
+
title: t('errorCreatingEncounter', 'Failed to admit patient'),
|
|
65
|
+
subtitle: err.message,
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
)
|
|
69
|
+
.finally(() => {
|
|
70
|
+
wardPatientGroupDetails?.mutate?.();
|
|
71
|
+
closeWorkspaceWithSavedChanges();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
17
76
|
return (
|
|
18
77
|
<div className={styles.admissionRequestActionBar}>
|
|
19
|
-
<Button kind="ghost" size={responsiveSize}>
|
|
78
|
+
<Button kind="ghost" size={responsiveSize} onClick={launchPatientTransferForm}>
|
|
20
79
|
{t('transferElsewhere', 'Transfer elsewhere')}
|
|
21
80
|
</Button>
|
|
22
|
-
<Button
|
|
81
|
+
<Button
|
|
82
|
+
kind="ghost"
|
|
83
|
+
renderIcon={ArrowRightIcon}
|
|
84
|
+
size={responsiveSize}
|
|
85
|
+
disabled={isLoadingEmrConfiguration || errorFetchingEmrConfiguration}
|
|
86
|
+
onClick={onAdmit}>
|
|
23
87
|
{t('admitPatient', 'Admit patient')}
|
|
24
88
|
</Button>
|
|
25
89
|
</div>
|
package/src/ward-workspace/admission-request-card/admission-request-card-header.component.tsx
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatDatetime, getLocale } from '@openmrs/esm-framework';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { WardPatientCardElement } from '../../ward-patient-card/ward-patient-card-element.component';
|
|
4
|
+
import { type WardPatientCardType } from '../../types';
|
|
5
|
+
import WardPatientAge from '../../ward-patient-card/row-elements/ward-patient-age';
|
|
6
|
+
import WardPatientGender from '../../ward-patient-card/row-elements/ward-patient-gender.component';
|
|
7
|
+
import WardPatientIdentifier from '../../ward-patient-card/row-elements/ward-patient-identifier';
|
|
9
8
|
import WardPatientName from '../../ward-patient-card/row-elements/ward-patient-name';
|
|
9
|
+
import styles from './admission-request-card.scss';
|
|
10
10
|
|
|
11
|
-
const AdmissionRequestCardHeader:
|
|
11
|
+
const AdmissionRequestCardHeader: WardPatientCardType = (wardPatient) => {
|
|
12
12
|
const { inpatientRequest } = wardPatient;
|
|
13
13
|
const { dispositionEncounter } = inpatientRequest;
|
|
14
|
-
const { id, headerRowElements } = useCurrentWardCardConfig();
|
|
15
14
|
const { patient } = wardPatient;
|
|
16
|
-
const extensionSlotState = wardPatient;
|
|
17
|
-
|
|
18
|
-
const rowsExtensionSlotName = id == 'default' ? 'ward-patient-card-slot' : `ward-patient-card-${id}-slot`;
|
|
19
15
|
|
|
20
16
|
return (
|
|
21
17
|
<div className={styles.admissionRequestCardHeaderContainer}>
|
|
22
18
|
<div className={styles.admissionRequestCardHeader}>
|
|
23
19
|
<WardPatientName patient={patient} />
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
elementId={elementId}
|
|
28
|
-
{...wardPatient}
|
|
29
|
-
/>
|
|
30
|
-
))}
|
|
20
|
+
<WardPatientIdentifier id="patient-identifier" patient={patient} />
|
|
21
|
+
<WardPatientGender patient={patient} />
|
|
22
|
+
<WardPatientAge patient={patient} />
|
|
31
23
|
</div>
|
|
32
24
|
<div className={classNames(styles.admissionRequestCardHeader, styles.admissionEncounterDetails)}>
|
|
33
25
|
<div>
|
|
@@ -39,11 +31,6 @@ const AdmissionRequestCardHeader: WardPatientCard = (wardPatient) => {
|
|
|
39
31
|
<div>{dispositionEncounter?.encounterProviders?.map((provider) => provider?.provider?.display).join(',')}</div>
|
|
40
32
|
<div>{dispositionEncounter?.location?.display}</div>
|
|
41
33
|
</div>
|
|
42
|
-
<ExtensionSlot
|
|
43
|
-
name={rowsExtensionSlotName}
|
|
44
|
-
state={extensionSlotState}
|
|
45
|
-
className={styles.admissionRequestCardRow}
|
|
46
|
-
/>
|
|
47
34
|
</div>
|
|
48
35
|
);
|
|
49
36
|
};
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type {
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { WardPatient, WardPatientCardType } from '../../types';
|
|
3
3
|
import AdmissionRequestCardActions from './admission-request-card-actions.component';
|
|
4
4
|
import AdmissionRequestCardHeader from './admission-request-card-header.component';
|
|
5
5
|
import styles from './admission-request-card.scss';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface AdmissionRequestCardProps {
|
|
8
|
+
wardPatient: WardPatient;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const AdmissionRequestCard: React.FC<AdmissionRequestCardProps> = ({ wardPatient, children }) => {
|
|
8
13
|
return (
|
|
9
14
|
<div className={styles.admissionRequestCard}>
|
|
10
15
|
<AdmissionRequestCardHeader {...wardPatient} />
|
|
16
|
+
{children}
|
|
11
17
|
<AdmissionRequestCardActions {...wardPatient} />
|
|
12
18
|
</div>
|
|
13
19
|
);
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
height: fit-content;
|
|
9
9
|
color: $color-gray-70;
|
|
10
10
|
margin-bottom: layout.$spacing-05;
|
|
11
|
+
|
|
12
|
+
> div {
|
|
13
|
+
margin: layout.$spacing-04;
|
|
14
|
+
width: unset;
|
|
15
|
+
}
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
.admissionRequestCardHeaderContainer {
|
|
@@ -25,10 +30,14 @@
|
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
.admissionRequestCardExtensionSlot {
|
|
34
|
+
display: none;
|
|
35
|
+
|
|
36
|
+
&:has(div:not(:empty)) {
|
|
37
|
+
display: block;
|
|
38
|
+
margin: layout.$spacing-03 0;
|
|
39
|
+
background-color: white;
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
.admissionEncounterDetails {
|
package/src/ward-workspace/admission-request-workspace/admission-requests-workspace.test.tsx
CHANGED
|
@@ -1,48 +1,70 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useAppContext } from '@openmrs/esm-framework';
|
|
2
2
|
import { screen } from '@testing-library/react';
|
|
3
|
-
import
|
|
4
|
-
import { useInpatientRequest } from '../../hooks/useInpatientRequest';
|
|
5
|
-
import { configSchema } from '../../config-schema';
|
|
6
|
-
import useWardLocation from '../../hooks/useWardLocation';
|
|
7
|
-
import AdmissionRequestsWorkspace from './admission-requests.workspace';
|
|
8
|
-
import { mockInpatientRequest, mockLocationInpatientWard } from '../../../../../__mocks__';
|
|
3
|
+
import React from 'react';
|
|
9
4
|
import { renderWithSwr } from '../../../../../tools';
|
|
5
|
+
import { mockWardViewContext } from '../../../mock';
|
|
6
|
+
import useEmrConfiguration from '../../hooks/useEmrConfiguration';
|
|
7
|
+
import { type WardViewContext } from '../../types';
|
|
8
|
+
import DefaultWardPendingPatients from '../../ward-view/default-ward/default-ward-pending-patients.component';
|
|
9
|
+
import AdmissionRequestsWorkspace, { type AdmissionRequestsWorkspaceProps } from './admission-requests.workspace';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
jest.mock('../../hooks/useInpatientRequest', () => ({
|
|
14
|
-
useInpatientRequest: jest.fn(),
|
|
15
|
-
}));
|
|
16
|
-
jest.mock('../../hooks/useWardLocation', () => jest.fn());
|
|
17
|
-
|
|
18
|
-
const mockUseWardLocation = useWardLocation as jest.Mock;
|
|
19
|
-
mockUseWardLocation.mockReturnValue({
|
|
20
|
-
location: mockLocationInpatientWard,
|
|
21
|
-
isLoadingLocation: false,
|
|
22
|
-
errorFetchingLocation: null,
|
|
23
|
-
invalidLocation: false,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const mockInpatientRequestResponse = {
|
|
27
|
-
error: undefined,
|
|
28
|
-
mutate: jest.fn(),
|
|
29
|
-
isValidating: false,
|
|
30
|
-
isLoading: false,
|
|
31
|
-
inpatientRequests: [mockInpatientRequest],
|
|
32
|
-
};
|
|
11
|
+
jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
|
|
33
12
|
|
|
34
|
-
jest.
|
|
13
|
+
jest.mock('../../hooks/useEmrConfiguration', () => jest.fn());
|
|
14
|
+
const mockedUseEmrConfiguration = jest.mocked(useEmrConfiguration);
|
|
35
15
|
|
|
36
|
-
const workspaceProps = {
|
|
16
|
+
const workspaceProps: AdmissionRequestsWorkspaceProps = {
|
|
37
17
|
closeWorkspace: jest.fn(),
|
|
38
18
|
promptBeforeClosing: jest.fn(),
|
|
39
19
|
closeWorkspaceWithSavedChanges: jest.fn(),
|
|
40
20
|
setTitle: jest.fn(),
|
|
21
|
+
wardPendingPatients: <DefaultWardPendingPatients />,
|
|
41
22
|
};
|
|
42
23
|
|
|
43
24
|
describe('Admission Requests Workspace', () => {
|
|
44
|
-
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
mockedUseEmrConfiguration.mockReturnValue({
|
|
27
|
+
isLoadingEmrConfiguration: false,
|
|
28
|
+
errorFetchingEmrConfiguration: null,
|
|
29
|
+
// @ts-ignore - we only need these keys for now
|
|
30
|
+
emrConfiguration: {
|
|
31
|
+
admissionEncounterType: {
|
|
32
|
+
uuid: 'admission-encounter-type-uuid',
|
|
33
|
+
display: 'Admission Encounter',
|
|
34
|
+
},
|
|
35
|
+
transferWithinHospitalEncounterType: {
|
|
36
|
+
uuid: 'transfer-within-hospital-encounter-type-uuid',
|
|
37
|
+
display: 'Transfer Within Hospital Encounter Type',
|
|
38
|
+
},
|
|
39
|
+
clinicianEncounterRole: {
|
|
40
|
+
uuid: 'clinician-encounter-role-uuid',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
mutateEmrConfiguration: jest.fn(),
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should render an admission request card', () => {
|
|
48
|
+
renderWithSwr(<AdmissionRequestsWorkspace {...workspaceProps} />);
|
|
49
|
+
const alice = mockWardViewContext.wardPatientGroupDetails.inpatientRequestResponse.inpatientRequests[0].patient;
|
|
50
|
+
expect(screen.getByText(alice.person?.preferredName?.display as string)).toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should render an admission request card with disabled "admit patient" button when emr config fails to load', () => {
|
|
54
|
+
mockedUseEmrConfiguration.mockReturnValue({
|
|
55
|
+
isLoadingEmrConfiguration: false,
|
|
56
|
+
errorFetchingEmrConfiguration: true,
|
|
57
|
+
emrConfiguration: null,
|
|
58
|
+
mutateEmrConfiguration: jest.fn(),
|
|
59
|
+
});
|
|
60
|
+
|
|
45
61
|
renderWithSwr(<AdmissionRequestsWorkspace {...workspaceProps} />);
|
|
46
|
-
expect(screen.getByText(
|
|
62
|
+
expect(screen.getByText("Some parts of the form didn't load")).toBeInTheDocument();
|
|
63
|
+
expect(
|
|
64
|
+
screen.getByText(
|
|
65
|
+
'Fetching EMR configuration failed. Try refreshing the page or contact your system administrator.',
|
|
66
|
+
),
|
|
67
|
+
).toBeInTheDocument();
|
|
68
|
+
expect(screen.getByRole('button', { name: /Admit patient/i })).toBeDisabled();
|
|
47
69
|
});
|
|
48
70
|
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Search } from '@carbon/react';
|
|
5
|
-
import { ErrorState } from '@openmrs/esm-framework';
|
|
1
|
+
import { InlineNotification, Search } from '@carbon/react';
|
|
2
|
+
import { type DefaultWorkspaceProps } from '@openmrs/esm-framework';
|
|
3
|
+
import React, { createContext, type ReactNode } from 'react';
|
|
6
4
|
import { useTranslation } from 'react-i18next';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import useEmrConfiguration from '../../hooks/useEmrConfiguration';
|
|
6
|
+
import styles from './admission-requests-workspace.scss';
|
|
7
|
+
|
|
8
|
+
export interface AdmissionRequestsWorkspaceProps extends DefaultWorkspaceProps {
|
|
9
|
+
wardPendingPatients: ReactNode;
|
|
10
|
+
}
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
isLoading: isLoadingInpatientRequests,
|
|
15
|
-
error: errorFetchingInpatientRequests,
|
|
16
|
-
} = useInpatientRequest(['ADMIT', 'TRANSFER']);
|
|
12
|
+
export const AdmissionRequestsWorkspaceContext = createContext<AdmissionRequestsWorkspaceProps>(null);
|
|
13
|
+
|
|
14
|
+
const AdmissionRequestsWorkspace: React.FC<AdmissionRequestsWorkspaceProps> = (props) => {
|
|
15
|
+
const { wardPendingPatients } = props;
|
|
17
16
|
const { t } = useTranslation();
|
|
18
17
|
const [searchTerm, setSearchTerm] = React.useState('');
|
|
19
18
|
const handleSearch = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
20
19
|
setSearchTerm(event.target.value);
|
|
21
20
|
};
|
|
21
|
+
const { errorFetchingEmrConfiguration } = useEmrConfiguration();
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<div className={styles.admissionRequestsWorkspaceContainer}>
|
|
@@ -30,30 +30,23 @@ const AdmissionRequestsWorkspace: React.FC<AdmissionRequestsWorkspaceProps> = ()
|
|
|
30
30
|
placeholder={t('searchForPatient', 'Search for a patient')}
|
|
31
31
|
disabled
|
|
32
32
|
/>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
{errorFetchingEmrConfiguration && (
|
|
34
|
+
<div className={styles.formError}>
|
|
35
|
+
<InlineNotification
|
|
36
|
+
kind="error"
|
|
37
|
+
title={t('somePartsOfTheFormDidntLoad', "Some parts of the form didn't load")}
|
|
38
|
+
subtitle={t(
|
|
39
|
+
'fetchingEmrConfigurationFailed',
|
|
40
|
+
'Fetching EMR configuration failed. Try refreshing the page or contact your system administrator.',
|
|
41
|
+
)}
|
|
42
|
+
lowContrast
|
|
43
|
+
hideCloseButton
|
|
41
44
|
/>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
patient={request.patient}
|
|
48
|
-
visit={request.visit}
|
|
49
|
-
bed={null}
|
|
50
|
-
inpatientRequest={request}
|
|
51
|
-
inpatientAdmission={null}
|
|
52
|
-
/>
|
|
53
|
-
))}
|
|
54
|
-
</>
|
|
55
|
-
)}
|
|
56
|
-
</div>
|
|
45
|
+
</div>
|
|
46
|
+
)}
|
|
47
|
+
<AdmissionRequestsWorkspaceContext.Provider value={props}>
|
|
48
|
+
<div className={styles.content}>{wardPendingPatients}</div>
|
|
49
|
+
</AdmissionRequestsWorkspaceContext.Provider>
|
|
57
50
|
</div>
|
|
58
51
|
);
|
|
59
52
|
};
|