@openmrs/esm-patient-programs-app 3.2.1-pre.217 → 3.2.1-pre.219

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 (51) hide show
  1. package/.turbo/turbo-build.log +34 -36
  2. package/dist/109.js +1 -0
  3. package/dist/13.js +1 -0
  4. package/dist/145.js +1 -1
  5. package/dist/154.js +2 -0
  6. package/dist/154.js.LICENSE.txt +53 -0
  7. package/dist/238.js +2 -0
  8. package/dist/{707.js.LICENSE.txt → 238.js.LICENSE.txt} +0 -0
  9. package/dist/340.js +1 -0
  10. package/dist/435.js +1 -1
  11. package/dist/461.js +1 -0
  12. package/dist/574.js +1 -1
  13. package/dist/709.js +1 -0
  14. package/dist/784.js +1 -1
  15. package/dist/784.js.LICENSE.txt +2 -7
  16. package/dist/858.js +1 -1
  17. package/dist/main.js +1 -0
  18. package/dist/openmrs-esm-patient-programs-app.js +1 -1
  19. package/dist/openmrs-esm-patient-programs-app.js.buildmanifest.json +128 -223
  20. package/dist/openmrs-esm-patient-programs-app.old +1 -1
  21. package/package.json +6 -10
  22. package/src/index.ts +1 -1
  23. package/src/programs/program-action-button/program-action-button.component.tsx +4 -4
  24. package/src/programs/programs-detailed-summary.component.tsx +42 -51
  25. package/src/programs/programs-detailed-summary.scss +1 -4
  26. package/src/programs/programs-detailed-summary.test.tsx +15 -5
  27. package/src/programs/programs-form.component.tsx +11 -10
  28. package/src/programs/programs-form.scss +1 -9
  29. package/src/programs/programs-form.test.tsx +104 -196
  30. package/src/programs/programs-overview.component.tsx +33 -39
  31. package/src/programs/programs-overview.scss +1 -3
  32. package/src/programs/programs-overview.test.tsx +6 -7
  33. package/translations/en.json +1 -1
  34. package/dist/186.js +0 -2
  35. package/dist/186.js.LICENSE.txt +0 -23
  36. package/dist/336.js +0 -2
  37. package/dist/336.js.LICENSE.txt +0 -20
  38. package/dist/337.js +0 -1
  39. package/dist/402.js +0 -1
  40. package/dist/478.js +0 -2
  41. package/dist/478.js.LICENSE.txt +0 -8
  42. package/dist/499.js +0 -1
  43. package/dist/60.js +0 -1
  44. package/dist/635.js +0 -2
  45. package/dist/635.js.LICENSE.txt +0 -16
  46. package/dist/692.js +0 -1
  47. package/dist/701.js +0 -1
  48. package/dist/707.js +0 -2
  49. package/dist/93.js +0 -1
  50. package/dist/963.js +0 -2
  51. package/dist/963.js.LICENSE.txt +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-patient-programs-app",
3
- "version": "3.2.1-pre.217",
3
+ "version": "3.2.1-pre.219",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Patient programs microfrontend for the OpenMRS SPA",
6
6
  "browser": "dist/openmrs-esm-patient-programs-app.js",
@@ -34,23 +34,19 @@
34
34
  "url": "https://github.com/openmrs/openmrs-esm-patient-chart/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@carbon/charts-react": "^0.49.4",
38
- "@carbon/icons-react": "^10.18.0",
39
- "@openmrs/esm-patient-common-lib": "^3.2.1-pre.217",
40
- "carbon-components-react": "^7.25.0",
37
+ "@carbon/react": "^1.8.0",
38
+ "@openmrs/esm-patient-common-lib": "^3.2.1-pre.219",
41
39
  "d3": "^7.0.3",
42
40
  "lodash-es": "^4.17.15"
43
41
  },
44
42
  "peerDependencies": {
45
43
  "@openmrs/esm-framework": "3.x",
46
44
  "@openmrs/esm-patient-common-lib": "3.x",
47
- "carbon-components": "10.x",
48
- "carbon-icons": "7.x",
49
45
  "dayjs": "1.x",
50
- "react": "16.x",
46
+ "react": "^18.2.0",
51
47
  "react-i18next": "11.x",
52
- "react-router-dom": "5.x",
48
+ "react-router-dom": "6.x",
53
49
  "rxjs": "6.x"
54
50
  },
55
- "gitHead": "99f3707d63ba78748b9457b3fdc293797f4d37b4"
51
+ "gitHead": "1b53149e0bae7918f85c340045a65422025bbfc5"
56
52
  }
package/src/index.ts CHANGED
@@ -49,7 +49,7 @@ function setupOpenMRS() {
49
49
  name: 'programs-form-workspace',
50
50
  load: getAsyncLifecycle(() => import('./programs/programs-form.component'), options),
51
51
  meta: {
52
- title: 'Record Program enrollment',
52
+ title: 'Record program enrollment',
53
53
  },
54
54
  },
55
55
  ],
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { Button } from 'carbon-components-react';
3
2
  import { useTranslation } from 'react-i18next';
4
- import TaskAdd20 from '@carbon/icons-react/es/task--add/20';
3
+ import { Button } from '@carbon/react';
4
+ import { TaskAdd } from '@carbon/react/icons';
5
5
  import { formEntrySub, launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
6
6
  import { ConfigurableProgram } from '../../types';
7
7
 
@@ -24,7 +24,7 @@ const ProgramActionButton: React.FC<ProgramActionButton> = ({ enrollment }) => {
24
24
  return (
25
25
  <Button
26
26
  onClick={() => launchEnrollmentForm(t('enrollment', 'Enrollment'))}
27
- renderIcon={TaskAdd20}
27
+ renderIcon={(props) => <TaskAdd size={20} {...props} />}
28
28
  kind="tertiary"
29
29
  size="small"
30
30
  >
@@ -35,7 +35,7 @@ const ProgramActionButton: React.FC<ProgramActionButton> = ({ enrollment }) => {
35
35
  return (
36
36
  <Button
37
37
  onClick={() => launchEnrollmentForm(t('discontinue', 'Discontinue'))}
38
- renderIcon={TaskAdd20}
38
+ renderIcon={(props) => <TaskAdd size={20} {...props} />}
39
39
  kind="danger--ghost"
40
40
  size="small"
41
41
  >
@@ -1,34 +1,29 @@
1
1
  import React from 'react';
2
- import Add16 from '@carbon/icons-react/es/add/16';
3
- import Edit16 from '@carbon/icons-react/es/edit/16';
4
- import filter from 'lodash-es/filter';
5
- import includes from 'lodash-es/includes';
6
- import map from 'lodash-es/map';
7
- import styles from './programs-detailed-summary.scss';
8
- import { CardHeader, EmptyState, ErrorState, launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
9
2
  import { useTranslation } from 'react-i18next';
10
- import { useAvailablePrograms, useEnrollments, usePrograms } from './programs.resource';
3
+ import capitalize from 'lodash-es/capitalize';
11
4
  import {
12
5
  Button,
13
6
  DataTable,
7
+ DataTableHeader,
8
+ DataTableRow,
14
9
  DataTableSkeleton,
15
10
  InlineLoading,
11
+ InlineNotification,
16
12
  Table,
13
+ TableBody,
17
14
  TableCell,
18
15
  TableContainer,
19
- TableBody,
20
16
  TableHead,
21
17
  TableHeader,
22
18
  TableRow,
23
- DataTableHeader,
24
- DataTableRow,
25
- InlineNotification,
26
- } from 'carbon-components-react';
27
- import { formatDate, formatDatetime, useConfig, usePagination } from '@openmrs/esm-framework';
28
- import { ConfigObject } from '../config-schema';
19
+ } from '@carbon/react';
20
+ import { Add, Edit } from '@carbon/react/icons';
21
+ import { formatDate, formatDatetime, useConfig, usePagination, ConfigObject } from '@openmrs/esm-framework';
22
+ import { CardHeader, EmptyState, ErrorState, launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
23
+ import { useAvailablePrograms, useEnrollments, usePrograms } from './programs.resource';
29
24
  import { ConfigurableProgram } from '../types';
30
- import capitalize from 'lodash-es/capitalize';
31
25
  import ProgramActionButton from './program-action-button/program-action-button.component';
26
+ import styles from './programs-detailed-summary.scss';
32
27
 
33
28
  interface ProgramsDetailedSummaryProps {
34
29
  patientUuid: string;
@@ -78,23 +73,19 @@ const ProgramsDetailedSummary: React.FC<ProgramsDetailedSummaryProps> = ({ patie
78
73
  );
79
74
 
80
75
  const tableRows = React.useMemo(() => {
81
- return paginatedEnrollments?.map((enrollment: ConfigurableProgram) => ({
82
- id: enrollment.uuid,
83
- display: enrollment.display,
84
- location: enrollment.location?.display,
85
- dateEnrolled: enrollment.dateEnrolled ? formatDatetime(new Date(enrollment.dateEnrolled)) : '--',
86
- status: isConfigurable
87
- ? capitalize(enrollment.enrollmentStatus)
88
- : enrollment.dateCompleted
89
- ? `${t('completedOn', 'Completed On')} ${formatDate(new Date(enrollment.dateCompleted))}`
90
- : t('active', 'Active'),
91
- actions: isConfigurable ? (
92
- <ProgramActionButton enrollment={enrollment} />
93
- ) : (
94
- <ProgramEditButton programEnrollmentId={enrollment.uuid} />
95
- ),
96
- }));
97
- }, [isConfigurable, paginatedEnrollments, t]);
76
+ return enrollments?.map((program) => {
77
+ return {
78
+ id: program.uuid,
79
+ display: program.display,
80
+ location: program.location?.display,
81
+ dateEnrolled: formatDatetime(new Date(program.dateEnrolled)),
82
+ status: program.dateCompleted
83
+ ? `${t('completedOn', 'Completed On')} ${formatDate(new Date(program.dateCompleted))}`
84
+ : t('active', 'Active'),
85
+ actions: <ProgramEditButton programEnrollmentId={program.uuid} />,
86
+ };
87
+ });
88
+ }, [enrollments, t]);
98
89
 
99
90
  const launchProgramsForm = React.useCallback(() => launchPatientWorkspace('programs-form-workspace'), []);
100
91
 
@@ -107,7 +98,7 @@ const ProgramsDetailedSummary: React.FC<ProgramsDetailedSummaryProps> = ({ patie
107
98
  <span>{isValidating ? <InlineLoading /> : null}</span>
108
99
  <Button
109
100
  kind="ghost"
110
- renderIcon={Add16}
101
+ renderIcon={(props) => <Add size={16} {...props} />}
111
102
  iconDescription="Add programs"
112
103
  onClick={launchProgramsForm}
113
104
  disabled={availablePrograms?.length && eligiblePrograms?.length === 0}
@@ -115,19 +106,19 @@ const ProgramsDetailedSummary: React.FC<ProgramsDetailedSummaryProps> = ({ patie
115
106
  {t('add', 'Add')}
116
107
  </Button>
117
108
  </CardHeader>
118
- <TableContainer>
119
- {availablePrograms?.length && eligiblePrograms?.length === 0 && (
120
- <InlineNotification
121
- style={{ minWidth: '100%', margin: '0rem', padding: '0rem' }}
122
- kind={'info'}
123
- lowContrast
124
- subtitle={t('noEligibleEnrollments', 'There are no more programs left to enroll this patient in')}
125
- title={t('fullyEnrolled', 'Enrolled in all programs')}
126
- />
127
- )}
128
- <DataTable rows={tableRows} headers={tableHeaders} isSortable={true} size="short">
129
- {({ rows, headers, getHeaderProps, getTableProps }) => (
130
- <Table {...getTableProps()} useZebraStyles>
109
+ {availablePrograms?.length && eligiblePrograms?.length === 0 ? (
110
+ <InlineNotification
111
+ style={{ minWidth: '100%', margin: '0rem', padding: '0rem' }}
112
+ kind={'info'}
113
+ lowContrast
114
+ subtitle={t('noEligibleEnrollments', 'There are no more programs left to enroll this patient in')}
115
+ title={t('fullyEnrolled', 'Enrolled in all programs')}
116
+ />
117
+ ) : null}
118
+ <DataTable rows={tableRows} headers={tableHeaders} isSortable size="xs" useZebraStyles>
119
+ {({ rows, headers, getHeaderProps, getTableProps }) => (
120
+ <TableContainer>
121
+ <Table {...getTableProps()}>
131
122
  <TableHead>
132
123
  <TableRow>
133
124
  {headers.map((header) => (
@@ -153,9 +144,9 @@ const ProgramsDetailedSummary: React.FC<ProgramsDetailedSummaryProps> = ({ patie
153
144
  ))}
154
145
  </TableBody>
155
146
  </Table>
156
- )}
157
- </DataTable>
158
- </TableContainer>
147
+ </TableContainer>
148
+ )}
149
+ </DataTable>
159
150
  </div>
160
151
  );
161
152
  }
@@ -175,7 +166,7 @@ function ProgramEditButton({ programEnrollmentId }: ProgramEditButtonProps) {
175
166
  return (
176
167
  <Button
177
168
  kind="ghost"
178
- renderIcon={Edit16}
169
+ renderIcon={(props) => <Edit size={16} {...props} />}
179
170
  iconDescription="Edit Program"
180
171
  onClick={launchEditProgramsForm}
181
172
  hasIconOnly
@@ -1,7 +1,4 @@
1
-
2
- @import "~@openmrs/esm-styleguide/src/vars";
3
- @import "~carbon-components/src/globals/scss/vars";
4
- @import "~carbon-components/src/globals/scss/mixins";
1
+ @import '~@openmrs/esm-styleguide/src/vars';
5
2
 
6
3
  .widgetCard {
7
4
  border: 1px solid $ui-03;
@@ -1,12 +1,15 @@
1
1
  import React from 'react';
2
- import { screen, within } from '@testing-library/react';
2
+ import { screen, within, waitFor } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
  import { openmrsFetch, usePagination } from '@openmrs/esm-framework';
5
+ import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
6
+ import { mockPatient } from '../../../../__mocks__/patient.mock';
5
7
  import { mockEnrolledProgramsResponse } from '../../../../__mocks__/programs.mock';
6
8
  import { renderWithSwr, waitForLoadingToFinish } from '../../../../tools/test-helpers';
7
- import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
8
9
  import ProgramsDetailedSummary from './programs-detailed-summary.component';
9
10
 
11
+ jest.setTimeout(20000);
12
+
10
13
  const mockOpenmrsFetch = openmrsFetch as jest.Mock;
11
14
  const mockUsePagination = usePagination as jest.Mock;
12
15
 
@@ -70,6 +73,8 @@ describe('ProgramsDetailedSummary ', () => {
70
73
  });
71
74
 
72
75
  it("renders a detailed tabular summary of the patient's program enrollments", async () => {
76
+ const user = userEvent.setup();
77
+
73
78
  mockOpenmrsFetch.mockReturnValueOnce({ data: { results: mockEnrolledProgramsResponse } });
74
79
  mockUsePagination.mockImplementation(() => ({
75
80
  currentPage: 1,
@@ -97,11 +102,13 @@ describe('ProgramsDetailedSummary ', () => {
97
102
  expect(editButton).toBeInTheDocument();
98
103
 
99
104
  // Clicking "Add" launches the programs form in a workspace
100
- userEvent.click(addButton);
105
+ await waitFor(() => user.click(addButton));
106
+
101
107
  expect(launchPatientWorkspace).toHaveBeenCalledWith('programs-form-workspace');
102
108
 
103
109
  // Clicking the edit button launches the edit form in a workspace
104
- userEvent.click(editButton);
110
+ await waitFor(() => user.click(editButton));
111
+
105
112
  expect(launchPatientWorkspace).toHaveBeenCalledWith('programs-form-workspace', {
106
113
  programEnrollmentId: mockEnrolledProgramsResponse[0].uuid,
107
114
  });
@@ -109,5 +116,8 @@ describe('ProgramsDetailedSummary ', () => {
109
116
  });
110
117
 
111
118
  function renderProgramsOverview() {
112
- renderWithSwr(<ProgramsDetailedSummary />);
119
+ const testProps = {
120
+ patientUuid: mockPatient.id,
121
+ };
122
+ renderWithSwr(<ProgramsDetailedSummary {...testProps} />);
113
123
  }
@@ -1,10 +1,10 @@
1
1
  import React, { SyntheticEvent } from 'react';
2
+ import { useTranslation } from 'react-i18next';
2
3
  import dayjs from 'dayjs';
3
4
  import filter from 'lodash-es/filter';
4
5
  import includes from 'lodash-es/includes';
5
6
  import map from 'lodash-es/map';
6
7
  import { useSWRConfig } from 'swr';
7
- import { useTranslation } from 'react-i18next';
8
8
  import {
9
9
  createErrorHandler,
10
10
  showNotification,
@@ -16,14 +16,15 @@ import {
16
16
  } from '@openmrs/esm-framework';
17
17
  import {
18
18
  Button,
19
+ ButtonSet,
19
20
  DatePicker,
20
21
  DatePickerInput,
21
- Select,
22
- SelectItem,
23
22
  Form,
24
23
  FormGroup,
25
- ButtonSet,
26
- } from 'carbon-components-react';
24
+ Select,
25
+ SelectItem,
26
+ Stack,
27
+ } from '@carbon/react';
27
28
  import {
28
29
  createProgramEnrollment,
29
30
  useAvailablePrograms,
@@ -161,8 +162,8 @@ const ProgramsForm: React.FC<ProgramsFormProps> = ({ closeWorkspace, patientUuid
161
162
 
162
163
  return (
163
164
  <Form className={styles.form} onSubmit={handleSubmit}>
164
- <div className={styles.formContainer}>
165
- <FormGroup style={{ width: '50%' }} legendText={t('program', 'Program')}>
165
+ <Stack className={styles.formContainer} gap={7}>
166
+ <FormGroup style={{ maxWidth: '50%' }} legendText={t('programName', 'Program name')}>
166
167
  <div className={styles.selectContainer}>
167
168
  <Select
168
169
  id="program"
@@ -181,7 +182,7 @@ const ProgramsForm: React.FC<ProgramsFormProps> = ({ closeWorkspace, patientUuid
181
182
  </Select>
182
183
  </div>
183
184
  </FormGroup>
184
- <FormGroup legendText={t('dateEnrolled', 'Date enrolled')}>
185
+ <FormGroup style={{ maxWidth: '50%' }} legendText={t('dateEnrolled', 'Date enrolled')}>
185
186
  <DatePicker
186
187
  id="enrollmentDate"
187
188
  datePickerType="single"
@@ -195,7 +196,7 @@ const ProgramsForm: React.FC<ProgramsFormProps> = ({ closeWorkspace, patientUuid
195
196
  <DatePickerInput id="enrollmentDateInput" labelText="" />
196
197
  </DatePicker>
197
198
  </FormGroup>
198
- <FormGroup legendText={t('dateCompleted', 'Date completed')}>
199
+ <FormGroup style={{ width: '50%' }} legendText={t('dateCompleted', 'Date completed')}>
199
200
  <DatePicker
200
201
  id="completionDate"
201
202
  datePickerType="single"
@@ -228,7 +229,7 @@ const ProgramsForm: React.FC<ProgramsFormProps> = ({ closeWorkspace, patientUuid
228
229
  ))}
229
230
  </Select>
230
231
  </FormGroup>
231
- </div>
232
+ </Stack>
232
233
  <ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
233
234
  <Button className={styles.button} kind="secondary" onClick={() => closeWorkspace()}>
234
235
  {t('cancel', 'Cancel')}
@@ -1,11 +1,4 @@
1
- @import "~@openmrs/esm-styleguide/src/vars";
2
- @import "~carbon-components/src/globals/scss/vars";
3
- @import "~carbon-components/src/globals/scss/mixins";
4
-
5
- .selectContainer {
6
- display: flex;
7
- align-items: center;
8
- }
1
+ @import '~@openmrs/esm-styleguide/src/vars';
9
2
 
10
3
  .loading {
11
4
  margin-left: 1rem;
@@ -13,7 +6,6 @@
13
6
  min-height: 2.5rem;
14
7
  }
15
8
 
16
-
17
9
  .button {
18
10
  height: 4rem;
19
11
  display: flex;