@openmrs/esm-patient-notes-app 11.3.0 → 11.3.1-patch.9310

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 (48) hide show
  1. package/.turbo/turbo-build.log +22 -19
  2. package/dist/2499.js +2 -0
  3. package/dist/2499.js.map +1 -0
  4. package/dist/4400.js +1 -0
  5. package/dist/4400.js.map +1 -0
  6. package/dist/5670.js +1 -0
  7. package/dist/5670.js.map +1 -0
  8. package/dist/6336.js +1 -0
  9. package/dist/6336.js.map +1 -0
  10. package/dist/6554.js +2 -0
  11. package/dist/6554.js.map +1 -0
  12. package/dist/8051.js +1 -1
  13. package/dist/8051.js.map +1 -1
  14. package/dist/9444.js +1 -0
  15. package/dist/9444.js.map +1 -0
  16. package/dist/9538.js +1 -1
  17. package/dist/main.js +1 -1
  18. package/dist/main.js.map +1 -1
  19. package/dist/openmrs-esm-patient-notes-app.js +1 -1
  20. package/dist/openmrs-esm-patient-notes-app.js.buildmanifest.json +168 -168
  21. package/dist/openmrs-esm-patient-notes-app.js.map +1 -1
  22. package/dist/routes.json +1 -1
  23. package/package.json +5 -4
  24. package/src/dashboard.meta.ts +3 -1
  25. package/src/index.ts +0 -1
  26. package/src/notes/notes-overview.extension.tsx +57 -3
  27. package/src/notes/visit-notes-form.test.tsx +32 -13
  28. package/src/notes/visit-notes-form.workspace.tsx +238 -241
  29. package/src/routes.json +11 -11
  30. package/src/visit-note-action-button.extension.tsx +15 -9
  31. package/src/visit-note-action-button.test.tsx +13 -30
  32. package/translations/it.json +1 -1
  33. package/dist/1433.js +0 -1
  34. package/dist/1433.js.map +0 -1
  35. package/dist/2356.js +0 -1
  36. package/dist/2356.js.map +0 -1
  37. package/dist/3691.js +0 -2
  38. package/dist/3691.js.map +0 -1
  39. package/dist/521.js +0 -2
  40. package/dist/521.js.map +0 -1
  41. package/dist/5639.js +0 -1
  42. package/dist/5639.js.map +0 -1
  43. package/dist/717.js +0 -1
  44. package/dist/717.js.map +0 -1
  45. package/src/notes/notes-main.component.tsx +0 -62
  46. package/src/notes/notes-main.test.tsx +0 -101
  47. /package/dist/{521.js.LICENSE.txt → 2499.js.LICENSE.txt} +0 -0
  48. /package/dist/{3691.js.LICENSE.txt → 6554.js.LICENSE.txt} +0 -0
@@ -1,4 +1,6 @@
1
- export const dashboardMeta = {
1
+ import { type DashboardLinkConfig } from '@openmrs/esm-patient-common-lib';
2
+
3
+ export const dashboardMeta: DashboardLinkConfig & { slot: string } = {
2
4
  slot: 'patient-chart-encounters-dashboard-slot',
3
5
  title: 'Encounters',
4
6
  path: 'Encounters',
package/src/index.ts CHANGED
@@ -28,7 +28,6 @@ export function startupApp() {
28
28
  }
29
29
 
30
30
  export const notesOverview = getSyncLifecycle(notesOverviewExtension, options);
31
-
32
31
  export const visitNotesActionButton = getSyncLifecycle(visitNotesActionButtonExtension, options);
33
32
 
34
33
  // t('visitNoteWorkspaceTitle', 'Visit Note')
@@ -1,6 +1,17 @@
1
- import React from 'react';
1
+ import React, { type ComponentProps } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
- import NotesMain from './notes-main.component';
3
+ import { Button, DataTableSkeleton, InlineLoading } from '@carbon/react';
4
+ import { AddIcon, launchWorkspace, useLayoutType } from '@openmrs/esm-framework';
5
+ import {
6
+ CardHeader,
7
+ EmptyState,
8
+ ErrorState,
9
+ launchStartVisitPrompt,
10
+ usePatientChartStore,
11
+ } from '@openmrs/esm-patient-common-lib';
12
+ import { useVisitNotes } from './visit-notes.resource';
13
+ import PaginatedNotes from './paginated-notes.component';
14
+ import styles from './notes-overview.scss';
4
15
 
5
16
  interface NotesOverviewProps {
6
17
  patientUuid: string;
@@ -8,13 +19,56 @@ interface NotesOverviewProps {
8
19
  basePath: string;
9
20
  }
10
21
 
22
+ /**
23
+ * This extension uses the patient chart store and MUST only be mounted within the patient chart
24
+ */
11
25
  const NotesOverview: React.FC<NotesOverviewProps> = ({ patientUuid, patient, basePath }) => {
12
26
  const pageSize = 5;
13
27
  const { t } = useTranslation();
14
28
  const pageUrl = `\${openmrsSpaBase}/patient/${patient.id}/chart/Forms & Notes`;
15
29
  const urlLabel = t('seeAll', 'See all');
16
30
 
17
- return <NotesMain patientUuid={patientUuid} pageSize={pageSize} urlLabel={urlLabel} pageUrl={pageUrl} />;
31
+ const { visitContext } = usePatientChartStore(patientUuid);
32
+ const displayText = t('visitNotes', 'Visit notes');
33
+ const headerTitle = t('visitNotes', 'Visit notes');
34
+ const { visitNotes, error, isLoading, isValidating } = useVisitNotes(patientUuid);
35
+ const layout = useLayoutType();
36
+ const isDesktop = layout === 'large-desktop' || layout === 'small-desktop';
37
+
38
+ const launchVisitNoteForm = React.useCallback(() => {
39
+ if (visitContext) {
40
+ launchWorkspace('visit-notes-form-workspace');
41
+ } else {
42
+ launchStartVisitPrompt();
43
+ }
44
+ }, [visitContext]);
45
+
46
+ if (isLoading) {
47
+ return <DataTableSkeleton role="progressbar" compact={isDesktop} zebra />;
48
+ }
49
+ if (error) {
50
+ return <ErrorState error={error} headerTitle={headerTitle} />;
51
+ }
52
+ if (!visitNotes?.length) {
53
+ return <EmptyState displayText={displayText} headerTitle={headerTitle} launchForm={launchVisitNoteForm} />;
54
+ }
55
+
56
+ return (
57
+ <div className={styles.widgetCard}>
58
+ <CardHeader title={headerTitle}>
59
+ <span>{isValidating ? <InlineLoading /> : null}</span>
60
+ <Button
61
+ kind="ghost"
62
+ renderIcon={(props: ComponentProps<typeof AddIcon>) => <AddIcon size={16} {...props} />}
63
+ iconDescription="Add visit note"
64
+ onClick={launchVisitNoteForm}
65
+ >
66
+ {t('add', 'Add')}
67
+ </Button>
68
+ </CardHeader>
69
+ <PaginatedNotes notes={visitNotes} pageSize={pageSize} urlLabel={urlLabel} pageUrl={pageUrl} />
70
+ </div>
71
+ );
18
72
  };
19
73
 
20
74
  export default NotesOverview;
@@ -1,7 +1,14 @@
1
1
  import React from 'react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
  import { screen, render } from '@testing-library/react';
4
- import { getDefaultsFromConfigSchema, showSnackbar, useConfig, useSession } from '@openmrs/esm-framework';
4
+ import {
5
+ type Encounter,
6
+ getDefaultsFromConfigSchema,
7
+ showSnackbar,
8
+ useConfig,
9
+ useSession,
10
+ } from '@openmrs/esm-framework';
11
+ import { type PatientWorkspace2DefinitionProps } from '@openmrs/esm-patient-common-lib';
5
12
  import { fetchDiagnosisConceptsByName, saveVisitNote, updateVisitNote } from './visit-notes.resource';
6
13
  import {
7
14
  ConfigMock,
@@ -12,20 +19,32 @@ import {
12
19
  } from '__mocks__';
13
20
  import { configSchema, type ConfigObject } from '../config-schema';
14
21
  import { mockPatient, getByTextWithMarkup } from 'tools';
15
- import VisitNotesForm from './visit-notes-form.workspace';
22
+ import VisitNotesForm, { type VisitNotesFormProps } from './visit-notes-form.workspace';
16
23
 
17
- const defaultProps = {
24
+ const defaultProps: PatientWorkspace2DefinitionProps<VisitNotesFormProps, {}> = {
18
25
  closeWorkspace: jest.fn(),
19
- closeWorkspaceWithSavedChanges: jest.fn(),
20
- formContext: 'creating' as const,
21
- patient: mockPatient,
22
- patientUuid: mockPatient.id,
23
- promptBeforeClosing: jest.fn(),
24
- setTitle: jest.fn(),
26
+ workspaceProps: {
27
+ formContext: 'creating' as const,
28
+ },
29
+ groupProps: {
30
+ patient: mockPatient,
31
+ patientUuid: mockPatient.id,
32
+ visitContext: null,
33
+ mutateVisitContext: null,
34
+ },
35
+ launchChildWorkspace: jest.fn(),
36
+ windowProps: {},
37
+ workspaceName: '',
38
+ windowName: '',
39
+ isRootWorkspace: false,
25
40
  };
26
41
 
27
- function renderVisitNotesForm(props = {}) {
28
- render(<VisitNotesForm {...defaultProps} {...props} />);
42
+ function renderVisitNotesForm(workspaceProps: Partial<VisitNotesFormProps> = {}) {
43
+ const props = {
44
+ ...defaultProps,
45
+ workspaceProps: { ...defaultProps.workspaceProps, ...workspaceProps },
46
+ };
47
+ render(<VisitNotesForm {...props} />);
29
48
  }
30
49
 
31
50
  const mockFetchDiagnosisConceptsByName = jest.mocked(fetchDiagnosisConceptsByName);
@@ -245,7 +264,7 @@ test('initializes form with existing encounter data when in edit mode', () => {
245
264
 
246
265
  renderVisitNotesForm({
247
266
  formContext: 'editing',
248
- encounter: mockEncounter,
267
+ encounter: mockEncounter as any as Encounter, // TODO: fix
249
268
  });
250
269
 
251
270
  // Verify date is pre-filled
@@ -311,7 +330,7 @@ test('updates existing visit note when in edit mode', async () => {
311
330
 
312
331
  renderVisitNotesForm({
313
332
  formContext: 'editing',
314
- encounter: mockEncounter,
333
+ encounter: mockEncounter as any as Encounter, // TODO: fix
315
334
  });
316
335
 
317
336
  // Update clinical note