@pih/esm-referrals-queue-app 2.0.0-pre.9 → 2.1.1-pre.101
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 +41 -0
- package/README.md +1 -17
- package/dist/13.js +2 -0
- package/dist/13.js.LICENSE.txt +38 -0
- package/dist/13.js.map +1 -0
- package/dist/144.js +2 -0
- package/dist/144.js.LICENSE.txt +19 -0
- package/dist/144.js.map +1 -0
- package/dist/146.js +1 -0
- package/dist/146.js.map +1 -0
- package/dist/15.js +2 -0
- package/dist/15.js.LICENSE.txt +28 -0
- package/dist/15.js.map +1 -0
- package/dist/300.js +1 -0
- package/dist/304.js +1 -0
- package/dist/304.js.map +1 -0
- package/dist/372.js +1 -0
- package/dist/372.js.map +1 -0
- package/dist/41.js +2 -0
- package/dist/41.js.map +1 -0
- package/dist/423.js +1 -0
- package/dist/423.js.map +1 -0
- package/dist/470.js +2 -0
- package/dist/470.js.LICENSE.txt +9 -0
- package/dist/470.js.map +1 -0
- package/dist/495.js +1 -0
- package/dist/495.js.map +1 -0
- package/dist/55.js +1 -0
- package/dist/84.js +2 -0
- package/dist/{147.js.LICENSE.txt → 84.js.LICENSE.txt} +7 -24
- package/dist/84.js.map +1 -0
- package/dist/876.js +2 -0
- package/dist/876.js.LICENSE.txt +9 -0
- package/dist/876.js.map +1 -0
- package/dist/89.js +1 -0
- package/dist/89.js.map +1 -0
- package/dist/913.js +2 -0
- package/dist/{879.js.LICENSE.txt → 913.js.LICENSE.txt} +13 -2
- package/dist/913.js.map +1 -0
- package/dist/92.js +2 -0
- package/dist/92.js.LICENSE.txt +9 -0
- package/dist/92.js.map +1 -0
- package/dist/99.js +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -0
- package/dist/pih-esm-referrals-queue-app.js +1 -1
- package/dist/pih-esm-referrals-queue-app.js.buildmanifest.json +429 -60
- package/dist/pih-esm-referrals-queue-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/jest.config.js +3 -0
- package/package.json +27 -70
- package/src/config-schema.ts +8 -16
- package/src/declarations.d.tsx +4 -4
- package/src/index.ts +11 -65
- package/src/referrals-queue/referrals-queue.component.tsx +71 -120
- package/src/referrals-queue/referrals-queue.resource.tsx +6 -9
- package/src/referrals-queue/referrals-queue.scss +24 -0
- package/src/referrals-queue/referrals-queue.test.tsx +148 -116
- package/src/root.component.test.tsx +3 -3
- package/src/root.component.tsx +6 -6
- package/src/routes.json +9 -0
- package/src/setup-tests.ts +8 -8
- package/src/table/referrals-table.component.tsx +83 -0
- package/src/util.ts +5 -9
- package/translations/en.json +13 -2
- package/translations/es.json +15 -0
- package/translations/fr.json +15 -0
- package/tsconfig.json +4 -22
- package/.editorconfig +0 -12
- package/.eslintignore +0 -2
- package/.eslintrc +0 -4
- package/.github/workflows/node.js.yml +0 -79
- package/.husky/pre-commit +0 -6
- package/.husky/pre-push +0 -6
- package/.prettierignore +0 -14
- package/LICENSE +0 -401
- package/__mocks__/react-i18next.js +0 -51
- package/dist/132.js +0 -1
- package/dist/147.js +0 -2
- package/dist/281.js +0 -1
- package/dist/294.js +0 -2
- package/dist/574.js +0 -1
- package/dist/595.js +0 -2
- package/dist/595.js.LICENSE.txt +0 -1
- package/dist/879.js +0 -2
- package/dist/90.js +0 -1
- package/dist/pih-esm-referrals-queue-app.old +0 -1
- package/jest.config.json +0 -19
- package/src/referrals-queue/react-dates-overrides.css +0 -39
- package/src/referrals-queue/referrals-queue.css +0 -63
- package/src/table/table.component.tsx +0 -95
- package/src/table/table.css +0 -16
- /package/dist/{294.js.LICENSE.txt → 41.js.LICENSE.txt} +0 -0
|
@@ -1,68 +1,82 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { of } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { of } from 'rxjs';
|
|
3
|
+
import { render, fireEvent, screen, within, waitFor } from '@testing-library/react';
|
|
4
|
+
import MockDate from 'mockdate';
|
|
5
|
+
import ReferralsQueue from './referrals-queue.component';
|
|
6
|
+
import { getReferrals } from './referrals-queue.resource';
|
|
7
|
+
|
|
8
|
+
const mockedUseConfig = jest.fn();
|
|
9
|
+
|
|
10
|
+
jest.mock('./referrals-queue.resource');
|
|
11
|
+
jest.mock('@openmrs/esm-framework', () => ({
|
|
12
|
+
...jest.requireActual('@openmrs/esm-framework'),
|
|
13
|
+
useConfig: () => mockedUseConfig(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
15
16
|
const mockedGetReferrals = getReferrals as jest.Mock;
|
|
16
17
|
|
|
17
18
|
const referrals = [
|
|
18
19
|
{
|
|
19
|
-
patient_uuid:
|
|
20
|
-
zl_emr_id:
|
|
21
|
-
patient_name:
|
|
22
|
-
referral_date:
|
|
20
|
+
patient_uuid: 'ptaaaaaa-2869-41a4-86af-811fa2ee65b8',
|
|
21
|
+
zl_emr_id: 'PTID1',
|
|
22
|
+
patient_name: 'Patient Commcare',
|
|
23
|
+
referral_date: '2020-03-25T00:00:00.000-0400',
|
|
23
24
|
details: null,
|
|
24
|
-
visit_uuid:
|
|
25
|
+
visit_uuid: 'visitaaa-091a-46fd-a442-2a9778d91a52',
|
|
25
26
|
encounter_id: 12,
|
|
26
|
-
referral_type:
|
|
27
|
-
encounter_uuid:
|
|
27
|
+
referral_type: 'Test Referral Type',
|
|
28
|
+
encounter_uuid: 'encounter-0fe1-4318-95a4-641d31745e09',
|
|
28
29
|
fulfillment_status: null,
|
|
29
30
|
},
|
|
30
31
|
{
|
|
31
|
-
patient_uuid:
|
|
32
|
-
zl_emr_id:
|
|
33
|
-
patient_name:
|
|
34
|
-
referral_date:
|
|
35
|
-
details:
|
|
36
|
-
visit_uuid:
|
|
32
|
+
patient_uuid: 'ptbbbbbb-de0e-489f-b4c7-fe4579e07aa9',
|
|
33
|
+
zl_emr_id: 'PTID2',
|
|
34
|
+
patient_name: 'Davina Mother',
|
|
35
|
+
referral_date: '2020-03-23T00:00:00.000-0400',
|
|
36
|
+
details: 'Suspected depression',
|
|
37
|
+
visit_uuid: 'visitbbb-64ca-4d53-9024-574a9214f76e',
|
|
37
38
|
encounter_id: 13,
|
|
38
|
-
referral_type:
|
|
39
|
-
encounter_uuid:
|
|
40
|
-
fulfillment_status:
|
|
39
|
+
referral_type: 'Mental Health',
|
|
40
|
+
encounter_uuid: 'encounter-d5cb-4f7e-a1aa-bd6741a96381',
|
|
41
|
+
fulfillment_status: 'Pending status',
|
|
41
42
|
},
|
|
42
43
|
{
|
|
43
|
-
person_uuid:
|
|
44
|
-
zl_emr_id:
|
|
45
|
-
patient_name:
|
|
46
|
-
referral_date:
|
|
47
|
-
details:
|
|
48
|
-
visit_uuid:
|
|
44
|
+
person_uuid: 'ptcccccc-de0e-489f-b4c7-fe4579e07aa9',
|
|
45
|
+
zl_emr_id: 'PTID3',
|
|
46
|
+
patient_name: 'Patient Prenatal',
|
|
47
|
+
referral_date: '2020-03-28T00:00:00.000-0400',
|
|
48
|
+
details: 'Urgent',
|
|
49
|
+
visit_uuid: 'visitccc-64ca-4d53-9024-574a9214f76e',
|
|
49
50
|
encounter_id: 14,
|
|
50
|
-
referral_type:
|
|
51
|
-
encounter_uuid:
|
|
52
|
-
fulfillment_status:
|
|
51
|
+
referral_type: 'Family Member',
|
|
52
|
+
encounter_uuid: 'encounter-67bc-435d-9929-670a98cefe4e',
|
|
53
|
+
fulfillment_status: 'Test Complete',
|
|
53
54
|
},
|
|
54
55
|
];
|
|
55
56
|
|
|
56
|
-
(window as any).openmrsBase =
|
|
57
|
+
(window as any).openmrsBase = '/openmrs';
|
|
57
58
|
// hack around js-dom to make navigation testable
|
|
58
59
|
delete window.location;
|
|
59
60
|
//@ts-ignore
|
|
60
|
-
window.location = { href:
|
|
61
|
-
|
|
62
|
-
describe(
|
|
63
|
-
const todayString =
|
|
61
|
+
window.location = { href: '/referrals-queue' };
|
|
62
|
+
|
|
63
|
+
describe('referrals queue', () => {
|
|
64
|
+
const todayString = '2020-10-31';
|
|
65
|
+
beforeAll(() => {
|
|
66
|
+
mockedUseConfig.mockReturnValue({
|
|
67
|
+
links: {
|
|
68
|
+
patientDash:
|
|
69
|
+
'${openmrsBase}/coreapps/clinicianfacing/patient.page?patientId=${patientUuid}&app=pih.app.clinicianDashboard',
|
|
70
|
+
visitPage:
|
|
71
|
+
'${openmrsBase}/pihcore/visit/visit.page?patient=${patientUuid}&visit=${visitUuid}&suppressActions=true#/overview',
|
|
72
|
+
homeVisitForm:
|
|
73
|
+
'${openmrsBase}/htmlformentryui/htmlform/editHtmlFormWithStandardUi.page?patientId=${patientUuid}&visitId=${visitUuid}&encounterId=${encounterUuid}&definitionUiResource=file:configuration/pih/htmlforms/section-mch-referral.xml&returnUrl=/mirebalais/spa/referrals-queue',
|
|
74
|
+
},
|
|
75
|
+
pendingStatuses: ['Pending status', 'Referral unmet'],
|
|
76
|
+
});
|
|
77
|
+
});
|
|
64
78
|
beforeEach(() => {
|
|
65
|
-
MockDate.set(todayString +
|
|
79
|
+
MockDate.set(todayString + 'T10:00:00.000-0400');
|
|
66
80
|
mockedGetReferrals.mockReset();
|
|
67
81
|
mockedGetReferrals.mockReturnValue(of(referrals));
|
|
68
82
|
render(<ReferralsQueue />);
|
|
@@ -72,15 +86,15 @@ describe("referrals queue", () => {
|
|
|
72
86
|
MockDate.reset();
|
|
73
87
|
});
|
|
74
88
|
|
|
75
|
-
it(
|
|
89
|
+
it('renders without failing', () => {
|
|
76
90
|
// in beforeEach
|
|
77
91
|
});
|
|
78
92
|
|
|
79
|
-
it(
|
|
93
|
+
it('renders the expected fields', () => {
|
|
80
94
|
for (let referral of referrals) {
|
|
81
|
-
const row = screen.getByText(referral.zl_emr_id).closest(
|
|
95
|
+
const row = screen.getByText(referral.zl_emr_id).closest('tr');
|
|
82
96
|
within(row).getByText(referral.patient_name);
|
|
83
|
-
within(row).getByText(referral.referral_type, { selector:
|
|
97
|
+
within(row).getByText(referral.referral_type, { selector: 'td' });
|
|
84
98
|
if (referral.details) {
|
|
85
99
|
within(row).getByText(referral.details);
|
|
86
100
|
}
|
|
@@ -88,112 +102,130 @@ describe("referrals queue", () => {
|
|
|
88
102
|
within(row).getByText(referral.fulfillment_status);
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
|
-
screen.getByText(
|
|
92
|
-
screen.getByText(
|
|
93
|
-
screen.getByText(
|
|
105
|
+
screen.getByText('25 Mar');
|
|
106
|
+
screen.getByText('23 Mar');
|
|
107
|
+
screen.getByText('28 Mar');
|
|
94
108
|
});
|
|
95
109
|
|
|
96
|
-
// TODO
|
|
97
|
-
|
|
98
|
-
const table = screen.getByRole(
|
|
110
|
+
// TODO figure out how to test links
|
|
111
|
+
it.skip('navigates to the links', async () => {
|
|
112
|
+
const table = screen.getByRole('table');
|
|
99
113
|
const pt0DashLink = within(table).getByText(referrals[0].zl_emr_id);
|
|
100
114
|
fireEvent.click(pt0DashLink);
|
|
101
115
|
await waitFor(() => {
|
|
102
|
-
expect(window.location.href).toBe(
|
|
103
|
-
"/openmrs/pt-dash/" + referrals[0].patient_uuid
|
|
104
|
-
);
|
|
116
|
+
expect(window.location.href).toBe('/openmrs/pt-dash/' + referrals[0].patient_uuid);
|
|
105
117
|
});
|
|
106
|
-
const pt1VisitLink = within(table).getByText(
|
|
118
|
+
const pt1VisitLink = within(table).getByText('23 Mar');
|
|
107
119
|
fireEvent.click(pt1VisitLink);
|
|
108
120
|
await waitFor(() => {
|
|
109
|
-
expect(window.location.href).toBe(
|
|
110
|
-
`/openmrs/visit/${referrals[1].patient_uuid}/${referrals[1].visit_uuid}`
|
|
111
|
-
);
|
|
121
|
+
expect(window.location.href).toBe(`/openmrs/visit/${referrals[1].patient_uuid}/${referrals[1].visit_uuid}`);
|
|
112
122
|
});
|
|
113
|
-
const pendingStatusLink = within(table).getByText(
|
|
123
|
+
const pendingStatusLink = within(table).getByText('Pending status');
|
|
114
124
|
fireEvent.click(pendingStatusLink);
|
|
115
125
|
await waitFor(() => {
|
|
116
126
|
expect(window.location.href).toBe(
|
|
117
|
-
`/openmrs/home-visit-form/${referrals[1].patient_uuid}/${referrals[1].visit_uuid}/${referrals[1].encounter_uuid}
|
|
127
|
+
`/openmrs/home-visit-form/${referrals[1].patient_uuid}/${referrals[1].visit_uuid}/${referrals[1].encounter_uuid}`,
|
|
118
128
|
);
|
|
119
129
|
});
|
|
120
|
-
})
|
|
130
|
+
});
|
|
121
131
|
|
|
122
132
|
it("doesn't make non-pending statuses into links", () => {
|
|
123
|
-
const table = screen.getByRole(
|
|
124
|
-
expect(within(table).getByText(
|
|
125
|
-
expect(within(table).getByText(
|
|
133
|
+
const table = screen.getByRole('table');
|
|
134
|
+
expect(within(table).getByText('Pending status').tagName).toBe('A'); // sanity check
|
|
135
|
+
expect(within(table).getByText('Test Complete').tagName).not.toBe('A'); // the actual test
|
|
126
136
|
});
|
|
127
137
|
|
|
128
|
-
it(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
it('filters by referral type', () => {
|
|
139
|
+
fireEvent.click(
|
|
140
|
+
screen.getByLabelText('Referral Type', {
|
|
141
|
+
selector: 'button',
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
fireEvent.click(
|
|
145
|
+
screen.getByText('Mental Health', {
|
|
146
|
+
selector: 'div',
|
|
147
|
+
}),
|
|
148
|
+
);
|
|
149
|
+
expect(screen.queryByText('PTID1')).toBeNull();
|
|
150
|
+
expect(screen.queryByText('PTID2')).not.toBeNull();
|
|
151
|
+
expect(screen.queryByText('PTID3')).toBeNull();
|
|
136
152
|
});
|
|
137
153
|
|
|
138
|
-
it(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
154
|
+
it('infers list of referral types from data', () => {
|
|
155
|
+
expect(screen.queryByText('Test Referral Type', { selector: 'span' })).toBeNull(); // sanity check
|
|
156
|
+
fireEvent.click(
|
|
157
|
+
screen.getByLabelText('Referral Type', {
|
|
158
|
+
selector: 'button',
|
|
159
|
+
}),
|
|
160
|
+
);
|
|
161
|
+
fireEvent.click(
|
|
162
|
+
screen.getByText('Test Referral Type', {
|
|
163
|
+
selector: 'div',
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
expect(screen.queryByText('Test Referral Type', { selector: 'span' })).not.toBeNull();
|
|
144
167
|
});
|
|
145
168
|
|
|
146
|
-
it(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
169
|
+
it('filters by statuses, with dropdown inferred from data', () => {
|
|
170
|
+
fireEvent.click(
|
|
171
|
+
screen.getByLabelText('Status', {
|
|
172
|
+
selector: 'button',
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
fireEvent.click(
|
|
176
|
+
screen.getByText('Test Complete', {
|
|
177
|
+
selector: 'div',
|
|
178
|
+
}),
|
|
179
|
+
);
|
|
180
|
+
expect(screen.queryByText('PTID1')).toBeNull();
|
|
181
|
+
expect(screen.queryByText('PTID2')).toBeNull();
|
|
182
|
+
expect(screen.queryByText('PTID3')).not.toBeNull();
|
|
152
183
|
});
|
|
153
184
|
|
|
154
|
-
|
|
155
|
-
|
|
185
|
+
// TODO figure out how to interact with Carbon datepicker
|
|
186
|
+
it.skip('calls getReferrals with the correct date arguments', () => {
|
|
187
|
+
const monthAgoString = '2020-09-30';
|
|
156
188
|
expect(mockedGetReferrals).lastCalledWith({
|
|
157
189
|
fromDate: monthAgoString,
|
|
158
190
|
toDate: todayString,
|
|
159
|
-
locale:
|
|
191
|
+
locale: 'en',
|
|
160
192
|
});
|
|
161
|
-
const fromDateInput = screen.getByLabelText(
|
|
162
|
-
fireEvent.change(fromDateInput, { target: { value:
|
|
193
|
+
const fromDateInput = screen.getByLabelText('From');
|
|
194
|
+
fireEvent.change(fromDateInput, { target: { value: '2020-01-01' } });
|
|
163
195
|
expect(mockedGetReferrals).lastCalledWith({
|
|
164
|
-
fromDate:
|
|
196
|
+
fromDate: '2020-01-01',
|
|
165
197
|
toDate: todayString,
|
|
166
|
-
locale:
|
|
198
|
+
locale: 'en',
|
|
167
199
|
});
|
|
168
|
-
const toDateInput = screen.getByLabelText(
|
|
169
|
-
fireEvent.change(toDateInput, { target: { value:
|
|
200
|
+
const toDateInput = screen.getByLabelText('To');
|
|
201
|
+
fireEvent.change(toDateInput, { target: { value: '2020-03-01' } });
|
|
170
202
|
expect(mockedGetReferrals).lastCalledWith({
|
|
171
|
-
fromDate:
|
|
172
|
-
toDate:
|
|
173
|
-
locale:
|
|
203
|
+
fromDate: '2020-01-01',
|
|
204
|
+
toDate: '2020-03-01',
|
|
205
|
+
locale: 'en',
|
|
174
206
|
});
|
|
175
207
|
});
|
|
176
208
|
|
|
177
|
-
it(
|
|
178
|
-
const queryBox = screen.getByLabelText(
|
|
179
|
-
fireEvent.change(queryBox, { target: { value:
|
|
180
|
-
expect(screen.queryByText(
|
|
181
|
-
expect(screen.queryByText(
|
|
209
|
+
it('filters the list of results by patient name query', () => {
|
|
210
|
+
const queryBox = screen.getByLabelText('Filter by patient');
|
|
211
|
+
fireEvent.change(queryBox, { target: { value: 'Mother' } });
|
|
212
|
+
expect(screen.queryByText('PTID2')).not.toBeNull();
|
|
213
|
+
expect(screen.queryByText('PTID1')).toBeNull();
|
|
182
214
|
});
|
|
183
215
|
|
|
184
|
-
it(
|
|
185
|
-
const queryBox = screen.getByLabelText(
|
|
186
|
-
fireEvent.change(queryBox, { target: { value:
|
|
187
|
-
expect(screen.queryByText(
|
|
188
|
-
expect(screen.queryByText(
|
|
216
|
+
it('filters the list of results by patient name partial token matches', () => {
|
|
217
|
+
const queryBox = screen.getByLabelText('Filter by patient');
|
|
218
|
+
fireEvent.change(queryBox, { target: { value: 'dav mo' } });
|
|
219
|
+
expect(screen.queryByText('PTID2')).not.toBeNull();
|
|
220
|
+
expect(screen.queryByText('PTID1')).toBeNull();
|
|
189
221
|
});
|
|
190
222
|
|
|
191
|
-
it(
|
|
192
|
-
const queryBox = screen.getByLabelText(
|
|
193
|
-
fireEvent.change(queryBox, { target: { value:
|
|
194
|
-
expect(screen.queryByText(
|
|
195
|
-
expect(screen.queryByText(
|
|
223
|
+
it('filters the list of results by patient id', () => {
|
|
224
|
+
const queryBox = screen.getByLabelText('Filter by patient');
|
|
225
|
+
fireEvent.change(queryBox, { target: { value: 'ptid1' } });
|
|
226
|
+
expect(screen.queryByText('PTID1')).not.toBeNull();
|
|
227
|
+
expect(screen.queryByText('PTID2')).toBeNull();
|
|
196
228
|
});
|
|
197
229
|
|
|
198
|
-
test.todo(
|
|
230
|
+
test.todo('makes the API call with the locale from the user session');
|
|
199
231
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render } from
|
|
3
|
-
import Root from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import Root from './root.component';
|
|
4
4
|
|
|
5
5
|
describe(`<Root />`, () => {
|
|
6
6
|
it(`renders without dying`, async () => {
|
package/src/root.component.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { BrowserRouter, Routes, Route } from
|
|
3
|
-
import ReferralsQueue from
|
|
4
|
-
import styles from
|
|
5
|
-
import { appPath } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
|
3
|
+
import ReferralsQueue from './referrals-queue/referrals-queue.component';
|
|
4
|
+
import styles from './root.css';
|
|
5
|
+
import { appPath } from './constants';
|
|
6
6
|
|
|
7
7
|
export default function Root() {
|
|
8
8
|
return (
|
|
9
|
-
<div className={
|
|
9
|
+
<div className={`${styles.ovconstantserflowAuto}`}>
|
|
10
10
|
<BrowserRouter basename={appPath}>
|
|
11
11
|
<Routes>
|
|
12
12
|
<Route path="/" element={<ReferralsQueue />} />
|
package/src/routes.json
ADDED
package/src/setup-tests.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
2
2
|
|
|
3
|
-
jest.mock(
|
|
4
|
-
const originalModule = jest.requireActual(
|
|
3
|
+
jest.mock('@openmrs/esm-framework', () => {
|
|
4
|
+
const originalModule = jest.requireActual('@openmrs/esm-framework');
|
|
5
5
|
|
|
6
6
|
return {
|
|
7
7
|
...originalModule,
|
|
@@ -9,16 +9,16 @@ jest.mock("@openmrs/esm-framework", () => {
|
|
|
9
9
|
return {
|
|
10
10
|
links: {
|
|
11
11
|
patientDash:
|
|
12
|
-
|
|
12
|
+
'${openmrsBase}/coreapps/clinicianfacing/patient.page?patientId=${patientUuid}&app=pih.app.clinicianDashboard',
|
|
13
13
|
visitPage:
|
|
14
|
-
|
|
14
|
+
'${openmrsBase}/pihcore/visit/visit.page?patient=${patientUuid}&visit=${visitUuid}&suppressActions=true#/overview',
|
|
15
15
|
homeVisitForm:
|
|
16
|
-
|
|
16
|
+
'${openmrsBase}/htmlformentryui/htmlform/editHtmlFormWithStandardUi.page?patientId=${patientUuid}&visitId=${visitUuid}&encounterId=${encounterUuid}&definitionUiResource=file:configuration/pih/htmlforms/section-mch-referral.xml&returnUrl=/mirebalais/spa/referrals-queue',
|
|
17
17
|
},
|
|
18
|
-
pendingStatuses: [
|
|
18
|
+
pendingStatuses: ['Pending status', 'Referral unmet'],
|
|
19
19
|
};
|
|
20
20
|
}),
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
window.getOpenmrsSpaBase = () =>
|
|
24
|
+
window.getOpenmrsSpaBase = () => 'openmrs/spa';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table, TableHead, TableHeader, TableRow, TableBody, TableCell } from '@carbon/react';
|
|
3
|
+
import { ConfigurableLink, interpolateString, useConfig } from '@openmrs/esm-framework';
|
|
4
|
+
import { Trans } from 'react-i18next';
|
|
5
|
+
import { formatDate } from '../util';
|
|
6
|
+
|
|
7
|
+
export interface ReferralsTableProps {
|
|
8
|
+
referrals: Referral[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function ReferrablesTable(props: ReferralsTableProps) {
|
|
12
|
+
const config = useConfig();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Table>
|
|
16
|
+
<TableHead>
|
|
17
|
+
<TableRow>
|
|
18
|
+
<TableHeader>
|
|
19
|
+
<Trans i18nKey="emr-id">EMR ID</Trans>
|
|
20
|
+
</TableHeader>
|
|
21
|
+
<TableHeader>
|
|
22
|
+
<Trans i18nKey="name">Name</Trans>
|
|
23
|
+
</TableHeader>
|
|
24
|
+
<TableHeader>
|
|
25
|
+
<Trans i18nKey="referral-date">Referral Date</Trans>
|
|
26
|
+
</TableHeader>
|
|
27
|
+
<TableHeader>
|
|
28
|
+
<Trans i18nKey="referral-type">Referral Type</Trans>
|
|
29
|
+
</TableHeader>
|
|
30
|
+
<TableHeader>
|
|
31
|
+
<Trans i18nKey="details">Details</Trans>
|
|
32
|
+
</TableHeader>
|
|
33
|
+
<TableHeader>
|
|
34
|
+
<Trans i18nKey="status">Status</Trans>
|
|
35
|
+
</TableHeader>
|
|
36
|
+
</TableRow>
|
|
37
|
+
</TableHead>
|
|
38
|
+
<TableBody>
|
|
39
|
+
{props.referrals &&
|
|
40
|
+
props.referrals.map((referral, index) => (
|
|
41
|
+
<React.Fragment key={index}>
|
|
42
|
+
<TableRow>
|
|
43
|
+
<TableCell>
|
|
44
|
+
<ConfigurableLink
|
|
45
|
+
to={interpolateString(config.links.patientDash, {
|
|
46
|
+
patientUuid: referral.patient_uuid || referral.person_uuid,
|
|
47
|
+
})}>
|
|
48
|
+
{referral.zl_emr_id}
|
|
49
|
+
</ConfigurableLink>
|
|
50
|
+
</TableCell>
|
|
51
|
+
<TableCell>{referral.patient_name}</TableCell>
|
|
52
|
+
<TableCell>
|
|
53
|
+
<ConfigurableLink
|
|
54
|
+
to={interpolateString(config.links.visitPage, {
|
|
55
|
+
patientUuid: referral.patient_uuid || referral.person_uuid,
|
|
56
|
+
visitUuid: referral.visit_uuid,
|
|
57
|
+
})}>
|
|
58
|
+
{formatDate(referral.referral_date)}
|
|
59
|
+
</ConfigurableLink>
|
|
60
|
+
</TableCell>
|
|
61
|
+
<TableCell>{referral.referral_type}</TableCell>
|
|
62
|
+
<TableCell>{referral.details}</TableCell>
|
|
63
|
+
<TableCell>
|
|
64
|
+
{config.pendingStatuses.includes(referral.fulfillment_status) ? (
|
|
65
|
+
<ConfigurableLink
|
|
66
|
+
to={interpolateString(config.links.homeVisitForm, {
|
|
67
|
+
patientUuid: referral.patient_uuid || referral.person_uuid,
|
|
68
|
+
visitUuid: referral.visit_uuid,
|
|
69
|
+
encounterUuid: referral.encounter_uuid,
|
|
70
|
+
})}>
|
|
71
|
+
{referral.fulfillment_status}
|
|
72
|
+
</ConfigurableLink>
|
|
73
|
+
) : (
|
|
74
|
+
referral.fulfillment_status
|
|
75
|
+
)}
|
|
76
|
+
</TableCell>
|
|
77
|
+
</TableRow>
|
|
78
|
+
</React.Fragment>
|
|
79
|
+
))}
|
|
80
|
+
</TableBody>
|
|
81
|
+
</Table>
|
|
82
|
+
);
|
|
83
|
+
}
|
package/src/util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import moment from
|
|
1
|
+
import moment from 'moment';
|
|
2
2
|
|
|
3
3
|
// We use UTC for the present TZ because the dates in the data
|
|
4
4
|
// are all midnight Eastern Time, which lines up with UTC
|
|
@@ -6,15 +6,11 @@ import moment from "moment";
|
|
|
6
6
|
export function formatDate(strDate: string) {
|
|
7
7
|
const date = moment.utc(strDate);
|
|
8
8
|
const today = moment.utc(new Date());
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
date.month() === today.month() &&
|
|
12
|
-
date.year() === today.year()
|
|
13
|
-
) {
|
|
14
|
-
return moment().calendar().split(" ")[0]; // locale-specific 'Today'
|
|
9
|
+
if (date.date() === today.date() && date.month() === today.month() && date.year() === today.year()) {
|
|
10
|
+
return moment().calendar().split(' ')[0]; // locale-specific 'Today'
|
|
15
11
|
} else if (date.year() === today.year()) {
|
|
16
|
-
return date.format(
|
|
12
|
+
return date.format('DD MMM');
|
|
17
13
|
} else {
|
|
18
|
-
return date.format(
|
|
14
|
+
return date.format('DD MMM YYYY');
|
|
19
15
|
}
|
|
20
16
|
}
|
package/translations/en.json
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
2
|
+
"any": "Any",
|
|
3
|
+
"details": "Details",
|
|
4
|
+
"emr-id": "EMR ID",
|
|
5
|
+
"filter-by-patient": "Filter by patient",
|
|
6
|
+
"from": "From",
|
|
7
|
+
"name": "Name",
|
|
8
|
+
"referral-date": "Referral Date",
|
|
9
|
+
"referral-type": "Referral Type",
|
|
10
|
+
"referrals-queue": "Referrals Queue",
|
|
11
|
+
"select-referral-type": "Select Referral Type",
|
|
12
|
+
"select-status": "Select Status",
|
|
13
|
+
"status": "Status",
|
|
14
|
+
"to": "To"
|
|
4
15
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"any": "Any",
|
|
3
|
+
"details": "Detalles",
|
|
4
|
+
"emr-id": "EMR ID",
|
|
5
|
+
"filter-by-patient": "Filtrar por paciente",
|
|
6
|
+
"from": "Desde",
|
|
7
|
+
"name": "Nombre",
|
|
8
|
+
"referral-date": "Fecha de referencia",
|
|
9
|
+
"referral-type": "Tipo de referencia",
|
|
10
|
+
"referrals-queue": "Cola de referencias",
|
|
11
|
+
"select-referral-type": "Seleccionar tipo de referencia",
|
|
12
|
+
"select-status": "Seleccionar estado",
|
|
13
|
+
"status": "Estado",
|
|
14
|
+
"to": "Hasta"
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"any": "Tout",
|
|
3
|
+
"details": "Détails",
|
|
4
|
+
"emr-id": "EMR ID",
|
|
5
|
+
"filter-by-patient": "Filtrer avec patient",
|
|
6
|
+
"from": "de",
|
|
7
|
+
"name": "Nom",
|
|
8
|
+
"referral-date": "Date de Référé",
|
|
9
|
+
"referral-type": "Type Référé",
|
|
10
|
+
"referrals-queue": "List de Référé",
|
|
11
|
+
"select-referral-type": "Sélectionnez le type de référé",
|
|
12
|
+
"select-status": "Sélectionnez le état",
|
|
13
|
+
"status": "État",
|
|
14
|
+
"to": "à"
|
|
15
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"jsx": "react",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"moduleResolution": "node",
|
|
9
|
-
"lib": [
|
|
10
|
-
"dom",
|
|
11
|
-
"es5",
|
|
12
|
-
"scripthost",
|
|
13
|
-
"es2015",
|
|
14
|
-
"es2015.promise",
|
|
15
|
-
"es2016.array.include",
|
|
16
|
-
"es2018",
|
|
17
|
-
"es2020"
|
|
18
|
-
],
|
|
19
|
-
"resolveJsonModule": true,
|
|
20
|
-
"noEmit": true,
|
|
21
|
-
"target": "esnext"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"include": ["src/**/*"],
|
|
4
|
+
"exclude": ["src/**/*.test.tsx"]
|
|
5
|
+
}
|
package/.editorconfig
DELETED
package/.eslintignore
DELETED
package/.eslintrc
DELETED