@uxland/primary-shell 7.4.0 → 7.5.0

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 (28) hide show
  1. package/dist/component-s17Jsk26.js +47 -0
  2. package/dist/component-s17Jsk26.js.map +1 -0
  3. package/dist/index-C3997nyY.js +45157 -0
  4. package/dist/index-C3997nyY.js.map +1 -0
  5. package/dist/index.js +18 -45096
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.umd.cjs +111 -94
  8. package/dist/index.umd.cjs.map +1 -1
  9. package/dist/primary/shell/src/api/api.d.ts +2 -0
  10. package/dist/primary/shell/src/api/import-data-manager/component/component.d.ts +15 -0
  11. package/dist/primary/shell/src/api/import-data-manager/component/template.d.ts +2 -0
  12. package/dist/primary/shell/src/api/import-data-manager/import-data-manager-impl.d.ts +27 -0
  13. package/dist/primary/shell/src/api/import-data-manager/import-data-manager-impl.test.d.ts +1 -0
  14. package/dist/primary/shell/src/api/import-data-manager/import-data-manager.d.ts +19 -0
  15. package/dist/primary/shell/src/api/import-data-manager/index.d.ts +2 -0
  16. package/dist/primary/shell/src/api/region-manager/regions.d.ts +1 -0
  17. package/dist/primary/shell/src/locales.d.ts +8 -0
  18. package/package.json +1 -1
  19. package/src/api/api.ts +4 -0
  20. package/src/api/import-data-manager/component/component.ts +34 -0
  21. package/src/api/import-data-manager/component/styles.css +58 -0
  22. package/src/api/import-data-manager/component/template.ts +24 -0
  23. package/src/api/import-data-manager/import-data-manager-impl.test.ts +282 -0
  24. package/src/api/import-data-manager/import-data-manager-impl.ts +80 -0
  25. package/src/api/import-data-manager/import-data-manager.ts +15 -0
  26. package/src/api/import-data-manager/index.ts +2 -0
  27. package/src/api/region-manager/regions.ts +1 -0
  28. package/src/locales.ts +9 -0
@@ -10,6 +10,7 @@ import { PluginBusyManager } from './plugin-busy-manager/plugin-busy-manager';
10
10
  import { PrimariaRegionManager } from './region-manager/region-manager';
11
11
  import { TokenManager } from './token-manager/token-manager';
12
12
  import { UserManager } from './user-manager/user-manager';
13
+ import { PrimariaImportDataManager } from './import-data-manager';
13
14
  export interface PrimariaApi extends HarmonixApi {
14
15
  httpClient: HttpClient;
15
16
  interactionService: PrimariaInteractionService;
@@ -22,6 +23,7 @@ export interface PrimariaApi extends HarmonixApi {
22
23
  ecapEventManager: EcapEventManager;
23
24
  pluginBusyManager: PluginBusyManager;
24
25
  pdfViewerManager: PdfViewerManager;
26
+ importDataManager: PrimariaImportDataManager;
25
27
  }
26
28
  export declare const PrimariaRegionHost: any;
27
29
  /**
@@ -0,0 +1,15 @@
1
+ import { IRegion } from '@uxland/regions';
2
+ import { ConfirmationContentProps } from '../../interaction-service';
3
+ declare const ImportDataManagerModal_base: any;
4
+ export declare class ImportDataManagerModal extends ImportDataManagerModal_base implements ConfirmationContentProps<undefined, undefined> {
5
+ data: undefined;
6
+ setResult: (result: undefined) => void;
7
+ setIsValid: (isValid: boolean) => void;
8
+ confirm: () => void;
9
+ cancel: () => void;
10
+ importDataRegion: IRegion | undefined;
11
+ render(): import('lit').TemplateResult<1>;
12
+ static styles: import('lit').CSSResult;
13
+ _accept: () => void;
14
+ }
15
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ImportDataManagerModal } from './component';
2
+ export declare const template: (props: ImportDataManagerModal) => import('lit').TemplateResult<1>;
@@ -0,0 +1,27 @@
1
+ import { PrimariaImportDataManager } from './import-data-manager';
2
+ import { PrimariaInteractionService } from '../interaction-service/interaction-service';
3
+ export declare class ImportDataManagerImpl implements PrimariaImportDataManager {
4
+ private interactionService;
5
+ private selectedItems;
6
+ private currentImporterId;
7
+ private pluginTexts;
8
+ constructor(interactionService: PrimariaInteractionService);
9
+ import(importerId: string): Promise<{
10
+ accepted: boolean;
11
+ data: Record<string, any[]>;
12
+ text: {
13
+ raw: string;
14
+ html: string;
15
+ };
16
+ }>;
17
+ selectItems(payload: {
18
+ pluginId: string;
19
+ data: any[];
20
+ text: {
21
+ raw: string;
22
+ html: string;
23
+ };
24
+ }): void;
25
+ getCurrentImporterId(): string;
26
+ private getConcatenatedText;
27
+ }
@@ -0,0 +1,19 @@
1
+ export interface PrimariaImportDataManager {
2
+ import(importerId: string): Promise<{
3
+ accepted: boolean;
4
+ data: Record<string, any[]>;
5
+ text: {
6
+ raw: string;
7
+ html: string;
8
+ };
9
+ }>;
10
+ selectItems(payload: {
11
+ pluginId: string;
12
+ data: any[];
13
+ text: {
14
+ raw: string;
15
+ html: string;
16
+ };
17
+ }): void;
18
+ getCurrentImporterId(): string;
19
+ }
@@ -0,0 +1,2 @@
1
+ export * from './import-data-manager';
2
+ export * from './import-data-manager-impl';
@@ -7,6 +7,7 @@ export declare const shellRegions: {
7
7
  quickActions: string;
8
8
  floating: string;
9
9
  communicationSidenav: string;
10
+ importData: string;
10
11
  };
11
12
  export declare const clinicalMonitoringRegions: {
12
13
  sidebar: string;
@@ -8,6 +8,7 @@ type LocaleKeys<T> = T extends object ? {
8
8
  export type ShellLocales = LocaleKeys<(typeof locales)[typeof defaultLang][typeof primariaShellId]>;
9
9
  export declare const translate: (path: ShellLocales) => any;
10
10
  export { shellLocaleManager };
11
+ declare const defaultLang = "ca";
11
12
  export declare const locales: {
12
13
  ca: {
13
14
  "primaria-shell": {
@@ -44,6 +45,13 @@ export declare const locales: {
44
45
  pdfVisor: {
45
46
  noPdfSelected: string;
46
47
  };
48
+ importDataManager: {
49
+ title: string;
50
+ actions: {
51
+ cancel: string;
52
+ import: string;
53
+ };
54
+ };
47
55
  };
48
56
  };
49
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "7.4.0",
3
+ "version": "7.5.0",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
package/src/api/api.ts CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  import { PrimariaRegionManager, createRegionManagerProxy } from "./region-manager/region-manager";
26
26
  import { TokenManager, createTokenManager } from "./token-manager/token-manager";
27
27
  import { UserManager, createUserManager } from "./user-manager/user-manager";
28
+ import { PrimariaImportDataManager, ImportDataManagerImpl } from "./import-data-manager";
28
29
 
29
30
  const broker = createBroker();
30
31
 
@@ -40,6 +41,7 @@ export interface PrimariaApi extends HarmonixApi {
40
41
  ecapEventManager: EcapEventManager;
41
42
  pluginBusyManager: PluginBusyManager;
42
43
  pdfViewerManager: PdfViewerManager;
44
+ importDataManager: PrimariaImportDataManager;
43
45
  }
44
46
 
45
47
  const regionManager: RegionManager = createRegionManager("primaria");
@@ -52,6 +54,7 @@ const interactionService = new ParimariaInteractionServiceImpl();
52
54
  const notificationService = new PrimariaNotificationServiceImpl();
53
55
  const ecapEventManager = createEcapEventManager();
54
56
  const pdfViewerManager = createPdfViewerManager(broker, notificationService);
57
+ const importDataManager = new ImportDataManagerImpl(interactionService);
55
58
 
56
59
  /**
57
60
  * Factory function that creates a Primaria API instance.
@@ -78,6 +81,7 @@ export const primariaApiFactory: ApiFactory<PrimariaApi> = (
78
81
  interactionService,
79
82
  notificationService,
80
83
  pdfViewerManager,
84
+ importDataManager,
81
85
  };
82
86
  };
83
87
 
@@ -0,0 +1,34 @@
1
+
2
+ import { IRegion, region } from "@uxland/regions";
3
+ import { LitElement, css, html, unsafeCSS } from "lit";
4
+ import { customElement } from "lit/decorators.js";
5
+ import styles from "./styles.css?inline";
6
+ import { template } from "./template";
7
+ import { ConfirmationContentProps } from "../../interaction-service";
8
+ import { PrimariaRegionHost } from "../../api";
9
+
10
+ @customElement("import-data-manager-modal")
11
+ export class ImportDataManagerModal
12
+ extends PrimariaRegionHost(LitElement) implements ConfirmationContentProps<undefined, undefined>
13
+ {
14
+ data: undefined;
15
+ setResult: (result: undefined) => void;
16
+ setIsValid: (isValid: boolean) => void;
17
+ confirm: () => void;
18
+ cancel: () => void;
19
+
20
+ @region({ targetId: "import-data-region", name: "import-data-region" })
21
+ importDataRegion: IRegion | undefined;
22
+
23
+ render() {
24
+ return html`${template(this)}`;
25
+ }
26
+
27
+ static styles = css`
28
+ ${unsafeCSS(styles)}
29
+ `;
30
+
31
+ _accept = () => {
32
+ this.confirm();
33
+ };
34
+ }
@@ -0,0 +1,58 @@
1
+ .container {
2
+ background-color: white;
3
+ display: flex;
4
+ flex-direction: column;
5
+ min-width: 500px;
6
+ width: 90vw;
7
+ height: 90vh;
8
+ border-radius: var(--dss-radius-sm);
9
+ overflow: hidden;
10
+ }
11
+
12
+ /* .header {
13
+ display: flex;
14
+ flex-direction: row;
15
+ align-items: center;
16
+ justify-content: space-between;
17
+ text-align: center;
18
+ color: black;
19
+ padding: var(--dss-spacing-sm);
20
+
21
+ .title {
22
+ display: flex;
23
+ flex-direction: row;
24
+ gap: 8px;
25
+ }
26
+ } */
27
+
28
+ .content{
29
+ display: grid;
30
+ height: 100%;
31
+ min-height: 1px;
32
+ grid-template-columns: 1fr 1fr;
33
+ grid-auto-rows: 1fr;
34
+ gap: 16px;
35
+ padding: 16px;
36
+ overflow-y: auto;
37
+ max-height: calc(90vh - 120px);
38
+ }
39
+
40
+ .content > * {
41
+ border: 1px solid var(--color-neutral-200);
42
+ border-radius: 8px;
43
+ padding: 16px;
44
+ background-color: var(--color-neutral-50);
45
+ min-height: 200px;
46
+ }
47
+
48
+ .footer {
49
+ display: flex;
50
+ flex-direction: row;
51
+ align-items: center;
52
+ background: white;
53
+ justify-content: end;
54
+ gap: 12px;
55
+ height: 56px;
56
+ border-top: 1px solid var(--color-neutral-100);
57
+ padding: var(--dss-spacing-sm);
58
+ }
@@ -0,0 +1,24 @@
1
+ import { html } from "lit";
2
+ import { translate } from "../../../locales";
3
+ import { ImportDataManagerModal } from "./component";
4
+
5
+ export const template = (props: ImportDataManagerModal) => {
6
+ return html`
7
+ <div class="container">
8
+ <!-- <div class="header">
9
+ <div class="title">
10
+ <div>${translate("importDataManager.title")}</div>
11
+ </div>
12
+ </div> -->
13
+ <div class="content" id="import-data-region"></div>
14
+ <div class="footer">
15
+ <dss-button label="${translate("importDataManager.actions.cancel")}" @click="${() => {
16
+ props.cancel();
17
+ }}" size="md" variant="secondary"></dss-button>
18
+ <dss-button label="${translate("importDataManager.actions.import")}" @click="${() => {
19
+ props._accept();
20
+ }}" size="md" variant="primary"></dss-button>
21
+ </div>
22
+ </div>
23
+ `;
24
+ };
@@ -0,0 +1,282 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { ImportDataManagerImpl } from './import-data-manager-impl';
3
+ import { PrimariaInteractionService, ConfirmationOptions, ConfirmComponentUI, ConfirmationResult } from '../interaction-service/interaction-service';
4
+
5
+ // Mock del PrimariaInteractionService
6
+ class MockInteractionService extends PrimariaInteractionService {
7
+ private mockConfirmResult: { confirmed: boolean; result?: unknown } = { confirmed: true };
8
+
9
+ // Mètode per configurar el resultat del mock
10
+ setMockConfirmResult(result: { confirmed: boolean; result?: unknown }) {
11
+ this.mockConfirmResult = result;
12
+ }
13
+
14
+ async confirm<TData = undefined, TResult = undefined>(
15
+ _data: TData | undefined,
16
+ _componentUI: ConfirmComponentUI<TData, TResult>,
17
+ _options?: ConfirmationOptions | undefined,
18
+ ): Promise<ConfirmationResult<TResult | undefined>> {
19
+ return Promise.resolve(this.mockConfirmResult as ConfirmationResult<TResult | undefined>);
20
+ }
21
+
22
+ async confirmMessage(
23
+ _message: string,
24
+ _options?: ConfirmationOptions | undefined,
25
+ ): Promise<ConfirmationResult> {
26
+ return Promise.resolve({ confirmed: this.mockConfirmResult.confirmed, result: undefined });
27
+ }
28
+ }
29
+
30
+ describe('ImportDataManagerImpl implements PrimariaImportDataManager', () => {
31
+ let importDataManager: ImportDataManagerImpl;
32
+ let mockInteractionService: MockInteractionService;
33
+
34
+ beforeEach(() => {
35
+ mockInteractionService = new MockInteractionService();
36
+ importDataManager = new ImportDataManagerImpl(mockInteractionService);
37
+ });
38
+
39
+ describe('getCurrentImporterId', () => {
40
+ it('should return empty string initially', () => {
41
+ expect(importDataManager.getCurrentImporterId()).toBe('');
42
+ });
43
+
44
+ it('should return the current importer ID after calling import', async () => {
45
+ mockInteractionService.setMockConfirmResult({ confirmed: true });
46
+
47
+ const promise = importDataManager.import('test-importer-123');
48
+ expect(importDataManager.getCurrentImporterId()).toBe('test-importer-123');
49
+
50
+ await promise;
51
+ expect(importDataManager.getCurrentImporterId()).toBe('');
52
+ });
53
+ });
54
+
55
+ describe('selectItems', () => {
56
+ it('should store selected items correctly', () => {
57
+ const payload = {
58
+ pluginId: 'test-plugin',
59
+ data: [{ id: '1', name: 'Test Item' }],
60
+ text: { raw: 'Test Item', html: '<p>Test Item</p>' }
61
+ };
62
+
63
+ importDataManager.selectItems(payload);
64
+
65
+ // Test via getCurrentImporterId and import method to verify internal state
66
+ expect(() => importDataManager.selectItems(payload)).not.toThrow();
67
+ });
68
+
69
+ it('should handle multiple plugin selections', () => {
70
+ const payload1 = {
71
+ pluginId: 'plugin-1',
72
+ data: [{ id: '1', name: 'Item 1' }],
73
+ text: { raw: 'Item 1', html: '<p>Item 1</p>' }
74
+ };
75
+
76
+ const payload2 = {
77
+ pluginId: 'plugin-2',
78
+ data: [{ id: '2', name: 'Item 2' }],
79
+ text: { raw: 'Item 2', html: '<p>Item 2</p>' }
80
+ };
81
+
82
+ expect(() => {
83
+ importDataManager.selectItems(payload1);
84
+ importDataManager.selectItems(payload2);
85
+ }).not.toThrow();
86
+ });
87
+
88
+ it('should overwrite previous selections from same plugin', () => {
89
+ const payload1 = {
90
+ pluginId: 'test-plugin',
91
+ data: [{ id: '1', name: 'First Item' }],
92
+ text: { raw: 'First Item', html: '<p>First Item</p>' }
93
+ };
94
+
95
+ const payload2 = {
96
+ pluginId: 'test-plugin',
97
+ data: [{ id: '2', name: 'Second Item' }],
98
+ text: { raw: 'Second Item', html: '<p>Second Item</p>' }
99
+ };
100
+
101
+ expect(() => {
102
+ importDataManager.selectItems(payload1);
103
+ importDataManager.selectItems(payload2);
104
+ }).not.toThrow();
105
+ });
106
+ });
107
+
108
+ describe('import', () => {
109
+ it('should return accepted result with concatenated text when confirmed', async () => {
110
+ mockInteractionService.setMockConfirmResult({ confirmed: true });
111
+
112
+ // Mock the import to allow setting up items during the import process
113
+ const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
114
+ vi.spyOn(mockInteractionService, 'confirm').mockImplementation(async (...args) => {
115
+ // Setup some selected items during the import process (simulating user interaction)
116
+ importDataManager.selectItems({
117
+ pluginId: 'plugin-1',
118
+ data: [{ id: '1', name: 'Item 1' }],
119
+ text: { raw: 'Item 1', html: '<p>Item 1</p>' }
120
+ });
121
+
122
+ importDataManager.selectItems({
123
+ pluginId: 'plugin-2',
124
+ data: [{ id: '2', name: 'Item 2' }],
125
+ text: { raw: 'Item 2', html: '<p>Item 2</p>' }
126
+ });
127
+
128
+ return originalConfirm(...args);
129
+ });
130
+
131
+ const result = await importDataManager.import('test-importer');
132
+
133
+ expect(result.accepted).toBe(true);
134
+ expect(result.data).toEqual({
135
+ 'plugin-1': [{ id: '1', name: 'Item 1' }],
136
+ 'plugin-2': [{ id: '2', name: 'Item 2' }]
137
+ });
138
+ expect(result.text.raw).toBe('Item 1\n\nItem 2');
139
+ expect(result.text.html).toBe('<p>Item 1</p><br><br><p>Item 2</p>');
140
+ });
141
+
142
+ it('should return cancelled result with empty data when not confirmed', async () => {
143
+ mockInteractionService.setMockConfirmResult({ confirmed: false });
144
+
145
+ // Setup some selected items
146
+ importDataManager.selectItems({
147
+ pluginId: 'plugin-1',
148
+ data: [{ id: '1', name: 'Item 1' }],
149
+ text: { raw: 'Item 1', html: '<p>Item 1</p>' }
150
+ });
151
+
152
+ const result = await importDataManager.import('test-importer');
153
+
154
+ expect(result.accepted).toBe(false);
155
+ expect(result.data).toEqual({});
156
+ expect(result.text.raw).toBe('');
157
+ expect(result.text.html).toBe('');
158
+ });
159
+
160
+ it('should clear state after successful import', async () => {
161
+ mockInteractionService.setMockConfirmResult({ confirmed: true });
162
+
163
+ // Setup selected items
164
+ importDataManager.selectItems({
165
+ pluginId: 'test-plugin',
166
+ data: [{ id: '1', name: 'Test Item' }],
167
+ text: { raw: 'Test Item', html: '<p>Test Item</p>' }
168
+ });
169
+
170
+ await importDataManager.import('test-importer');
171
+
172
+ // Verify state is cleared
173
+ expect(importDataManager.getCurrentImporterId()).toBe('');
174
+
175
+ // Verify that subsequent import returns empty data
176
+ const result = await importDataManager.import('another-importer');
177
+ expect(result.data).toEqual({});
178
+ expect(result.text.raw).toBe('');
179
+ expect(result.text.html).toBe('');
180
+ });
181
+
182
+ it('should clear state after cancelled import', async () => {
183
+ mockInteractionService.setMockConfirmResult({ confirmed: false });
184
+
185
+ // Setup selected items
186
+ importDataManager.selectItems({
187
+ pluginId: 'test-plugin',
188
+ data: [{ id: '1', name: 'Test Item' }],
189
+ text: { raw: 'Test Item', html: '<p>Test Item</p>' }
190
+ });
191
+
192
+ await importDataManager.import('test-importer');
193
+
194
+ // Verify state is cleared
195
+ expect(importDataManager.getCurrentImporterId()).toBe('');
196
+ });
197
+
198
+ it('should handle empty selections', async () => {
199
+ mockInteractionService.setMockConfirmResult({ confirmed: true });
200
+
201
+ const result = await importDataManager.import('test-importer');
202
+
203
+ expect(result.accepted).toBe(true);
204
+ expect(result.data).toEqual({});
205
+ expect(result.text.raw).toBe('');
206
+ expect(result.text.html).toBe('');
207
+ });
208
+
209
+ it('should handle error and clear state', async () => {
210
+ mockInteractionService.setMockConfirmResult({ confirmed: true });
211
+
212
+ // Mock the interaction service to throw an error
213
+ vi.spyOn(mockInteractionService, 'confirm').mockRejectedValueOnce(new Error('Test error'));
214
+
215
+ // Setup selected items
216
+ importDataManager.selectItems({
217
+ pluginId: 'test-plugin',
218
+ data: [{ id: '1', name: 'Test Item' }],
219
+ text: { raw: 'Test Item', html: '<p>Test Item</p>' }
220
+ });
221
+
222
+ await expect(importDataManager.import('test-importer')).rejects.toThrow('Test error');
223
+
224
+ // Verify state is cleared even after error
225
+ expect(importDataManager.getCurrentImporterId()).toBe('');
226
+ });
227
+
228
+ it('should handle text concatenation correctly with multiple plugins', async () => {
229
+ mockInteractionService.setMockConfirmResult({ confirmed: true });
230
+
231
+ // Mock the import to allow setting up items during the import process
232
+ const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
233
+ vi.spyOn(mockInteractionService, 'confirm').mockImplementation(async (...args) => {
234
+ importDataManager.selectItems({
235
+ pluginId: 'diagnostics',
236
+ data: [{ code: 'E11.9', name: 'Diabetes' }],
237
+ text: { raw: 'E11.9 - Diabetes', html: '<p><strong>E11.9</strong> - Diabetes</p>' }
238
+ });
239
+
240
+ importDataManager.selectItems({
241
+ pluginId: 'allergies',
242
+ data: [{ name: 'Penicillin', severity: 'High' }],
243
+ text: { raw: 'Penicillin - High severity', html: '<p><strong>Penicillin</strong> - High severity</p>' }
244
+ });
245
+
246
+ return originalConfirm(...args);
247
+ });
248
+
249
+ const result = await importDataManager.import('test-importer');
250
+
251
+ expect(result.text.raw).toBe('E11.9 - Diabetes\n\nPenicillin - High severity');
252
+ expect(result.text.html).toBe('<p><strong>E11.9</strong> - Diabetes</p><br><br><p><strong>Penicillin</strong> - High severity</p>');
253
+ });
254
+
255
+ it('should handle empty text values in concatenation', async () => {
256
+ mockInteractionService.setMockConfirmResult({ confirmed: true });
257
+
258
+ // Mock the import to allow setting up items during the import process
259
+ const originalConfirm = mockInteractionService.confirm.bind(mockInteractionService);
260
+ vi.spyOn(mockInteractionService, 'confirm').mockImplementation(async (...args) => {
261
+ importDataManager.selectItems({
262
+ pluginId: 'plugin-1',
263
+ data: [{ id: '1' }],
264
+ text: { raw: '', html: '' }
265
+ });
266
+
267
+ importDataManager.selectItems({
268
+ pluginId: 'plugin-2',
269
+ data: [{ id: '2' }],
270
+ text: { raw: 'Item 2', html: '<p>Item 2</p>' }
271
+ });
272
+
273
+ return originalConfirm(...args);
274
+ });
275
+
276
+ const result = await importDataManager.import('test-importer');
277
+
278
+ expect(result.text.raw).toBe('Item 2');
279
+ expect(result.text.html).toBe('<p>Item 2</p>');
280
+ });
281
+ });
282
+ });
@@ -0,0 +1,80 @@
1
+ import { PrimariaImportDataManager } from './import-data-manager';
2
+ import { PrimariaInteractionService } from '../interaction-service/interaction-service';
3
+
4
+ export class ImportDataManagerImpl implements PrimariaImportDataManager {
5
+ private selectedItems: Record<string, any[]> = {};
6
+ private currentImporterId = '';
7
+ private pluginTexts: Record<string, {raw: string, html: string}> = {};
8
+
9
+ constructor(private interactionService: PrimariaInteractionService) {}
10
+
11
+ async import(importerId: string): Promise<{
12
+ accepted: boolean;
13
+ data: Record<string, any[]>;
14
+ text: {raw: string, html: string};
15
+ }> {
16
+ this.currentImporterId = importerId;
17
+ this.selectedItems = {};
18
+ this.pluginTexts = {};
19
+
20
+ try {
21
+ // Import component dynamically to avoid circular dependency
22
+ const { ImportDataManagerModal } = await import("./component/component");
23
+
24
+ const { confirmed } = await this.interactionService.confirm(
25
+ undefined,
26
+ { component: ImportDataManagerModal as any },
27
+ {
28
+ fullCustomization: true,
29
+ },
30
+ );
31
+
32
+ const concatenatedText = this.getConcatenatedText();
33
+
34
+ const finalResult = {
35
+ accepted: confirmed,
36
+ data: confirmed ? this.selectedItems : {},
37
+ text: confirmed ? concatenatedText : {raw: '', html: ''}
38
+ };
39
+
40
+ this.selectedItems = {};
41
+ this.currentImporterId = '';
42
+ this.pluginTexts = {};
43
+
44
+ return finalResult;
45
+ } catch (error) {
46
+ this.selectedItems = {};
47
+ this.currentImporterId = '';
48
+ this.pluginTexts = {};
49
+ throw error;
50
+ }
51
+ }
52
+
53
+ selectItems(payload: {
54
+ pluginId: string,
55
+ data: any[],
56
+ text: {raw: string, html: string}
57
+ }): void {
58
+ this.selectedItems[payload.pluginId] = payload.data;
59
+ this.pluginTexts[payload.pluginId] = payload.text;
60
+ }
61
+
62
+ getCurrentImporterId(): string {
63
+ return this.currentImporterId;
64
+ }
65
+
66
+ private getConcatenatedText(): {raw: string, html: string} {
67
+ const rawTexts: string[] = [];
68
+ const htmlTexts: string[] = [];
69
+
70
+ for (const text of Object.values(this.pluginTexts)) {
71
+ if (text.raw) rawTexts.push(text.raw);
72
+ if (text.html) htmlTexts.push(text.html);
73
+ }
74
+
75
+ return {
76
+ raw: rawTexts.join('\n\n'),
77
+ html: htmlTexts.join('<br><br>')
78
+ };
79
+ }
80
+ }
@@ -0,0 +1,15 @@
1
+ export interface PrimariaImportDataManager {
2
+ import(importerId: string): Promise<{
3
+ accepted: boolean;
4
+ data: Record<string, any[]>;
5
+ text: {raw: string, html: string};
6
+ }>;
7
+
8
+ selectItems(payload: {
9
+ pluginId: string,
10
+ data: any[],
11
+ text: {raw: string, html: string}
12
+ }): void;
13
+
14
+ getCurrentImporterId(): string;
15
+ }
@@ -0,0 +1,2 @@
1
+ export * from './import-data-manager';
2
+ export * from './import-data-manager-impl';
@@ -7,6 +7,7 @@ export const shellRegions = {
7
7
  quickActions: "quick-actions-region",
8
8
  floating: "floating-region",
9
9
  communicationSidenav: "communication-sidenav-region",
10
+ importData: "import-data-region",
10
11
  };
11
12
 
12
13
  export const clinicalMonitoringRegions = {