@openmrs/esm-patient-chart-app 11.3.1-pre.9452 → 11.3.1-pre.9455

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 (86) hide show
  1. package/.turbo/turbo-build.log +11 -11
  2. package/dist/2540.js +1 -1
  3. package/dist/2540.js.map +1 -1
  4. package/dist/2761.js.map +1 -1
  5. package/dist/3697.js +1 -0
  6. package/dist/3697.js.map +1 -0
  7. package/dist/4300.js +1 -1
  8. package/dist/506.js +1 -1
  9. package/dist/506.js.map +1 -1
  10. package/dist/5827.js +1 -0
  11. package/dist/5827.js.map +1 -0
  12. package/dist/6411.js +1 -1
  13. package/dist/6411.js.map +1 -1
  14. package/dist/6568.js +1 -1
  15. package/dist/6568.js.map +1 -1
  16. package/dist/6924.js +1 -1
  17. package/dist/6924.js.map +1 -1
  18. package/dist/7818.js +1 -0
  19. package/dist/7818.js.map +1 -0
  20. package/dist/7822.js +1 -1
  21. package/dist/7822.js.map +1 -1
  22. package/dist/8260.js +1 -1
  23. package/dist/8260.js.map +1 -1
  24. package/dist/{3119.js → 8278.js} +1 -1
  25. package/dist/{3119.js.map → 8278.js.map} +1 -1
  26. package/dist/8454.js +1 -1
  27. package/dist/8454.js.map +1 -1
  28. package/dist/8709.js +1 -1
  29. package/dist/8709.js.map +1 -1
  30. package/dist/{6997.js → 9294.js} +1 -1
  31. package/dist/9294.js.map +1 -0
  32. package/dist/main.js +1 -1
  33. package/dist/main.js.map +1 -1
  34. package/dist/openmrs-esm-patient-chart-app.js +1 -1
  35. package/dist/openmrs-esm-patient-chart-app.js.buildmanifest.json +134 -158
  36. package/dist/openmrs-esm-patient-chart-app.js.map +1 -1
  37. package/dist/routes.json +1 -1
  38. package/package.json +2 -2
  39. package/src/actions-buttons/mark-patient-deceased.component.tsx +2 -2
  40. package/src/actions-buttons/start-visit.component.tsx +10 -5
  41. package/src/actions-buttons/start-visit.test.tsx +9 -5
  42. package/src/clinical-views/encounter-list/encounter-list-tabs.extension.tsx +1 -1
  43. package/src/clinical-views/utils/helpers.ts +2 -2
  44. package/src/index.ts +12 -18
  45. package/src/mark-patient-deceased/mark-patient-deceased-form.test.tsx +15 -9
  46. package/src/mark-patient-deceased/mark-patient-deceased-form.workspace.tsx +147 -138
  47. package/src/patient-chart/chart-review/dashboard-view.component.tsx +2 -2
  48. package/src/patient-chart/patient-chart.component.tsx +45 -42
  49. package/src/patient-chart/patient-chart.resources.ts +52 -10
  50. package/src/patient-chart/patient-chart.scss +0 -4
  51. package/src/routes.json +17 -6
  52. package/src/visit/hooks/useDeleteVisit.tsx +1 -1
  53. package/src/visit/start-visit-button.component.tsx +2 -2
  54. package/src/visit/start-visit-button.test.tsx +2 -2
  55. package/src/visit/visit-action-items/edit-visit-details.component.tsx +29 -8
  56. package/src/visit/visit-form/exported-visit-form.workspace.tsx +2 -10
  57. package/src/visit/visit-form/visit-form.test.tsx +27 -18
  58. package/src/visit/visit-form/visit-form.workspace.tsx +38 -675
  59. package/src/visit/visit-history-table/visit-actions-cell.component.tsx +3 -2
  60. package/src/visit/visit-history-table/visit-date-cell.component.tsx +1 -0
  61. package/src/visit/visit-history-table/visit-diagnoses-cell.component.tsx +1 -0
  62. package/src/visit/visit-history-table/visit-history-table.component.tsx +3 -2
  63. package/src/visit/visit-history-table/visit-type-cell.component.tsx +1 -0
  64. package/src/visit/visit-prompt/delete-visit-dialog.test.tsx +1 -1
  65. package/src/visit/visit-prompt/{end-visit-dialog.component.tsx → end-visit-dialog.modal.tsx} +1 -1
  66. package/src/visit/visit-prompt/end-visit-dialog.test.tsx +1 -1
  67. package/src/visit/visit-prompt/{start-visit-dialog.component.tsx → start-visit-dialog.modal.tsx} +10 -4
  68. package/src/visit/visit-prompt/start-visit-dialog.test.tsx +3 -3
  69. package/src/visit/visits-widget/current-visit-summary.extension.tsx +3 -3
  70. package/src/visit/visits-widget/past-visits-components/encounters-table/encounters-table.component.tsx +12 -35
  71. package/src/visit/visits-widget/visit-context/retrospective-data-date-time-picker/retrospective-date-time-picker.component.tsx +1 -0
  72. package/src/visit/visits-widget/visit-context/visit-context-switcher.modal.tsx +2 -2
  73. package/src/visit/visits-widget/visit-context/visit-context-switcher.test.tsx +22 -20
  74. package/src/visit/visits-widget/visit-detail-overview.component.tsx +3 -2
  75. package/src/visit/visits-widget/visit-detail-overview.test.tsx +4 -4
  76. package/translations/en.json +1 -1
  77. package/dist/276.js +0 -1
  78. package/dist/276.js.map +0 -1
  79. package/dist/3905.js +0 -1
  80. package/dist/3905.js.map +0 -1
  81. package/dist/5048.js +0 -1
  82. package/dist/5048.js.map +0 -1
  83. package/dist/6997.js.map +0 -1
  84. package/dist/7810.js +0 -1
  85. package/dist/7810.js.map +0 -1
  86. /package/src/visit/visit-prompt/{delete-visit-dialog.component.tsx → delete-visit-dialog.modal.tsx} +0 -0
@@ -1,21 +1,33 @@
1
- import React, { useMemo, useState } from 'react';
1
+ import { ExtensionSlot, useLeftNav } from '@openmrs/esm-framework';
2
2
  import classNames from 'classnames';
3
+ import React, { useMemo, useState } from 'react';
3
4
  import { useParams } from 'react-router-dom';
4
- import { ExtensionSlot, WorkspaceContainer, useWorkspaces, useLeftNav } from '@openmrs/esm-framework';
5
5
  import { spaBasePath } from '../constants';
6
- import { usePatientChartPatientAndVisit } from './patient-chart.resources';
7
- import { type LayoutMode } from './chart-review/dashboard-view.component';
8
- import ChartReview from '../patient-chart/chart-review/chart-review.component';
9
6
  import Loader from '../loader/loader.component';
7
+ import ChartReview from '../patient-chart/chart-review/chart-review.component';
10
8
  import SideMenuPanel from '../side-nav/side-menu.component';
9
+ import { type LayoutMode } from './chart-review/dashboard-view.component';
11
10
  import styles from './patient-chart.scss';
11
+ import { usePatientChartPatientAndVisit } from './patient-chart.resources';
12
12
 
13
13
  const PatientChart: React.FC = () => {
14
14
  const { patientUuid, view: encodedView } = useParams();
15
- const { workspaceWindowState, active } = useWorkspaces();
15
+
16
+ // specify key to ensure that WrapPatientChart instance is re-created
17
+ // when we switch patient
18
+ return <WrappedPatientChart key={patientUuid} patientUuid={patientUuid} encodedView={encodedView} />;
19
+ };
20
+
21
+ interface WrappedPatientChartProps {
22
+ patientUuid: string;
23
+ encodedView: string;
24
+ }
25
+
26
+ const WrappedPatientChart: React.FC<WrappedPatientChartProps> = ({ patientUuid, encodedView }) => {
27
+ const view = decodeURIComponent(encodedView);
16
28
  const [layoutMode, setLayoutMode] = useState<LayoutMode>();
17
29
  const state = usePatientChartPatientAndVisit(patientUuid);
18
- const view = decodeURIComponent(encodedView);
30
+ const { isLoadingPatient, patient } = state;
19
31
 
20
32
  const leftNavBasePath = useMemo(() => spaBasePath.replace(':patientUuid', patientUuid), [patientUuid]);
21
33
 
@@ -25,43 +37,34 @@ const PatientChart: React.FC = () => {
25
37
  <>
26
38
  <SideMenuPanel />
27
39
  <main className={classNames('omrs-main-content', styles.chartContainer)}>
28
- <div
29
- className={classNames(
30
- styles.innerChartContainer,
31
- workspaceWindowState === 'normal' && active ? styles.closeWorkspace : styles.activeWorkspace,
32
- )}
33
- >
34
- {state.isLoadingPatient ? (
35
- <Loader />
36
- ) : (
37
- <>
38
- <aside>
39
- <ExtensionSlot name="patient-header-slot" state={state} />
40
- <ExtensionSlot name="patient-highlights-bar-slot" state={state} />
41
- <ExtensionSlot name="patient-info-slot" state={state} />
42
- </aside>
43
- <div className={styles.grid}>
44
- <div
45
- className={classNames(styles.chartReview, { [styles.widthContained]: layoutMode === 'contained' })}
46
- >
47
- <ChartReview
48
- patient={state.patient}
49
- patientUuid={state.patientUuid}
50
- view={view}
51
- setDashboardLayoutMode={setLayoutMode}
52
- />
40
+ <>
41
+ <div className={classNames(styles.innerChartContainer)}>
42
+ {isLoadingPatient ? (
43
+ <Loader />
44
+ ) : (
45
+ <>
46
+ <aside>
47
+ <ExtensionSlot name="patient-header-slot" state={state} />
48
+ <ExtensionSlot name="patient-highlights-bar-slot" state={state} />
49
+ <ExtensionSlot name="patient-info-slot" state={state} />
50
+ </aside>
51
+ <div className={styles.grid}>
52
+ <div
53
+ className={classNames(styles.chartReview, { [styles.widthContained]: layoutMode == 'contained' })}
54
+ >
55
+ <ChartReview
56
+ patient={patient}
57
+ patientUuid={patientUuid}
58
+ view={view}
59
+ setDashboardLayoutMode={setLayoutMode}
60
+ />
61
+ </div>
53
62
  </div>
54
- </div>
55
- </>
56
- )}
57
- </div>
63
+ </>
64
+ )}
65
+ </div>
66
+ </>
58
67
  </main>
59
- <WorkspaceContainer
60
- actionMenuProps={state}
61
- additionalWorkspaceProps={state}
62
- contextKey={`patient/${patientUuid}`}
63
- showSiderailAndBottomNav
64
- />
65
68
  </>
66
69
  );
67
70
  };
@@ -1,7 +1,15 @@
1
- import { useEffect, useMemo } from 'react';
1
+ import { useEffect, useMemo, useRef } from 'react';
2
2
  import useSWR from 'swr';
3
- import { openmrsFetch, restBaseUrl, usePatient, useVisit, type Visit } from '@openmrs/esm-framework';
4
- import { usePatientChartStore } from '@openmrs/esm-patient-common-lib';
3
+ import {
4
+ closeWorkspaceGroup2,
5
+ launchWorkspaceGroup2,
6
+ openmrsFetch,
7
+ restBaseUrl,
8
+ usePatient,
9
+ useVisit,
10
+ type Visit,
11
+ } from '@openmrs/esm-framework';
12
+ import { type PatientWorkspaceGroupProps, usePatientChartStore } from '@openmrs/esm-patient-common-lib';
5
13
 
6
14
  const defaultVisitCustomRepresentation =
7
15
  'custom:(uuid,display,voided,indication,startDatetime,stopDatetime,' +
@@ -32,7 +40,7 @@ export function useVisitByUuid(visitUuid: string | null, representation: string
32
40
  * in‑app navigation. On a full page reload, visitContext is rehydrated by refetching
33
41
  * (via useVisit/useVisitByUuId) rather than restored from storage.
34
42
  * When we enter the chart, we want to update the visit context as follows:
35
- * does the stored visitContext exist and belong to the patient?
43
+ * does the the stored visitContext exist and belong to the patient?
36
44
  * 1. If so, the visitContext should be valid but possibly stale; fetch the visit again
37
45
  * and update the context
38
46
  * 2. If not, fetch the active visit of the patient, If it exists, set it as the
@@ -50,7 +58,7 @@ export function usePatientChartPatientAndVisit(patientUuid: string) {
50
58
  setVisitContext,
51
59
  } = usePatientChartStore(patientUuid);
52
60
 
53
- const isVisitContextValid = visitContext && visitContext.patient?.uuid === patientUuid;
61
+ const isVisitContextValid = visitContext && visitContext.patient.uuid === patientUuid;
54
62
  const {
55
63
  visit: newVisitContext,
56
64
  mutate: newMutateVisitContext,
@@ -62,14 +70,39 @@ export function usePatientChartPatientAndVisit(patientUuid: string) {
62
70
  mutate: mutateActiveVisit,
63
71
  } = useVisit(isVisitContextValid ? null : patientUuid);
64
72
 
73
+ const isWorkspaceGroupLaunched = useRef(false);
74
+
65
75
  useEffect(() => {
66
- if (!isValidatingVisitContext && !isValidatingActiveVisit && storePatientUuid) {
76
+ if (!isValidatingVisitContext && !isValidatingActiveVisit && patient) {
77
+ let groupProps: PatientWorkspaceGroupProps = null;
67
78
  if (activeVisit) {
68
- setVisitContext(activeVisit, mutateActiveVisit);
79
+ groupProps = {
80
+ patientUuid: patient.id,
81
+ patient,
82
+ visitContext: activeVisit,
83
+ mutateVisitContext: mutateActiveVisit,
84
+ };
69
85
  } else if (newVisitContext) {
70
- setVisitContext(newVisitContext, newMutateVisitContext);
86
+ groupProps = {
87
+ patientUuid: patient.id,
88
+ patient,
89
+ visitContext: newVisitContext,
90
+ mutateVisitContext: newMutateVisitContext,
91
+ };
71
92
  } else {
72
- setVisitContext(null, null);
93
+ groupProps = {
94
+ patientUuid: patient.id,
95
+ patient,
96
+ visitContext: null,
97
+ mutateVisitContext: null,
98
+ };
99
+ }
100
+
101
+ setVisitContext(groupProps.visitContext, groupProps.mutateVisitContext);
102
+
103
+ if (!isWorkspaceGroupLaunched.current) {
104
+ launchWorkspaceGroup2('patient-chart', groupProps);
105
+ isWorkspaceGroupLaunched.current = true;
73
106
  }
74
107
  }
75
108
  }, [
@@ -81,6 +114,8 @@ export function usePatientChartPatientAndVisit(patientUuid: string) {
81
114
  isValidatingActiveVisit,
82
115
  storePatientUuid,
83
116
  mutateActiveVisit,
117
+ isWorkspaceGroupLaunched,
118
+ patient,
84
119
  ]);
85
120
 
86
121
  useEffect(() => {
@@ -93,6 +128,12 @@ export function usePatientChartPatientAndVisit(patientUuid: string) {
93
128
  };
94
129
  }, [patient, setPatient, isLoadingPatient]);
95
130
 
131
+ useEffect(() => {
132
+ return () => {
133
+ closeWorkspaceGroup2();
134
+ };
135
+ }, []);
136
+
96
137
  const state = useMemo(
97
138
  () => ({
98
139
  patientUuid,
@@ -100,8 +141,9 @@ export function usePatientChartPatientAndVisit(patientUuid: string) {
100
141
  visitContext,
101
142
  mutateVisitContext,
102
143
  isLoadingPatient,
144
+ setPatient,
103
145
  }),
104
- [patient, patientUuid, visitContext, mutateVisitContext, isLoadingPatient],
146
+ [patient, patientUuid, visitContext, mutateVisitContext, isLoadingPatient, setPatient],
105
147
  );
106
148
 
107
149
  return state;
@@ -44,10 +44,6 @@ $actionPanelExpandedOffset: $actionNavOffset + $actionPanelOffset;
44
44
  flex-direction: column;
45
45
  }
46
46
 
47
- .closeWorkspace {
48
- padding-right: 0;
49
- }
50
-
51
47
  // Overriding styles for RTL support
52
48
  html[dir='rtl'] {
53
49
  .chartContainer {
package/src/routes.json CHANGED
@@ -225,18 +225,29 @@
225
225
  "offline": true
226
226
  }
227
227
  ],
228
- "workspaces": [
228
+ "workspaces2": [
229
229
  {
230
230
  "name": "mark-patient-deceased-workspace-form",
231
231
  "component": "markPatientDeceasedForm",
232
- "title": "Mark patient deceased",
233
- "type": "form"
232
+ "window": "mark-patient-deceased"
234
233
  },
235
234
  {
236
235
  "name": "start-visit-workspace-form",
237
236
  "component": "startVisitWorkspace",
238
- "title": "startVisitWorkspaceTitle",
239
- "type": "start-visit"
237
+ "window": "start-visit"
240
238
  }
241
- ]
239
+ ],
240
+ "workspaceWindows2": [
241
+ {
242
+ "name": "start-visit",
243
+ "group": "patient-chart"
244
+ },
245
+ {
246
+ "name": "mark-patient-deceased",
247
+ "group": "patient-chart"
248
+ }
249
+ ],
250
+ "workspaceGroups2": [{
251
+ "name":"patient-chart"
252
+ }]
242
253
  }
@@ -64,7 +64,7 @@ export function useDeleteVisit(
64
64
  .then(() => {
65
65
  // Update active visit data
66
66
  mutateActiveVisit();
67
- if (activeVisit.uuid === visitContext?.uuid) {
67
+ if (activeVisit.uuid == visitContext?.uuid) {
68
68
  setVisitContext(null, null);
69
69
  }
70
70
 
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { Button } from '@carbon/react';
4
- import { launchWorkspace, showSnackbar } from '@openmrs/esm-framework';
4
+ import { launchWorkspace2, showSnackbar } from '@openmrs/esm-framework';
5
5
 
6
6
  interface StartVisitButtonProps {
7
7
  patientUuid: string;
@@ -20,7 +20,7 @@ const StartVisitButton = ({ patientUuid, handleReturnToSearchList, hidePatientSe
20
20
  hidePatientSearch?.();
21
21
 
22
22
  try {
23
- launchWorkspace(startVisitWorkspaceForm, {
23
+ launchWorkspace2(startVisitWorkspaceForm, {
24
24
  patientUuid,
25
25
  openedFrom: 'patient-chart-start-visit',
26
26
  handleReturnToSearchList,
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
  import { render, screen } from '@testing-library/react';
4
- import { launchWorkspace } from '@openmrs/esm-framework';
4
+ import { launchWorkspace2 } from '@openmrs/esm-framework';
5
5
  import { mockPatient } from 'tools';
6
6
  import StartVisitButton from './start-visit-button.component';
7
7
 
8
- const mockLaunchWorkspace = jest.mocked(launchWorkspace);
8
+ const mockLaunchWorkspace = jest.mocked(launchWorkspace2);
9
9
 
10
10
  describe('StartVisitButton', () => {
11
11
  it('renders the start visit button', () => {
@@ -6,13 +6,20 @@ import {
6
6
  UserHasAccess,
7
7
  type Visit,
8
8
  getCoreTranslation,
9
- launchWorkspace,
9
+ launchWorkspace2,
10
10
  useLayoutType,
11
11
  } from '@openmrs/esm-framework';
12
+ import { type VisitFormProps } from '../visit-form/visit-form.workspace';
13
+ import {
14
+ invalidateVisitAndEncounterData,
15
+ invalidateVisitByUuid,
16
+ type PatientWorkspaceGroupProps,
17
+ } from '@openmrs/esm-patient-common-lib';
18
+ import { useSWRConfig } from 'swr';
12
19
 
13
20
  interface EditVisitDetailsActionItemProps {
14
- patientUuid: string;
15
21
  visit: Visit;
22
+ patient: fhir.Patient;
16
23
 
17
24
  /**
18
25
  * If true, renders as IconButton instead
@@ -20,18 +27,32 @@ interface EditVisitDetailsActionItemProps {
20
27
  compact?: boolean;
21
28
  }
22
29
 
23
- const EditVisitDetailsActionItem: React.FC<EditVisitDetailsActionItemProps> = ({ visit, compact }) => {
30
+ /**
31
+ * This component
32
+ */
33
+ const EditVisitDetailsActionItem: React.FC<EditVisitDetailsActionItemProps> = ({ visit, patient, compact }) => {
24
34
  const { t } = useTranslation();
35
+ const { mutate: globalMutate } = useSWRConfig();
25
36
 
26
37
  const isTablet = useLayoutType() === 'tablet';
27
38
  const responsiveSize = isTablet ? 'lg' : 'sm';
39
+ const patientUuid = patient.id;
28
40
 
29
41
  const editVisitDetails = () => {
30
- launchWorkspace('start-visit-workspace-form', {
31
- workspaceTitle: t('editVisitDetails', 'Edit visit details'),
32
- visitToEdit: visit,
33
- openedFrom: 'patient-chart-edit-visit',
34
- });
42
+ launchWorkspace2<VisitFormProps, {}, PatientWorkspaceGroupProps>(
43
+ 'start-visit-workspace-form',
44
+ { openedFrom: 'patient-chart-edit-visit' },
45
+ {},
46
+ {
47
+ patient,
48
+ patientUuid: patientUuid,
49
+ visitContext: visit,
50
+ mutateVisitContext: () => {
51
+ invalidateVisitByUuid(globalMutate, visit.uuid);
52
+ invalidateVisitAndEncounterData(globalMutate, patientUuid);
53
+ },
54
+ },
55
+ );
35
56
  };
36
57
 
37
58
  return (
@@ -21,7 +21,6 @@ import { zodResolver } from '@hookform/resolvers/zod';
21
21
  import {
22
22
  Extension,
23
23
  ExtensionSlot,
24
- launchWorkspaceGroup2,
25
24
  OpenmrsFetchError,
26
25
  saveVisit,
27
26
  showSnackbar,
@@ -30,7 +29,6 @@ import {
30
29
  useConnectivity,
31
30
  useEmrConfiguration,
32
31
  useLayoutType,
33
- useVisit,
34
32
  type Visit,
35
33
  Workspace2,
36
34
  type Workspace2DefinitionProps,
@@ -39,7 +37,6 @@ import {
39
37
  } from '@openmrs/esm-framework';
40
38
  import {
41
39
  createOfflineVisitForPatient,
42
- invalidateVisitByUuid,
43
40
  invalidateVisitAndEncounterData,
44
41
  useActivePatientEnrollment,
45
42
  } from '@openmrs/esm-patient-common-lib';
@@ -103,13 +100,8 @@ export interface ExportedVisitFormProps {
103
100
  }
104
101
 
105
102
  /**
106
- * This form is used for starting a new visit and for editing
107
- * an existing visit for a patient. It is similar to visit-form.workspace.tsx, but
108
- * is not tied to the patient-chart workspace group (i.e. it is not required to operate on
109
- * the same patient and same visit as all other workspaces within that group.) This workspace is
110
- * suitable for use *outside* the patient chart, in workflows where we need to start a visit for any
111
- * arbitrary patient (ex: the patient search workspace window).
112
- *
103
+ * This workspace is meant for use outside the patient chart.
104
+ * @see visit-form.workspace.tsx
113
105
  */
114
106
  const ExportedVisitForm: React.FC<Workspace2DefinitionProps<ExportedVisitFormProps, {}, {}>> = ({
115
107
  closeWorkspace,
@@ -26,10 +26,8 @@ import {
26
26
  useVisitFormCallbacks,
27
27
  useVisitFormSchemaAndDefaultValues,
28
28
  } from './visit-form.resource';
29
- import VisitForm from './visit-form.workspace';
30
-
31
- // Fixed reference time used in time-dependent tests
32
- const FIXED_NOW = new Date('2023-01-01T08:00:00.000Z');
29
+ import VisitForm, { type VisitFormProps } from './visit-form.workspace';
30
+ import { type PatientWorkspace2DefinitionProps } from '@openmrs/esm-patient-common-lib/src';
33
31
 
34
32
  const visitUuid = 'test_visit_uuid';
35
33
  const visitAttributes = {
@@ -56,20 +54,23 @@ const visitAttributes = {
56
54
  };
57
55
 
58
56
  const mockCloseWorkspace = jest.fn();
59
- const mockPromptBeforeClosing = jest.fn();
60
- const mockSetTitle = jest.fn();
61
57
  const mockMutateVisitContext = jest.fn();
62
-
63
- const testProps = {
64
- openedFrom: 'test',
65
- patientUuid: mockPatient.id,
66
- patient: mockPatient,
58
+ const defaultProps: PatientWorkspace2DefinitionProps<VisitFormProps, {}> = {
67
59
  closeWorkspace: mockCloseWorkspace,
68
- closeWorkspaceWithSavedChanges: mockCloseWorkspace,
69
- promptBeforeClosing: mockPromptBeforeClosing,
70
- setTitle: mockSetTitle,
71
- visitContext: null,
72
- mutateVisitContext: mockMutateVisitContext,
60
+ workspaceProps: {
61
+ openedFrom: 'test',
62
+ },
63
+ windowProps: {},
64
+ groupProps: {
65
+ patientUuid: mockPatient.id,
66
+ patient: mockPatient,
67
+ visitContext: null,
68
+ mutateVisitContext: mockMutateVisitContext,
69
+ },
70
+ workspaceName: '',
71
+ launchChildWorkspace: jest.fn(),
72
+ windowName: '',
73
+ isRootWorkspace: false,
73
74
  };
74
75
 
75
76
  const mockSaveVisit = jest.mocked(saveVisit);
@@ -155,9 +156,10 @@ jest.mock('../hooks/useDefaultFacilityLocation', () => {
155
156
 
156
157
  return {
157
158
  ...requireActual,
158
- useDefaultLoginLocation: jest.fn(() => ({
159
+ useDefaultFacilityLocation: jest.fn(() => ({
159
160
  defaultFacility: null,
160
161
  isLoading: false,
162
+ error: null,
161
163
  })),
162
164
  };
163
165
  });
@@ -867,5 +869,12 @@ describe('useVisitFormSchemaAndDefaultValues', () => {
867
869
  });
868
870
 
869
871
  function renderVisitForm(visitToEdit?: Visit) {
870
- return render(<VisitForm {...{ ...testProps, visitToEdit }} />);
872
+ const props: PatientWorkspace2DefinitionProps<VisitFormProps, {}> = {
873
+ ...defaultProps,
874
+ groupProps: {
875
+ ...defaultProps.groupProps,
876
+ visitContext: visitToEdit ?? null,
877
+ },
878
+ };
879
+ return render(<VisitForm {...props} />);
871
880
  }