@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
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { showSnackbar, useAppContext, useFeatureFlag, useSession } from '@openmrs/esm-framework';
|
|
2
2
|
import { screen } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { mockLocationInpatientWard, mockPatientAlice } from '../../../../../__mocks__';
|
|
4
6
|
import { renderWithSwr } from '../../../../../tools';
|
|
7
|
+
import { mockWardPatientGroupDetails, mockWardViewContext } from '../../../mock';
|
|
8
|
+
import { useAssignedBedByPatient } from '../../hooks/useAssignedBedByPatient';
|
|
9
|
+
import useWardLocation from '../../hooks/useWardLocation';
|
|
10
|
+
import type { DispositionType, WardViewContext } from '../../types';
|
|
11
|
+
import { assignPatientToBed, removePatientFromBed, useAdmitPatient } from '../../ward.resource';
|
|
5
12
|
import AdmitPatientFormWorkspace from './admit-patient-form.workspace';
|
|
6
|
-
import {
|
|
7
|
-
mockAdmissionLocation,
|
|
8
|
-
mockInpatientRequest,
|
|
9
|
-
mockLocationInpatientWard,
|
|
10
|
-
mockPatientAlice,
|
|
11
|
-
} from '../../../../../__mocks__';
|
|
12
|
-
import type { DispositionType } from '../../types';
|
|
13
13
|
import type { AdmitPatientFormWorkspaceProps } from './types';
|
|
14
|
-
import { useAdmissionLocation } from '../../hooks/useAdmissionLocation';
|
|
15
|
-
import { openmrsFetch, provide, showSnackbar, useFeatureFlag, useSession } from '@openmrs/esm-framework';
|
|
16
|
-
import useEmrConfiguration from '../../hooks/useEmrConfiguration';
|
|
17
|
-
import useWardLocation from '../../hooks/useWardLocation';
|
|
18
|
-
import { useInpatientRequest } from '../../hooks/useInpatientRequest';
|
|
19
14
|
|
|
20
15
|
jest.mock('../../hooks/useAdmissionLocation', () => ({
|
|
21
16
|
useAdmissionLocation: jest.fn(),
|
|
@@ -23,20 +18,47 @@ jest.mock('../../hooks/useAdmissionLocation', () => ({
|
|
|
23
18
|
|
|
24
19
|
jest.mock('../../hooks/useWardLocation', () => jest.fn());
|
|
25
20
|
|
|
26
|
-
jest.mock('../../hooks/useEmrConfiguration', () => jest.fn());
|
|
27
|
-
|
|
28
21
|
jest.mock('../../hooks/useInpatientRequest', () => ({
|
|
29
22
|
useInpatientRequest: jest.fn(),
|
|
30
23
|
}));
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
jest.mock('../../hooks/useWardPatientGrouping', () => ({
|
|
26
|
+
useWardPatientGrouping: jest.fn(),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
jest.mock('../../hooks/useInpatientAdmission', () => ({
|
|
30
|
+
useInpatientAdmission: jest.fn(),
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
jest.mock('../../hooks/useAssignedBedByPatient', () => ({
|
|
34
|
+
useAssignedBedByPatient: jest.fn(),
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
jest.mock('../../ward.resource', () => ({
|
|
38
|
+
createEncounter: jest.fn(),
|
|
39
|
+
useAdmitPatient: jest.fn(),
|
|
40
|
+
assignPatientToBed: jest.fn(),
|
|
41
|
+
removePatientFromBed: jest.fn(),
|
|
42
|
+
}));
|
|
43
|
+
|
|
34
44
|
const mockedUseWardLocation = jest.mocked(useWardLocation);
|
|
35
|
-
const mockedOpenmrsFetch = jest.mocked(openmrsFetch);
|
|
36
|
-
const mockedUseAdmissionLocation = jest.mocked(useAdmissionLocation);
|
|
37
45
|
const mockedUseFeatureFlag = jest.mocked(useFeatureFlag);
|
|
38
46
|
const mockedShowSnackbar = jest.mocked(showSnackbar);
|
|
39
47
|
const mockedUseSession = jest.mocked(useSession);
|
|
48
|
+
const mockedUseAssignedBedByPatient = jest.mocked(useAssignedBedByPatient);
|
|
49
|
+
const mockedAssignPatientToBed = jest.mocked(assignPatientToBed);
|
|
50
|
+
const mockedRemovePatientFromBed = jest.mocked(removePatientFromBed);
|
|
51
|
+
const mockedUseAdmitPatient = jest.mocked(useAdmitPatient);
|
|
52
|
+
|
|
53
|
+
jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
|
|
54
|
+
|
|
55
|
+
const mockUseAdmitPatientObj: ReturnType<typeof useAdmitPatient> = {
|
|
56
|
+
admitPatient: jest.fn(),
|
|
57
|
+
isLoadingEmrConfiguration: false,
|
|
58
|
+
errorFetchingEmrConfiguration: false,
|
|
59
|
+
};
|
|
60
|
+
jest.mocked(useAdmitPatient).mockReturnValue(mockUseAdmitPatientObj);
|
|
61
|
+
const mockedAdmitPatient = mockUseAdmitPatientObj.admitPatient;
|
|
40
62
|
|
|
41
63
|
const mockWorkspaceProps: AdmitPatientFormWorkspaceProps = {
|
|
42
64
|
patient: mockPatientAlice,
|
|
@@ -51,18 +73,10 @@ function renderAdmissionForm(dispositionType: DispositionType = 'ADMIT') {
|
|
|
51
73
|
renderWithSwr(<AdmitPatientFormWorkspace {...{ ...mockWorkspaceProps, dispositionType }} />);
|
|
52
74
|
}
|
|
53
75
|
|
|
54
|
-
const mockedMutateInpatientRequest = jest.fn();
|
|
55
|
-
|
|
56
76
|
describe('Testing AdmitPatientForm', () => {
|
|
57
77
|
beforeEach(() => {
|
|
58
78
|
jest.clearAllMocks();
|
|
59
|
-
|
|
60
|
-
isLoading: false,
|
|
61
|
-
isValidating: false,
|
|
62
|
-
admissionLocation: mockAdmissionLocation,
|
|
63
|
-
mutate: jest.fn(),
|
|
64
|
-
error: undefined,
|
|
65
|
-
});
|
|
79
|
+
|
|
66
80
|
mockedUseSession.mockReturnValue({
|
|
67
81
|
currentProvider: {
|
|
68
82
|
uuid: 'current-provider-uuid',
|
|
@@ -72,38 +86,48 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
72
86
|
sessionId: 'session-id',
|
|
73
87
|
});
|
|
74
88
|
mockedUseFeatureFlag.mockReturnValue(true);
|
|
75
|
-
|
|
76
|
-
isLoadingEmrConfiguration: false,
|
|
77
|
-
errorFetchingEmrConfiguration: null,
|
|
78
|
-
// @ts-ignore - we only need these two keys for now
|
|
79
|
-
emrConfiguration: {
|
|
80
|
-
admissionEncounterType: {
|
|
81
|
-
uuid: 'admission-encounter-type-uuid',
|
|
82
|
-
display: 'Admission Encounter',
|
|
83
|
-
},
|
|
84
|
-
transferWithinHospitalEncounterType: {
|
|
85
|
-
uuid: 'transfer-within-hospital-encounter-type-uuid',
|
|
86
|
-
display: 'Transfer Within Hospital Encounter Type',
|
|
87
|
-
},
|
|
88
|
-
clinicianEncounterRole: {
|
|
89
|
-
uuid: 'clinician-encounter-role-uuid',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
mutateEmrConfiguration: jest.fn(),
|
|
93
|
-
});
|
|
94
|
-
mockedUseInpatientRequest.mockReturnValue({
|
|
95
|
-
mutate: mockedMutateInpatientRequest,
|
|
96
|
-
error: undefined,
|
|
97
|
-
inpatientRequests: [mockInpatientRequest],
|
|
98
|
-
isLoading: false,
|
|
99
|
-
isValidating: false,
|
|
100
|
-
});
|
|
89
|
+
|
|
101
90
|
mockedUseWardLocation.mockReturnValue({
|
|
102
91
|
location: mockLocationInpatientWard,
|
|
103
92
|
invalidLocation: false,
|
|
104
93
|
isLoadingLocation: false,
|
|
105
94
|
errorFetchingLocation: null,
|
|
106
95
|
});
|
|
96
|
+
|
|
97
|
+
// @ts-ignore - we don't need to mock the entire object
|
|
98
|
+
mockedUseAssignedBedByPatient.mockReturnValue({
|
|
99
|
+
data: {
|
|
100
|
+
data: {
|
|
101
|
+
results: [
|
|
102
|
+
{
|
|
103
|
+
bedId: 1,
|
|
104
|
+
bedNumber: 1,
|
|
105
|
+
bedType: null,
|
|
106
|
+
patients: [mockPatientAlice],
|
|
107
|
+
physicalLocation: mockLocationInpatientWard,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// @ts-ignore - we only need these two keys for now
|
|
115
|
+
mockedAdmitPatient.mockResolvedValue({
|
|
116
|
+
ok: true,
|
|
117
|
+
data: {
|
|
118
|
+
uuid: 'encounter-uuid',
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// @ts-ignore - we only need the ok key for now
|
|
123
|
+
mockedAssignPatientToBed.mockResolvedValue({
|
|
124
|
+
ok: true,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// @ts-ignore - we only need the ok key for now
|
|
128
|
+
mockedRemovePatientFromBed.mockResolvedValue({
|
|
129
|
+
ok: true,
|
|
130
|
+
});
|
|
107
131
|
});
|
|
108
132
|
|
|
109
133
|
it('should render admit patient form', async () => {
|
|
@@ -116,118 +140,45 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
116
140
|
});
|
|
117
141
|
screen.getByText('Admit');
|
|
118
142
|
expect(screen.getByText('Select a bed')).toBeInTheDocument();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
);
|
|
124
|
-
expect(screen.getByText('bed1 · Alice Johnson')).toBeInTheDocument();
|
|
125
|
-
expect(screen.getByText('bed2 · Empty')).toBeInTheDocument();
|
|
126
|
-
expect(screen.getByText('bed3 · Empty')).toBeInTheDocument();
|
|
127
|
-
expect(screen.getByText('bed4 · Empty')).toBeInTheDocument();
|
|
143
|
+
|
|
144
|
+
expect(screen.getByRole('radio', { name: 'bed1 · Alice Johnson' })).toBeInTheDocument();
|
|
145
|
+
expect(screen.getByRole('radio', { name: 'bed2 · Empty' })).toBeInTheDocument();
|
|
146
|
+
expect(screen.getByRole('radio', { name: 'bed3 · Empty' })).toBeInTheDocument();
|
|
147
|
+
expect(screen.getByRole('radio', { name: 'bed4 · Empty' })).toBeInTheDocument();
|
|
128
148
|
});
|
|
129
149
|
|
|
130
150
|
it('should block the form if emr configuration is not fetched properly', () => {
|
|
131
|
-
|
|
151
|
+
mockedUseAdmitPatient.mockReturnValueOnce({
|
|
152
|
+
admitPatient: mockedAdmitPatient,
|
|
132
153
|
isLoadingEmrConfiguration: false,
|
|
133
154
|
errorFetchingEmrConfiguration: true,
|
|
134
|
-
emrConfiguration: null,
|
|
135
|
-
mutateEmrConfiguration: jest.fn(),
|
|
136
155
|
});
|
|
137
156
|
|
|
138
157
|
renderAdmissionForm();
|
|
139
158
|
|
|
140
159
|
const admitButton = screen.getByText('Admit');
|
|
141
160
|
expect(admitButton).toBeDisabled();
|
|
142
|
-
expect(screen.getByText("Some parts of the form didn't load")).toBeInTheDocument();
|
|
143
|
-
expect(
|
|
144
|
-
screen.getByText(
|
|
145
|
-
'Fetching EMR configuration failed. Try refreshing the page or contact your system administrator.',
|
|
146
|
-
),
|
|
147
|
-
).toBeInTheDocument();
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('should render admit patient form if bed management module is not present', () => {
|
|
151
|
-
mockedUseFeatureFlag.mockReturnValue(false);
|
|
152
|
-
renderAdmissionForm();
|
|
153
|
-
expect(screen.getByText('Select a bed')).toBeInTheDocument();
|
|
154
|
-
expect(screen.getByText('Unable to select beds')).toBeInTheDocument();
|
|
155
|
-
expect(screen.getByText('Bed management module is not present to allow bed selection')).toBeInTheDocument();
|
|
156
161
|
});
|
|
157
162
|
|
|
158
163
|
it('should render admit patient form if bed management module is present, but no beds are configured', () => {
|
|
159
164
|
mockedUseFeatureFlag.mockReturnValue(true);
|
|
160
|
-
|
|
161
|
-
isLoading: false,
|
|
162
|
-
isValidating: false,
|
|
163
|
-
admissionLocation: {
|
|
164
|
-
...mockAdmissionLocation,
|
|
165
|
-
totalBeds: 0,
|
|
166
|
-
bedLayouts: [],
|
|
167
|
-
},
|
|
168
|
-
mutate: jest.fn(),
|
|
169
|
-
error: null,
|
|
170
|
-
});
|
|
165
|
+
const replacedProperty = jest.replaceProperty(mockWardPatientGroupDetails(), 'bedLayouts', []);
|
|
171
166
|
renderAdmissionForm();
|
|
172
167
|
expect(screen.getByText('Select a bed')).toBeInTheDocument();
|
|
173
|
-
expect(screen.getByText(
|
|
168
|
+
expect(screen.getByText(/No beds configured/i)).toBeInTheDocument();
|
|
169
|
+
replacedProperty.restore();
|
|
174
170
|
});
|
|
175
171
|
|
|
176
172
|
it('should submit the form, create encounter and submit bed', async () => {
|
|
177
|
-
mockedUseAdmissionLocation.mockReturnValueOnce({
|
|
178
|
-
isLoading: false,
|
|
179
|
-
isValidating: false,
|
|
180
|
-
admissionLocation: mockAdmissionLocation,
|
|
181
|
-
mutate: jest.fn(),
|
|
182
|
-
error: null,
|
|
183
|
-
});
|
|
184
|
-
// @ts-ignore - we only need these two keys for now
|
|
185
|
-
mockedOpenmrsFetch.mockResolvedValue({
|
|
186
|
-
ok: true,
|
|
187
|
-
data: {
|
|
188
|
-
uuid: 'encounter-uuid',
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
173
|
const user = userEvent.setup();
|
|
192
174
|
renderAdmissionForm();
|
|
193
|
-
const
|
|
194
|
-
name: 'Choose an option',
|
|
195
|
-
});
|
|
196
|
-
await user.click(combobox);
|
|
197
|
-
const bedOption = screen.getByText('bed3 · Empty');
|
|
175
|
+
const bedOption = screen.getByRole('radio', { name: 'bed3 · Empty' });
|
|
198
176
|
await user.click(bedOption);
|
|
199
177
|
const admitButton = screen.getByRole('button', { name: 'Admit' });
|
|
200
178
|
expect(admitButton).toBeEnabled();
|
|
201
179
|
await user.click(admitButton);
|
|
202
|
-
expect(
|
|
203
|
-
expect(
|
|
204
|
-
method: 'POST',
|
|
205
|
-
headers: {
|
|
206
|
-
'content-type': 'application/json',
|
|
207
|
-
},
|
|
208
|
-
body: {
|
|
209
|
-
patient: mockPatientAlice.uuid,
|
|
210
|
-
encounterType: 'admission-encounter-type-uuid',
|
|
211
|
-
location: mockAdmissionLocation.ward.uuid,
|
|
212
|
-
obs: [],
|
|
213
|
-
encounterProviders: [
|
|
214
|
-
{
|
|
215
|
-
provider: 'current-provider-uuid',
|
|
216
|
-
encounterRole: 'clinician-encounter-role-uuid',
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
},
|
|
220
|
-
});
|
|
221
|
-
expect(mockedOpenmrsFetch).toHaveBeenCalledWith('/ws/rest/v1/beds/3', {
|
|
222
|
-
method: 'POST',
|
|
223
|
-
headers: {
|
|
224
|
-
'content-type': 'application/json',
|
|
225
|
-
},
|
|
226
|
-
body: {
|
|
227
|
-
patientUuid: mockPatientAlice.uuid,
|
|
228
|
-
encounterUuid: 'encounter-uuid',
|
|
229
|
-
},
|
|
230
|
-
});
|
|
180
|
+
expect(mockedAdmitPatient).toHaveBeenCalledWith(mockPatientAlice, 'ADMIT');
|
|
181
|
+
expect(mockedAssignPatientToBed).toHaveBeenCalledWith(3, mockPatientAlice.uuid, 'encounter-uuid');
|
|
231
182
|
expect(mockedShowSnackbar).toHaveBeenCalledWith({
|
|
232
183
|
kind: 'success',
|
|
233
184
|
subtitle: '{{patientName}} has been successfully admitted and assigned to bed bed3',
|
|
@@ -236,19 +187,14 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
236
187
|
});
|
|
237
188
|
|
|
238
189
|
it('should show snackbar if there was an issue creating an encounter', async () => {
|
|
239
|
-
|
|
190
|
+
mockedAdmitPatient.mockRejectedValue(new Error('Failed to create encounter'));
|
|
240
191
|
const user = userEvent.setup();
|
|
241
192
|
renderAdmissionForm();
|
|
242
|
-
const
|
|
243
|
-
name: 'Choose an option',
|
|
244
|
-
});
|
|
245
|
-
await user.click(combobox);
|
|
246
|
-
const bedOption = screen.getByText('bed3 · Empty');
|
|
193
|
+
const bedOption = screen.getByRole('radio', { name: 'bed3 · Empty' });
|
|
247
194
|
await user.click(bedOption);
|
|
248
195
|
const admitButton = screen.getByRole('button', { name: 'Admit' });
|
|
249
196
|
expect(admitButton).toBeEnabled();
|
|
250
197
|
await user.click(admitButton);
|
|
251
|
-
expect(mockedOpenmrsFetch).toHaveBeenCalledTimes(1);
|
|
252
198
|
expect(mockedShowSnackbar).toHaveBeenCalledWith({
|
|
253
199
|
kind: 'error',
|
|
254
200
|
title: 'Failed to admit patient',
|
|
@@ -257,31 +203,15 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
257
203
|
});
|
|
258
204
|
|
|
259
205
|
it('should show warning snackbar if encounter was created and bed assignment was not successful', async () => {
|
|
260
|
-
|
|
261
|
-
mockedOpenmrsFetch.mockImplementation((url) => {
|
|
262
|
-
if (url.startsWith('/ws/rest/v1/beds')) {
|
|
263
|
-
return Promise.reject(new Error('Failed to assign bed'));
|
|
264
|
-
}
|
|
265
|
-
return Promise.resolve({
|
|
266
|
-
ok: true,
|
|
267
|
-
data: {
|
|
268
|
-
uuid: 'encounter-uuid',
|
|
269
|
-
},
|
|
270
|
-
});
|
|
271
|
-
});
|
|
206
|
+
mockedAssignPatientToBed.mockRejectedValue(new Error('Failed to assign bed'));
|
|
272
207
|
|
|
273
208
|
const user = userEvent.setup();
|
|
274
209
|
renderAdmissionForm();
|
|
275
|
-
const
|
|
276
|
-
name: 'Choose an option',
|
|
277
|
-
});
|
|
278
|
-
await user.click(combobox);
|
|
279
|
-
const bedOption = screen.getByText('bed3 · Empty');
|
|
210
|
+
const bedOption = screen.getByRole('radio', { name: 'bed3 · Empty' });
|
|
280
211
|
await user.click(bedOption);
|
|
281
212
|
const admitButton = screen.getByRole('button', { name: 'Admit' });
|
|
282
213
|
expect(admitButton).toBeEnabled();
|
|
283
214
|
await user.click(admitButton);
|
|
284
|
-
expect(mockedOpenmrsFetch).toHaveBeenCalledTimes(2);
|
|
285
215
|
expect(mockedShowSnackbar).toHaveBeenCalledWith({
|
|
286
216
|
kind: 'warning',
|
|
287
217
|
title: 'Patient admitted successfully',
|
|
@@ -289,49 +219,14 @@ describe('Testing AdmitPatientForm', () => {
|
|
|
289
219
|
});
|
|
290
220
|
});
|
|
291
221
|
|
|
292
|
-
it('should admit patient if no
|
|
293
|
-
mockedUseAdmissionLocation.mockReturnValueOnce({
|
|
294
|
-
isLoading: false,
|
|
295
|
-
isValidating: false,
|
|
296
|
-
admissionLocation: {
|
|
297
|
-
...mockAdmissionLocation,
|
|
298
|
-
totalBeds: 0,
|
|
299
|
-
bedLayouts: [],
|
|
300
|
-
},
|
|
301
|
-
mutate: jest.fn(),
|
|
302
|
-
error: null,
|
|
303
|
-
});
|
|
304
|
-
// @ts-ignore - we only need these two keys for now
|
|
305
|
-
mockedOpenmrsFetch.mockResolvedValue({
|
|
306
|
-
ok: true,
|
|
307
|
-
data: {
|
|
308
|
-
uuid: 'encounter-uuid',
|
|
309
|
-
},
|
|
310
|
-
});
|
|
222
|
+
it('should admit patient if no bed is selected', async () => {
|
|
311
223
|
const user = userEvent.setup();
|
|
312
224
|
renderAdmissionForm();
|
|
313
225
|
const admitButton = screen.getByRole('button', { name: 'Admit' });
|
|
314
226
|
expect(admitButton).toBeEnabled();
|
|
315
227
|
await user.click(admitButton);
|
|
316
|
-
expect(
|
|
317
|
-
expect(
|
|
318
|
-
method: 'POST',
|
|
319
|
-
headers: {
|
|
320
|
-
'content-type': 'application/json',
|
|
321
|
-
},
|
|
322
|
-
body: {
|
|
323
|
-
patient: mockPatientAlice.uuid,
|
|
324
|
-
encounterType: 'admission-encounter-type-uuid',
|
|
325
|
-
location: mockAdmissionLocation.ward.uuid,
|
|
326
|
-
obs: [],
|
|
327
|
-
encounterProviders: [
|
|
328
|
-
{
|
|
329
|
-
provider: 'current-provider-uuid',
|
|
330
|
-
encounterRole: 'clinician-encounter-role-uuid',
|
|
331
|
-
},
|
|
332
|
-
],
|
|
333
|
-
},
|
|
334
|
-
});
|
|
228
|
+
expect(mockedAdmitPatient).toHaveBeenCalledWith(mockPatientAlice, 'ADMIT');
|
|
229
|
+
expect(mockedRemovePatientFromBed).toHaveBeenCalledWith(1, mockPatientAlice.uuid);
|
|
335
230
|
expect(mockedShowSnackbar).toHaveBeenCalledWith({
|
|
336
231
|
kind: 'success',
|
|
337
232
|
subtitle: 'Patient admitted successfully to Inpatient Ward',
|