@openmrs/esm-ward-app 10.0.2 → 10.0.3-pre.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 +4 -3
- package/dist/1070.js +1 -0
- package/dist/1070.js.map +1 -0
- package/dist/1480.js +1 -0
- package/dist/1480.js.map +1 -0
- package/dist/1646.js +1 -0
- package/dist/1646.js.map +1 -0
- package/dist/1664.js +1 -0
- package/dist/1664.js.map +1 -0
- package/dist/1780.js +1 -0
- package/dist/1780.js.map +1 -0
- package/dist/1789.js +1 -0
- package/dist/1789.js.map +1 -0
- package/dist/1869.js +1 -0
- package/dist/1869.js.map +1 -0
- package/dist/1877.js +1 -0
- package/dist/1877.js.map +1 -0
- package/dist/1978.js +1 -0
- package/dist/1978.js.map +1 -0
- package/dist/2101.js +1 -0
- package/dist/2101.js.map +1 -0
- package/dist/2317.js +1 -0
- package/dist/2317.js.map +1 -0
- package/dist/2416.js +1 -0
- package/dist/2416.js.map +1 -0
- package/dist/2495.js +1 -0
- package/dist/2495.js.map +1 -0
- package/dist/282.js +1 -0
- package/dist/282.js.map +1 -0
- package/dist/2881.js +1 -0
- package/dist/2881.js.map +1 -0
- package/dist/2898.js +1 -0
- package/dist/2898.js.map +1 -0
- package/dist/3378.js +1 -0
- package/dist/3378.js.map +1 -0
- package/dist/3514.js +38 -0
- package/dist/3514.js.map +1 -0
- package/dist/3720.js +1 -0
- package/dist/3720.js.map +1 -0
- package/dist/3852.js +1 -0
- package/dist/3852.js.map +1 -0
- package/dist/3963.js +1 -0
- package/dist/3963.js.map +1 -0
- package/dist/3989.js +1 -0
- package/dist/3989.js.map +1 -0
- package/dist/4106.js +1 -0
- package/dist/4106.js.map +1 -0
- package/dist/4111.js +1 -0
- package/dist/4111.js.map +1 -0
- package/dist/434.js +1 -0
- package/dist/434.js.map +1 -0
- package/dist/4348.js +1 -0
- package/dist/4348.js.map +1 -0
- package/dist/4383.js +1 -0
- package/dist/4383.js.map +1 -0
- package/dist/4658.js +1 -0
- package/dist/4658.js.map +1 -0
- package/dist/466.js +1 -0
- package/dist/466.js.map +1 -0
- package/dist/4928.js +1 -0
- package/dist/4928.js.map +1 -0
- package/dist/502.js +1 -0
- package/dist/502.js.map +1 -0
- package/dist/5117.js +1 -0
- package/dist/5117.js.map +1 -0
- package/dist/5132.js +1 -0
- package/dist/5132.js.map +1 -0
- package/dist/5145.js +1 -0
- package/dist/5145.js.map +1 -0
- package/dist/5503.js +1 -0
- package/dist/5503.js.map +1 -0
- package/dist/5509.js +1 -0
- package/dist/5509.js.map +1 -0
- package/dist/556.js +1 -0
- package/dist/556.js.map +1 -0
- package/dist/5576.js +1 -0
- package/dist/5576.js.map +1 -0
- package/dist/5644.js +1 -0
- package/dist/5644.js.map +1 -0
- package/dist/5709.js +1 -0
- package/dist/5709.js.map +1 -0
- package/dist/5773.js +1 -0
- package/dist/5773.js.map +1 -0
- package/dist/582.js +1 -0
- package/dist/582.js.map +1 -0
- package/dist/5940.js +1 -0
- package/dist/5940.js.map +1 -0
- package/dist/6047.js +1 -0
- package/dist/6047.js.map +1 -0
- package/dist/6174.js +1 -0
- package/dist/6174.js.map +1 -0
- package/dist/6270.js +1 -0
- package/dist/6270.js.map +1 -0
- package/dist/6371.js +1 -0
- package/dist/6371.js.map +1 -0
- package/dist/6377.js +1 -0
- package/dist/6377.js.map +1 -0
- package/dist/6418.js +1 -0
- package/dist/6418.js.map +1 -0
- package/dist/6444.js +1 -0
- package/dist/6444.js.map +1 -0
- package/dist/6508.js +1 -0
- package/dist/6508.js.map +1 -0
- package/dist/6673.js +11 -0
- package/dist/6673.js.map +1 -0
- package/dist/6703.js +1 -0
- package/dist/6703.js.map +1 -0
- package/dist/6724.js +1 -0
- package/dist/6724.js.map +1 -0
- package/dist/6802.js +1 -0
- package/dist/6802.js.map +1 -0
- package/dist/689.js +1 -0
- package/dist/689.js.map +1 -0
- package/dist/6904.js +1 -0
- package/dist/6904.js.map +1 -0
- package/dist/7045.js +1 -0
- package/dist/7045.js.map +1 -0
- package/dist/7175.js +1 -0
- package/dist/7175.js.map +1 -0
- package/dist/7182.js +1 -0
- package/dist/7182.js.map +1 -0
- package/dist/7249.js +1 -0
- package/dist/7249.js.map +1 -0
- package/dist/7330.js +1 -0
- package/dist/7330.js.map +1 -0
- package/dist/7742.js +1 -0
- package/dist/7742.js.map +1 -0
- package/dist/7912.js +1 -0
- package/dist/7912.js.map +1 -0
- package/dist/8063.js +1 -0
- package/dist/8063.js.map +1 -0
- package/dist/833.js +1 -0
- package/dist/833.js.map +1 -0
- package/dist/8340.js +1 -0
- package/dist/8340.js.map +1 -0
- package/dist/8358.js +1 -0
- package/dist/8358.js.map +1 -0
- package/dist/8359.js +1 -0
- package/dist/8359.js.map +1 -0
- package/dist/8417.js +1 -0
- package/dist/8417.js.map +1 -0
- package/dist/8424.js +1 -0
- package/dist/8424.js.map +1 -0
- package/dist/8493.js +1 -0
- package/dist/8493.js.map +1 -0
- package/dist/85.js +1 -0
- package/dist/85.js.map +1 -0
- package/dist/8695.js +1 -0
- package/dist/8695.js.map +1 -0
- package/dist/9011.js +1 -0
- package/dist/{6925.js.map → 9011.js.map} +1 -1
- package/dist/903.js +1 -0
- package/dist/903.js.map +1 -0
- package/dist/9061.js +1 -0
- package/dist/9061.js.map +1 -0
- package/dist/9072.js +1 -0
- package/dist/9072.js.map +1 -0
- package/dist/9080.js +1 -0
- package/dist/9080.js.map +1 -0
- package/dist/9427.js +1 -0
- package/dist/9427.js.map +1 -0
- package/dist/9712.js +1 -0
- package/dist/9712.js.map +1 -0
- package/dist/9771.js +1 -0
- package/dist/9771.js.map +1 -0
- package/dist/9806.js +1 -0
- package/dist/9806.js.map +1 -0
- package/dist/9983.js +1 -0
- package/dist/9983.js.map +1 -0
- package/dist/main.js +6 -5
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-ward-app.js +6 -5
- package/dist/openmrs-esm-ward-app.js.buildmanifest.json +669 -585
- package/dist/openmrs-esm-ward-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +3 -2
- package/src/action-menu-buttons/order-basket-action-button.component.tsx +3 -2
- package/src/beds/empty-bed.component.tsx +1 -1
- package/src/beds/ward-bed.component.tsx +6 -2
- package/src/ward-patient-card/card-rows/mother-child-row.component.tsx +3 -39
- package/src/ward-patient-card/row-elements/ward-mother-or-child.component.tsx +50 -0
- package/src/ward-view/maternal-ward/maternal-ward-pending-patients.component.tsx +14 -6
- package/src/ward-view/maternal-ward/maternal-ward-view.resource.ts +2 -2
- package/src/ward-workspace/admission-request-card/admission-request-card-actions.component.tsx +14 -5
- package/src/ward-workspace/admission-request-card/maternal-admission-request-card.component.tsx +136 -0
- package/src/ward-workspace/admission-request-card/maternal-admission-request-card.resource.ts +11 -0
- package/src/ward-workspace/admit-patient-button.component.tsx +44 -26
- package/src/ward-workspace/admit-patient-form-workspace/admit-patient-form.test.tsx +19 -4
- package/src/ward-workspace/admit-patient-form-workspace/admit-patient-form.workspace.tsx +74 -69
- package/src/ward-workspace/cancel-admission-request-workspace/cancel-admission-request.component.tsx +41 -17
- package/src/ward-workspace/cancel-admission-request-workspace/cancel-admission-request.workspace.tsx +8 -2
- package/src/ward-workspace/create-admission-encounter/create-admission-encounter.workspace.tsx +9 -5
- package/src/ward-workspace/patient-transfer-bed-swap/patient-admit-or-transfer-request-form.component.tsx +29 -14
- package/src/ward-workspace/patient-transfer-request-workspace/patient-transfer-request.workspace.tsx +6 -1
- package/src/ward.resource.ts +4 -0
- package/translations/am.json +13 -12
- package/translations/ar.json +13 -12
- package/translations/ar_SY.json +13 -12
- package/translations/bn.json +13 -12
- package/translations/cs.json +13 -12
- package/translations/de.json +137 -136
- package/translations/en.json +13 -12
- package/translations/en_US.json +13 -12
- package/translations/es.json +13 -12
- package/translations/es_MX.json +13 -12
- package/translations/fr.json +13 -12
- package/translations/he.json +13 -12
- package/translations/hi.json +13 -12
- package/translations/hi_IN.json +13 -12
- package/translations/id.json +13 -12
- package/translations/it.json +13 -12
- package/translations/ka.json +13 -12
- package/translations/km.json +13 -12
- package/translations/ku.json +13 -12
- package/translations/ky.json +13 -12
- package/translations/lg.json +13 -12
- package/translations/ne.json +13 -12
- package/translations/pl.json +13 -12
- package/translations/pt.json +13 -12
- package/translations/pt_BR.json +13 -12
- package/translations/qu.json +13 -12
- package/translations/ro_RO.json +13 -12
- package/translations/ru_RU.json +13 -12
- package/translations/si.json +13 -12
- package/translations/sq.json +13 -12
- package/translations/sw.json +13 -12
- package/translations/sw_KE.json +13 -12
- package/translations/tr.json +13 -12
- package/translations/tr_TR.json +13 -12
- package/translations/uk.json +13 -12
- package/translations/uz.json +13 -12
- package/translations/uz@Latn.json +13 -12
- package/translations/uz_UZ.json +13 -12
- package/translations/vi.json +13 -12
- package/translations/zh.json +142 -141
- package/translations/zh_CN.json +93 -92
- package/translations/zh_TW.json +13 -12
- package/dist/1011.js +0 -1
- package/dist/1011.js.map +0 -1
- package/dist/126.js +0 -1
- package/dist/1307.js +0 -1
- package/dist/1307.js.map +0 -1
- package/dist/1369.js +0 -1
- package/dist/1369.js.map +0 -1
- package/dist/15.js +0 -1
- package/dist/1554.js +0 -1
- package/dist/1554.js.map +0 -1
- package/dist/1564.js +0 -1
- package/dist/1567.js +0 -1
- package/dist/1739.js +0 -1
- package/dist/1739.js.map +0 -1
- package/dist/1845.js +0 -1
- package/dist/1895.js +0 -1
- package/dist/1895.js.map +0 -1
- package/dist/1953.js +0 -1
- package/dist/2016.js +0 -1
- package/dist/2016.js.map +0 -1
- package/dist/2117.js +0 -1
- package/dist/2117.js.map +0 -1
- package/dist/215.js +0 -1
- package/dist/2178.js +0 -1
- package/dist/2191.js +0 -1
- package/dist/2191.js.map +0 -1
- package/dist/239.js +0 -1
- package/dist/239.js.map +0 -1
- package/dist/2459.js +0 -1
- package/dist/2459.js.map +0 -1
- package/dist/2566.js +0 -1
- package/dist/2586.js +0 -1
- package/dist/2586.js.map +0 -1
- package/dist/2640.js +0 -1
- package/dist/2640.js.map +0 -1
- package/dist/2759.js +0 -1
- package/dist/3089.js +0 -1
- package/dist/3089.js.map +0 -1
- package/dist/3230.js +0 -1
- package/dist/3441.js +0 -1
- package/dist/3565.js +0 -1
- package/dist/3571.js +0 -1
- package/dist/3571.js.map +0 -1
- package/dist/3624.js +0 -1
- package/dist/3624.js.map +0 -1
- package/dist/3746.js +0 -1
- package/dist/3925.js +0 -1
- package/dist/3946.js +0 -1
- package/dist/3948.js +0 -11
- package/dist/3948.js.map +0 -1
- package/dist/4285.js +0 -1
- package/dist/4285.js.map +0 -1
- package/dist/4373.js +0 -1
- package/dist/4373.js.map +0 -1
- package/dist/4425.js +0 -1
- package/dist/4425.js.map +0 -1
- package/dist/4675.js +0 -1
- package/dist/4675.js.map +0 -1
- package/dist/4744.js +0 -1
- package/dist/4744.js.map +0 -1
- package/dist/4809.js +0 -1
- package/dist/4894.js +0 -1
- package/dist/4970.js +0 -1
- package/dist/4970.js.map +0 -1
- package/dist/5130.js +0 -1
- package/dist/5187.js +0 -1
- package/dist/5490.js +0 -1
- package/dist/5490.js.map +0 -1
- package/dist/5491.js +0 -1
- package/dist/5491.js.map +0 -1
- package/dist/5595.js +0 -1
- package/dist/5659.js +0 -1
- package/dist/5659.js.map +0 -1
- package/dist/5961.js +0 -1
- package/dist/6026.js +0 -1
- package/dist/6026.js.map +0 -1
- package/dist/6133.js +0 -1
- package/dist/6199.js +0 -1
- package/dist/6199.js.map +0 -1
- package/dist/6285.js +0 -1
- package/dist/6285.js.map +0 -1
- package/dist/6296.js +0 -1
- package/dist/6296.js.map +0 -1
- package/dist/634.js +0 -1
- package/dist/634.js.map +0 -1
- package/dist/6455.js +0 -1
- package/dist/6455.js.map +0 -1
- package/dist/6456.js +0 -1
- package/dist/6466.js +0 -1
- package/dist/6515.js +0 -1
- package/dist/6515.js.map +0 -1
- package/dist/6613.js +0 -1
- package/dist/6783.js +0 -1
- package/dist/6925.js +0 -1
- package/dist/7073.js +0 -1
- package/dist/7073.js.map +0 -1
- package/dist/7348.js +0 -1
- package/dist/74.js +0 -1
- package/dist/74.js.map +0 -1
- package/dist/7543.js +0 -1
- package/dist/7607.js +0 -1
- package/dist/772.js +0 -1
- package/dist/8599.js +0 -1
- package/dist/8727.js +0 -1
- package/dist/8847.js +0 -1
- package/dist/892.js +0 -38
- package/dist/892.js.map +0 -1
- package/dist/9015.js +0 -1
- package/dist/906.js +0 -1
- package/dist/9065.js +0 -1
- package/dist/9071.js +0 -1
- package/dist/9071.js.map +0 -1
- package/dist/9182.js +0 -1
- package/dist/9314.js +0 -1
- package/dist/9314.js.map +0 -1
- package/dist/9339.js +0 -1
- package/dist/9453.js +0 -1
- package/dist/9668.js +0 -1
- package/dist/9668.js.map +0 -1
- package/dist/9727.js +0 -1
- package/dist/9727.js.map +0 -1
- package/dist/9833.js +0 -1
- package/dist/9833.js.map +0 -1
- package/dist/9920.js +0 -1
- package/dist/9938.js +0 -1
- /package/src/ward-patient-card/{card-rows/mother-child-row.scss → row-elements/ward-mother-or-child.scss} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { ActionMenuButton2, AddIcon, ShoppingCartIcon } from '@openmrs/esm-framework';
|
|
3
|
+
import { ActionMenuButton2, AddIcon, ShoppingCartIcon, usePatient } from '@openmrs/esm-framework';
|
|
4
4
|
import { type WardPatientWorkspaceDefinition } from '../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -8,6 +8,7 @@ import { type WardPatientWorkspaceDefinition } from '../types';
|
|
|
8
8
|
*/
|
|
9
9
|
function WardPatientOrderBasketActionButton({ groupProps: { wardPatient } }: WardPatientWorkspaceDefinition) {
|
|
10
10
|
const { t } = useTranslation();
|
|
11
|
+
const { patient: fhirPatient } = usePatient(wardPatient.patient.uuid);
|
|
11
12
|
|
|
12
13
|
return (
|
|
13
14
|
<ActionMenuButton2
|
|
@@ -17,7 +18,7 @@ function WardPatientOrderBasketActionButton({ groupProps: { wardPatient } }: War
|
|
|
17
18
|
workspaceName: 'ward-patient-order-basket-workspace',
|
|
18
19
|
windowProps: {
|
|
19
20
|
patientUuid: wardPatient.patient.uuid,
|
|
20
|
-
patient:
|
|
21
|
+
patient: fhirPatient,
|
|
21
22
|
visitContext: wardPatient.visit,
|
|
22
23
|
drugOrderWorkspaceName: 'ward-patient-order-basket-add-drug-order-workspace',
|
|
23
24
|
labOrderWorkspaceName: 'ward-patient-order-basket-add-lab-order-workspace',
|
|
@@ -12,7 +12,7 @@ const EmptyBed: React.FC<EmptyBedProps> = ({ bed }) => {
|
|
|
12
12
|
const { t } = useTranslation();
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
|
-
<div className={styles.emptyBed}>
|
|
15
|
+
<div id={`bed-${bed.bedNumber}`} className={styles.emptyBed}>
|
|
16
16
|
<span className={`${wardPatientCardStyles.wardPatientBedNumber} ${wardPatientCardStyles.empty}`}>
|
|
17
17
|
{bed.bedNumber}
|
|
18
18
|
</span>
|
|
@@ -15,7 +15,7 @@ const WardBed: React.FC<WardBedProps> = (props) => {
|
|
|
15
15
|
return patientCards?.length > 0 ? <OccupiedBed {...props} /> : <EmptyBed bed={bed} />;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const OccupiedBed: React.FC<WardBedProps> = ({ patientCards, isLoadingDivider }) => {
|
|
18
|
+
const OccupiedBed: React.FC<WardBedProps> = ({ patientCards, isLoadingDivider, bed }) => {
|
|
19
19
|
// interlace patient card with bed dividers between each of them
|
|
20
20
|
const patientCardsWithDividers = patientCards.flatMap((patientCard, index) => {
|
|
21
21
|
if (index == 0) {
|
|
@@ -25,7 +25,11 @@ const OccupiedBed: React.FC<WardBedProps> = ({ patientCards, isLoadingDivider })
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
return
|
|
28
|
+
return (
|
|
29
|
+
<div id={`bed-${bed.bedNumber}`} className={styles.occupiedBed}>
|
|
30
|
+
{patientCardsWithDividers}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
export default WardBed;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { type InpatientAdmission, type MaternalWardViewContext } from '../../types';
|
|
2
|
+
import { useAppContext } from '@openmrs/esm-framework';
|
|
3
|
+
import { type MaternalWardViewContext } from '../../types';
|
|
5
4
|
import { type MaternalWardPatientCardProps } from '../../ward-view/maternal-ward/maternal-ward-patient-card.component';
|
|
6
|
-
import
|
|
7
|
-
import WardPatientIdentifier from '../row-elements/ward-patient-identifier.component';
|
|
8
|
-
import WardPatientLocation from '../row-elements/ward-patient-location.component';
|
|
9
|
-
import WardPatientName from '../row-elements/ward-patient-name.component';
|
|
10
|
-
import wardPatientCardStyles from '../ward-patient-card.scss';
|
|
11
|
-
import styles from './mother-child-row.scss';
|
|
5
|
+
import MotherOrChild from '../row-elements/ward-mother-or-child.component';
|
|
12
6
|
|
|
13
7
|
/**
|
|
14
8
|
* This component displays the mother or children of the patient in the patient card. The patient's child is
|
|
@@ -51,34 +45,4 @@ const MotherChildRow: React.FC<MaternalWardPatientCardProps> = ({ wardPatient, c
|
|
|
51
45
|
);
|
|
52
46
|
};
|
|
53
47
|
|
|
54
|
-
interface MotherOrChildProp {
|
|
55
|
-
otherPatient: Patient;
|
|
56
|
-
otherPatientAdmission: InpatientAdmission;
|
|
57
|
-
isOtherPatientTheMother: boolean;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const MotherOrChild: React.FC<MotherOrChildProp> = ({
|
|
61
|
-
otherPatient,
|
|
62
|
-
otherPatientAdmission,
|
|
63
|
-
isOtherPatientTheMother,
|
|
64
|
-
}) => {
|
|
65
|
-
const Icon = isOtherPatientTheMother ? MotherIcon : BabyIcon;
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<div
|
|
69
|
-
key={otherPatient.uuid}
|
|
70
|
-
className={classNames(styles.motherOrBabyRow, wardPatientCardStyles.wardPatientCardRow)}>
|
|
71
|
-
<div className={styles.motherOrBabyIconDiv}>
|
|
72
|
-
<Icon className={styles.motherOrBabyIcon} size={24} />
|
|
73
|
-
</div>
|
|
74
|
-
<div className={classNames(styles.motherOrBabyRowElementsDiv, wardPatientCardStyles.dotSeparatedChildren)}>
|
|
75
|
-
<WardPatientName patient={otherPatient} />
|
|
76
|
-
<WardPatientIdentifier id="patient-identifier" patient={otherPatient} />
|
|
77
|
-
<WardPatientAge patient={otherPatient} />
|
|
78
|
-
<WardPatientLocation inpatientAdmission={otherPatientAdmission} />
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
48
|
export default MotherChildRow;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { BabyIcon, MotherIcon, type Patient } from '@openmrs/esm-framework';
|
|
4
|
+
import WardPatientAge from '../row-elements/ward-patient-age.component';
|
|
5
|
+
import WardPatientIdentifier from '../row-elements/ward-patient-identifier.component';
|
|
6
|
+
import WardPatientLocation from '../row-elements/ward-patient-location.component';
|
|
7
|
+
import WardPatientName from '../row-elements/ward-patient-name.component';
|
|
8
|
+
import { type InpatientAdmission } from '../../types';
|
|
9
|
+
import styles from './ward-mother-or-child.scss';
|
|
10
|
+
import wardPatientCardStyles from '../ward-patient-card.scss';
|
|
11
|
+
|
|
12
|
+
interface MotherOrChildProp {
|
|
13
|
+
otherPatient: Patient;
|
|
14
|
+
otherPatientAdmission: InpatientAdmission;
|
|
15
|
+
isOtherPatientTheMother: boolean;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A row element that displays a related patient (otherPatient) to the ward patient. The related patient
|
|
21
|
+
* can either be the mother or child of the ward patient.
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
const MotherOrChild: React.FC<MotherOrChildProp> = ({
|
|
25
|
+
otherPatient,
|
|
26
|
+
otherPatientAdmission,
|
|
27
|
+
isOtherPatientTheMother,
|
|
28
|
+
children,
|
|
29
|
+
}) => {
|
|
30
|
+
const Icon = isOtherPatientTheMother ? MotherIcon : BabyIcon;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div key={otherPatient.uuid} className={wardPatientCardStyles.wardPatientCardRow}>
|
|
34
|
+
{children}
|
|
35
|
+
<div className={styles.motherOrBabyRow}>
|
|
36
|
+
<div className={styles.motherOrBabyIconDiv}>
|
|
37
|
+
<Icon className={styles.motherOrBabyIcon} size={24} />
|
|
38
|
+
</div>
|
|
39
|
+
<div className={classNames(styles.motherOrBabyRowElementsDiv, wardPatientCardStyles.dotSeparatedChildren)}>
|
|
40
|
+
<WardPatientName patient={otherPatient} />
|
|
41
|
+
<WardPatientIdentifier id="patient-identifier" patient={otherPatient} />
|
|
42
|
+
<WardPatientAge patient={otherPatient} />
|
|
43
|
+
<WardPatientLocation inpatientAdmission={otherPatientAdmission} />
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default MotherOrChild;
|
|
@@ -6,7 +6,7 @@ import AdmissionRequestNoteRow from '../../ward-patient-card/card-rows/admission
|
|
|
6
6
|
import CodedObsTagsRow from '../../ward-patient-card/card-rows/coded-obs-tags-row.component';
|
|
7
7
|
import MotherChildRow from '../../ward-patient-card/card-rows/mother-child-row.component';
|
|
8
8
|
import WardPatientSkeletonText from '../../ward-patient-card/row-elements/ward-patient-skeleton-text.component';
|
|
9
|
-
import
|
|
9
|
+
import MaternalAdmissionRequestCard from '../../ward-workspace/admission-request-card/maternal-admission-request-card.component';
|
|
10
10
|
|
|
11
11
|
function MaternalWardPendingPatients() {
|
|
12
12
|
const { wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {};
|
|
@@ -18,6 +18,15 @@ function MaternalWardPendingPatients() {
|
|
|
18
18
|
error: errorFetchingInpatientRequests,
|
|
19
19
|
} = inpatientRequestResponse ?? {};
|
|
20
20
|
|
|
21
|
+
const inpatientRequestsOfWardByPatientUuid = inpatientRequests?.reduce(
|
|
22
|
+
(map, inpatientRequest) => {
|
|
23
|
+
const patientUuid = inpatientRequest.patient.uuid;
|
|
24
|
+
map[patientUuid] = inpatientRequest;
|
|
25
|
+
return map;
|
|
26
|
+
},
|
|
27
|
+
{} as Record<string, InpatientRequest>,
|
|
28
|
+
);
|
|
29
|
+
|
|
21
30
|
return isLoadingInpatientRequests ? (
|
|
22
31
|
<WardPatientSkeletonText />
|
|
23
32
|
) : errorFetchingInpatientRequests ? (
|
|
@@ -34,11 +43,10 @@ function MaternalWardPendingPatients() {
|
|
|
34
43
|
};
|
|
35
44
|
|
|
36
45
|
return (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</AdmissionRequestCard>
|
|
46
|
+
<MaternalAdmissionRequestCard
|
|
47
|
+
key={`admission-request-card-${i}`}
|
|
48
|
+
wardPatient={wardPatient}
|
|
49
|
+
inpatientRequestsOfWardByPatientUuid={inpatientRequestsOfWardByPatientUuid}></MaternalAdmissionRequestCard>
|
|
42
50
|
);
|
|
43
51
|
})}
|
|
44
52
|
</>
|
|
@@ -17,14 +17,14 @@ export function useMotherChildrenRelationshipsByPatient(
|
|
|
17
17
|
mothers: allWardPatientUuids,
|
|
18
18
|
requireMotherHasActiveVisit: true,
|
|
19
19
|
requireChildHasActiveVisit: true,
|
|
20
|
-
requireChildBornDuringMothersActiveVisit:
|
|
20
|
+
requireChildBornDuringMothersActiveVisit: false,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const getMotherRequestParams: MothersAndChildrenSearchCriteria = {
|
|
24
24
|
children: allWardPatientUuids,
|
|
25
25
|
requireMotherHasActiveVisit: true,
|
|
26
26
|
requireChildHasActiveVisit: true,
|
|
27
|
-
requireChildBornDuringMothersActiveVisit:
|
|
27
|
+
requireChildBornDuringMothersActiveVisit: false,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const {
|
package/src/ward-workspace/admission-request-card/admission-request-card-actions.component.tsx
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Button } from '@carbon/react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { closeWorkspaceGroup2,
|
|
5
|
-
import type {
|
|
4
|
+
import { closeWorkspaceGroup2, useLayoutType, useWorkspace2Context } from '@openmrs/esm-framework';
|
|
5
|
+
import type { WardPatient } from '../../types';
|
|
6
6
|
import AdmitPatientButton from '../admit-patient-button.component';
|
|
7
7
|
import styles from './admission-request-card.scss';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
interface AdmissionRequestCardActionsProps {
|
|
10
|
+
wardPatient: WardPatient;
|
|
11
|
+
relatedTransferPatients?: WardPatient[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const AdmissionRequestCardActions: React.FC<AdmissionRequestCardActionsProps> = ({
|
|
15
|
+
wardPatient,
|
|
16
|
+
relatedTransferPatients,
|
|
17
|
+
}) => {
|
|
10
18
|
const { t } = useTranslation();
|
|
11
19
|
const responsiveSize = useLayoutType() === 'tablet' ? 'lg' : 'md';
|
|
12
20
|
const { closeWorkspace, launchChildWorkspace } = useWorkspace2Context();
|
|
13
21
|
|
|
14
22
|
const launchPatientTransferForm = () => {
|
|
15
|
-
launchChildWorkspace('transfer-elsewhere-workspace', { wardPatient });
|
|
23
|
+
launchChildWorkspace('transfer-elsewhere-workspace', { wardPatient, relatedTransferPatients });
|
|
16
24
|
};
|
|
17
25
|
|
|
18
26
|
const launchCancelAdmissionForm = () => {
|
|
19
|
-
launchChildWorkspace('cancel-admission-request-workspace', { wardPatient });
|
|
27
|
+
launchChildWorkspace('cancel-admission-request-workspace', { wardPatient, relatedTransferPatients });
|
|
20
28
|
};
|
|
21
29
|
|
|
22
30
|
const isTransfer = wardPatient.inpatientRequest.dispositionType == 'TRANSFER';
|
|
@@ -31,6 +39,7 @@ const AdmissionRequestCardActions: WardPatientCardType = ({ wardPatient }) => {
|
|
|
31
39
|
</Button>
|
|
32
40
|
<AdmitPatientButton
|
|
33
41
|
wardPatient={wardPatient}
|
|
42
|
+
relatedTransferPatients={relatedTransferPatients}
|
|
34
43
|
dispositionType={wardPatient.inpatientRequest.dispositionType}
|
|
35
44
|
onAdmitPatientSuccess={async () => {
|
|
36
45
|
await closeWorkspace({ discardUnsavedChanges: true });
|
package/src/ward-workspace/admission-request-card/maternal-admission-request-card.component.tsx
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React, { useMemo, useState, type ReactNode } from 'react';
|
|
2
|
+
import { Checkbox, CheckboxGroup } from '@carbon/react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useAppContext } from '@openmrs/esm-framework';
|
|
5
|
+
import { makeWardPatient } from './maternal-admission-request-card.resource';
|
|
6
|
+
import type { InpatientRequest, MaternalWardViewContext, WardPatient } from '../../types';
|
|
7
|
+
import AdmissionRequestCardActions from './admission-request-card-actions.component';
|
|
8
|
+
import AdmissionRequestCardHeader from './admission-request-card-header.component';
|
|
9
|
+
import AdmissionRequestNoteRow from '../../ward-patient-card/card-rows/admission-request-note-row.component';
|
|
10
|
+
import CodedObsTagsRow from '../../ward-patient-card/card-rows/coded-obs-tags-row.component';
|
|
11
|
+
import MotherOrChild from '../../ward-patient-card/row-elements/ward-mother-or-child.component';
|
|
12
|
+
import styles from './admission-request-card.scss';
|
|
13
|
+
|
|
14
|
+
interface MaternalAdmissionRequestCardProps {
|
|
15
|
+
wardPatient: WardPatient;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
inpatientRequestsOfWardByPatientUuid: Record<string, InpatientRequest>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const MaternalAdmissionRequestCard: React.FC<MaternalAdmissionRequestCardProps> = ({
|
|
21
|
+
wardPatient,
|
|
22
|
+
children,
|
|
23
|
+
inpatientRequestsOfWardByPatientUuid,
|
|
24
|
+
}) => {
|
|
25
|
+
const { motherChildRelationships } = useAppContext<MaternalWardViewContext>('maternal-ward-view-context') ?? {};
|
|
26
|
+
const [selectedRelatedPatient, setCheckedRelatedPatient] = useState<string[]>([]);
|
|
27
|
+
const { t } = useTranslation();
|
|
28
|
+
|
|
29
|
+
const { childrenByMotherUuid, motherByChildUuid } = motherChildRelationships ?? {};
|
|
30
|
+
|
|
31
|
+
const motherOfPatient = useMemo(
|
|
32
|
+
() => motherByChildUuid?.get(wardPatient.patient.uuid) ?? null,
|
|
33
|
+
[motherByChildUuid, wardPatient.patient.uuid],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const childrenOfPatient = useMemo(
|
|
37
|
+
() => childrenByMotherUuid?.get(wardPatient.patient.uuid) ?? [],
|
|
38
|
+
[childrenByMotherUuid, wardPatient.patient.uuid],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const relatedPendingWardMother: WardPatient | null = useMemo(() => {
|
|
42
|
+
if (!motherOfPatient) return null;
|
|
43
|
+
const request = inpatientRequestsOfWardByPatientUuid[motherOfPatient.patient.uuid];
|
|
44
|
+
return request ? makeWardPatient(request) : null;
|
|
45
|
+
}, [motherOfPatient, inpatientRequestsOfWardByPatientUuid]);
|
|
46
|
+
|
|
47
|
+
const relatedPendingWardChildren: WardPatient[] = useMemo(() => {
|
|
48
|
+
const wardPatients: WardPatient[] = [];
|
|
49
|
+
for (const child of childrenOfPatient ?? []) {
|
|
50
|
+
const request = inpatientRequestsOfWardByPatientUuid[child.patient.uuid];
|
|
51
|
+
if (request) wardPatients.push(makeWardPatient(request));
|
|
52
|
+
}
|
|
53
|
+
return wardPatients;
|
|
54
|
+
}, [childrenOfPatient, inpatientRequestsOfWardByPatientUuid]);
|
|
55
|
+
|
|
56
|
+
const selectedRelatedWardPatients = useMemo(
|
|
57
|
+
() =>
|
|
58
|
+
[...(relatedPendingWardMother ? [relatedPendingWardMother] : []), ...relatedPendingWardChildren].filter((wp) =>
|
|
59
|
+
selectedRelatedPatient.includes(wp.patient.uuid),
|
|
60
|
+
),
|
|
61
|
+
[relatedPendingWardMother, relatedPendingWardChildren, selectedRelatedPatient],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div className={styles.admissionRequestCard}>
|
|
66
|
+
<AdmissionRequestCardHeader {...{ wardPatient }} />
|
|
67
|
+
<CodedObsTagsRow id="pregnancy-complications" {...wardPatient} />
|
|
68
|
+
{motherOfPatient && (
|
|
69
|
+
<MotherOrChild
|
|
70
|
+
otherPatient={motherOfPatient.patient}
|
|
71
|
+
otherPatientAdmission={motherOfPatient.currentAdmission}
|
|
72
|
+
isOtherPatientTheMother={true}>
|
|
73
|
+
{relatedPendingWardMother && (
|
|
74
|
+
<div>
|
|
75
|
+
<CheckboxGroup legendText={''}>
|
|
76
|
+
<Checkbox
|
|
77
|
+
checked={selectedRelatedPatient.includes(motherOfPatient.patient.uuid)}
|
|
78
|
+
className={styles.checkbox}
|
|
79
|
+
id={motherOfPatient.patient.uuid}
|
|
80
|
+
key={'also-transfer-' + motherOfPatient.patient.uuid}
|
|
81
|
+
labelText={
|
|
82
|
+
relatedPendingWardMother.inpatientRequest.dispositionType === 'ADMIT'
|
|
83
|
+
? t('alsoAdmitOrCancel', 'Also admit / cancel:')
|
|
84
|
+
: t('alsoTransferOrCancel', 'Also transfer / cancel:')
|
|
85
|
+
}
|
|
86
|
+
onChange={(_, { checked, id }) => {
|
|
87
|
+
const currentValue = selectedRelatedPatient;
|
|
88
|
+
setCheckedRelatedPatient(
|
|
89
|
+
checked ? [...currentValue, id] : currentValue.filter((item) => item !== id),
|
|
90
|
+
);
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
</CheckboxGroup>
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
</MotherOrChild>
|
|
97
|
+
)}
|
|
98
|
+
{childrenOfPatient?.map((childOfPatient) => (
|
|
99
|
+
<MotherOrChild
|
|
100
|
+
key={childOfPatient.patient.uuid}
|
|
101
|
+
otherPatient={childOfPatient.patient}
|
|
102
|
+
otherPatientAdmission={childOfPatient.currentAdmission}
|
|
103
|
+
isOtherPatientTheMother={false}>
|
|
104
|
+
{relatedPendingWardChildren.some((wp) => wp.patient.uuid === childOfPatient.patient.uuid) && (
|
|
105
|
+
<div>
|
|
106
|
+
<CheckboxGroup legendText={''}>
|
|
107
|
+
<Checkbox
|
|
108
|
+
checked={selectedRelatedPatient.includes(childOfPatient.patient.uuid)}
|
|
109
|
+
className={styles.checkbox}
|
|
110
|
+
id={childOfPatient.patient.uuid}
|
|
111
|
+
key={'also-transfer-' + childOfPatient.patient.uuid}
|
|
112
|
+
labelText={
|
|
113
|
+
relatedPendingWardChildren.find((wp) => wp.patient.uuid === childOfPatient.patient.uuid)
|
|
114
|
+
?.inpatientRequest.dispositionType === 'ADMIT'
|
|
115
|
+
? t('alsoAdmitOrCancel', 'Also admit / cancel:')
|
|
116
|
+
: t('alsoTransferOrCancel', 'Also transfer / cancel:')
|
|
117
|
+
}
|
|
118
|
+
onChange={(_, { checked, id }) => {
|
|
119
|
+
const currentValue = selectedRelatedPatient;
|
|
120
|
+
setCheckedRelatedPatient(
|
|
121
|
+
checked ? [...currentValue, id] : currentValue.filter((item) => item !== id),
|
|
122
|
+
);
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
</CheckboxGroup>
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
</MotherOrChild>
|
|
129
|
+
))}
|
|
130
|
+
<AdmissionRequestNoteRow id={'admission-request-note'} wardPatient={wardPatient} />
|
|
131
|
+
<AdmissionRequestCardActions wardPatient={wardPatient} relatedTransferPatients={selectedRelatedWardPatients} />
|
|
132
|
+
</div>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default MaternalAdmissionRequestCard;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type InpatientRequest, type WardPatient } from '../../types';
|
|
2
|
+
|
|
3
|
+
export function makeWardPatient(request: InpatientRequest): WardPatient {
|
|
4
|
+
return {
|
|
5
|
+
patient: request.patient,
|
|
6
|
+
visit: request.visit,
|
|
7
|
+
bed: null,
|
|
8
|
+
inpatientAdmission: null,
|
|
9
|
+
inpatientRequest: request,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -16,6 +16,8 @@ import { useAdmitPatient } from '../ward.resource';
|
|
|
16
16
|
interface AdmitPatientButtonProps {
|
|
17
17
|
wardPatient: WardPatient;
|
|
18
18
|
|
|
19
|
+
relatedTransferPatients?: WardPatient[];
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* whether to create an admit or transfer encounter for the given patient
|
|
21
23
|
*/
|
|
@@ -26,6 +28,7 @@ interface AdmitPatientButtonProps {
|
|
|
26
28
|
|
|
27
29
|
const AdmitPatientButton: React.FC<AdmitPatientButtonProps> = ({
|
|
28
30
|
wardPatient,
|
|
31
|
+
relatedTransferPatients,
|
|
29
32
|
onAdmitPatientSuccess,
|
|
30
33
|
disabled,
|
|
31
34
|
dispositionType,
|
|
@@ -39,7 +42,8 @@ const AdmitPatientButton: React.FC<AdmitPatientButtonProps> = ({
|
|
|
39
42
|
const [isAdmitting, setIsAdmitting] = useState(false);
|
|
40
43
|
const { launchChildWorkspace } = useWorkspace2Context();
|
|
41
44
|
|
|
42
|
-
const launchPatientAdmissionForm = () =>
|
|
45
|
+
const launchPatientAdmissionForm = () =>
|
|
46
|
+
launchChildWorkspace('admit-patient-form-workspace', { wardPatient, relatedTransferPatients });
|
|
43
47
|
|
|
44
48
|
const isBedManagementModuleInstalled = useFeatureFlag('bedmanagement-module');
|
|
45
49
|
|
|
@@ -51,45 +55,59 @@ const AdmitPatientButton: React.FC<AdmitPatientButtonProps> = ({
|
|
|
51
55
|
launchPatientAdmissionForm();
|
|
52
56
|
} else {
|
|
53
57
|
setIsAdmitting(true);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
const allPatientsToAdmit = [wardPatient, ...(relatedTransferPatients ?? [])];
|
|
59
|
+
const results = await Promise.allSettled(
|
|
60
|
+
allPatientsToAdmit.map((wp) =>
|
|
61
|
+
admitPatient(wp.patient, wp.inpatientRequest?.dispositionType ?? dispositionType, wp.visit.uuid),
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
await wardPatientGroupDetails?.mutate?.();
|
|
65
|
+
|
|
66
|
+
results.forEach((result, i) => {
|
|
67
|
+
const wp = allPatientsToAdmit[i];
|
|
68
|
+
const patientName = wp.patient.person.preferredName.display;
|
|
69
|
+
const wpDispositionType = wp.inpatientRequest?.dispositionType ?? dispositionType;
|
|
70
|
+
if (result.status === 'fulfilled') {
|
|
58
71
|
showSnackbar({
|
|
59
72
|
kind: 'success',
|
|
60
73
|
title:
|
|
61
|
-
|
|
74
|
+
wpDispositionType === 'ADMIT'
|
|
62
75
|
? t('patientAdmittedSuccessfully', 'Patient admitted successfully')
|
|
63
76
|
: t('patientTransferredSuccessfully', 'Patient transferred successfully'),
|
|
64
77
|
subtitle:
|
|
65
|
-
|
|
66
|
-
? t('patientAdmittedToLocation', '
|
|
78
|
+
wpDispositionType === 'ADMIT'
|
|
79
|
+
? t('patientAdmittedToLocation', '{{patientName}} admitted successfully to {{location}}', {
|
|
80
|
+
patientName,
|
|
67
81
|
location: location?.display,
|
|
68
82
|
})
|
|
69
|
-
: t('patientTransferredToLocation', '
|
|
83
|
+
: t('patientTransferredToLocation', '{{patientName}} transferred successfully to {{location}}', {
|
|
84
|
+
patientName,
|
|
70
85
|
location: location?.display,
|
|
71
86
|
}),
|
|
72
87
|
});
|
|
88
|
+
} else {
|
|
89
|
+
// TODO: better way to handle / display error messages
|
|
90
|
+
// https://openmrs.atlassian.net/browse/O3-5423
|
|
91
|
+
const err = result.reason;
|
|
92
|
+
const errorMessage =
|
|
93
|
+
err?.responseBody?.error?.globalErrors?.[0]?.message ??
|
|
94
|
+
err?.message ??
|
|
95
|
+
t('unknownError', 'An unknown error occurred');
|
|
96
|
+
showSnackbar({
|
|
97
|
+
kind: 'error',
|
|
98
|
+
title:
|
|
99
|
+
wpDispositionType === 'ADMIT'
|
|
100
|
+
? t('errorAdmittingPatient', 'Failed to admit {{patientName}}', { patientName })
|
|
101
|
+
: t('errorTransferringPatient', 'Failed to transfer {{patientName}}', { patientName }),
|
|
102
|
+
subtitle: errorMessage,
|
|
103
|
+
});
|
|
73
104
|
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (results.some((r) => r.status === 'fulfilled')) {
|
|
74
108
|
onAdmitPatientSuccess();
|
|
75
|
-
} catch (err) {
|
|
76
|
-
// TODO: better way to handle / display error messages
|
|
77
|
-
// https://openmrs.atlassian.net/browse/O3-5423
|
|
78
|
-
const errorMessage =
|
|
79
|
-
err?.responseBody?.error?.globalErrors?.[0]?.message ??
|
|
80
|
-
err.message ??
|
|
81
|
-
t('unknownError', 'An unknown error occurred');
|
|
82
|
-
showSnackbar({
|
|
83
|
-
kind: 'error',
|
|
84
|
-
title:
|
|
85
|
-
dispositionType === 'ADMIT'
|
|
86
|
-
? t('errrorAdmitingPatient', 'Failed to admit patient')
|
|
87
|
-
: t('errorTransferringPatient', 'Failed to transfer patient'),
|
|
88
|
-
subtitle: errorMessage,
|
|
89
|
-
});
|
|
90
|
-
} finally {
|
|
91
|
-
setIsAdmitting(false);
|
|
92
109
|
}
|
|
110
|
+
setIsAdmitting(false);
|
|
93
111
|
}
|
|
94
112
|
};
|
|
95
113
|
|
|
@@ -13,7 +13,12 @@ import { renderWithSwr } from 'tools';
|
|
|
13
13
|
import { mockWardPatientGroupDetails, mockWardViewContext } from '../../../mock';
|
|
14
14
|
import { useAssignedBedByPatient } from '../../hooks/useAssignedBedByPatient';
|
|
15
15
|
import type { WardPatient, WardPatientWorkspaceProps, WardViewContext } from '../../types';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
assignPatientToBed,
|
|
18
|
+
getAssignedBedByPatient,
|
|
19
|
+
removePatientFromBed,
|
|
20
|
+
useAdmitPatient,
|
|
21
|
+
} from '../../ward.resource';
|
|
17
22
|
import AdmitPatientFormWorkspace from './admit-patient-form.workspace';
|
|
18
23
|
import useWardLocation from '../../hooks/useWardLocation';
|
|
19
24
|
|
|
@@ -43,6 +48,7 @@ jest.mock('../../ward.resource', () => ({
|
|
|
43
48
|
useAdmitPatient: jest.fn(),
|
|
44
49
|
assignPatientToBed: jest.fn(),
|
|
45
50
|
removePatientFromBed: jest.fn(),
|
|
51
|
+
getAssignedBedByPatient: jest.fn(),
|
|
46
52
|
}));
|
|
47
53
|
|
|
48
54
|
const mockedUseWardLocation = jest.mocked(useWardLocation);
|
|
@@ -53,6 +59,7 @@ const mockedUseAssignedBedByPatient = jest.mocked(useAssignedBedByPatient);
|
|
|
53
59
|
const mockedAssignPatientToBed = jest.mocked(assignPatientToBed);
|
|
54
60
|
const mockedRemovePatientFromBed = jest.mocked(removePatientFromBed);
|
|
55
61
|
const mockedUseAdmitPatient = jest.mocked(useAdmitPatient);
|
|
62
|
+
const mockedGetAssignedBedByPatient = jest.mocked(getAssignedBedByPatient);
|
|
56
63
|
|
|
57
64
|
jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
|
|
58
65
|
|
|
@@ -83,6 +90,7 @@ const mockWorkspaceProps: Workspace2DefinitionProps<WardPatientWorkspaceProps, {
|
|
|
83
90
|
workspaceName: '',
|
|
84
91
|
windowName: '',
|
|
85
92
|
isRootWorkspace: false,
|
|
93
|
+
showActionMenu: false,
|
|
86
94
|
};
|
|
87
95
|
|
|
88
96
|
function renderAdmissionForm() {
|
|
@@ -146,6 +154,13 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
146
154
|
mockedRemovePatientFromBed.mockResolvedValue({
|
|
147
155
|
ok: true,
|
|
148
156
|
});
|
|
157
|
+
|
|
158
|
+
// @ts-ignore - we only need the data key for now
|
|
159
|
+
mockedGetAssignedBedByPatient.mockResolvedValue({
|
|
160
|
+
data: {
|
|
161
|
+
results: [{ bedId: 1 }],
|
|
162
|
+
},
|
|
163
|
+
});
|
|
149
164
|
});
|
|
150
165
|
|
|
151
166
|
it('should render admit patient form', async () => {
|
|
@@ -213,7 +228,7 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
213
228
|
await user.click(admitButton);
|
|
214
229
|
expect(mockedShowSnackbar).toHaveBeenCalledWith({
|
|
215
230
|
kind: 'error',
|
|
216
|
-
title: 'Failed to admit
|
|
231
|
+
title: 'Failed to admit Alice Johnson',
|
|
217
232
|
subtitle: 'Failed to create encounter',
|
|
218
233
|
});
|
|
219
234
|
});
|
|
@@ -231,7 +246,7 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
231
246
|
expect(mockedShowSnackbar).toHaveBeenCalledWith({
|
|
232
247
|
kind: 'warning',
|
|
233
248
|
title: 'Patient admitted successfully',
|
|
234
|
-
subtitle: '
|
|
249
|
+
subtitle: 'Alice Johnson admitted successfully but failed to assign bed',
|
|
235
250
|
});
|
|
236
251
|
});
|
|
237
252
|
|
|
@@ -245,7 +260,7 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
245
260
|
expect(mockedRemovePatientFromBed).toHaveBeenCalledWith(1, mockPatientAlice.uuid);
|
|
246
261
|
expect(mockedShowSnackbar).toHaveBeenCalledWith({
|
|
247
262
|
kind: 'success',
|
|
248
|
-
subtitle: '
|
|
263
|
+
subtitle: 'Alice Johnson admitted successfully to Inpatient Ward',
|
|
249
264
|
title: 'Patient admitted successfully',
|
|
250
265
|
});
|
|
251
266
|
});
|