@uxland/primary-shell 8.3.3 → 8.3.5

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 (154) hide show
  1. package/README.md +18 -1
  2. package/dist/{component-BYXgNvke.js → component-Dv2Cw4dX.js} +2 -2
  3. package/dist/{component-BYXgNvke.js.map → component-Dv2Cw4dX.js.map} +1 -1
  4. package/dist/{index-CDpyZ5Yt.js → index-CCC4rQo1.js} +2629 -2628
  5. package/dist/{index-CDpyZ5Yt.js.map → index-CCC4rQo1.js.map} +1 -1
  6. package/dist/index.js +21 -22
  7. package/dist/index.js.map +1 -1
  8. package/dist/{plugin-CMgpCPh9.js → plugin-D3sg1ev9.js} +5 -6
  9. package/dist/{plugin-CMgpCPh9.js.map → plugin-D3sg1ev9.js.map} +1 -1
  10. package/package.json +7 -15
  11. package/src/UI/bootstrapper.ts +0 -14
  12. package/src/UI/components/bootstrapper.ts +0 -25
  13. package/src/UI/components/clinical-pathways-action-menu/clinical-pathways-action-menu.ts +0 -13
  14. package/src/UI/components/communication-action-menu/communication-action-menu.ts +0 -13
  15. package/src/UI/components/error-view/component.ts +0 -17
  16. package/src/UI/components/error-view/styles.css +0 -27
  17. package/src/UI/components/error-view/template.ts +0 -12
  18. package/src/UI/components/nav-divider/nav-divider.ts +0 -41
  19. package/src/UI/components/nav-divider/styles.css +0 -21
  20. package/src/UI/components/nav-divider/template.ts +0 -8
  21. package/src/UI/components/petitioner-action-menu/petitioner-action-menu.ts +0 -13
  22. package/src/UI/components/primaria-accordion/primaria-accordion.ts +0 -45
  23. package/src/UI/components/primaria-shell/constants.ts +0 -4
  24. package/src/UI/components/primaria-shell/primaria-shell.ts +0 -105
  25. package/src/UI/components/primaria-shell/shell-header/header-divider/header-divider.ts +0 -13
  26. package/src/UI/components/primaria-shell/shell-header/header-divider/styles.css +0 -5
  27. package/src/UI/components/primaria-shell/shell-header/header-divider/template.ts +0 -8
  28. package/src/UI/components/primaria-shell/shell-header/shell-header.ts +0 -71
  29. package/src/UI/components/primaria-shell/shell-header/styles.css +0 -45
  30. package/src/UI/components/primaria-shell/shell-header/template.ts +0 -37
  31. package/src/UI/components/primaria-shell/styles.css +0 -185
  32. package/src/UI/components/primaria-shell/template.ts +0 -72
  33. package/src/UI/components/sidenav-action-menu/sidenav-action-menu.ts +0 -62
  34. package/src/UI/components/sidenav-action-menu/styles.css +0 -25
  35. package/src/UI/components/sidenav-action-menu/template.ts +0 -24
  36. package/src/UI/fonts/fonts.css +0 -48
  37. package/src/UI/fonts/open-sans-v40-latin-300.woff2 +0 -0
  38. package/src/UI/fonts/open-sans-v40-latin-500.woff2 +0 -0
  39. package/src/UI/fonts/open-sans-v40-latin-600.woff2 +0 -0
  40. package/src/UI/fonts/open-sans-v40-latin-700.woff2 +0 -0
  41. package/src/UI/fonts/open-sans-v40-latin-800.woff2 +0 -0
  42. package/src/UI/fonts/open-sans-v40-latin-regular.woff2 +0 -0
  43. package/src/UI/images/Gencat_Logotip.svg +0 -70
  44. package/src/UI/images/Salut_Logotip.svg +0 -8
  45. package/src/UI/index.ts +0 -1
  46. package/src/UI/internal-views/administrative-nav-menu.ts +0 -302
  47. package/src/UI/internal-views/common-nav-menu.ts +0 -94
  48. package/src/UI/internal-views/doctor-nav-menu.ts +0 -297
  49. package/src/UI/internal-views/doctor-quick-action-menu.ts +0 -16
  50. package/src/UI/internal-views/handle-views.ts +0 -24
  51. package/src/UI/shared-components/bootstrapper.ts +0 -18
  52. package/src/UI/shared-components/index.ts +0 -1
  53. package/src/UI/shared-components/primaria-character-limit-badge/primaria-character-limit-badge.ts +0 -27
  54. package/src/UI/shared-components/primaria-character-limit-badge/styles.css +0 -8
  55. package/src/UI/shared-components/primaria-content-switcher/primaria-content-switcher.ts +0 -78
  56. package/src/UI/shared-components/primaria-nav-item/primaria-nav-item.ts +0 -71
  57. package/src/UI/shared-components/primaria-nav-item/styles.css +0 -25
  58. package/src/UI/shared-components/primaria-nav-item/template.ts +0 -27
  59. package/src/UI/shared-components/primaria-nav-tree-menu/primaria-nav-tree-menu.ts +0 -41
  60. package/src/UI/shared-components/primaria-nav-tree-menu/styles.css +0 -11
  61. package/src/UI/shared-components/primaria-nav-tree-menu/template.ts +0 -46
  62. package/src/UI/shared-components/primaria-region/index.ts +0 -1
  63. package/src/UI/shared-components/primaria-region/primaria-region.ts +0 -199
  64. package/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.ts +0 -261
  65. package/src/UI/shared-components/primaria-text-editor/styles.css +0 -966
  66. package/src/UI/shared-components/primaria-text-editor/template.ts +0 -8
  67. package/src/UI/shared-components/primaria-text-editor/utils.ts +0 -39
  68. package/src/UI/shared-components/quick-action-item/quick-action-item.ts +0 -21
  69. package/src/UI/shared-components/quick-action-item/template.ts +0 -8
  70. package/src/UI/shared-components/typings.ts +0 -19
  71. package/src/api/activity-monitor/activity-monitor.test.ts +0 -67
  72. package/src/api/activity-monitor/activity-monitor.ts +0 -26
  73. package/src/api/api.test.ts +0 -37
  74. package/src/api/api.ts +0 -119
  75. package/src/api/broker/broker-events.ts +0 -39
  76. package/src/api/broker/broker-requests.ts +0 -20
  77. package/src/api/broker/factory.test.ts +0 -378
  78. package/src/api/broker/factory.ts +0 -151
  79. package/src/api/broker/primaria-broker.ts +0 -20
  80. package/src/api/context-manager/context-manager.test.ts +0 -86
  81. package/src/api/context-manager/context-manager.ts +0 -42
  82. package/src/api/ecap-event-manager/ecap-event-manager.test.ts +0 -100
  83. package/src/api/ecap-event-manager/ecap-event-manager.ts +0 -58
  84. package/src/api/ecap-event-manager/typings.ts +0 -6
  85. package/src/api/exit-guard-manager/exit-guard-manager.test.ts +0 -75
  86. package/src/api/exit-guard-manager/exit-guard-manager.ts +0 -31
  87. package/src/api/global-state/global-state.test.ts +0 -45
  88. package/src/api/global-state/global-state.ts +0 -38
  89. package/src/api/http-client/http-client.test.ts +0 -196
  90. package/src/api/http-client/http-client.ts +0 -97
  91. package/src/api/import-data-manager/component/component.ts +0 -29
  92. package/src/api/import-data-manager/component/styles.css +0 -79
  93. package/src/api/import-data-manager/component/template.ts +0 -49
  94. package/src/api/import-data-manager/import-data-manager-impl.test.ts +0 -364
  95. package/src/api/import-data-manager/import-data-manager-impl.ts +0 -121
  96. package/src/api/import-data-manager/import-data-manager.ts +0 -42
  97. package/src/api/import-data-manager/index.ts +0 -2
  98. package/src/api/interaction-service/confirmation-message.tsx +0 -5
  99. package/src/api/interaction-service/index.ts +0 -1
  100. package/src/api/interaction-service/interaction-service-impl.tsx +0 -260
  101. package/src/api/interaction-service/interaction-service.ts +0 -52
  102. package/src/api/interaction-service/modal-styles.css +0 -97
  103. package/src/api/localization/localization.test.ts +0 -61
  104. package/src/api/localization/localization.ts +0 -58
  105. package/src/api/notification-service/notification-service-impl.test.ts +0 -84
  106. package/src/api/notification-service/notification-service.ts +0 -6
  107. package/src/api/notification-service/notification.service-impl.ts +0 -67
  108. package/src/api/pdf-viewer-manager/constants.ts +0 -1
  109. package/src/api/pdf-viewer-manager/events.ts +0 -5
  110. package/src/api/pdf-viewer-manager/handle-views.ts +0 -32
  111. package/src/api/pdf-viewer-manager/pdf-viewer-manager.test.ts +0 -126
  112. package/src/api/pdf-viewer-manager/pdf-viewer-manager.ts +0 -96
  113. package/src/api/pdf-viewer-manager/pdf-visor/pdf-selector/pdf-selector.ts +0 -39
  114. package/src/api/pdf-viewer-manager/pdf-visor/pdf-selector/styles.css +0 -45
  115. package/src/api/pdf-viewer-manager/pdf-visor/pdf-selector/template.ts +0 -32
  116. package/src/api/pdf-viewer-manager/pdf-visor/pdf-visor.ts +0 -122
  117. package/src/api/pdf-viewer-manager/pdf-visor/styles.css +0 -29
  118. package/src/api/pdf-viewer-manager/pdf-visor/utils.ts +0 -16
  119. package/src/api/quick-action-busy-manager/quick-action-busy-manager.test.ts +0 -61
  120. package/src/api/quick-action-busy-manager/quick-action-busy-manager.ts +0 -45
  121. package/src/api/region-manager/region-manager.test.ts +0 -239
  122. package/src/api/region-manager/region-manager.ts +0 -263
  123. package/src/api/region-manager/regions.ts +0 -30
  124. package/src/api/region-manager/remove-view-idempotency.test.ts +0 -98
  125. package/src/api/session-refresh-timer/session-refresh-timer.test.ts +0 -102
  126. package/src/api/session-refresh-timer/session-refresh-timer.ts +0 -75
  127. package/src/api/token-manager/token-manager.test.ts +0 -146
  128. package/src/api/token-manager/token-manager.ts +0 -70
  129. package/src/api/user-manager/user-manager.ts +0 -79
  130. package/src/bootstrapper.ts +0 -41
  131. package/src/constants.ts +0 -1
  132. package/src/disposer.ts +0 -19
  133. package/src/features/bootstrapper.ts +0 -21
  134. package/src/features/exit/bootstrapper.ts +0 -17
  135. package/src/features/exit/handler.test.ts +0 -187
  136. package/src/features/exit/handler.ts +0 -58
  137. package/src/features/exit/request.ts +0 -10
  138. package/src/features/get-patient-cip/action.ts +0 -5
  139. package/src/features/get-user-info/backend-adapter.ts +0 -48
  140. package/src/features/get-user-info/bootstrapper.ts +0 -20
  141. package/src/features/get-user-info/handler.test.ts +0 -66
  142. package/src/features/get-user-info/handler.ts +0 -23
  143. package/src/features/get-user-info/model.ts +0 -10
  144. package/src/features/get-user-info/pds-token.ts +0 -28
  145. package/src/features/get-user-info/request.ts +0 -4
  146. package/src/features/get-visi-id/action.ts +0 -11
  147. package/src/features/navigate-to-ecap/navigate-to-ecap.ts +0 -21
  148. package/src/features/utils.ts +0 -27
  149. package/src/handle-plugins.ts +0 -82
  150. package/src/index.ts +0 -101
  151. package/src/infrastructure/ioc/container.ts +0 -14
  152. package/src/infrastructure/ioc/types.ts +0 -5
  153. package/src/locales.ts +0 -70
  154. package/src/types/custom.d.ts +0 -30
@@ -1,29 +0,0 @@
1
- import { LitElement, css, html, unsafeCSS } from "lit";
2
- import { customElement } from "lit/decorators.js";
3
- import { ConfirmationContentProps } from "../../interaction-service";
4
- import styles from "./styles.css?inline";
5
- import { template } from "./template";
6
-
7
- @customElement("import-data-manager-modal")
8
- export class ImportDataManagerModal extends LitElement implements ConfirmationContentProps<undefined, undefined> {
9
- data: undefined;
10
- setResult: (result: undefined) => void;
11
- setIsValid: (isValid: boolean) => void;
12
- confirm: () => void;
13
- // Injectat pel servei d'interacció igual que la resta; faltava des que es va afegir a la
14
- // interfície.
15
- confirmResult: (result: undefined) => void;
16
- cancel: () => void;
17
-
18
- render() {
19
- return html`${template(this)}`;
20
- }
21
-
22
- static styles = css`
23
- ${unsafeCSS(styles)}
24
- `;
25
-
26
- _accept = () => {
27
- this.confirm();
28
- };
29
- }
@@ -1,79 +0,0 @@
1
- .container {
2
- background-color: white;
3
- display: flex;
4
- flex-direction: column;
5
- min-width: 500px;
6
- width: 95vw;
7
- height: 95vh;
8
- border-radius: var(--dss-radius-sm);
9
- overflow: hidden;
10
- }
11
-
12
- /* Three columns so the title is centred on the modal, not on the space left
13
- over by the close button. */
14
- .header {
15
- display: grid;
16
- grid-template-columns: 1fr auto 1fr;
17
- align-items: center;
18
- color: black;
19
- padding: var(--dss-spacing-sm);
20
- }
21
-
22
- .header__title {
23
- grid-column: 2;
24
- text-align: center;
25
- }
26
-
27
- .header__close {
28
- grid-column: 3;
29
- justify-self: end;
30
- }
31
-
32
- .content{
33
- display: grid;
34
- flex: 1;
35
- min-height: 0;
36
- grid-template-columns: 50% 50%;
37
- padding: 16px;
38
- }
39
-
40
- .content > primaria-region {
41
- width: 100%;
42
- height: 100%;
43
- min-height: 0;
44
- }
45
-
46
- .content primaria-region > div {
47
- width: 100%;
48
- height: 100%;
49
- border-radius: 8px;
50
- padding: 0 16px;
51
- box-sizing: border-box;
52
- }
53
-
54
- /* Both columns are a vertical stack of injected views, 16px apart, that scrolls
55
- as a whole. Each view keeps its natural height and bounds its own inner
56
- scroll, and must not shrink — otherwise the column squeezes the views instead
57
- of scrolling. */
58
- .content > primaria-region > div {
59
- display: flex;
60
- flex-direction: column;
61
- gap: 16px;
62
- overflow-y: auto;
63
- }
64
-
65
- .content > primaria-region > div > * {
66
- flex-shrink: 0;
67
- }
68
-
69
- .footer {
70
- display: flex;
71
- flex-direction: row;
72
- align-items: center;
73
- background: white;
74
- justify-content: center;
75
- gap: 12px;
76
- height: 56px;
77
- border-top: 1px solid var(--color-neutral-100);
78
- padding: var(--dss-spacing-sm);
79
- }
@@ -1,49 +0,0 @@
1
- import { html } from "lit";
2
- import { translate } from "../../../locales";
3
- import { shellApi } from "../../api";
4
- import { ImportDataManagerModal } from "./component";
5
-
6
- export const template = (props: ImportDataManagerModal) => {
7
- return html`
8
- <div class="container">
9
- <div class="header">
10
- <dss-typography class="header__title" tag="h2" variant="headline-4">
11
- ${translate("importDataManager.title")}
12
- </dss-typography>
13
- <dss-icon-button
14
- class="header__close"
15
- icon="close"
16
- size="lg"
17
- variant="neutral"
18
- label="${translate("importDataManager.actions.close")}"
19
- @onClick="${() => {
20
- props.cancel();
21
- }}"
22
- ></dss-icon-button>
23
- </div>
24
- <div class="content">
25
- <primaria-region name="${shellApi.regionManager.regions.shell.importDataActivityHistory}"></primaria-region>
26
- <primaria-region name="${shellApi.regionManager.regions.shell.importData}"></primaria-region>
27
- </div>
28
- <div class="footer">
29
- <dss-button
30
- label="${translate("importDataManager.actions.cancel")}"
31
- @click="${() => {
32
- props.cancel();
33
- }}"
34
- size="md"
35
- variant="secondary"
36
- ></dss-button>
37
- <dss-button
38
- icon="add_circle"
39
- label="${translate("importDataManager.actions.import")}"
40
- @click="${() => {
41
- props._accept();
42
- }}"
43
- size="md"
44
- variant="primary"
45
- ></dss-button>
46
- </div>
47
- </div>
48
- `;
49
- };
@@ -1,364 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import { ImportDataManagerImpl } from "./import-data-manager-impl";
3
- import {
4
- PrimariaInteractionService,
5
- ConfirmationOptions,
6
- ConfirmComponentUI,
7
- ConfirmationResult,
8
- } from "../interaction-service/interaction-service";
9
-
10
- // Mock del PrimariaInteractionService
11
- class MockInteractionService extends PrimariaInteractionService {
12
- private mockConfirmResult: { confirmed: boolean; result?: unknown } = { confirmed: true };
13
-
14
- dispose(): void {}
15
-
16
- // Mètode per configurar el resultat del mock
17
- setMockConfirmResult(result: { confirmed: boolean; result?: unknown }) {
18
- this.mockConfirmResult = result;
19
- }
20
-
21
- async confirm<TData = undefined, TResult = undefined>(
22
- _data: TData | undefined,
23
- _componentUI: ConfirmComponentUI<TData, TResult>,
24
- _options?: ConfirmationOptions | undefined,
25
- ): Promise<ConfirmationResult<TResult | undefined>> {
26
- return Promise.resolve(this.mockConfirmResult as ConfirmationResult<TResult | undefined>);
27
- }
28
-
29
- async confirmMessage(_message: string, _options?: ConfirmationOptions | undefined): Promise<ConfirmationResult> {
30
- return Promise.resolve({ confirmed: this.mockConfirmResult.confirmed, result: undefined });
31
- }
32
- }
33
-
34
- describe("ImportDataManagerImpl implements PrimariaImportDataManager", () => {
35
- let importDataManager: ImportDataManagerImpl;
36
- let mockInteractionService: MockInteractionService;
37
-
38
- beforeEach(() => {
39
- mockInteractionService = new MockInteractionService();
40
- importDataManager = new ImportDataManagerImpl(mockInteractionService);
41
- });
42
-
43
- describe("getCurrentImporterId", () => {
44
- it("should return empty string initially", () => {
45
- expect(importDataManager.getCurrentImporterId()).toBe("");
46
- });
47
-
48
- it("should return the current importer ID after calling import", async () => {
49
- mockInteractionService.setMockConfirmResult({ confirmed: true });
50
-
51
- const promise = importDataManager.import("test-importer-123");
52
- expect(importDataManager.getCurrentImporterId()).toBe("test-importer-123");
53
-
54
- await promise;
55
- expect(importDataManager.getCurrentImporterId()).toBe("");
56
- });
57
- });
58
-
59
- describe("selectItems", () => {
60
- it("should store selected items correctly", () => {
61
- const payload = {
62
- pluginId: "test-plugin",
63
- data: [{ id: "1", name: "Test Item" }],
64
- text: { raw: "Test Item", html: "<p>Test Item</p>" },
65
- };
66
-
67
- importDataManager.selectItems(payload);
68
-
69
- // Test via getCurrentImporterId and import method to verify internal state
70
- expect(() => importDataManager.selectItems(payload)).not.toThrow();
71
- });
72
-
73
- it("should handle multiple plugin selections", () => {
74
- const payload1 = {
75
- pluginId: "plugin-1",
76
- data: [{ id: "1", name: "Item 1" }],
77
- text: { raw: "Item 1", html: "<p>Item 1</p>" },
78
- };
79
-
80
- const payload2 = {
81
- pluginId: "plugin-2",
82
- data: [{ id: "2", name: "Item 2" }],
83
- text: { raw: "Item 2", html: "<p>Item 2</p>" },
84
- };
85
-
86
- expect(() => {
87
- importDataManager.selectItems(payload1);
88
- importDataManager.selectItems(payload2);
89
- }).not.toThrow();
90
- });
91
-
92
- it("should overwrite previous selections from same plugin", () => {
93
- const payload1 = {
94
- pluginId: "test-plugin",
95
- data: [{ id: "1", name: "First Item" }],
96
- text: { raw: "First Item", html: "<p>First Item</p>" },
97
- };
98
-
99
- const payload2 = {
100
- pluginId: "test-plugin",
101
- data: [{ id: "2", name: "Second Item" }],
102
- text: { raw: "Second Item", html: "<p>Second Item</p>" },
103
- };
104
-
105
- expect(() => {
106
- importDataManager.selectItems(payload1);
107
- importDataManager.selectItems(payload2);
108
- }).not.toThrow();
109
- });
110
- });
111
-
112
- describe("import", () => {
113
- it("should return accepted result with concatenated text when confirmed", async () => {
114
- mockInteractionService.setMockConfirmResult({ confirmed: true });
115
-
116
- // Mock the import to allow setting up items during the import process
117
- const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
118
- vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
119
- // Setup some selected items during the import process (simulating user interaction)
120
- importDataManager.selectItems({
121
- pluginId: "plugin-1",
122
- data: [{ id: "1", name: "Item 1" }],
123
- text: { raw: "Item 1", html: "<p>Item 1</p>" },
124
- });
125
-
126
- importDataManager.selectItems({
127
- pluginId: "plugin-2",
128
- data: [{ id: "2", name: "Item 2" }],
129
- text: { raw: "Item 2", html: "<p>Item 2</p>" },
130
- });
131
-
132
- return originalConfirm(...args);
133
- });
134
-
135
- const result = await importDataManager.import("test-importer");
136
-
137
- expect(result.accepted).toBe(true);
138
- expect(result.data).toEqual({
139
- "plugin-1": [{ id: "1", name: "Item 1" }],
140
- "plugin-2": [{ id: "2", name: "Item 2" }],
141
- });
142
- expect(result.text.raw).toBe("Item 1\n\nItem 2\n");
143
- expect(result.text.html).toBe("<p>Item 1</p><br><br><p>Item 2</p><p><br></p>");
144
- });
145
-
146
- it("should return cancelled result with empty data when not confirmed", async () => {
147
- mockInteractionService.setMockConfirmResult({ confirmed: false });
148
-
149
- // Setup some selected items
150
- importDataManager.selectItems({
151
- pluginId: "plugin-1",
152
- data: [{ id: "1", name: "Item 1" }],
153
- text: { raw: "Item 1", html: "<p>Item 1</p>" },
154
- });
155
-
156
- const result = await importDataManager.import("test-importer");
157
-
158
- expect(result.accepted).toBe(false);
159
- expect(result.data).toEqual({});
160
- expect(result.text.raw).toBe("");
161
- expect(result.text.html).toBe("");
162
- });
163
-
164
- it("should clear state after successful import", async () => {
165
- mockInteractionService.setMockConfirmResult({ confirmed: true });
166
-
167
- // Setup selected items
168
- importDataManager.selectItems({
169
- pluginId: "test-plugin",
170
- data: [{ id: "1", name: "Test Item" }],
171
- text: { raw: "Test Item", html: "<p>Test Item</p>" },
172
- });
173
-
174
- await importDataManager.import("test-importer");
175
-
176
- // Verify state is cleared
177
- expect(importDataManager.getCurrentImporterId()).toBe("");
178
-
179
- // Verify that subsequent import returns empty data
180
- const result = await importDataManager.import("another-importer");
181
- expect(result.data).toEqual({});
182
- expect(result.text.raw).toBe("");
183
- expect(result.text.html).toBe("");
184
- });
185
-
186
- it("should clear state after cancelled import", async () => {
187
- mockInteractionService.setMockConfirmResult({ confirmed: false });
188
-
189
- // Setup selected items
190
- importDataManager.selectItems({
191
- pluginId: "test-plugin",
192
- data: [{ id: "1", name: "Test Item" }],
193
- text: { raw: "Test Item", html: "<p>Test Item</p>" },
194
- });
195
-
196
- await importDataManager.import("test-importer");
197
-
198
- // Verify state is cleared
199
- expect(importDataManager.getCurrentImporterId()).toBe("");
200
- });
201
-
202
- it("should handle empty selections", async () => {
203
- mockInteractionService.setMockConfirmResult({ confirmed: true });
204
-
205
- const result = await importDataManager.import("test-importer");
206
-
207
- expect(result.accepted).toBe(true);
208
- expect(result.data).toEqual({});
209
- expect(result.text.raw).toBe("");
210
- expect(result.text.html).toBe("");
211
- });
212
-
213
- it("should handle error and clear state", async () => {
214
- mockInteractionService.setMockConfirmResult({ confirmed: true });
215
-
216
- // Mock the interaction service to throw an error
217
- vi.spyOn(mockInteractionService, "confirm").mockRejectedValueOnce(new Error("Test error"));
218
-
219
- // Setup selected items
220
- importDataManager.selectItems({
221
- pluginId: "test-plugin",
222
- data: [{ id: "1", name: "Test Item" }],
223
- text: { raw: "Test Item", html: "<p>Test Item</p>" },
224
- });
225
-
226
- await expect(importDataManager.import("test-importer")).rejects.toThrow("Test error");
227
-
228
- // Verify state is cleared even after error
229
- expect(importDataManager.getCurrentImporterId()).toBe("");
230
- });
231
-
232
- it("should handle text concatenation correctly with multiple plugins", async () => {
233
- mockInteractionService.setMockConfirmResult({ confirmed: true });
234
-
235
- // Mock the import to allow setting up items during the import process
236
- const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
237
- vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
238
- importDataManager.selectItems({
239
- pluginId: "diagnostics",
240
- data: [{ code: "E11.9", name: "Diabetes" }],
241
- text: { raw: "E11.9 - Diabetes", html: "<p><strong>E11.9</strong> - Diabetes</p>" },
242
- });
243
-
244
- importDataManager.selectItems({
245
- pluginId: "allergies",
246
- data: [{ name: "Penicillin", severity: "High" }],
247
- text: { raw: "Penicillin - High severity", html: "<p><strong>Penicillin</strong> - High severity</p>" },
248
- });
249
-
250
- return originalConfirm(...args);
251
- });
252
-
253
- const result = await importDataManager.import("test-importer");
254
-
255
- expect(result.text.raw).toBe("E11.9 - Diabetes\n\nPenicillin - High severity\n");
256
- expect(result.text.html).toBe(
257
- "<p><strong>E11.9</strong> - Diabetes</p><br><br><p><strong>Penicillin</strong> - High severity</p><p><br></p>",
258
- );
259
- });
260
-
261
- it("should handle empty text values in concatenation", async () => {
262
- mockInteractionService.setMockConfirmResult({ confirmed: true });
263
-
264
- // Mock the import to allow setting up items during the import process
265
- const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
266
- vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
267
- importDataManager.selectItems({
268
- pluginId: "plugin-1",
269
- data: [{ id: "1" }],
270
- text: { raw: "", html: "" },
271
- });
272
-
273
- importDataManager.selectItems({
274
- pluginId: "plugin-2",
275
- data: [{ id: "2" }],
276
- text: { raw: "Item 2", html: "<p>Item 2</p>" },
277
- });
278
-
279
- return originalConfirm(...args);
280
- });
281
-
282
- const result = await importDataManager.import("test-importer");
283
-
284
- expect(result.text.raw).toBe("Item 2\n");
285
- expect(result.text.html).toBe("<p>Item 2</p><p><br></p>");
286
- });
287
-
288
- it("heads the texts sharing a title with that title, just once", async () => {
289
- mockInteractionService.setMockConfirmResult({ confirmed: true });
290
-
291
- const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
292
- vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
293
- importDataManager.selectItems({
294
- pluginId: "clinical-course",
295
- data: [{ id: "draft" }],
296
- text: { raw: "Esborrany", html: "<p>Esborrany</p>" },
297
- title: "Seguiment Clínic",
298
- });
299
-
300
- importDataManager.selectItems({
301
- pluginId: "activity-history",
302
- data: [{ id: "note" }],
303
- text: { raw: "Nota", html: "<p>Nota</p>" },
304
- title: "Seguiment Clínic",
305
- });
306
-
307
- return originalConfirm(...args);
308
- });
309
-
310
- const result = await importDataManager.import("test-importer");
311
-
312
- expect(result.text.raw).toBe("Seguiment Clínic\n\nEsborrany\n\nNota\n");
313
- expect(result.text.html).toBe("<p><strong>Seguiment Clínic</strong></p><p>Esborrany</p><br><br><p>Nota</p><p><br></p>");
314
- });
315
-
316
- it("keeps untitled texts without any heading", async () => {
317
- mockInteractionService.setMockConfirmResult({ confirmed: true });
318
-
319
- const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
320
- vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
321
- importDataManager.selectItems({
322
- pluginId: "activity-history",
323
- data: [{ id: "note" }],
324
- text: { raw: "Nota", html: "<p>Nota</p>" },
325
- title: "Seguiment Clínic",
326
- });
327
-
328
- importDataManager.selectItems({
329
- pluginId: "diagnostics",
330
- data: [{ id: "diag" }],
331
- text: { raw: "E11.9", html: "<p>E11.9</p>" },
332
- });
333
-
334
- return originalConfirm(...args);
335
- });
336
-
337
- const result = await importDataManager.import("test-importer");
338
-
339
- expect(result.text.raw).toBe("Seguiment Clínic\n\nNota\n\nE11.9\n");
340
- expect(result.text.html).toBe("<p><strong>Seguiment Clínic</strong></p><p>Nota</p><br><br><p>E11.9</p><p><br></p>");
341
- });
342
-
343
- it("leaves out the title of a plugin that ends up contributing no text", async () => {
344
- mockInteractionService.setMockConfirmResult({ confirmed: true });
345
-
346
- const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
347
- vi.spyOn(mockInteractionService, "confirm").mockImplementation(async (...args) => {
348
- importDataManager.selectItems({
349
- pluginId: "clinical-course",
350
- data: [],
351
- text: { raw: "", html: "" },
352
- title: "Seguiment Clínic",
353
- });
354
-
355
- return originalConfirm(...args);
356
- });
357
-
358
- const result = await importDataManager.import("test-importer");
359
-
360
- expect(result.text.raw).toBe("");
361
- expect(result.text.html).toBe("");
362
- });
363
- });
364
- });
@@ -1,121 +0,0 @@
1
- import { PrimariaInteractionService } from "../interaction-service/interaction-service";
2
- import { ImportParams, PrimariaImportDataManager } from "./import-data-manager";
3
-
4
- export class ImportDataManagerImpl implements PrimariaImportDataManager {
5
- private selectedItems: Record<string, any[]> = {};
6
- private currentImporterId = "";
7
- private currentImportParams: ImportParams | undefined;
8
- private pluginTexts: Record<string, { raw: string; html: string; title?: string }> = {};
9
-
10
- constructor(private interactionService: PrimariaInteractionService) {}
11
-
12
- async import(
13
- importerId: string,
14
- params?: ImportParams,
15
- ): Promise<{
16
- accepted: boolean;
17
- data: Record<string, any[]>;
18
- text: { raw: string; html: string };
19
- }> {
20
- this.currentImporterId = importerId;
21
- this.currentImportParams = params;
22
- this.selectedItems = {};
23
- this.pluginTexts = {};
24
-
25
- try {
26
- // Import component dynamically to avoid circular dependency
27
- const { ImportDataManagerModal } = await import("./component/component");
28
-
29
- const { confirmed } = await this.interactionService.confirm(
30
- undefined,
31
- { component: ImportDataManagerModal as any },
32
- {
33
- fullCustomization: true,
34
- },
35
- );
36
-
37
- const concatenatedText = this.getConcatenatedText();
38
-
39
- const finalResult = {
40
- accepted: confirmed,
41
- data: confirmed ? this.selectedItems : {},
42
- text: confirmed ? concatenatedText : { raw: "", html: "" },
43
- };
44
-
45
- if (confirmed) {
46
- console.log("[ImportDataManager] Imported data:", finalResult);
47
- }
48
-
49
- this.selectedItems = {};
50
- this.currentImporterId = "";
51
- this.currentImportParams = undefined;
52
- this.pluginTexts = {};
53
-
54
- return finalResult;
55
- } catch (error) {
56
- this.selectedItems = {};
57
- this.currentImporterId = "";
58
- this.currentImportParams = undefined;
59
- this.pluginTexts = {};
60
- throw error;
61
- }
62
- }
63
-
64
- selectItems(payload: { pluginId: string; data: any[]; text: { raw: string; html: string }; title?: string }): void {
65
- console.log(
66
- `[ImportDataManager] selectItems — pluginId: "${payload.pluginId}" | items: ${payload.data.length} | text.raw: ${payload.text.raw.length} chars | text.html: ${payload.text.html.length} chars`,
67
- );
68
- this.selectedItems[payload.pluginId] = payload.data;
69
- this.pluginTexts[payload.pluginId] = { ...payload.text, title: payload.title };
70
- }
71
-
72
- getCurrentImporterId(): string {
73
- return this.currentImporterId;
74
- }
75
-
76
- getCurrentImportParams(): ImportParams | undefined {
77
- return this.currentImportParams;
78
- }
79
-
80
- /**
81
- * Ajunta el text de cada plugin que ha contribuït a la importació.
82
- *
83
- * Els que declaren el mateix títol formen una sola secció, encapçalada un
84
- * cop (dues iniciatives poden omplir el mateix apartat del modal: el curs
85
- * clínic i l'històric d'activitat ho fan amb "Seguiment Clínic"). Els que no
86
- * en declaren cap van tots junts, sense títol.
87
- *
88
- * El resultat acaba amb una línia en blanc perquè qui rep el text pugui
89
- * seguir escrivint a sota.
90
- */
91
- private getConcatenatedText(): { raw: string; html: string } {
92
- const sections: { title: string; raw: string[]; html: string[] }[] = [];
93
-
94
- for (const { raw, html, title } of Object.values(this.pluginTexts)) {
95
- if (!raw && !html) continue;
96
- const sectionTitle = title ?? "";
97
- let section = sections.find((s) => s.title === sectionTitle);
98
- if (!section) {
99
- section = { title: sectionTitle, raw: [], html: [] };
100
- sections.push(section);
101
- }
102
- if (raw) section.raw.push(raw);
103
- if (html) section.html.push(html);
104
- }
105
-
106
- const raw = sections
107
- .filter((section) => section.raw.length > 0)
108
- .map((section) => (section.title ? `${section.title}\n\n` : "") + section.raw.join("\n\n"))
109
- .join("\n\n");
110
-
111
- const html = sections
112
- .filter((section) => section.html.length > 0)
113
- .map((section) => (section.title ? `<p><strong>${section.title}</strong></p>` : "") + section.html.join("<br><br>"))
114
- .join("<br><br>");
115
-
116
- return {
117
- raw: raw ? `${raw}\n` : "",
118
- html: html ? `${html}<p><br></p>` : "",
119
- };
120
- }
121
- }
@@ -1,42 +0,0 @@
1
- export interface ImportParamsDiagnostic {
2
- code: string;
3
- catalog: string;
4
- description: string;
5
- }
6
-
7
- export interface ImportParams {
8
- /** Optional list of diagnostics the consumer wants the activity-history
9
- * importer to filter by. If absent, the diagnostics filter is hidden.
10
- * Plugins must map their own diagnostic shape to this common model. */
11
- diagnostics?: ImportParamsDiagnostic[];
12
- /** Open extension point for future per-importer parameters. */
13
- [key: string]: unknown;
14
- }
15
-
16
- export interface PrimariaImportDataManager {
17
- import(
18
- importerId: string,
19
- params?: ImportParams,
20
- ): Promise<{
21
- accepted: boolean;
22
- data: Record<string, any[]>;
23
- text: { raw: string; html: string };
24
- }>;
25
-
26
- selectItems(payload: {
27
- pluginId: string;
28
- data: any[];
29
- text: { raw: string; html: string };
30
- /** Títol que encapçala aquest text dins del resultat de la importació. Els
31
- * plugins que en declaren un de mateix queden sota un sol títol, en l'ordre
32
- * en què han publicat la seva selecció. Sense títol, el text s'afegeix tal
33
- * qual. */
34
- title?: string;
35
- }): void;
36
-
37
- getCurrentImporterId(): string;
38
-
39
- /** Returns the params the current importer was opened with (or undefined
40
- * if no import is in progress). */
41
- getCurrentImportParams(): ImportParams | undefined;
42
- }
@@ -1,2 +0,0 @@
1
- export * from "./import-data-manager";
2
- export * from "./import-data-manager-impl";