@uxland/primary-shell 5.3.3 → 5.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 (55) hide show
  1. package/dist/index.js +6334 -6231
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.umd.cjs +444 -435
  4. package/dist/index.umd.cjs.map +1 -1
  5. package/dist/primary/shell/src/UI/internal-views/lower-nav-menu-views.d.ts +1 -0
  6. package/dist/primary/shell/src/UI/internal-views/upper-nav-views.d.ts +1 -0
  7. package/dist/primary/shell/src/api/ecap-event-manager/ecap-event-manager.d.ts +2 -2
  8. package/dist/primary/shell/src/disposer.d.ts +1 -0
  9. package/dist/primary/shell/src/features/exit/handler.d.ts +2 -1
  10. package/dist/primary/shell/src/features/exit/request.d.ts +2 -0
  11. package/dist/primary/shell/src/features/get-user-info/backend-adapter.d.ts +1 -0
  12. package/dist/primary/shell/src/features/visit/finalize-visit/bootstrapper.d.ts +4 -0
  13. package/dist/primary/shell/src/features/visit/finalize-visit/component/finalize-visit-button.d.ts +9 -0
  14. package/dist/primary/shell/src/features/visit/finalize-visit/component/template.d.ts +3 -0
  15. package/dist/primary/shell/src/features/visit/finalize-visit/handler.d.ts +8 -0
  16. package/dist/primary/shell/src/features/visit/finalize-visit/request.d.ts +4 -0
  17. package/dist/primary/shell/src/features/visit/get-visit-id/bootstrapper.d.ts +4 -0
  18. package/dist/primary/shell/src/features/visit/get-visit-id/handler.d.ts +9 -0
  19. package/dist/primary/shell/src/features/visit/get-visit-id/request.d.ts +2 -0
  20. package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/domain/business-rules.d.ts +2 -1
  21. package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/domain/model.d.ts +9 -1
  22. package/dist/primary/shell/src/locales.d.ts +1 -0
  23. package/package.json +4 -4
  24. package/src/UI/bootstrapper.ts +2 -0
  25. package/src/UI/components/bootstrapper.ts +2 -0
  26. package/src/UI/components/primaria-shell/shell-header/template.ts +2 -1
  27. package/src/UI/internal-views/handle-views.ts +13 -0
  28. package/src/UI/internal-views/lower-nav-menu-views.ts +19 -0
  29. package/src/UI/internal-views/upper-nav-views.ts +200 -0
  30. package/src/api/ecap-event-manager/ecap-event-manager.ts +3 -3
  31. package/src/bootstrapper.ts +0 -2
  32. package/src/disposer.ts +4 -0
  33. package/src/features/bootstrapper.ts +6 -0
  34. package/src/features/exit/handler.ts +12 -4
  35. package/src/features/exit/request.ts +3 -1
  36. package/src/features/get-user-info/backend-adapter.ts +14 -3
  37. package/src/features/visit/finalize-visit/bootstrapper.ts +17 -0
  38. package/src/features/visit/finalize-visit/component/finalize-visit-button.ts +36 -0
  39. package/src/features/visit/finalize-visit/component/template.ts +9 -0
  40. package/src/features/visit/finalize-visit/handler.ts +18 -0
  41. package/src/features/visit/finalize-visit/request.ts +3 -0
  42. package/src/features/visit/get-visit-id/bootstrapper.ts +17 -0
  43. package/src/features/visit/get-visit-id/handler.ts +27 -0
  44. package/src/features/visit/get-visit-id/request.ts +1 -0
  45. package/src/internal-plugins/activity-history/activity-history-item/domain/business-rules.ts +25 -1
  46. package/src/internal-plugins/activity-history/activity-history-item/domain/is-valid-history-item/is-valid-history-item.test.ts +48 -6
  47. package/src/internal-plugins/activity-history/activity-history-item/domain/is-valid-history-item/is-valid-history-item.ts +13 -7
  48. package/src/internal-plugins/activity-history/activity-history-item/domain/model.ts +10 -1
  49. package/src/internal-plugins/activity-history/activity-history-item/list/UI/timeline/activity-history-timeline.ts +20 -3
  50. package/src/internal-plugins/activity-history/activity-history-item/list/UI/timeline/styles.css +8 -4
  51. package/src/internal-plugins/activity-history/activity-history-item/list/UI/timeline/template.ts +10 -10
  52. package/src/internal-plugins/activity-history/activity-history-item/list/group-history-items/group-history-items.ts +7 -4
  53. package/src/locales.ts +1 -0
  54. package/src/handle-views.ts +0 -255
  55. /package/dist/primary/shell/src/{handle-views.d.ts → UI/internal-views/handle-views.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ export declare const registerLowerNavMenuViews: () => void;
@@ -0,0 +1 @@
1
+ export declare const registerUpperNavMenuViews: () => void;
@@ -5,10 +5,10 @@ export declare abstract class EcapEventManager {
5
5
  * @param eventType - Event type.
6
6
  * @param url - Asociated URL to event.
7
7
  */
8
- abstract publish(eventType: string, accio: string, payload: Record<string, string>): void;
8
+ abstract publish(eventType: string, accio: string, payload?: Record<string, string>): void;
9
9
  }
10
10
  declare class EcapEventManagerImpl implements EcapEventManager {
11
- publish(eventType: string, accio: string, payload: Record<string, string>): void;
11
+ publish(eventType: string, accio: string, payload?: Record<string, string>): void;
12
12
  private createEcapEvent;
13
13
  private raiseEcapEvent;
14
14
  }
@@ -1,2 +1,3 @@
1
1
  export declare const disposeShell: () => void;
2
2
  export declare const raiseCloseEvent: () => void;
3
+ export declare const raiseCustomCloseEvent: (event: string) => void;
@@ -4,7 +4,8 @@ import { ExitShell } from './request';
4
4
  export declare class ExitShellHandler {
5
5
  private api;
6
6
  constructor(api: PrimariaApi);
7
- handle(message: ExitShell): Promise<void>;
7
+ handle({ ecapEvent }: ExitShell): Promise<void>;
8
8
  private askForClose;
9
9
  private timeout;
10
+ private emitClose;
10
11
  }
@@ -1,4 +1,6 @@
1
1
  import { IRequest } from '../..';
2
2
 
3
3
  export declare class ExitShell implements IRequest<void> {
4
+ ecapEvent?: string | undefined;
5
+ constructor(ecapEvent?: string | undefined);
4
6
  }
@@ -8,4 +8,5 @@ export declare class GetUserInfoBackendAdapter implements UserInfoBackendAdapter
8
8
  private api;
9
9
  constructor(api: typeof shellApi);
10
10
  getUserInfo(): Promise<IUserInfo>;
11
+ getUserId(access_info: any): any;
11
12
  }
@@ -0,0 +1,4 @@
1
+ import { PrimariaApi } from '../../../api/api';
2
+
3
+ export declare const useFinalizeVisit: (api: PrimariaApi) => void;
4
+ export declare const disposeFinalizeVisit: () => void;
@@ -0,0 +1,9 @@
1
+ import { LitElement } from 'lit';
2
+
3
+ export declare class FinalizeVisitButton extends LitElement {
4
+ render(): import('lit').TemplateResult<1>;
5
+ connectedCallback(): void;
6
+ visitId: string | undefined;
7
+ getVisitId(): Promise<void>;
8
+ finalizeVisitHandler(): void;
9
+ }
@@ -0,0 +1,3 @@
1
+ import { FinalizeVisitButton } from './finalize-visit-button';
2
+
3
+ export declare const template: (props: FinalizeVisitButton) => import('lit').TemplateResult<1>;
@@ -0,0 +1,8 @@
1
+ import { PrimariaApi } from '../../../api/api';
2
+ import { FinalizeVisit } from './request';
3
+
4
+ export declare class FinalizeVisitHandler {
5
+ private api;
6
+ constructor(api: PrimariaApi);
7
+ handle(data: FinalizeVisit): Promise<void>;
8
+ }
@@ -0,0 +1,4 @@
1
+ export declare class FinalizeVisit {
2
+ visitId: string;
3
+ constructor(visitId: string);
4
+ }
@@ -0,0 +1,4 @@
1
+ import { PrimariaApi } from '../../../api/api';
2
+
3
+ export declare const useGetVisitId: (api: PrimariaApi) => void;
4
+ export declare const disposeGetVisitId: () => void;
@@ -0,0 +1,9 @@
1
+ import { PrimariaApi } from '../../../api/api';
2
+ import { GetVisitId } from './request';
3
+
4
+ export declare class GetVisitIdHandler {
5
+ private api;
6
+ constructor(api: PrimariaApi);
7
+ handle(message: GetVisitId): Promise<string | undefined>;
8
+ private getVisitId;
9
+ }
@@ -0,0 +1,2 @@
1
+ export declare class GetVisitId {
2
+ }
@@ -1,3 +1,4 @@
1
- import { IActivityHistoryItem } from './model';
1
+ import { IActivityHistoryItem, IActivityHistoryItemWithComponent } from './model';
2
2
 
3
3
  export declare function shouldShowRole(item: IActivityHistoryItem): boolean;
4
+ export declare const hasItemDivider: (item: IActivityHistoryItemWithComponent, items: IActivityHistoryItemWithComponent[]) => boolean;
@@ -8,12 +8,20 @@ export interface IErrorHistoryItem {
8
8
  message: string;
9
9
  }
10
10
  export type TSearchActivityHistoryItemPredicate = (searchString: string, item: IActivityHistoryItem) => boolean;
11
+ export interface IActivityHistoryDiagnostic {
12
+ codi: string;
13
+ cataleg: string;
14
+ descripcio: string;
15
+ idEcap: string;
16
+ idCipds: string;
17
+ idCdr: string;
18
+ }
11
19
  export interface IActivityHistoryItem {
12
20
  id: string;
13
21
  date: string;
14
22
  professional: IOwner;
15
23
  relevant: boolean;
16
- diagnostics: IEntityDescription[];
24
+ diagnostics: IActivityHistoryDiagnostic[];
17
25
  center: IEntityDescription;
18
26
  up: IEntityDescription;
19
27
  ep: IEntityDescription;
@@ -18,6 +18,7 @@ export declare const locales: {
18
18
  toggleMenuClose: string;
19
19
  toggleMenuOpen: string;
20
20
  askExit: string;
21
+ finalizeVisit: string;
21
22
  };
22
23
  clinicalMonitoring: {
23
24
  title: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "5.3.3",
3
+ "version": "5.3.5",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -25,14 +25,13 @@
25
25
  "url": "https://github.com/uxland/harmonix/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@lit-labs/virtualizer": "^2.1.0",
29
28
  "@uxland/harmonix": "^1.0.5",
30
29
  "@uxland/harmonix-adapters": "^1.0.1"
31
30
  },
32
31
  "devDependencies": {
33
32
  "@primaria/plugins-core": "^1.0.14",
34
33
  "@reduxjs/toolkit": "^2.6.1",
35
- "@salut/design-system-salut": "../../design-system-salut-2.4.0.tgz",
34
+ "@salut/design-system-salut": "../../design-system-salut-2.4.1.tgz",
36
35
  "@types/react": "^19.0.12",
37
36
  "@uxland/lit-utilities": "^1.0.0",
38
37
  "@uxland/localization": "^1.0.3",
@@ -52,7 +51,8 @@
52
51
  "reflect-metadata": "^0.2.2",
53
52
  "tslib": "^2.3.0",
54
53
  "uxl-quill": "^1.0.1",
55
- "vite": "^5.2.8"
54
+ "vite": "^5.2.8",
55
+ "@lit-labs/virtualizer": "^2.1.0"
56
56
  },
57
57
  "scripts": {
58
58
  "serve": "vite",
@@ -1,6 +1,7 @@
1
1
  import { regionAdapterRegistry, selectableAdapterFactory } from "@uxland/regions";
2
2
  import { useComponents } from "./components/bootstrapper";
3
3
  import { useSharedUI } from "./shared-components/bootstrapper";
4
+ import { useInternalViews } from "./internal-views/handle-views";
4
5
 
5
6
  export const useUI = () => {
6
7
  regionAdapterRegistry.registerAdapterFactory(
@@ -9,4 +10,5 @@ export const useUI = () => {
9
10
  );
10
11
  useSharedUI();
11
12
  useComponents();
13
+ useInternalViews();
12
14
  };
@@ -4,6 +4,7 @@ import { PrimariaErrorView } from "./error-view/component";
4
4
  import { QuickActionsMenu } from "./quick-actions-menu/quick-actions-menu";
5
5
  import { PrimariaShellHeader } from "./primaria-shell/shell-header/shell-header";
6
6
  import { PocEventsEcap } from "./poc-events-ecap/poc-events-ecap";
7
+ import { FinalizeVisitButton } from "../../features/visit/finalize-visit/component/finalize-visit-button";
7
8
 
8
9
  export const useComponents = () => {
9
10
  //@ts-ignore
@@ -12,6 +13,7 @@ export const useComponents = () => {
12
13
  customElement("primaria-shell-header")(PrimariaShellHeader);
13
14
  customElement("primaria-error-view")(PrimariaErrorView);
14
15
  customElement("quick-actions-menu")(QuickActionsMenu);
16
+ customElement("finalize-visit-button")(FinalizeVisitButton);
15
17
  //@ts-ignore
16
18
  customElement("poc-events-ecap")(PocEventsEcap);
17
19
  };
@@ -1,4 +1,4 @@
1
- import { html } from "lit";
1
+ import { html, nothing } from "lit";
2
2
  import salutLogo from "../../../../UI/images/Salut_Logotip.svg";
3
3
  import { PrimariaShellHeader } from "./shell-header";
4
4
  import { when } from "lit/directives/when.js";
@@ -18,6 +18,7 @@ export const template = (props: PrimariaShellHeader) => {
18
18
  <div id="header-region-container"></div>
19
19
  </div>
20
20
  <div class="header__right">
21
+ <finalize-visit-button></finalize-visit-button>
21
22
  <div id="header-actions-region-container"></div>
22
23
  ${when(
23
24
  props.professional,
@@ -0,0 +1,13 @@
1
+ import { registerPDFVisorMainView } from "../../api/pdf-viewer-manager/handle-views";
2
+ import { registerLowerNavMenuViews } from "./lower-nav-menu-views";
3
+ import { registerUpperNavMenuViews } from "./upper-nav-views";
4
+
5
+ const registerMainViews = () => {
6
+ registerPDFVisorMainView();
7
+ };
8
+
9
+ export const useInternalViews = () => {
10
+ registerMainViews();
11
+ registerUpperNavMenuViews();
12
+ registerLowerNavMenuViews();
13
+ };
@@ -0,0 +1,19 @@
1
+ import { shellApi } from "../../api/api";
2
+ import { shellRegions } from "../../api/region-manager/regions";
3
+ import { PrimariaNavItem } from "../shared-components/primaria-nav-item/primaria-nav-item";
4
+
5
+ export const registerLowerNavMenuViews = () => {
6
+ shellApi.regionManager.registerView(shellRegions.navigationLowerLeftMenu, {
7
+ id: "configuration-center",
8
+ factory: () => {
9
+ const menuItem = new PrimariaNavItem({
10
+ icon: "settings",
11
+ label: "Centre de configuració",
12
+ callbackFn: () => {
13
+ // shellApi.regionManager.activateView(shellRegions.main, "");
14
+ },
15
+ });
16
+ return Promise.resolve(menuItem);
17
+ },
18
+ });
19
+ };
@@ -0,0 +1,200 @@
1
+ import { shellApi } from "../../api/api";
2
+ import { shellRegions } from "../../api/region-manager/regions";
3
+ import { ExitShell } from "../../features/exit/request";
4
+ import { getPatientCip } from "../../features/get-patient-cip/action";
5
+ import { navigateToEcapWithoutClosingWithCip } from "../../features/navigate-to-ecap/navigate-without-closing-and-with-cip";
6
+ import { PrimariaNavItem } from "../shared-components/primaria-nav-item/primaria-nav-item";
7
+ import { PrimariaNavTreeMenu } from "../shared-components/primaria-nav-tree-menu/primaria-nav-tree-menu";
8
+
9
+ type MenuItemConfig =
10
+ | {
11
+ id: string;
12
+ sortHint?: string;
13
+ icon: string;
14
+ label: string;
15
+ type: "item";
16
+ callbackFn: () => void | Promise<void>;
17
+ }
18
+ | {
19
+ id: string;
20
+ sortHint?: string;
21
+ icon: string;
22
+ label: string;
23
+ type: "tree";
24
+ actionMenuItems: {
25
+ icon: string;
26
+ label: string;
27
+ callbackFn: () => void | Promise<void>;
28
+ }[];
29
+ };
30
+
31
+ const upperNavMenuItems: MenuItemConfig[] = [
32
+ {
33
+ id: "landing",
34
+ icon: "home",
35
+ label: "Pàgina inici",
36
+ type: "item",
37
+ sortHint: "0010",
38
+ callbackFn: () => shellApi.broker.send(new ExitShell("OBRIR_PI")),
39
+ },
40
+ {
41
+ id: "processes",
42
+ icon: "account_tree",
43
+ label: "Vies clíniques",
44
+ type: "tree",
45
+ sortHint: "0040",
46
+ actionMenuItems: [
47
+ {
48
+ icon: "open_in_new",
49
+ label: "ARES",
50
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("PROCES_ATENCIO"),
51
+ },
52
+ {
53
+ icon: "open_in_new",
54
+ label: "Procés Obstètric",
55
+ callbackFn: () => {},
56
+ },
57
+ {
58
+ icon: "open_in_new",
59
+ label: "Nen sa",
60
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("NEN_SA"),
61
+ },
62
+ {
63
+ icon: "open_in_new",
64
+ label: "Odontologia",
65
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("ODONTOLOGO"),
66
+ },
67
+ {
68
+ icon: "open_in_new",
69
+ label: "Situació d'especial cura",
70
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("SIT_ESPEC_CURA_DEV"),
71
+ },
72
+ ],
73
+ },
74
+ {
75
+ id: "unique-petition",
76
+ icon: "playlist_add",
77
+ label: "Petitori",
78
+ type: "tree",
79
+ sortHint: "0050",
80
+ actionMenuItems: [
81
+ {
82
+ icon: "open_in_new",
83
+ label: "Analítiques",
84
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("LABORATORI"),
85
+ },
86
+ {
87
+ icon: "open_in_new",
88
+ label: "Ordres Clíniques",
89
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("RESULT_OC"),
90
+ },
91
+ {
92
+ icon: "open_in_new",
93
+ label: "OC Exprés",
94
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("OC_EXPRES"),
95
+ },
96
+ {
97
+ icon: "open_in_new",
98
+ label: "Sol·licitud de trasllat",
99
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("TRANSPORT"),
100
+ },
101
+ ],
102
+ },
103
+ {
104
+ id: "results-reports",
105
+ icon: "folder_shared",
106
+ label: "Documents",
107
+ type: "tree",
108
+ sortHint: "0070",
109
+ actionMenuItems: [
110
+ {
111
+ icon: "open_in_new",
112
+ label: "Resultats i informes ECAP",
113
+ callbackFn: () => {},
114
+ },
115
+ {
116
+ icon: "open_in_new",
117
+ label: "Documents usuari",
118
+ callbackFn: () =>
119
+ setTimeout(() => {
120
+ navigateToEcapWithoutClosingWithCip("CRIDA_DOCS_USU");
121
+ }, 0),
122
+ },
123
+ ],
124
+ },
125
+ {
126
+ id: "communication",
127
+ icon: "3p",
128
+ label: "Comunicació",
129
+ type: "tree",
130
+ sortHint: "0120",
131
+ actionMenuItems: [
132
+ {
133
+ icon: "open_in_new",
134
+ label: "SMS",
135
+ callbackFn: async () => {
136
+ const CIP = await getPatientCip(shellApi);
137
+ shellApi.ecapEventManager.publish("MISSATGES_DEV", "NO_TANCAR", {
138
+ CIP: CIP || "",
139
+ TipusMissatge: "SMS",
140
+ });
141
+ },
142
+ },
143
+ { icon: "open_in_new", label: "Econsulta", callbackFn: () => {} },
144
+ { icon: "open_in_new", label: "Mail", callbackFn: () => {} },
145
+ {
146
+ icon: "open_in_new",
147
+ label: "Veu IP",
148
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("VOIP"),
149
+ },
150
+ { icon: "open_in_new", label: "Videoconsulta", callbackFn: () => {} },
151
+ ],
152
+ },
153
+ {
154
+ id: "visits",
155
+ icon: "event",
156
+ label: "Visites",
157
+ type: "item",
158
+ sortHint: "0130",
159
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("CONSULTA_VISITES"),
160
+ },
161
+ {
162
+ id: "it",
163
+ icon: "add_box",
164
+ label: "IT",
165
+ type: "item",
166
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("REV_IT"),
167
+ },
168
+ {
169
+ id: "variable activities",
170
+ icon: "add_box",
171
+ label: "Activitats variables",
172
+ type: "item",
173
+ callbackFn: () => navigateToEcapWithoutClosingWithCip("SIA_DEV"),
174
+ },
175
+ ];
176
+
177
+ export const registerUpperNavMenuViews = () => {
178
+ for (const item of upperNavMenuItems) {
179
+ shellApi.regionManager.registerView(shellRegions.navigationMenu, {
180
+ id: item.id,
181
+ sortHint: item.sortHint,
182
+ factory: () => {
183
+ const menuItem =
184
+ item.type === "item"
185
+ ? new PrimariaNavItem({
186
+ icon: item.icon,
187
+ label: item.label,
188
+ callbackFn: item.callbackFn,
189
+ })
190
+ : new PrimariaNavTreeMenu({
191
+ icon: item.icon,
192
+ label: item.label,
193
+ actionMenuItems: item.actionMenuItems,
194
+ });
195
+
196
+ return Promise.resolve(menuItem);
197
+ },
198
+ });
199
+ }
200
+ };
@@ -7,12 +7,12 @@ export abstract class EcapEventManager {
7
7
  * @param eventType - Event type.
8
8
  * @param url - Asociated URL to event.
9
9
  */
10
- abstract publish(eventType: string, accio: string, payload: Record<string, string>): void;
10
+ abstract publish(eventType: string, accio: string, payload?: Record<string, string>): void;
11
11
  }
12
12
 
13
13
  class EcapEventManagerImpl implements EcapEventManager {
14
- publish(eventType: string, accio: string, payload: Record<string, string>) {
15
- const ecapEvent = this.createEcapEvent(eventType, accio, payload);
14
+ publish(eventType: string, accio: string, payload?: Record<string, string>) {
15
+ const ecapEvent = this.createEcapEvent(eventType, accio, payload ?? {});
16
16
  this.raiseEcapEvent(ecapEvent);
17
17
  }
18
18
 
@@ -1,14 +1,12 @@
1
1
  import { PrimariaShell } from "./UI/components/primaria-shell/primaria-shell";
2
2
  import { shellApi } from "./api/api";
3
3
  import { useFeatures } from "./features/bootstrapper";
4
- import { useInternalViews } from "./handle-views";
5
4
  import { useLocalization } from "./locales";
6
5
  import { useUI } from "./UI/bootstrapper";
7
6
 
8
7
  export const initializeShell = (hostAppElement: HTMLElement) => {
9
8
  useLocalization(shellApi);
10
9
  useUI();
11
- useInternalViews();
12
10
  useFeatures(shellApi);
13
11
  const shell = new PrimariaShell();
14
12
  hostAppElement.appendChild(shell as any);
package/src/disposer.ts CHANGED
@@ -7,3 +7,7 @@ export const disposeShell = () => {
7
7
  export const raiseCloseEvent = () => {
8
8
  shellApi.ecapEventManager.publish("CLOSE_FORM", "", {});
9
9
  };
10
+
11
+ export const raiseCustomCloseEvent = (event: string) => {
12
+ shellApi.ecapEventManager.publish(event, "", {});
13
+ };
@@ -9,11 +9,15 @@ import {
9
9
  disposeClinicalMonitoring,
10
10
  useClinicalMonitoring,
11
11
  } from "./clinical-monitoring/bootstrapper";
12
+ import { disposeGetVisitId, useGetVisitId } from "./visit/get-visit-id/bootstrapper";
13
+ import { disposeFinalizeVisit, useFinalizeVisit } from "./visit/finalize-visit/bootstrapper";
12
14
 
13
15
  export const useFeatures = (api: PrimariaApi) => {
14
16
  container.bind(TYPES.primaryApi).toConstantValue(api);
15
17
  useGetUserInfo(api);
16
18
  useExitShell(api);
19
+ useGetVisitId(api);
20
+ useFinalizeVisit(api);
17
21
  useClinicalMonitoring(api);
18
22
  api.broker.send(new GetUserInfo());
19
23
  };
@@ -21,6 +25,8 @@ export const useFeatures = (api: PrimariaApi) => {
21
25
  export const disposeFeatures = (api: PrimariaApi) => {
22
26
  disposeGetUserInfo();
23
27
  disposeExitShell();
28
+ disposeGetVisitId();
29
+ disposeFinalizeVisit();
24
30
  disposeClinicalMonitoring(api);
25
31
  container.unbindAll();
26
32
  api.regionManager._destroy();
@@ -2,7 +2,7 @@ import { PrimariaApi } from "@uxland/primary-shell";
2
2
  import { TYPES } from "../../infrastructure/ioc/types";
3
3
  import { inject } from "inversify";
4
4
  import { ExitShell } from "./request";
5
- import { disposeShell, raiseCloseEvent } from "../../disposer";
5
+ import { disposeShell, raiseCloseEvent, raiseCustomCloseEvent } from "../../disposer";
6
6
  import { disposePlugins } from "../../handle-plugins";
7
7
  import { PluginBusyTask } from "../../api/plugin-busy-manager/plugin-busy-manager";
8
8
  import { PluginBusyList } from "../../api/plugin-busy-manager/plugin-busy-list/component";
@@ -10,7 +10,7 @@ import { translate } from "../../locales";
10
10
 
11
11
  export class ExitShellHandler {
12
12
  constructor(@inject(TYPES.primaryApi) private api: PrimariaApi) {}
13
- async handle(message: ExitShell): Promise<void> {
13
+ async handle({ ecapEvent }: ExitShell): Promise<void> {
14
14
  try {
15
15
  const busyTasks = this.api.pluginBusyManager.getBusyPluginTasks();
16
16
  if (busyTasks.length > 0) {
@@ -24,10 +24,10 @@ export class ExitShellHandler {
24
24
  this.timeout(5000), // Si passen 5s, es segueix amb l'execució
25
25
  ]);
26
26
  disposeShell();
27
- raiseCloseEvent();
27
+ this.emitClose(ecapEvent);
28
28
  } catch (error) {
29
29
  this.api.notificationService.error(error.message);
30
- raiseCloseEvent();
30
+ this.emitClose(ecapEvent);
31
31
  }
32
32
  }
33
33
 
@@ -43,4 +43,12 @@ export class ExitShellHandler {
43
43
  private timeout(ms: number) {
44
44
  return new Promise<void>((resolve) => setTimeout(resolve, ms));
45
45
  }
46
+
47
+ private emitClose(ecapEvent?: string): void {
48
+ if (ecapEvent) {
49
+ raiseCustomCloseEvent(ecapEvent);
50
+ } else {
51
+ raiseCloseEvent();
52
+ }
53
+ }
46
54
  }
@@ -1,3 +1,5 @@
1
1
  import { IRequest } from "@uxland/primary-shell";
2
2
 
3
- export class ExitShell implements IRequest<void> {}
3
+ export class ExitShell implements IRequest<void> {
4
+ constructor(public ecapEvent?: string) {}
5
+ }
@@ -11,14 +11,14 @@ export abstract class UserInfoBackendAdapter {
11
11
  export class GetUserInfoBackendAdapter implements UserInfoBackendAdapter {
12
12
  constructor(@inject(TYPES.primaryApi) private api: typeof shellApi) {}
13
13
  getUserInfo(): Promise<IUserInfo> {
14
- const decodedToken = jwtDecode(this.api.tokenManager.getToken())
14
+ const decodedToken = jwtDecode(this.api.tokenManager.getToken());
15
15
  const userInfo: IUserInfo = {
16
- userId: decodedToken.access_info.trace_user_id,
16
+ userId: this.getUserId(decodedToken.access_info),
17
17
  firstName: decodedToken.access_info.trace_user_given_name,
18
18
  familyName: decodedToken.access_info.trace_user_family_name,
19
19
  lastName: decodedToken.access_info.trace_user_last_name,
20
20
  registrationNumber: decodedToken.access_info.identifier.find(
21
- (id: { type: string; value: string }) => id.type === "NUMCOL"
21
+ (id: { type: string; value: string }) => id.type === "NUMCOL",
22
22
  )?.value,
23
23
  workCenter: decodedToken.access_info.center_code,
24
24
  role: decodedToken.access_info.role_type,
@@ -26,4 +26,15 @@ export class GetUserInfoBackendAdapter implements UserInfoBackendAdapter {
26
26
  };
27
27
  return Promise.resolve(userInfo);
28
28
  }
29
+
30
+ getUserId(access_info) {
31
+ return (
32
+ access_info.identifier?.find(
33
+ (identifierItem: { type: string; value: string }) => identifierItem.type === "DNI",
34
+ )?.value ||
35
+ access_info.identifier?.find(
36
+ (identifierItem: { type: string; value: string }) => identifierItem.type === "NIE",
37
+ )?.value
38
+ );
39
+ }
29
40
  }
@@ -0,0 +1,17 @@
1
+ import { PrimariaApi } from "../../../api/api";
2
+ import { BrokerDisposableHandler } from "../../../api/broker/primaria-broker";
3
+ import { container } from "../../../infrastructure/ioc/container";
4
+ import { registerRequest } from "../../utils";
5
+ import { FinalizeVisitHandler } from "./handler";
6
+ import { FinalizeVisit } from "./request";
7
+
8
+ let request: BrokerDisposableHandler;
9
+
10
+ export const useFinalizeVisit = (api: PrimariaApi) => {
11
+ disposeFinalizeVisit();
12
+ request = registerRequest(api, container)(FinalizeVisit, FinalizeVisitHandler);
13
+ };
14
+
15
+ export const disposeFinalizeVisit = () => {
16
+ request?.dispose();
17
+ };