@acorex-platform/extension-health-human-capital-management-client 0.0.21
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/fesm2022/acorex-platform-extension-health-human-capital-management-client-acorex-platform-extension-health-human-capital-management-client-C6Xgmw5Z.mjs +598 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-acorex-platform-extension-health-human-capital-management-client-C6Xgmw5Z.mjs.map +1 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-contracts.mjs +16 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-contracts.mjs.map +1 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-edit-my-health-profile.command-Xmbl54L5.mjs +141 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-edit-my-health-profile.command-Xmbl54L5.mjs.map +1 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-manage-my-health-conditions.command-Dkvx6R-w.mjs +78 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-manage-my-health-conditions.command-Dkvx6R-w.mjs.map +1 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-manage-my-health-entity-list-dialog.service-DqmxkgFo.mjs +108 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-manage-my-health-entity-list-dialog.service-DqmxkgFo.mjs.map +1 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-manage-my-health-events.command-CI2pOceW.mjs +111 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client-manage-my-health-events.command-CI2pOceW.mjs.map +1 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client.mjs +2 -0
- package/fesm2022/acorex-platform-extension-health-human-capital-management-client.mjs.map +1 -0
- package/package.json +28 -0
- package/types/acorex-platform-extension-health-human-capital-management-client-contracts.d.ts +9 -0
- package/types/acorex-platform-extension-health-human-capital-management-client.d.ts +36 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
import { AXMHealthCoreModule } from '@acorex-platform/module-health-core-client';
|
|
2
|
+
import { AXMHumanCapitalManagementModule } from '@acorex-platform/module-human-capital-management-client';
|
|
3
|
+
import { AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER } from '@acorex-platform/framework-client/core';
|
|
4
|
+
import { AXPEntityService, AXP_ENTITY_MODIFIER } from '@acorex-platform/framework-client/layout/entity';
|
|
5
|
+
import { provideCommandSetups } from '@acorex-platform/framework-client/runtime';
|
|
6
|
+
import * as i0 from '@angular/core';
|
|
7
|
+
import { inject, Injectable, NgModule } from '@angular/core';
|
|
8
|
+
import { AXEHealthCoreProfileCommandKeys } from '@acorex-platform/extension-health-human-capital-management-client/contracts';
|
|
9
|
+
import { RootConfig, HEALTH_PERSON_SUBJECT_TYPE, healthPersonSubjectReferenceConditions } from '@acorex-platform/module-health-core-client/contracts';
|
|
10
|
+
import { RootConfig as RootConfig$1 } from '@acorex-platform/module-human-capital-management-client/contracts';
|
|
11
|
+
import { AXPEntityCommandScope, entityDetailsCrudActions } from '@acorex-platform/framework-shared/entity';
|
|
12
|
+
import { PROFILE_PAGE_GROUPS_HOOK, isUserProfileSectionsGroupRequested, PROFILE_PAGE_SECTIONS_HOOK } from '@acorex-platform/module-auth-client';
|
|
13
|
+
import { AXPSessionService } from '@acorex-platform/framework-client/auth';
|
|
14
|
+
import { first, get } from 'lodash-es';
|
|
15
|
+
import { RootConfig as RootConfig$2 } from '@acorex-platform/module-person-core-client/contracts';
|
|
16
|
+
import { isValidMultiLanguageObject, resolveMultiLanguageString } from '@acorex/core/translation';
|
|
17
|
+
|
|
18
|
+
//#region ---- Imports ----
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ---- Helpers ----
|
|
21
|
+
function healthEventStartActions() {
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
title: '@health-core:health-events.actions.start.title',
|
|
25
|
+
icon: 'fa-light fa-play',
|
|
26
|
+
command: {
|
|
27
|
+
name: 'Entity:Create',
|
|
28
|
+
options: {
|
|
29
|
+
process: {
|
|
30
|
+
redirect: false,
|
|
31
|
+
canCreateNewOne: true,
|
|
32
|
+
data: {},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
priority: 'primary',
|
|
37
|
+
type: 'create',
|
|
38
|
+
scope: AXPEntityCommandScope.TypeLevel,
|
|
39
|
+
items: `{{ await ${RootConfig.module.name}.HealthEvents('${HEALTH_PERSON_SUBJECT_TYPE}') }}`,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
function healthRecordCreateAction(titleKey) {
|
|
44
|
+
return {
|
|
45
|
+
title: titleKey,
|
|
46
|
+
icon: 'fa-light fa-plus',
|
|
47
|
+
command: {
|
|
48
|
+
name: 'Entity:Create',
|
|
49
|
+
options: {
|
|
50
|
+
process: {
|
|
51
|
+
redirect: false,
|
|
52
|
+
data: {
|
|
53
|
+
subject: {
|
|
54
|
+
type: HEALTH_PERSON_SUBJECT_TYPE,
|
|
55
|
+
id: '{{ context.eval("personId") }}',
|
|
56
|
+
title: '{{ context.eval("person.fullName") || (context.eval("person.firstName") + " " + context.eval("person.lastName")) }}',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
priority: 'primary',
|
|
63
|
+
type: 'create',
|
|
64
|
+
scope: AXPEntityCommandScope.TypeLevel,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ---- Entity modifier ----
|
|
69
|
+
/** Adds health-related entities to the HCM Employee detail view. */
|
|
70
|
+
const AXEHealthHcmEmployeeHealthEntityModifier = {
|
|
71
|
+
entityName: RootConfig$1.entities.employee.name,
|
|
72
|
+
modifier: (ctx) => {
|
|
73
|
+
ctx.relatedEntities.add({
|
|
74
|
+
entity: `${RootConfig.module.name}.${RootConfig.entities.healthProfile.name}`,
|
|
75
|
+
title: '@health-core:health-profiles.entities.health-profile.title',
|
|
76
|
+
conditions: healthPersonSubjectReferenceConditions(),
|
|
77
|
+
excludeProperties: ['subject.id'],
|
|
78
|
+
layout: {
|
|
79
|
+
type: 'page-detail', position: 'after', order: 6,
|
|
80
|
+
},
|
|
81
|
+
}, {
|
|
82
|
+
entity: `${RootConfig.module.name}.${RootConfig.entities.healthCondition.name}`,
|
|
83
|
+
title: '@health-core:health-conditions.entities.health-condition.plural',
|
|
84
|
+
conditions: healthPersonSubjectReferenceConditions(),
|
|
85
|
+
excludeProperties: ['subject.id'],
|
|
86
|
+
actions: [
|
|
87
|
+
healthRecordCreateAction('@health-core:health-conditions.actions.create.title'),
|
|
88
|
+
...entityDetailsCrudActions('subject.id', { create: false }),
|
|
89
|
+
],
|
|
90
|
+
layout: { type: 'page-list', position: 'after', order: 7 },
|
|
91
|
+
}, {
|
|
92
|
+
entity: `${RootConfig.module.name}.${RootConfig.entities.healthEvent.name}`,
|
|
93
|
+
title: '@health-core:health-events.entities.health-event.plural',
|
|
94
|
+
columns: ['recordTypeId', 'occurredDate', 'endDate', 'provider', 'statusId'],
|
|
95
|
+
conditions: healthPersonSubjectReferenceConditions(),
|
|
96
|
+
excludeProperties: ['subject.id'],
|
|
97
|
+
actions: [
|
|
98
|
+
...healthEventStartActions(),
|
|
99
|
+
...entityDetailsCrudActions('subject.id', { create: false, edit: false, delete: false, view: false }),
|
|
100
|
+
],
|
|
101
|
+
layout: { type: 'page-list', position: 'after', order: 8 },
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
//#endregion
|
|
106
|
+
|
|
107
|
+
//#region ----- Imports -----
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region ----- Service -----
|
|
110
|
+
/** Resolves polymorphic health subjects from the current user's HCM employee (includes person). */
|
|
111
|
+
class AXEHealthSubjectResolverService {
|
|
112
|
+
constructor() {
|
|
113
|
+
//#region ----- Services & Dependencies -----
|
|
114
|
+
this.sessionService = inject(AXPSessionService);
|
|
115
|
+
this.entityService = inject(AXPEntityService);
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region ----- State Signals -----
|
|
118
|
+
this.cachedUserId = null;
|
|
119
|
+
this.cachedContext = null;
|
|
120
|
+
this.inflight = null;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region ----- Public API -----
|
|
124
|
+
async resolveForCurrentUser() {
|
|
125
|
+
const userId = this.sessionService.user?.id;
|
|
126
|
+
if (!userId) {
|
|
127
|
+
this.clearCache();
|
|
128
|
+
return { personSubject: null, employeeSubject: null };
|
|
129
|
+
}
|
|
130
|
+
if (this.cachedUserId === userId && this.cachedContext) {
|
|
131
|
+
return this.cachedContext;
|
|
132
|
+
}
|
|
133
|
+
if (this.inflight && this.cachedUserId === userId) {
|
|
134
|
+
return this.inflight;
|
|
135
|
+
}
|
|
136
|
+
this.cachedUserId = userId;
|
|
137
|
+
this.inflight = this.loadContext(userId).finally(() => {
|
|
138
|
+
this.inflight = null;
|
|
139
|
+
});
|
|
140
|
+
this.cachedContext = await this.inflight;
|
|
141
|
+
return this.cachedContext;
|
|
142
|
+
}
|
|
143
|
+
clearCache() {
|
|
144
|
+
this.cachedUserId = null;
|
|
145
|
+
this.cachedContext = null;
|
|
146
|
+
this.inflight = null;
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region ----- Private Methods -----
|
|
150
|
+
async loadContext(userId) {
|
|
151
|
+
const employee = await this.findEmployeeByUserId(userId);
|
|
152
|
+
if (!employee) {
|
|
153
|
+
return { personSubject: null, employeeSubject: null };
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
personSubject: this.toPersonSubjectFromEmployee(employee),
|
|
157
|
+
employeeSubject: this.toEmployeeSubject(employee),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async findEmployeeByUserId(userId) {
|
|
161
|
+
const employeeResult = await this.entityService
|
|
162
|
+
.withEntity(RootConfig$1.module.name, RootConfig$1.entities.employee.name)
|
|
163
|
+
.data()
|
|
164
|
+
.query({
|
|
165
|
+
filter: { field: 'userId', operator: { type: 'equal' }, value: userId },
|
|
166
|
+
take: 1,
|
|
167
|
+
skip: 0,
|
|
168
|
+
});
|
|
169
|
+
return first(employeeResult.items);
|
|
170
|
+
}
|
|
171
|
+
toEmployeeSubject(employee) {
|
|
172
|
+
const employeeTitle = get(employee, 'person.fullName') || get(employee, 'employeeCode') || employee.id;
|
|
173
|
+
return {
|
|
174
|
+
type: `${RootConfig$1.module.name}.${RootConfig$1.entities.employee.name}`,
|
|
175
|
+
id: employee.id,
|
|
176
|
+
title: employeeTitle,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
toPersonSubjectFromEmployee(employee) {
|
|
180
|
+
const personId = get(employee, 'person.id') || get(employee, 'personId');
|
|
181
|
+
if (!personId) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const personTitle = get(employee, 'person.fullName') ||
|
|
185
|
+
`${get(employee, 'person.firstName', '')} ${get(employee, 'person.lastName', '')}`.trim() ||
|
|
186
|
+
personId;
|
|
187
|
+
return {
|
|
188
|
+
type: `${RootConfig$2.module.name}.${RootConfig$2.entities.person.name}`,
|
|
189
|
+
id: personId,
|
|
190
|
+
title: personTitle,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXEHealthSubjectResolverService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
194
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXEHealthSubjectResolverService, providedIn: 'root' }); }
|
|
195
|
+
}
|
|
196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXEHealthSubjectResolverService, decorators: [{
|
|
197
|
+
type: Injectable,
|
|
198
|
+
args: [{ providedIn: 'root' }]
|
|
199
|
+
}] });
|
|
200
|
+
|
|
201
|
+
//#region ---- Health profile group ----
|
|
202
|
+
/** Adds the Health tab when the current user has a resolvable person health subject. */
|
|
203
|
+
const HealthHcmProfileGroupsHookProvider = {
|
|
204
|
+
key: PROFILE_PAGE_GROUPS_HOOK,
|
|
205
|
+
priority: 25,
|
|
206
|
+
execute: async (payload) => {
|
|
207
|
+
const subjectResolver = inject(AXEHealthSubjectResolverService);
|
|
208
|
+
const subjects = await subjectResolver.resolveForCurrentUser();
|
|
209
|
+
if (!subjects.personSubject) {
|
|
210
|
+
return payload;
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
...payload,
|
|
214
|
+
groups: [
|
|
215
|
+
...payload.groups,
|
|
216
|
+
{
|
|
217
|
+
id: 'health',
|
|
218
|
+
title: '@health-core:profile-page.groups.health.title',
|
|
219
|
+
icon: 'far fa-heart-pulse',
|
|
220
|
+
priority: 25,
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
//#endregion
|
|
227
|
+
|
|
228
|
+
//#region ----- Imports -----
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region ----- Constants -----
|
|
231
|
+
const HEALTH_PROFILE_SUMMARY_SECTION_ID = 'health-profile-summary';
|
|
232
|
+
const FIELD_TITLES = {
|
|
233
|
+
bloodType: '@health-core:health-profiles.entities.health-profile.fields.blood-type-id',
|
|
234
|
+
disabilityStatus: '@health-core:health-profiles.entities.health-profile.fields.disability-status-id',
|
|
235
|
+
smokingStatus: '@health-core:health-profiles.entities.health-profile.fields.smoking-status',
|
|
236
|
+
alcoholConsumption: '@health-core:health-profiles.entities.health-profile.fields.alcohol-consumption',
|
|
237
|
+
healthRiskLevel: '@health-core:health-profiles.entities.health-profile.fields.health-risk-level',
|
|
238
|
+
doctorName: '@health-core:health-profiles.entities.health-profile.fields.doctor-name',
|
|
239
|
+
emergencyContactName: '@health-core:health-profiles.entities.health-profile.fields.emergency-contact-name',
|
|
240
|
+
};
|
|
241
|
+
const SMOKING_STATUS_LABELS = {
|
|
242
|
+
never: '@health-core:datasources.smoking-status-options.samples.never',
|
|
243
|
+
former: '@health-core:datasources.smoking-status-options.samples.former',
|
|
244
|
+
current: '@health-core:datasources.smoking-status-options.samples.current',
|
|
245
|
+
'prefer-not-to-say': '@health-core:datasources.smoking-status-options.samples.prefer-not-to-say',
|
|
246
|
+
};
|
|
247
|
+
const ALCOHOL_CONSUMPTION_LABELS = {
|
|
248
|
+
never: '@health-core:datasources.alcohol-consumption-options.samples.never',
|
|
249
|
+
occasional: '@health-core:datasources.alcohol-consumption-options.samples.occasional',
|
|
250
|
+
regular: '@health-core:datasources.alcohol-consumption-options.samples.regular',
|
|
251
|
+
heavy: '@health-core:datasources.alcohol-consumption-options.samples.heavy',
|
|
252
|
+
'prefer-not-to-say': '@health-core:datasources.alcohol-consumption-options.samples.prefer-not-to-say',
|
|
253
|
+
};
|
|
254
|
+
const HEALTH_RISK_LEVEL_LABELS = {
|
|
255
|
+
low: '@health-core:datasources.health-risk-level-options.samples.low',
|
|
256
|
+
medium: '@health-core:datasources.health-risk-level-options.samples.medium',
|
|
257
|
+
high: '@health-core:datasources.health-risk-level-options.samples.high',
|
|
258
|
+
critical: '@health-core:datasources.health-risk-level-options.samples.critical',
|
|
259
|
+
};
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region ----- Insights -----
|
|
262
|
+
/** Builds Medical Summary card insights from a health profile row. */
|
|
263
|
+
function buildHealthProfileInsights(profile) {
|
|
264
|
+
const insights = [];
|
|
265
|
+
const bloodTypeTitle = resolveLookupTitle(profile.bloodType?.title);
|
|
266
|
+
if (bloodTypeTitle) {
|
|
267
|
+
insights.push({
|
|
268
|
+
id: 'blood-type',
|
|
269
|
+
icon: 'far fa-droplet',
|
|
270
|
+
title: FIELD_TITLES.bloodType,
|
|
271
|
+
text: bloodTypeTitle,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
const disabilityTitle = resolveLookupTitle(profile.disabilityStatus?.title);
|
|
275
|
+
if (disabilityTitle) {
|
|
276
|
+
insights.push({
|
|
277
|
+
id: 'disability-status',
|
|
278
|
+
icon: 'far fa-wheelchair',
|
|
279
|
+
title: FIELD_TITLES.disabilityStatus,
|
|
280
|
+
text: disabilityTitle,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
const smokingLabel = resolveEnumLabel(profile.smokingStatus, SMOKING_STATUS_LABELS);
|
|
284
|
+
if (smokingLabel) {
|
|
285
|
+
insights.push({
|
|
286
|
+
id: 'smoking-status',
|
|
287
|
+
icon: 'far fa-smoking',
|
|
288
|
+
title: FIELD_TITLES.smokingStatus,
|
|
289
|
+
text: smokingLabel,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
const alcoholLabel = resolveEnumLabel(profile.alcoholConsumption, ALCOHOL_CONSUMPTION_LABELS);
|
|
293
|
+
if (alcoholLabel) {
|
|
294
|
+
insights.push({
|
|
295
|
+
id: 'alcohol-consumption',
|
|
296
|
+
icon: 'far fa-wine-glass',
|
|
297
|
+
title: FIELD_TITLES.alcoholConsumption,
|
|
298
|
+
text: alcoholLabel,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
const doctorName = profile.doctorName?.trim();
|
|
302
|
+
if (doctorName) {
|
|
303
|
+
insights.push({
|
|
304
|
+
id: 'doctor-name',
|
|
305
|
+
icon: 'far fa-user-doctor',
|
|
306
|
+
title: FIELD_TITLES.doctorName,
|
|
307
|
+
text: doctorName,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
const emergencyContact = profile.emergencyContactName?.trim();
|
|
311
|
+
if (emergencyContact) {
|
|
312
|
+
insights.push({
|
|
313
|
+
id: 'emergency-contact',
|
|
314
|
+
icon: 'far fa-user-nurse',
|
|
315
|
+
title: FIELD_TITLES.emergencyContactName,
|
|
316
|
+
text: emergencyContact,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
// Risk last so it stays visually distinct at the end of the badge row.
|
|
320
|
+
const riskLabel = resolveEnumLabel(profile.healthRiskLevel, HEALTH_RISK_LEVEL_LABELS);
|
|
321
|
+
if (riskLabel) {
|
|
322
|
+
insights.push({
|
|
323
|
+
id: 'health-risk-level',
|
|
324
|
+
icon: 'far fa-triangle-exclamation',
|
|
325
|
+
title: FIELD_TITLES.healthRiskLevel,
|
|
326
|
+
text: riskLabel,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
return insights;
|
|
330
|
+
}
|
|
331
|
+
function resolveEnumLabel(value, labels) {
|
|
332
|
+
const key = value?.trim();
|
|
333
|
+
if (!key) {
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
return labels[key] ?? key;
|
|
337
|
+
}
|
|
338
|
+
function resolveLookupTitle(title) {
|
|
339
|
+
if (title == null) {
|
|
340
|
+
return undefined;
|
|
341
|
+
}
|
|
342
|
+
if (typeof title === 'string') {
|
|
343
|
+
const trimmed = title.trim();
|
|
344
|
+
return trimmed.length ? trimmed : undefined;
|
|
345
|
+
}
|
|
346
|
+
if (isValidMultiLanguageObject(title)) {
|
|
347
|
+
const resolved = resolveMultiLanguageString(title, 'en-US').trim();
|
|
348
|
+
return resolved.length ? resolved : undefined;
|
|
349
|
+
}
|
|
350
|
+
return undefined;
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
|
|
354
|
+
//#region ----- Imports -----
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region ----- Health profile insights hook -----
|
|
357
|
+
/** Adds live health profile summary and passes existing profile id into the edit action. */
|
|
358
|
+
const HealthHcmProfileSectionsInsightsHookProvider = {
|
|
359
|
+
key: PROFILE_PAGE_SECTIONS_HOOK,
|
|
360
|
+
priority: 26,
|
|
361
|
+
execute: async (payload) => {
|
|
362
|
+
if (!isUserProfileSectionsGroupRequested(payload, 'health')) {
|
|
363
|
+
return payload;
|
|
364
|
+
}
|
|
365
|
+
const subjectResolver = inject(AXEHealthSubjectResolverService);
|
|
366
|
+
const entityService = inject(AXPEntityService);
|
|
367
|
+
const subjects = await subjectResolver.resolveForCurrentUser();
|
|
368
|
+
const personSubject = subjects.personSubject;
|
|
369
|
+
if (!personSubject?.id || !personSubject.type) {
|
|
370
|
+
return payload;
|
|
371
|
+
}
|
|
372
|
+
const result = await entityService
|
|
373
|
+
.withEntity(RootConfig.module.name, RootConfig.entities.healthProfile.name)
|
|
374
|
+
.data()
|
|
375
|
+
.query({
|
|
376
|
+
filter: {
|
|
377
|
+
logic: 'and',
|
|
378
|
+
filters: [
|
|
379
|
+
{ field: 'subject.type', operator: { type: 'equal' }, value: HEALTH_PERSON_SUBJECT_TYPE },
|
|
380
|
+
{ field: 'subject.id', operator: { type: 'equal' }, value: personSubject.id },
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
take: 1,
|
|
384
|
+
skip: 0,
|
|
385
|
+
});
|
|
386
|
+
const profile = result.items[0];
|
|
387
|
+
const existingProfileId = profile?.id ?? null;
|
|
388
|
+
const insights = profile ? buildHealthProfileInsights(profile) : [];
|
|
389
|
+
return {
|
|
390
|
+
...payload,
|
|
391
|
+
sections: payload.sections.map((section) => {
|
|
392
|
+
if (section.id !== HEALTH_PROFILE_SUMMARY_SECTION_ID) {
|
|
393
|
+
return section;
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
...section,
|
|
397
|
+
...(insights.length ? { insights } : { insights: undefined }),
|
|
398
|
+
actions: (section.actions ?? []).map((action) => {
|
|
399
|
+
if (action.command?.name !== AXEHealthCoreProfileCommandKeys.Profile.EditMyHealthProfile) {
|
|
400
|
+
return action;
|
|
401
|
+
}
|
|
402
|
+
return {
|
|
403
|
+
...action,
|
|
404
|
+
command: {
|
|
405
|
+
...action.command,
|
|
406
|
+
options: {
|
|
407
|
+
...(action.command.options ?? {}),
|
|
408
|
+
existingProfileId,
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
}),
|
|
413
|
+
};
|
|
414
|
+
}),
|
|
415
|
+
};
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
//#endregion
|
|
419
|
+
|
|
420
|
+
//#region ---- Health profile sections ----
|
|
421
|
+
/** Contributes health section cards on the profile Health tab (person subject). */
|
|
422
|
+
const HealthHcmProfileSectionsHookProvider = {
|
|
423
|
+
key: PROFILE_PAGE_SECTIONS_HOOK,
|
|
424
|
+
priority: 25,
|
|
425
|
+
execute: async (payload) => {
|
|
426
|
+
if (!isUserProfileSectionsGroupRequested(payload, 'health')) {
|
|
427
|
+
return payload;
|
|
428
|
+
}
|
|
429
|
+
const subjectResolver = inject(AXEHealthSubjectResolverService);
|
|
430
|
+
const subjects = await subjectResolver.resolveForCurrentUser();
|
|
431
|
+
if (!subjects.personSubject) {
|
|
432
|
+
return payload;
|
|
433
|
+
}
|
|
434
|
+
const sections = [
|
|
435
|
+
{
|
|
436
|
+
id: 'health-profile-summary',
|
|
437
|
+
groupId: 'health',
|
|
438
|
+
title: '@health-core:health-profiles.entities.health-profile.title',
|
|
439
|
+
description: '@health-core:profile-page.sections.health-profile.description',
|
|
440
|
+
icon: 'far fa-heart-pulse',
|
|
441
|
+
priority: 10,
|
|
442
|
+
layout: { colSpan: 6 },
|
|
443
|
+
actions: [
|
|
444
|
+
{
|
|
445
|
+
name: 'manage-health-profile',
|
|
446
|
+
title: '@general:actions.edit.title',
|
|
447
|
+
icon: 'far fa-pen',
|
|
448
|
+
command: {
|
|
449
|
+
name: AXEHealthCoreProfileCommandKeys.Profile.EditMyHealthProfile,
|
|
450
|
+
},
|
|
451
|
+
default: true,
|
|
452
|
+
},
|
|
453
|
+
],
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
id: 'health-conditions',
|
|
457
|
+
groupId: 'health',
|
|
458
|
+
title: '@health-core:health-conditions.entities.health-condition.plural',
|
|
459
|
+
description: '@health-core:profile-page.sections.health-conditions.description',
|
|
460
|
+
icon: 'far fa-file-medical',
|
|
461
|
+
priority: 20,
|
|
462
|
+
layout: { colSpan: 6 },
|
|
463
|
+
actions: [
|
|
464
|
+
{
|
|
465
|
+
name: 'manage-health-conditions',
|
|
466
|
+
title: '@general:actions.edit.title',
|
|
467
|
+
icon: 'far fa-pen',
|
|
468
|
+
command: {
|
|
469
|
+
name: AXEHealthCoreProfileCommandKeys.Profile.ManageMyHealthConditions,
|
|
470
|
+
},
|
|
471
|
+
default: true,
|
|
472
|
+
},
|
|
473
|
+
],
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
id: 'health-events',
|
|
477
|
+
groupId: 'health',
|
|
478
|
+
title: '@health-core:health-events.entities.health-event.plural',
|
|
479
|
+
description: '@health-core:profile-page.sections.health-events.description',
|
|
480
|
+
icon: 'far fa-notes-medical',
|
|
481
|
+
priority: 30,
|
|
482
|
+
layout: { colSpan: 6 },
|
|
483
|
+
actions: [
|
|
484
|
+
{
|
|
485
|
+
name: 'manage-health-events',
|
|
486
|
+
title: '@general:actions.edit.title',
|
|
487
|
+
icon: 'far fa-pen',
|
|
488
|
+
command: {
|
|
489
|
+
name: AXEHealthCoreProfileCommandKeys.Profile.ManageMyHealthEvents,
|
|
490
|
+
},
|
|
491
|
+
default: true,
|
|
492
|
+
},
|
|
493
|
+
],
|
|
494
|
+
},
|
|
495
|
+
];
|
|
496
|
+
return {
|
|
497
|
+
...payload,
|
|
498
|
+
sections: [...payload.sections, ...sections],
|
|
499
|
+
};
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
//#endregion
|
|
503
|
+
|
|
504
|
+
//#region ---- Imports ----
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region ---- Module ----
|
|
507
|
+
/**
|
|
508
|
+
* Bridges HealthCore health records with HCM Employee detail and My Profile Health tab.
|
|
509
|
+
*/
|
|
510
|
+
class AXEHealthHumanCapitalManagementExtensionModule {
|
|
511
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXEHealthHumanCapitalManagementExtensionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
512
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.8", ngImport: i0, type: AXEHealthHumanCapitalManagementExtensionModule, imports: [AXMHealthCoreModule, AXMHumanCapitalManagementModule] }); }
|
|
513
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXEHealthHumanCapitalManagementExtensionModule, providers: [
|
|
514
|
+
{
|
|
515
|
+
provide: AXP_ENTITY_MODIFIER,
|
|
516
|
+
useValue: AXEHealthHcmEmployeeHealthEntityModifier,
|
|
517
|
+
multi: true,
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
provide: AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER,
|
|
521
|
+
useValue: HealthHcmProfileGroupsHookProvider,
|
|
522
|
+
multi: true,
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
provide: AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER,
|
|
526
|
+
useValue: HealthHcmProfileSectionsHookProvider,
|
|
527
|
+
multi: true,
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
provide: AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER,
|
|
531
|
+
useValue: HealthHcmProfileSectionsInsightsHookProvider,
|
|
532
|
+
multi: true,
|
|
533
|
+
},
|
|
534
|
+
provideCommandSetups([
|
|
535
|
+
{
|
|
536
|
+
key: AXEHealthCoreProfileCommandKeys.Profile.EditMyHealthProfile,
|
|
537
|
+
command: () => import('./acorex-platform-extension-health-human-capital-management-client-edit-my-health-profile.command-Xmbl54L5.mjs').then((c) => c.AXEEditMyHealthProfileCommand),
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
key: AXEHealthCoreProfileCommandKeys.Profile.ManageMyHealthConditions,
|
|
541
|
+
command: () => import('./acorex-platform-extension-health-human-capital-management-client-manage-my-health-conditions.command-Dkvx6R-w.mjs').then((c) => c.AXEManageMyHealthConditionsCommand),
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
key: AXEHealthCoreProfileCommandKeys.Profile.ManageMyHealthEvents,
|
|
545
|
+
command: () => import('./acorex-platform-extension-health-human-capital-management-client-manage-my-health-events.command-CI2pOceW.mjs').then((c) => c.AXEManageMyHealthEventsCommand),
|
|
546
|
+
},
|
|
547
|
+
]),
|
|
548
|
+
], imports: [AXMHealthCoreModule, AXMHumanCapitalManagementModule] }); }
|
|
549
|
+
}
|
|
550
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXEHealthHumanCapitalManagementExtensionModule, decorators: [{
|
|
551
|
+
type: NgModule,
|
|
552
|
+
args: [{
|
|
553
|
+
imports: [AXMHealthCoreModule, AXMHumanCapitalManagementModule],
|
|
554
|
+
providers: [
|
|
555
|
+
{
|
|
556
|
+
provide: AXP_ENTITY_MODIFIER,
|
|
557
|
+
useValue: AXEHealthHcmEmployeeHealthEntityModifier,
|
|
558
|
+
multi: true,
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
provide: AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER,
|
|
562
|
+
useValue: HealthHcmProfileGroupsHookProvider,
|
|
563
|
+
multi: true,
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
provide: AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER,
|
|
567
|
+
useValue: HealthHcmProfileSectionsHookProvider,
|
|
568
|
+
multi: true,
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
provide: AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER,
|
|
572
|
+
useValue: HealthHcmProfileSectionsInsightsHookProvider,
|
|
573
|
+
multi: true,
|
|
574
|
+
},
|
|
575
|
+
provideCommandSetups([
|
|
576
|
+
{
|
|
577
|
+
key: AXEHealthCoreProfileCommandKeys.Profile.EditMyHealthProfile,
|
|
578
|
+
command: () => import('./acorex-platform-extension-health-human-capital-management-client-edit-my-health-profile.command-Xmbl54L5.mjs').then((c) => c.AXEEditMyHealthProfileCommand),
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
key: AXEHealthCoreProfileCommandKeys.Profile.ManageMyHealthConditions,
|
|
582
|
+
command: () => import('./acorex-platform-extension-health-human-capital-management-client-manage-my-health-conditions.command-Dkvx6R-w.mjs').then((c) => c.AXEManageMyHealthConditionsCommand),
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
key: AXEHealthCoreProfileCommandKeys.Profile.ManageMyHealthEvents,
|
|
586
|
+
command: () => import('./acorex-platform-extension-health-human-capital-management-client-manage-my-health-events.command-CI2pOceW.mjs').then((c) => c.AXEManageMyHealthEventsCommand),
|
|
587
|
+
},
|
|
588
|
+
]),
|
|
589
|
+
],
|
|
590
|
+
}]
|
|
591
|
+
}] });
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Generated bundle index. Do not edit.
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
export { AXEHealthSubjectResolverService as A, HEALTH_PROFILE_SUMMARY_SECTION_ID as H, AXEHealthHumanCapitalManagementExtensionModule as a, buildHealthProfileInsights as b };
|
|
598
|
+
//# sourceMappingURL=acorex-platform-extension-health-human-capital-management-client-acorex-platform-extension-health-human-capital-management-client-C6Xgmw5Z.mjs.map
|