@uxland/primary-shell 2.1.0 → 2.1.2
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.
- package/dist/UI/components/patient-header/patient-header.d.ts +9 -0
- package/dist/UI/components/patient-header/template.d.ts +3 -0
- package/dist/UI/components/professional-header/professional-header.d.ts +9 -0
- package/dist/UI/components/professional-header/template.d.ts +3 -0
- package/dist/api/api.d.ts +2 -6
- package/dist/api/http-client/http-client.d.ts +6 -0
- package/dist/features/bootstrapper.d.ts +4 -0
- package/dist/features/get-patient-info/backend-adapter.d.ts +9 -0
- package/dist/features/get-patient-info/bootstrapper.d.ts +2 -0
- package/dist/features/get-patient-info/handler.d.ts +11 -0
- package/dist/features/get-patient-info/model.d.ts +7 -0
- package/dist/features/get-patient-info/request.d.ts +5 -0
- package/dist/features/get-user-info/backend-adapter.d.ts +9 -0
- package/dist/features/get-user-info/bootstrapper.d.ts +2 -0
- package/dist/features/get-user-info/handler.d.ts +11 -0
- package/dist/features/get-user-info/model.d.ts +8 -0
- package/dist/features/get-user-info/request.d.ts +5 -0
- package/dist/features/utils.d.ts +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12046 -7727
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +413 -359
- package/dist/index.umd.cjs.map +1 -1
- package/dist/infrastructure/ioc/container.d.ts +7 -0
- package/dist/infrastructure/ioc/types.d.ts +5 -0
- package/package.json +8 -3
- package/src/UI/components/index.ts +2 -0
- package/src/UI/components/patient-header/patient-header.ts +28 -0
- package/src/UI/components/patient-header/styles.scss +25 -0
- package/src/UI/components/patient-header/template.ts +18 -0
- package/src/UI/components/primaria-shell/template.ts +2 -0
- package/src/UI/components/professional-header/professional-header.ts +27 -0
- package/src/UI/components/professional-header/styles.scss +25 -0
- package/src/UI/components/professional-header/template.ts +18 -0
- package/src/UI/shared-components/primaria-interaction/components/notifier-component.ts +2 -2
- package/src/api/api.ts +3 -13
- package/src/api/broker/factory.test.ts +8 -3
- package/src/api/broker/factory.ts +3 -0
- package/src/api/global-state/global-state.test.ts +1 -1
- package/src/api/global-state/global-state.ts +1 -1
- package/src/api/http-client/http-client.ts +14 -0
- package/src/features/bootstrapper.ts +16 -0
- package/src/features/get-patient-info/backend-adapter.ts +24 -0
- package/src/features/get-patient-info/bootstrapper.ts +17 -0
- package/src/features/get-patient-info/handler.ts +25 -0
- package/src/features/get-patient-info/model.ts +7 -0
- package/src/features/get-patient-info/request.ts +4 -0
- package/src/features/get-user-info/backend-adapter.ts +24 -0
- package/src/features/get-user-info/bootstrapper.ts +17 -0
- package/src/features/get-user-info/handler.ts +26 -0
- package/src/features/get-user-info/model.ts +8 -0
- package/src/features/get-user-info/request.ts +4 -0
- package/src/features/utils.ts +20 -0
- package/src/index.ts +1 -0
- package/src/infrastructure/ioc/container.ts +14 -0
- package/src/infrastructure/ioc/types.ts +5 -0
- package/src/initializer.ts +12 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Container } from 'inversify';
|
|
2
|
+
|
|
3
|
+
declare const container: Container;
|
|
4
|
+
declare const lazyInject: (serviceIdentifier: string | symbol | import("inversify").interfaces.Newable<any> | import("inversify").interfaces.Abstract<any>) => (proto: any, key: string) => void;
|
|
5
|
+
export { container, lazyInject };
|
|
6
|
+
export declare const registerDep: (dep: any) => void;
|
|
7
|
+
export declare const unregisterDep: (dep: any) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxland/primary-shell",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Primaria Shell",
|
|
5
5
|
"author": "UXLand <dev@uxland.es>",
|
|
6
6
|
"homepage": "https://github.com/uxland/harmonix/tree/app#readme",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/uxland/harmonix/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@uxland/harmonix": "^1.0.0"
|
|
28
|
+
"@uxland/harmonix": "^1.0.0",
|
|
29
|
+
"axios": "^1.7.2"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"lit": "^3.1.0",
|
|
@@ -39,7 +40,11 @@
|
|
|
39
40
|
"mediatr-ts": "^1.2.1",
|
|
40
41
|
"tslib": "^2.3.0",
|
|
41
42
|
"vite": "^5.2.8",
|
|
42
|
-
"
|
|
43
|
+
"inversify": "^6.0.2",
|
|
44
|
+
"inversify-inject-decorators": "^3.1.0",
|
|
45
|
+
"jwt-decode": "^4.0.0",
|
|
46
|
+
"@salut/design-system-salut": "1.6.0",
|
|
47
|
+
"reflect-metadata": "^0.2.2"
|
|
43
48
|
},
|
|
44
49
|
"scripts": {
|
|
45
50
|
"serve": "vite",
|
|
@@ -3,3 +3,5 @@ import "./clinical-monitoring/clinical-monitoring";
|
|
|
3
3
|
import "./title-view/title-view";
|
|
4
4
|
import "./primaria-breadcumbs/primaria-breadcumbs";
|
|
5
5
|
import "../shared-components";
|
|
6
|
+
import "../components/patient-header/patient-header";
|
|
7
|
+
import "../components/professional-header/professional-header";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LitElement, css, html, unsafeCSS } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import styles from "./styles.scss?inline";
|
|
4
|
+
import { template } from "./template";
|
|
5
|
+
import { shellApi } from "../../../api/api";
|
|
6
|
+
import { IPatientInfo } from "primary/shell/src/features/get-patient-info/model";
|
|
7
|
+
import { GetPatientInfo } from "../../../features/get-patient-info/request";
|
|
8
|
+
|
|
9
|
+
@customElement("patient-header")
|
|
10
|
+
export class PatientHeader extends LitElement {
|
|
11
|
+
render() {
|
|
12
|
+
return html`${template(this)}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static styles = css`
|
|
16
|
+
${unsafeCSS(styles)}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
@property({ type: Object })
|
|
20
|
+
patient: IPatientInfo;
|
|
21
|
+
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
shellApi.broker.send(new GetPatientInfo()).then((response: IPatientInfo) => {
|
|
25
|
+
this.patient = response;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
gap: 16px;
|
|
3
|
+
@include layout-horizontal;
|
|
4
|
+
@include layout-center;
|
|
5
|
+
.details {
|
|
6
|
+
color: var(--color-neutral-500);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.name-details {
|
|
11
|
+
display: flex;
|
|
12
|
+
@include layout-vertical;
|
|
13
|
+
line-height: 24px;
|
|
14
|
+
size: 14px;
|
|
15
|
+
.name {
|
|
16
|
+
font-family: var(--font-semibold);
|
|
17
|
+
color: var(--color-primary-700);
|
|
18
|
+
font-weight: 600;
|
|
19
|
+
text-decoration: underline;
|
|
20
|
+
}
|
|
21
|
+
.details {
|
|
22
|
+
font-weight: 400;
|
|
23
|
+
font-family: var(--font-regular);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { PatientHeader } from "./patient-header";
|
|
3
|
+
|
|
4
|
+
export const template = (props: PatientHeader) => html`
|
|
5
|
+
<div class="wrapper">
|
|
6
|
+
<dss-avatar size="lg" name="${props.patient.firstName.charAt(
|
|
7
|
+
0,
|
|
8
|
+
)}" surname="${props.patient.lastName.charAt(0)}"></dss-avatar>
|
|
9
|
+
<div class="name-details">
|
|
10
|
+
<div class="name">
|
|
11
|
+
${props.patient.firstName} ${props.patient.lastName}
|
|
12
|
+
</div>
|
|
13
|
+
<div class="details">
|
|
14
|
+
${props.patient.patientId}
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
@@ -15,9 +15,11 @@ export const template = (props: PrimariaShell) => html`
|
|
|
15
15
|
<img src=${salutLogo} alt="logo" />
|
|
16
16
|
</div>
|
|
17
17
|
<primaria-content-switcher id="header-region-container"></primaria-content-switcher>
|
|
18
|
+
<patient-header></patient-header>
|
|
18
19
|
</div>
|
|
19
20
|
<div class="header__right">
|
|
20
21
|
<div id="header-actions-region-container"></div>
|
|
22
|
+
<professional-header></professional-header>
|
|
21
23
|
</div>
|
|
22
24
|
</div>
|
|
23
25
|
<div class="main-container">
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LitElement, css, html, unsafeCSS } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import styles from "./styles.scss?inline";
|
|
4
|
+
import { template } from "./template";
|
|
5
|
+
import { shellApi } from "../../../api/api";
|
|
6
|
+
import { IUserInfo } from "primary/shell/src/features/get-user-info/model";
|
|
7
|
+
import { GetUserInfo } from "../../../features/get-user-info/request";
|
|
8
|
+
|
|
9
|
+
@customElement("professional-header")
|
|
10
|
+
export class ProfessionalHeader extends LitElement {
|
|
11
|
+
render() {
|
|
12
|
+
return html`${template(this)}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static styles = css`
|
|
16
|
+
${unsafeCSS(styles)}
|
|
17
|
+
`;
|
|
18
|
+
@property({ type: Object })
|
|
19
|
+
professional: IUserInfo;
|
|
20
|
+
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
super.connectedCallback();
|
|
23
|
+
shellApi.broker.send(new GetUserInfo()).then((response: IUserInfo) => {
|
|
24
|
+
this.professional = response;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
gap: 16px;
|
|
3
|
+
@include layout-horizontal;
|
|
4
|
+
@include layout-center;
|
|
5
|
+
.details {
|
|
6
|
+
color: var(--color-neutral-500);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.name-details {
|
|
11
|
+
display: flex;
|
|
12
|
+
@include layout-vertical;
|
|
13
|
+
line-height: 24px;
|
|
14
|
+
size: 14px;
|
|
15
|
+
.name {
|
|
16
|
+
font-family: var(--font-semibold);
|
|
17
|
+
color: var(--color-primary-700);
|
|
18
|
+
font-weight: 600;
|
|
19
|
+
text-decoration: underline;
|
|
20
|
+
}
|
|
21
|
+
.details {
|
|
22
|
+
font-weight: 400;
|
|
23
|
+
font-family: var(--font-regular);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { ProfessionalHeader } from "./professional-header";
|
|
3
|
+
|
|
4
|
+
export const template = (props: ProfessionalHeader) => html`
|
|
5
|
+
<div class="wrapper">
|
|
6
|
+
<dss-avatar size="lg" name="${props.professional.firstName.charAt(
|
|
7
|
+
0,
|
|
8
|
+
)}" surname="${props.professional.lastName.charAt(0)}"></dss-avatar>
|
|
9
|
+
<div class="name-details">
|
|
10
|
+
<div class="name">
|
|
11
|
+
${props.professional.firstName} ${props.professional.lastName}
|
|
12
|
+
</div>
|
|
13
|
+
<div class="details">
|
|
14
|
+
${props.professional.speciality}
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
@@ -22,9 +22,9 @@ export class NotifierComponent extends LitElement {
|
|
|
22
22
|
render() {
|
|
23
23
|
return html`
|
|
24
24
|
<div class="snackbar ${this.options.type}">
|
|
25
|
-
<i class="dss-icon-button dss-icon-button--primary dss-icon-button--md ">
|
|
25
|
+
<dss-container><i class="dss-icon-button dss-icon-button--primary dss-icon-button--md ">
|
|
26
26
|
<span class="dss-icon">${ifDefined(getIcon(this.options.type))}</span>
|
|
27
|
-
</i>
|
|
27
|
+
</i></dss-container>
|
|
28
28
|
<div class="snackbar__message">${this.options.message ?? ""}</div>
|
|
29
29
|
<div class="snackbar__action">
|
|
30
30
|
<dss-container><button class="dss-icon-button dss-icon-button--success dss-icon-button--md">
|
package/src/api/api.ts
CHANGED
|
@@ -15,15 +15,12 @@ import {
|
|
|
15
15
|
import { PrimariaGlobalStateManager, createGlobalStateManager } from "./global-state/global-state";
|
|
16
16
|
import { PrimariaBroker } from "./broker/primaria-broker";
|
|
17
17
|
import { createBroker } from "./broker/factory";
|
|
18
|
+
import { HttpClient, createHttpClient } from "./http-client/http-client";
|
|
18
19
|
const broker = createBroker();
|
|
19
20
|
|
|
20
|
-
interface PrimariaHttpClient {
|
|
21
|
-
get(url: string): Promise<any>;
|
|
22
|
-
post(url: string, data: any): Promise<any>;
|
|
23
|
-
}
|
|
24
21
|
|
|
25
22
|
export interface PrimariaApi extends HarmonixApi {
|
|
26
|
-
httpClient:
|
|
23
|
+
httpClient: HttpClient;
|
|
27
24
|
interactionManager: PrimariaInteractionManager;
|
|
28
25
|
broker: PrimariaBroker;
|
|
29
26
|
regionManager: PrimariaRegionManager;
|
|
@@ -45,14 +42,7 @@ export const primariaApiFactory: ApiFactory<PrimariaApi> = (
|
|
|
45
42
|
return {
|
|
46
43
|
pluginInfo: pluginInfo,
|
|
47
44
|
regionManager: createRegionManagerProxy(pluginInfo, regionManager),
|
|
48
|
-
httpClient:
|
|
49
|
-
get: (url: string) => fetch(url).then((r) => r.json()),
|
|
50
|
-
post: (url: string, data: any) =>
|
|
51
|
-
fetch(url, {
|
|
52
|
-
method: "POST",
|
|
53
|
-
body: JSON.stringify(data),
|
|
54
|
-
}).then((r) => r.json()),
|
|
55
|
-
},
|
|
45
|
+
httpClient: createHttpClient(),
|
|
56
46
|
interactionManager: { ...createInteractionManager() },
|
|
57
47
|
broker: broker,
|
|
58
48
|
createLocaleManager: createLocaleManager(pluginInfo.pluginId) as any,
|
|
@@ -40,7 +40,7 @@ describe("Broker test", () => {
|
|
|
40
40
|
describe("Given some subscriptions for an event", () => {
|
|
41
41
|
let handlers: Mock[];
|
|
42
42
|
beforeEach(() => {
|
|
43
|
-
handlers = Array.from({
|
|
43
|
+
handlers = Array.from({length: 5}).map(() => {
|
|
44
44
|
const handler = vi.fn();
|
|
45
45
|
sut.subscribe("MyEvent", handler);
|
|
46
46
|
return handler;
|
|
@@ -48,15 +48,20 @@ describe("Broker test", () => {
|
|
|
48
48
|
});
|
|
49
49
|
describe("When event is published", () => {
|
|
50
50
|
beforeEach(() => {
|
|
51
|
-
sut.publish("MyEvent", {
|
|
51
|
+
sut.publish("MyEvent", {greeting: "Hello"});
|
|
52
52
|
});
|
|
53
53
|
it("Then handler is called", () => {
|
|
54
54
|
for (const handler of handlers) {
|
|
55
|
-
expect(handler).toBeCalledWith({
|
|
55
|
+
expect(handler).toBeCalledWith({greeting: "Hello"});
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
|
+
describe("Given no subscriptions for an event", () => {
|
|
61
|
+
it("When event is published, Then nothing happens", () => {
|
|
62
|
+
expect(() => sut.publish("MyEvent", { greeting: "Hello" })).not.toThrow();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
60
65
|
});
|
|
61
66
|
});
|
|
62
67
|
describe("Message broker test", () => {
|
|
@@ -30,6 +30,9 @@ class Broker implements PrimariaBroker {
|
|
|
30
30
|
publish(event: string | IEvent, payload?: unknown): Promise<void> {
|
|
31
31
|
const eventPayload =
|
|
32
32
|
typeof event === "string" ? this.getEvent(event as string, payload) : event;
|
|
33
|
+
const classConstructor = eventPayload.constructor || Object.getPrototypeOf(eventPayload).constructor;
|
|
34
|
+
const handlerSubscriptions = mediatorSettings.dispatcher.notifications._mappings.filter(m => m.notification === classConstructor);
|
|
35
|
+
if (!handlerSubscriptions.length) return Promise.resolve();
|
|
33
36
|
return this.mediator.publish(eventPayload);
|
|
34
37
|
}
|
|
35
38
|
subscribe<TEvent extends IEvent>(
|
|
@@ -25,7 +25,7 @@ describe("PrimariaGlobalStateManagerImpl", () => {
|
|
|
25
25
|
globalStateManager.setData(key, value);
|
|
26
26
|
|
|
27
27
|
expect(globalStateManager.getData(key)).toBe(value);
|
|
28
|
-
expect(brokerMock.publish).toHaveBeenCalledWith("
|
|
28
|
+
expect(brokerMock.publish).toHaveBeenCalledWith("data_set", {
|
|
29
29
|
key: key,
|
|
30
30
|
value: value,
|
|
31
31
|
});
|
|
@@ -19,7 +19,7 @@ class PrimariaGlobalStateManagerImpl implements PrimariaGlobalStateManager {
|
|
|
19
19
|
*/
|
|
20
20
|
setData(key: string, value: any): void {
|
|
21
21
|
this.state[key] = value;
|
|
22
|
-
this.broker.publish("
|
|
22
|
+
this.broker.publish("data_set", {
|
|
23
23
|
key: key,
|
|
24
24
|
value: value,
|
|
25
25
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
3
|
+
const token = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ1S2hQbXhscHB4d2sxUDVfWmQ5am9CeTV6N2p5MHFPd0ZWY3RwZjBDa0E4In0.eyJleHAiOjE3MjEzMDc3MTcsImlhdCI6MTcyMTMwNzQxNywianRpIjoiNWRkMDE1YzgtNTQ5Yy00ZGM2LWE4YWItMTUzNDJiMWRhNThmIiwiaXNzIjoiaHR0cHM6Ly9pbnRlZ3JhY2lvLnBkcy5oZXMuY2F0c2FsdXQuaW50cmFuZXQuZ2VuY2F0LmNhdC9hdXRoL3JlYWxtcy9FVEMiLCJzdWIiOiJlMjRlMzFlMC01NWZiLTRhZmEtYTQzNi0yYmRhOGYyYWQ0ZWUiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJldGMtY2NmLWludCIsInNlc3Npb25fc3RhdGUiOiJhY2M2ZDBlYi1iMTBjLTQ3ZDEtYjFlOC0xYWQ5ODU5NTAyNTkiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiZGVmYXVsdC1yb2xlcy1oZXMtY2FtIl19LCJzY29wZSI6IiIsInNpZ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face HttpClient {
|
|
10
|
+
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
|
11
|
+
}
|
|
12
|
+
export const createHttpClient = () : HttpClient => {
|
|
13
|
+
return {request: instance.request}
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PrimariaApi } from "@uxland/primary-shell";
|
|
2
|
+
import { container } from "../infrastructure/ioc/container";
|
|
3
|
+
import { TYPES } from "../infrastructure/ioc/types";
|
|
4
|
+
import { bootstrapGetUserInfo, teardownGetUserInfo } from "./get-user-info/bootstrapper";
|
|
5
|
+
import { bootstrapGetPatientInfo, teardownGetPatientInfo } from "./get-patient-info/bootstrapper";
|
|
6
|
+
|
|
7
|
+
export const bootstrapFeatures = (api: PrimariaApi) => {
|
|
8
|
+
container.bind(TYPES.primaryApi).toConstantValue(api);
|
|
9
|
+
bootstrapGetUserInfo();
|
|
10
|
+
bootstrapGetPatientInfo();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const teardownFeatures = () => {
|
|
14
|
+
teardownGetUserInfo();
|
|
15
|
+
teardownGetPatientInfo();
|
|
16
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { injectable } from "inversify";
|
|
2
|
+
import { IPatientInfo } from "./model";
|
|
3
|
+
import { jwtDecode } from "jwt-decode";
|
|
4
|
+
|
|
5
|
+
export abstract class PatientInfoBackendAdapter {
|
|
6
|
+
abstract getPatientInfo(): Promise<IPatientInfo>;
|
|
7
|
+
}
|
|
8
|
+
@injectable()
|
|
9
|
+
export class GetPatientInfoBackendAdapter implements PatientInfoBackendAdapter {
|
|
10
|
+
token =
|
|
11
|
+
"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ1S2hQbXhscHB4d2sxUDVfWmQ5am9CeTV6N2p5MHFPd0ZWY3RwZjBDa0E4In0.eyJleHAiOjE3MjEzMDc3MTcsImlhdCI6MTcyMTMwNzQxN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0.NiDKnMchNB4zqL9zOdq15G8y2BYGOyjk8n1xofB2WyxhVpbTXhXAgApS-4DCqczmdPt4sOwtt-FVVxcYku2gKcQQ1Leapb7CmHoUT_ak5ovOE8ZrD5Ryz6rfC_O1lO8Ut4M_J-KzMxj7WvUNYhkIqcHFSMwDdNC6xxc4ZYMOUI4bOif_Tiy7CxvMIpFGm1YS_jiGS2PGI8Y1o_1DApqMs88MxK9ItO-DIfQgKcR3wV6J-QZueaKVtih-kLma33TZc0jz7xG1EyOMJ5cC4r1Sxp877b9ut4JCmMaWOfWNf2tldLcpXTvV_BWg53YpwYOl4pvZdg3lFWEb009DofTQbQ";
|
|
12
|
+
getPatientInfo(): Promise<IPatientInfo> {
|
|
13
|
+
const decodedToken = jwtDecode(this.token);
|
|
14
|
+
console.log(decodedToken);
|
|
15
|
+
const patientInfo: IPatientInfo = {
|
|
16
|
+
patientId: decodedToken.access_info.professional_id,
|
|
17
|
+
firstName: decodedToken.access_info.patient_given_name,
|
|
18
|
+
lastName: decodedToken.access_info.patient_last_name,
|
|
19
|
+
gender: decodedToken.access_info.patient_gender,
|
|
20
|
+
birthdate: decodedToken.access_info.patient_birthdate,
|
|
21
|
+
};
|
|
22
|
+
return Promise.resolve(patientInfo);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { shellApi } from "../../api/api";
|
|
2
|
+
import { container, registerDep, unregisterDep } from "../../infrastructure/ioc/container";
|
|
3
|
+
import { registerRequest, unregisterRequest } from "../utils";
|
|
4
|
+
import { GetPatientInfoBackendAdapter } from "./backend-adapter";
|
|
5
|
+
import { GetPatientInfoHandler } from "./handler";
|
|
6
|
+
import { GetPatientInfo } from "./request";
|
|
7
|
+
|
|
8
|
+
export const bootstrapGetPatientInfo = () => {
|
|
9
|
+
teardownGetPatientInfo();
|
|
10
|
+
registerRequest(shellApi, container)(GetPatientInfo, GetPatientInfoHandler);
|
|
11
|
+
registerDep(GetPatientInfoBackendAdapter);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const teardownGetPatientInfo = () => {
|
|
15
|
+
unregisterRequest(container)(GetPatientInfoHandler);
|
|
16
|
+
unregisterDep(GetPatientInfoBackendAdapter);
|
|
17
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { inject } from "inversify";
|
|
2
|
+
import { TYPES } from "../../infrastructure/ioc/types";
|
|
3
|
+
import { PrimariaApi } from "@uxland/primary-shell";
|
|
4
|
+
import { GetPatientInfoBackendAdapter, PatientInfoBackendAdapter } from "./backend-adapter";
|
|
5
|
+
import { GetPatientInfo } from "./request";
|
|
6
|
+
import { IPatientInfo } from "./model";
|
|
7
|
+
|
|
8
|
+
export class GetPatientInfoHandler {
|
|
9
|
+
constructor(
|
|
10
|
+
@inject(TYPES.primaryApi) private api: PrimariaApi,
|
|
11
|
+
@inject(GetPatientInfoBackendAdapter) private backendAdapter: PatientInfoBackendAdapter,
|
|
12
|
+
) {}
|
|
13
|
+
async handle(message: GetPatientInfo): Promise<IPatientInfo | undefined> {
|
|
14
|
+
try {
|
|
15
|
+
const patientInfo = await this.backendAdapter.getPatientInfo();
|
|
16
|
+
this.api.globalStateManager.setData("patientInfo", patientInfo);
|
|
17
|
+
return patientInfo;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
this.api.interactionManager.notify({
|
|
20
|
+
type: "error",
|
|
21
|
+
message: error.message,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { injectable } from "inversify";
|
|
2
|
+
import { IUserInfo } from "./model";
|
|
3
|
+
import { jwtDecode } from "jwt-decode";
|
|
4
|
+
|
|
5
|
+
export abstract class UserInfoBackendAdapter {
|
|
6
|
+
abstract getUserInfo(): Promise<IUserInfo>;
|
|
7
|
+
}
|
|
8
|
+
@injectable()
|
|
9
|
+
export class GetUserInfoBackendAdapter implements UserInfoBackendAdapter {
|
|
10
|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lvbmFsX3NlcnZpY2UiOiJTRVJWMDEiLCJwYXRpZW50X2xhc3RfbmFtZSI6IkFSRUdBTEwiLCJlcF9jb2RlIjoiMDIwOCJ9LCJjbGllbnRBZGRyZXNzIjoiMTAuNTMuMjU0LjE1MCIsImNsaWVudF9pZCI6ImV0Yy1jY2YtaW50In0.NiDKnMchNB4zqL9zOdq15G8y2BYGOyjk8n1xofB2WyxhVpbTXhXAgApS-4DCqczmdPt4sOwtt-FVVxcYku2gKcQQ1Leapb7CmHoUT_ak5ovOE8ZrD5Ryz6rfC_O1lO8Ut4M_J-KzMxj7WvUNYhkIqcHFSMwDdNC6xxc4ZYMOUI4bOif_Tiy7CxvMIpFGm1YS_jiGS2PGI8Y1o_1DApqMs88MxK9ItO-DIfQgKcR3wV6J-QZueaKVtih-kLma33TZc0jz7xG1EyOMJ5cC4r1Sxp877b9ut4JCmMaWOfWNf2tldLcpXTvV_BWg53YpwYOl4pvZdg3lFWEb009DofTQbQ";
|
|
12
|
+
getUserInfo(): Promise<IUserInfo> {
|
|
13
|
+
const decodedToken = jwtDecode(this.token);
|
|
14
|
+
const userInfo: IUserInfo = {
|
|
15
|
+
userId: decodedToken.access_info.professional_id,
|
|
16
|
+
firstName: "Nom", // TODO get professional data
|
|
17
|
+
lastName: "Cognom", // TODO get professional data
|
|
18
|
+
role: decodedToken.access_info.professional_role,
|
|
19
|
+
speciality: decodedToken.access_info.professional_speciality,
|
|
20
|
+
service: decodedToken.access_info.professional_service,
|
|
21
|
+
};
|
|
22
|
+
return Promise.resolve(userInfo);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { shellApi } from "../../api/api";
|
|
2
|
+
import { container, registerDep, unregisterDep } from "../../infrastructure/ioc/container";
|
|
3
|
+
import { registerRequest, unregisterRequest } from "../utils";
|
|
4
|
+
import { GetUserInfoBackendAdapter } from "./backend-adapter";
|
|
5
|
+
import { GetUserInfoHandler } from "./handler";
|
|
6
|
+
import { GetUserInfo } from "./request";
|
|
7
|
+
|
|
8
|
+
export const bootstrapGetUserInfo = () => {
|
|
9
|
+
teardownGetUserInfo();
|
|
10
|
+
registerRequest(shellApi, container)(GetUserInfo, GetUserInfoHandler);
|
|
11
|
+
registerDep(GetUserInfoBackendAdapter);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const teardownGetUserInfo = () => {
|
|
15
|
+
unregisterRequest(container)(GetUserInfoHandler);
|
|
16
|
+
unregisterDep(GetUserInfoBackendAdapter);
|
|
17
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PrimariaApi } from "@uxland/primary-shell";
|
|
2
|
+
import { TYPES } from "../../infrastructure/ioc/types";
|
|
3
|
+
import { inject } from "inversify";
|
|
4
|
+
import { GetUserInfo } from "./request";
|
|
5
|
+
import { IUserInfo } from "./model";
|
|
6
|
+
import { UserInfoBackendAdapter } from "./backend-adapter";
|
|
7
|
+
import { GetUserInfoBackendAdapter } from "./backend-adapter";
|
|
8
|
+
|
|
9
|
+
export class GetUserInfoHandler {
|
|
10
|
+
constructor(
|
|
11
|
+
@inject(TYPES.primaryApi) private api: PrimariaApi,
|
|
12
|
+
@inject(GetUserInfoBackendAdapter) private backendAdapter: UserInfoBackendAdapter,
|
|
13
|
+
) {}
|
|
14
|
+
async handle(message: GetUserInfo): Promise<IUserInfo | undefined> {
|
|
15
|
+
try {
|
|
16
|
+
const userInfo = await this.backendAdapter.getUserInfo();
|
|
17
|
+
this.api.globalStateManager.setData("userInfo", userInfo);
|
|
18
|
+
return userInfo;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
this.api.interactionManager.notify({
|
|
21
|
+
type: "error",
|
|
22
|
+
message: error.message,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Container, injectable, interfaces } from "inversify";
|
|
2
|
+
import { IRequest, IRequestClass } from "..";
|
|
3
|
+
import { PrimariaApi } from "../api/api";
|
|
4
|
+
import Newable = interfaces.Newable;
|
|
5
|
+
|
|
6
|
+
//TODO aixo ho fan ja les Broker extensions de plugins/core. Veure si s'ha de canviar
|
|
7
|
+
export const registerRequest =
|
|
8
|
+
(api: PrimariaApi, container: Container) =>
|
|
9
|
+
(command: IRequestClass<any>, handler: Newable<any>) => {
|
|
10
|
+
container.bind(handler).to(handler).inTransientScope();
|
|
11
|
+
injectable()(handler);
|
|
12
|
+
api.broker.registerRequest(command, (cmd: IRequest<any>) => {
|
|
13
|
+
const handlerInstance = container.get(handler);
|
|
14
|
+
return handlerInstance.handle(cmd);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const unregisterRequest = (container: Container) => (handler: Newable<any>) => {
|
|
19
|
+
container.isBound(handler) && container.unbind(handler);
|
|
20
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Container } from "inversify";
|
|
2
|
+
import getDecorators from "inversify-inject-decorators";
|
|
3
|
+
const container = new Container();
|
|
4
|
+
const { lazyInject } = getDecorators(container, false);
|
|
5
|
+
|
|
6
|
+
export { container, lazyInject };
|
|
7
|
+
|
|
8
|
+
export const registerDep = (dep: any) => {
|
|
9
|
+
container.bind(dep).toSelf();
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const unregisterDep = (dep: any) => {
|
|
13
|
+
container.isBound(dep) && container.unbind(dep);
|
|
14
|
+
};
|
package/src/initializer.ts
CHANGED
|
@@ -6,6 +6,9 @@ import { shellApi } from "./api/api";
|
|
|
6
6
|
import { initializeLocalization } from "./locales";
|
|
7
7
|
import { shellRegions } from "./regions";
|
|
8
8
|
import { clinicalMonitoringId } from "./constants";
|
|
9
|
+
import { bootstrapFeatures } from "./features/bootstrapper";
|
|
10
|
+
import { GetUserInfo } from "./features/get-user-info/request";
|
|
11
|
+
import { GetPatientInfo } from "./features/get-patient-info/request";
|
|
9
12
|
|
|
10
13
|
export const initializeShell = async (element: HTMLElement) => {
|
|
11
14
|
initializeLocalization(shellApi);
|
|
@@ -13,6 +16,15 @@ export const initializeShell = async (element: HTMLElement) => {
|
|
|
13
16
|
const shell = new PrimariaShell();
|
|
14
17
|
element.appendChild(shell as any);
|
|
15
18
|
registerViews();
|
|
19
|
+
bootstrapFeatures(shellApi);
|
|
20
|
+
// shellApi.broker.subscribe("data_set", (event: any) => {
|
|
21
|
+
// console.log(event);
|
|
22
|
+
// });
|
|
23
|
+
// shellApi.broker.subscribe("data_set", (event: any) => {
|
|
24
|
+
// console.log(event, "2");
|
|
25
|
+
// });
|
|
26
|
+
shellApi.broker.send(new GetUserInfo());
|
|
27
|
+
shellApi.broker.send(new GetPatientInfo());
|
|
16
28
|
};
|
|
17
29
|
|
|
18
30
|
const registerViews = () => {
|