@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.
Files changed (93) hide show
  1. package/.turbo/turbo-build.log +41 -0
  2. package/README.md +1 -17
  3. package/dist/13.js +2 -0
  4. package/dist/13.js.LICENSE.txt +38 -0
  5. package/dist/13.js.map +1 -0
  6. package/dist/144.js +2 -0
  7. package/dist/144.js.LICENSE.txt +19 -0
  8. package/dist/144.js.map +1 -0
  9. package/dist/146.js +1 -0
  10. package/dist/146.js.map +1 -0
  11. package/dist/15.js +2 -0
  12. package/dist/15.js.LICENSE.txt +28 -0
  13. package/dist/15.js.map +1 -0
  14. package/dist/300.js +1 -0
  15. package/dist/304.js +1 -0
  16. package/dist/304.js.map +1 -0
  17. package/dist/372.js +1 -0
  18. package/dist/372.js.map +1 -0
  19. package/dist/41.js +2 -0
  20. package/dist/41.js.map +1 -0
  21. package/dist/423.js +1 -0
  22. package/dist/423.js.map +1 -0
  23. package/dist/470.js +2 -0
  24. package/dist/470.js.LICENSE.txt +9 -0
  25. package/dist/470.js.map +1 -0
  26. package/dist/495.js +1 -0
  27. package/dist/495.js.map +1 -0
  28. package/dist/55.js +1 -0
  29. package/dist/84.js +2 -0
  30. package/dist/{147.js.LICENSE.txt → 84.js.LICENSE.txt} +7 -24
  31. package/dist/84.js.map +1 -0
  32. package/dist/876.js +2 -0
  33. package/dist/876.js.LICENSE.txt +9 -0
  34. package/dist/876.js.map +1 -0
  35. package/dist/89.js +1 -0
  36. package/dist/89.js.map +1 -0
  37. package/dist/913.js +2 -0
  38. package/dist/{879.js.LICENSE.txt → 913.js.LICENSE.txt} +13 -2
  39. package/dist/913.js.map +1 -0
  40. package/dist/92.js +2 -0
  41. package/dist/92.js.LICENSE.txt +9 -0
  42. package/dist/92.js.map +1 -0
  43. package/dist/99.js +1 -0
  44. package/dist/main.js +1 -1
  45. package/dist/main.js.map +1 -0
  46. package/dist/pih-esm-referrals-queue-app.js +1 -1
  47. package/dist/pih-esm-referrals-queue-app.js.buildmanifest.json +429 -60
  48. package/dist/pih-esm-referrals-queue-app.js.map +1 -0
  49. package/dist/routes.json +1 -0
  50. package/jest.config.js +3 -0
  51. package/package.json +27 -70
  52. package/src/config-schema.ts +8 -16
  53. package/src/declarations.d.tsx +4 -4
  54. package/src/index.ts +11 -65
  55. package/src/referrals-queue/referrals-queue.component.tsx +71 -120
  56. package/src/referrals-queue/referrals-queue.resource.tsx +6 -9
  57. package/src/referrals-queue/referrals-queue.scss +24 -0
  58. package/src/referrals-queue/referrals-queue.test.tsx +148 -116
  59. package/src/root.component.test.tsx +3 -3
  60. package/src/root.component.tsx +6 -6
  61. package/src/routes.json +9 -0
  62. package/src/setup-tests.ts +8 -8
  63. package/src/table/referrals-table.component.tsx +83 -0
  64. package/src/util.ts +5 -9
  65. package/translations/en.json +13 -2
  66. package/translations/es.json +15 -0
  67. package/translations/fr.json +15 -0
  68. package/tsconfig.json +4 -22
  69. package/.editorconfig +0 -12
  70. package/.eslintignore +0 -2
  71. package/.eslintrc +0 -4
  72. package/.github/workflows/node.js.yml +0 -79
  73. package/.husky/pre-commit +0 -6
  74. package/.husky/pre-push +0 -6
  75. package/.prettierignore +0 -14
  76. package/LICENSE +0 -401
  77. package/__mocks__/react-i18next.js +0 -51
  78. package/dist/132.js +0 -1
  79. package/dist/147.js +0 -2
  80. package/dist/281.js +0 -1
  81. package/dist/294.js +0 -2
  82. package/dist/574.js +0 -1
  83. package/dist/595.js +0 -2
  84. package/dist/595.js.LICENSE.txt +0 -1
  85. package/dist/879.js +0 -2
  86. package/dist/90.js +0 -1
  87. package/dist/pih-esm-referrals-queue-app.old +0 -1
  88. package/jest.config.json +0 -19
  89. package/src/referrals-queue/react-dates-overrides.css +0 -39
  90. package/src/referrals-queue/referrals-queue.css +0 -63
  91. package/src/table/table.component.tsx +0 -95
  92. package/src/table/table.css +0 -16
  93. /package/dist/{294.js.LICENSE.txt → 41.js.LICENSE.txt} +0 -0
@@ -1,68 +1,82 @@
1
- import React from "react";
2
- import { of } from "rxjs";
3
- import {
4
- render,
5
- fireEvent,
6
- screen,
7
- within,
8
- waitFor,
9
- } from "@testing-library/react";
10
- import MockDate from "mockdate";
11
- import ReferralsQueue from "./referrals-queue.component";
12
- import { getReferrals } from "./referrals-queue.resource";
13
-
14
- jest.mock("./referrals-queue.resource");
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: "ptaaaaaa-2869-41a4-86af-811fa2ee65b8",
20
- zl_emr_id: "PTID1",
21
- patient_name: "Patient Commcare",
22
- referral_date: "2020-03-25T00:00:00.000-0400",
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: "visitaaa-091a-46fd-a442-2a9778d91a52",
25
+ visit_uuid: 'visitaaa-091a-46fd-a442-2a9778d91a52',
25
26
  encounter_id: 12,
26
- referral_type: "Test Referral Type",
27
- encounter_uuid: "encounter-0fe1-4318-95a4-641d31745e09",
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: "ptbbbbbb-de0e-489f-b4c7-fe4579e07aa9",
32
- zl_emr_id: "PTID2",
33
- patient_name: "Davina Mother",
34
- referral_date: "2020-03-23T00:00:00.000-0400",
35
- details: "Suspected depression",
36
- visit_uuid: "visitbbb-64ca-4d53-9024-574a9214f76e",
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: "Mental Health",
39
- encounter_uuid: "encounter-d5cb-4f7e-a1aa-bd6741a96381",
40
- fulfillment_status: "Pending 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: "ptcccccc-de0e-489f-b4c7-fe4579e07aa9",
44
- zl_emr_id: "PTID3",
45
- patient_name: "Patient Prenatal",
46
- referral_date: "2020-03-28T00:00:00.000-0400",
47
- details: "Urgent",
48
- visit_uuid: "visitccc-64ca-4d53-9024-574a9214f76e",
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: "Family Member",
51
- encounter_uuid: "encounter-67bc-435d-9929-670a98cefe4e",
52
- fulfillment_status: "Test Complete",
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 = "/openmrs";
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: "/referrals-queue" };
61
-
62
- describe("referrals queue", () => {
63
- const todayString = "2020-10-31";
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 + "T10:00:00.000-0400");
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("renders without failing", () => {
89
+ it('renders without failing', () => {
76
90
  // in beforeEach
77
91
  });
78
92
 
79
- it("renders the expected fields", () => {
93
+ it('renders the expected fields', () => {
80
94
  for (let referral of referrals) {
81
- const row = screen.getByText(referral.zl_emr_id).closest("tr");
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: "td" });
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("25 Mar");
92
- screen.getByText("23 Mar");
93
- screen.getByText("28 Mar");
105
+ screen.getByText('25 Mar');
106
+ screen.getByText('23 Mar');
107
+ screen.getByText('28 Mar');
94
108
  });
95
109
 
96
- // TODO: fix and re-enable
97
- /*it("navigates to the links", async () => {
98
- const table = screen.getByRole("table");
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("23 Mar");
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("Pending status");
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("table");
124
- expect(within(table).getByText("Pending status").tagName).toBe("A"); // sanity check
125
- expect(within(table).getByText("Test Complete").tagName).not.toBe("A"); // the actual test
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("filters by referral type", () => {
129
- const dropdown = screen.getByLabelText("Referral Type", {
130
- selector: "select",
131
- });
132
- fireEvent.change(dropdown, { target: { value: "Mental Health" } });
133
- expect(screen.queryByText("PTID1")).toBeNull();
134
- expect(screen.queryByText("PTID2")).not.toBeNull();
135
- expect(screen.queryByText("PTID3")).toBeNull();
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("infers list of referral types from data", () => {
139
- const dropdown = screen.getByLabelText("Referral Type", {
140
- selector: "select",
141
- });
142
- fireEvent.change(dropdown, { target: { value: "Test Referral Type" } });
143
- expect(screen.queryByDisplayValue("Test Referral Type")).not.toBeNull();
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("filters by statuses, with dropdown inferred from data", () => {
147
- const dropdown = screen.getByLabelText("Status", { selector: "select" });
148
- fireEvent.change(dropdown, { target: { value: "Test Complete" } });
149
- expect(screen.queryByText("PTID1")).toBeNull();
150
- expect(screen.queryByText("PTID2")).toBeNull();
151
- expect(screen.queryByText("PTID3")).not.toBeNull();
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
- it("calls getReferrals with the correct date arguments", () => {
155
- const monthAgoString = "2020-09-30";
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: "en",
191
+ locale: 'en',
160
192
  });
161
- const fromDateInput = screen.getByLabelText("From");
162
- fireEvent.change(fromDateInput, { target: { value: "2020-01-01" } });
193
+ const fromDateInput = screen.getByLabelText('From');
194
+ fireEvent.change(fromDateInput, { target: { value: '2020-01-01' } });
163
195
  expect(mockedGetReferrals).lastCalledWith({
164
- fromDate: "2020-01-01",
196
+ fromDate: '2020-01-01',
165
197
  toDate: todayString,
166
- locale: "en",
198
+ locale: 'en',
167
199
  });
168
- const toDateInput = screen.getByLabelText("To");
169
- fireEvent.change(toDateInput, { target: { value: "2020-03-01" } });
200
+ const toDateInput = screen.getByLabelText('To');
201
+ fireEvent.change(toDateInput, { target: { value: '2020-03-01' } });
170
202
  expect(mockedGetReferrals).lastCalledWith({
171
- fromDate: "2020-01-01",
172
- toDate: "2020-03-01",
173
- locale: "en",
203
+ fromDate: '2020-01-01',
204
+ toDate: '2020-03-01',
205
+ locale: 'en',
174
206
  });
175
207
  });
176
208
 
177
- it("filters the list of results by patient name query", () => {
178
- const queryBox = screen.getByLabelText("Filter by patient");
179
- fireEvent.change(queryBox, { target: { value: "Mother" } });
180
- expect(screen.queryByText("PTID2")).not.toBeNull();
181
- expect(screen.queryByText("PTID1")).toBeNull();
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("filters the list of results by patient name partial token matches", () => {
185
- const queryBox = screen.getByLabelText("Filter by patient");
186
- fireEvent.change(queryBox, { target: { value: "dav mo" } });
187
- expect(screen.queryByText("PTID2")).not.toBeNull();
188
- expect(screen.queryByText("PTID1")).toBeNull();
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("filters the list of results by patient id", () => {
192
- const queryBox = screen.getByLabelText("Filter by patient");
193
- fireEvent.change(queryBox, { target: { value: "ptid1" } });
194
- expect(screen.queryByText("PTID1")).not.toBeNull();
195
- expect(screen.queryByText("PTID2")).toBeNull();
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("makes the API call with the locale from the user session");
230
+ test.todo('makes the API call with the locale from the user session');
199
231
  });
@@ -1,6 +1,6 @@
1
- import React from "react";
2
- import { render } from "@testing-library/react";
3
- import Root from "./root.component";
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 () => {
@@ -1,12 +1,12 @@
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";
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={`omrs-main-content ${styles.ovconstantserflowAuto}`}>
9
+ <div className={`${styles.ovconstantserflowAuto}`}>
10
10
  <BrowserRouter basename={appPath}>
11
11
  <Routes>
12
12
  <Route path="/" element={<ReferralsQueue />} />
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json.openmrs.org/routes.schema.json",
3
+ "pages": [
4
+ {
5
+ "component": "root",
6
+ "route": "referrals-queue"
7
+ }
8
+ ]
9
+ }
@@ -1,7 +1,7 @@
1
- import "@testing-library/jest-dom/extend-expect";
1
+ import '@testing-library/jest-dom/extend-expect';
2
2
 
3
- jest.mock("@openmrs/esm-framework", () => {
4
- const originalModule = jest.requireActual("@openmrs/esm-framework");
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
- "${openmrsBase}/coreapps/clinicianfacing/patient.page?patientId=${patientUuid}&app=pih.app.clinicianDashboard",
12
+ '${openmrsBase}/coreapps/clinicianfacing/patient.page?patientId=${patientUuid}&app=pih.app.clinicianDashboard',
13
13
  visitPage:
14
- "${openmrsBase}/pihcore/visit/visit.page?patient=${patientUuid}&visit=${visitUuid}&suppressActions=true#/overview",
14
+ '${openmrsBase}/pihcore/visit/visit.page?patient=${patientUuid}&visit=${visitUuid}&suppressActions=true#/overview',
15
15
  homeVisitForm:
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",
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: ["Pending status", "Referral unmet"],
18
+ pendingStatuses: ['Pending status', 'Referral unmet'],
19
19
  };
20
20
  }),
21
21
  };
22
22
  });
23
23
 
24
- window.getOpenmrsSpaBase = () => "openmrs/spa";
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 "moment";
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
- date.date() === today.date() &&
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("DD MMM");
12
+ return date.format('DD MMM');
17
13
  } else {
18
- return date.format("DD MMM YYYY");
14
+ return date.format('DD MMM YYYY');
19
15
  }
20
16
  }
@@ -1,4 +1,15 @@
1
1
  {
2
- "casualGreeting": "hey",
3
- "formalGreeting": "hello"
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
- "compilerOptions": {
3
- "esModuleInterop": true,
4
- "module": "esnext",
5
- "allowSyntheticDefaultImports": true,
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
@@ -1,12 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = space
5
- indent_size = 2
6
- charset = utf-8
7
- trim_trailing_whitespace = true
8
- insert_final_newline = true
9
- end_of_line = lf
10
-
11
- [*.md]
12
- trim_trailing_whitespace = false
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- src/**/*.test.tsx
2
- **/*.d.tsx
package/.eslintrc DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "parser": "@typescript-eslint/parser",
3
- "extends": ["ts-react-important-stuff", "plugin:prettier/recommended"]
4
- }