@doolehealth/service-lib 0.0.1

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 (72) hide show
  1. package/README.md +24 -0
  2. package/esm2022/doolehealth-service-lib.mjs +5 -0
  3. package/esm2022/lib/configuration.mjs +5 -0
  4. package/esm2022/lib/models/user.mjs +2 -0
  5. package/esm2022/lib/service-lib.component.mjs +19 -0
  6. package/esm2022/lib/service-lib.module.mjs +33 -0
  7. package/esm2022/lib/services/analytics.service.mjs +73 -0
  8. package/esm2022/lib/services/api-endpoints.service.mjs +51 -0
  9. package/esm2022/lib/services/authentication.service.mjs +400 -0
  10. package/esm2022/lib/services/change-endpoints.service.mjs +90 -0
  11. package/esm2022/lib/services/date.service.mjs +419 -0
  12. package/esm2022/lib/services/doole.service.mjs +1299 -0
  13. package/esm2022/lib/services/encryption.service.mjs +31 -0
  14. package/esm2022/lib/services/error.service.mjs +49 -0
  15. package/esm2022/lib/services/events.service.mjs +63 -0
  16. package/esm2022/lib/services/highcharts.service.mjs +621 -0
  17. package/esm2022/lib/services/http.service.mjs +124 -0
  18. package/esm2022/lib/services/language.service.mjs +38 -0
  19. package/esm2022/lib/services/loading.service.mjs +45 -0
  20. package/esm2022/lib/services/logging.service.mjs +28 -0
  21. package/esm2022/lib/services/navigation.service.mjs +41 -0
  22. package/esm2022/lib/services/network.service.mjs +42 -0
  23. package/esm2022/lib/services/notification.service.mjs +202 -0
  24. package/esm2022/lib/services/opentok.service.mjs +25 -0
  25. package/esm2022/lib/services/roles.service.mjs +44 -0
  26. package/esm2022/lib/services/storage.service.mjs +37 -0
  27. package/esm2022/lib/services/token.service.mjs +59 -0
  28. package/esm2022/lib/util/chatParameters.mjs +17 -0
  29. package/esm2022/lib/util/data-store.mjs +54 -0
  30. package/esm2022/lib/util/environment.mjs +29 -0
  31. package/esm2022/lib/util/language.model.mjs +3 -0
  32. package/esm2022/lib/util/notification-options.mjs +245 -0
  33. package/esm2022/lib/util/query-string-parameters.mjs +11 -0
  34. package/esm2022/lib/util/url-builder.mjs +15 -0
  35. package/esm2022/public-api.mjs +30 -0
  36. package/fesm2022/doolehealth-service-lib.mjs +4025 -0
  37. package/fesm2022/doolehealth-service-lib.mjs.map +1 -0
  38. package/index.d.ts +5 -0
  39. package/lib/configuration.d.ts +46 -0
  40. package/lib/models/user.d.ts +133 -0
  41. package/lib/service-lib.component.d.ts +5 -0
  42. package/lib/service-lib.module.d.ts +13 -0
  43. package/lib/services/analytics.service.d.ts +17 -0
  44. package/lib/services/api-endpoints.service.d.ts +13 -0
  45. package/lib/services/authentication.service.d.ts +102 -0
  46. package/lib/services/change-endpoints.service.d.ts +38 -0
  47. package/lib/services/date.service.d.ts +58 -0
  48. package/lib/services/doole.service.d.ts +169 -0
  49. package/lib/services/encryption.service.d.ts +9 -0
  50. package/lib/services/error.service.d.ts +11 -0
  51. package/lib/services/events.service.d.ts +32 -0
  52. package/lib/services/highcharts.service.d.ts +69 -0
  53. package/lib/services/http.service.d.ts +28 -0
  54. package/lib/services/language.service.d.ts +15 -0
  55. package/lib/services/loading.service.d.ts +22 -0
  56. package/lib/services/logging.service.d.ts +9 -0
  57. package/lib/services/navigation.service.d.ts +13 -0
  58. package/lib/services/network.service.d.ts +14 -0
  59. package/lib/services/notification.service.d.ts +25 -0
  60. package/lib/services/opentok.service.d.ts +17 -0
  61. package/lib/services/roles.service.d.ts +28 -0
  62. package/lib/services/storage.service.d.ts +10 -0
  63. package/lib/services/token.service.d.ts +16 -0
  64. package/lib/util/chatParameters.d.ts +25 -0
  65. package/lib/util/data-store.d.ts +13 -0
  66. package/lib/util/environment.d.ts +18 -0
  67. package/lib/util/language.model.d.ts +4 -0
  68. package/lib/util/notification-options.d.ts +145 -0
  69. package/lib/util/query-string-parameters.d.ts +6 -0
  70. package/lib/util/url-builder.d.ts +9 -0
  71. package/package.json +38 -0
  72. package/public-api.d.ts +23 -0
@@ -0,0 +1,4025 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Component, InjectionToken, NgModule, Injectable, Inject, PLATFORM_ID, ViewChild } from '@angular/core';
3
+ import * as i2$2 from '@angular/common';
4
+ import { CommonModule, DatePipe } from '@angular/common';
5
+ import { BehaviorSubject, Subject, Observable, merge, of, fromEvent } from 'rxjs';
6
+ import { Preferences } from '@capacitor/preferences';
7
+ import { map, tap, catchError, mapTo } from 'rxjs/operators';
8
+ import * as i1 from '@angular/common/http';
9
+ import { HttpErrorResponse, HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
10
+ import * as i6 from '@angular/router';
11
+ import { RouterOutlet, NavigationEnd } from '@angular/router';
12
+ import * as i1$1 from '@ngx-translate/core';
13
+ import { TranslateService } from '@ngx-translate/core';
14
+ import { Capacitor } from '@capacitor/core';
15
+ import * as CryptoJS from 'crypto-js';
16
+ import * as i2 from '@ionic/angular';
17
+ import * as i5 from '@angular/fire/compat/auth';
18
+ import * as i2$1 from '@awesome-cordova-plugins/file-transfer/ngx';
19
+ import * as i3 from '@awesome-cordova-plugins/file/ngx';
20
+ import moment from 'moment';
21
+ import * as HighCharts from 'highcharts';
22
+ import highchartsMore from 'highcharts/highcharts-more';
23
+ import * as i1$2 from '@angular/material/snack-bar';
24
+ import { MatSnackBarConfig } from '@angular/material/snack-bar';
25
+ import * as i1$3 from '@awesome-cordova-plugins/network/ngx';
26
+ import { CallCapacitor } from '@doole/videocall-notications-plugins';
27
+ import { FirebaseAnalytics } from '@capacitor-community/firebase-analytics';
28
+
29
+ class ServiceLibComponent {
30
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ServiceLibComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
31
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.10", type: ServiceLibComponent, selector: "dev-service-lib", ngImport: i0, template: `
32
+ <p>
33
+ service-lib works!
34
+ </p>
35
+ `, isInline: true, styles: [""] }); }
36
+ }
37
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ServiceLibComponent, decorators: [{
38
+ type: Component,
39
+ args: [{ selector: 'dev-service-lib', template: `
40
+ <p>
41
+ service-lib works!
42
+ </p>
43
+ ` }]
44
+ }] });
45
+
46
+ const CONFIGURACION_TOKEN = new InjectionToken('configuracion');
47
+ const PUSHERS_CONFIG_TOKEN = new InjectionToken('pushers.config');
48
+ const FIREBASE_CONFIG_TOKEN = new InjectionToken('environment');
49
+
50
+ class ServiceLibModule {
51
+ static forRoot(config, configPushers, environment) {
52
+ return {
53
+ ngModule: ServiceLibModule,
54
+ providers: [
55
+ { provide: CONFIGURACION_TOKEN, useValue: config },
56
+ { provide: PUSHERS_CONFIG_TOKEN, useValue: configPushers },
57
+ { provide: FIREBASE_CONFIG_TOKEN, useValue: environment },
58
+ ]
59
+ };
60
+ }
61
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ServiceLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
62
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.10", ngImport: i0, type: ServiceLibModule, declarations: [ServiceLibComponent], imports: [CommonModule], exports: [ServiceLibComponent] }); }
63
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ServiceLibModule, imports: [CommonModule] }); }
64
+ }
65
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ServiceLibModule, decorators: [{
66
+ type: NgModule,
67
+ args: [{
68
+ declarations: [ServiceLibComponent],
69
+ imports: [
70
+ CommonModule,
71
+ ],
72
+ exports: [
73
+ ServiceLibComponent
74
+ ]
75
+ }]
76
+ }] });
77
+
78
+ class QueryStringParameters {
79
+ constructor() {
80
+ this.toString = () => this.paramsAndValues.join('&');
81
+ this.paramsAndValues = [];
82
+ }
83
+ push(key, value) {
84
+ value = encodeURIComponent(value.toString());
85
+ this.paramsAndValues.push([key, value].join('='));
86
+ }
87
+ }
88
+
89
+ // Application Classes
90
+ class UrlBuilder {
91
+ constructor(baseUrl, action, queryString) {
92
+ this.baseUrl = baseUrl;
93
+ this.action = action;
94
+ this.url = [baseUrl, action].join('/');
95
+ this.queryString = queryString || new QueryStringParameters();
96
+ }
97
+ toString() {
98
+ const qs = this.queryString ? this.queryString.toString() : '';
99
+ return qs ? `${this.url}?${qs}` : this.url;
100
+ }
101
+ }
102
+
103
+ var _INDEX_ENPOINT = 0; //Por defecto index 0
104
+ const ENDPOINT = 'endpoint';
105
+ class ChangeEndpointsService {
106
+ constructor(constants, pusher) {
107
+ this.constants = constants;
108
+ this.pusher = pusher;
109
+ this._endpointIndex = new BehaviorSubject(this.getIndexEndPointLocalstorage());
110
+ this._LIST_ENPOINT = [];
111
+ this.addEndPoint();
112
+ this.setDefaultEndPoint();
113
+ }
114
+ async addEndPoint() {
115
+ this._LIST_ENPOINT = [];
116
+ this._LIST_ENPOINT.push({
117
+ id: 0,
118
+ name: 'enviroment.production',
119
+ api: this.constants.API_DOOLE_ENDPOINT,
120
+ endpoint: this.constants.DOOLE_ENDPOINT,
121
+ device_ios: { ios_push: 'ios_dev', ios_voip: 'iosvoipdev' },
122
+ pusher_key: this.pusher.PUSHER_KEY_PRO,
123
+ color: 'primary',
124
+ settings_bio: 'settings-bio0',
125
+ biometric: 'biometric0',
126
+ show_bio_dialog: 'show-bio-dialog0',
127
+ registered_user: 'registered-user0',
128
+ });
129
+ this._LIST_ENPOINT.push({
130
+ id: 1,
131
+ name: 'enviroment.development',
132
+ api: this.constants.API_ENDPOINT_DEV,
133
+ endpoint: this.constants.ENDPOINT_DEV,
134
+ device_ios: { ios_push: 'ios_dev', ios_voip: 'iosvoipdev' },
135
+ pusher_key: this.pusher.PUSHER_KEY_DEV,
136
+ color: 'warning',
137
+ settings_bio: 'settings-bio1',
138
+ biometric: 'biometric1',
139
+ show_bio_dialog: 'show-bio-dialog1',
140
+ registered_user: 'registered-user1',
141
+ });
142
+ // device_ios: {ios_push: 'ios', ios_voip: 'iosvoip'},
143
+ }
144
+ setEndPoint(index) {
145
+ console.log("DINTRE DEL LIB");
146
+ this._ENVIROMENT = this._LIST_ENPOINT[index];
147
+ _INDEX_ENPOINT = index;
148
+ this.API_ENDPOINT = this._ENVIROMENT.api;
149
+ this.DOOLE_ENDPOINT = this._ENVIROMENT.endpoint;
150
+ this.setIndexEndPointLocalstorage(index);
151
+ this._endpointIndex.next(index);
152
+ }
153
+ setIndexEndPointLocalstorage(endpoint) {
154
+ localStorage.setItem(ENDPOINT, JSON.stringify(endpoint));
155
+ }
156
+ getIndexEndPointLocalstorage() {
157
+ let endpoint = localStorage.getItem(ENDPOINT);
158
+ //console.log(`[ChangeEndpointsService] setEndPointLocalstorage()`, endpoint);
159
+ if (endpoint)
160
+ return Number(JSON.parse(endpoint));
161
+ return undefined;
162
+ }
163
+ getEndpointIndexObservable() {
164
+ return this._endpointIndex.asObservable();
165
+ }
166
+ setDefaultEndPoint() {
167
+ if (this.API_ENDPOINT == undefined || this.DOOLE_ENDPOINT == undefined) {
168
+ let index = this.getIndexEndPointLocalstorage();
169
+ index = (index == undefined) ? _INDEX_ENPOINT : index;
170
+ this.setEndPoint(index);
171
+ }
172
+ }
173
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ChangeEndpointsService, deps: [{ token: CONFIGURACION_TOKEN }, { token: PUSHERS_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
174
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ChangeEndpointsService, providedIn: 'root' }); }
175
+ }
176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ChangeEndpointsService, decorators: [{
177
+ type: Injectable,
178
+ args: [{
179
+ providedIn: 'root'
180
+ }]
181
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
182
+ type: Inject,
183
+ args: [CONFIGURACION_TOKEN]
184
+ }] }, { type: undefined, decorators: [{
185
+ type: Inject,
186
+ args: [PUSHERS_CONFIG_TOKEN]
187
+ }] }] });
188
+
189
+ class ApiEndpointsService {
190
+ constructor(
191
+ // Application Constants
192
+ //private constants: Constants,
193
+ endpoints) {
194
+ this.endpoints = endpoints;
195
+ this.getEndpoint = (action) => this.createUrl(action);
196
+ this.getEndpointWithParameters = (action, parameters) => this.createUrlWithQueryParameters(action, parameters);
197
+ }
198
+ /* #region URL CREATOR */
199
+ // URL
200
+ createUrl(action, isDooleAPI = false) {
201
+ const urlBuilder = new UrlBuilder(this.endpoints.API_ENDPOINT, action);
202
+ return urlBuilder.toString();
203
+ }
204
+ // URL WITH QUERY PARAMS
205
+ createUrlWithQueryParameters(action, queryStringHandler) {
206
+ const urlBuilder = new UrlBuilder(this.endpoints.API_ENDPOINT, action);
207
+ // Push extra query string params
208
+ if (queryStringHandler) {
209
+ queryStringHandler(urlBuilder.queryString);
210
+ }
211
+ return urlBuilder.toString();
212
+ }
213
+ // URL WITH PATH VARIABLES
214
+ createUrlWithPathVariables(action, pathVariables = []) {
215
+ let encodedPathVariablesUrl = '';
216
+ // Push extra path variables
217
+ for (const pathVariable of pathVariables) {
218
+ if (pathVariable !== null) {
219
+ encodedPathVariablesUrl +=
220
+ `/${encodeURIComponent(pathVariable.toString())}`;
221
+ }
222
+ }
223
+ const urlBuilder = new UrlBuilder(this.endpoints.API_ENDPOINT, `${action}${encodedPathVariablesUrl}`);
224
+ return urlBuilder.toString();
225
+ }
226
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ApiEndpointsService, deps: [{ token: ChangeEndpointsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
227
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ApiEndpointsService, providedIn: 'root' }); }
228
+ }
229
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ApiEndpointsService, decorators: [{
230
+ type: Injectable,
231
+ args: [{
232
+ providedIn: 'root'
233
+ }]
234
+ }], ctorParameters: () => [{ type: ChangeEndpointsService }] });
235
+
236
+ class EncryptionService {
237
+ constructor() {
238
+ this.secretKey = 'D001E-APP';
239
+ }
240
+ encryptData(data) {
241
+ const encryptedData = CryptoJS.AES.encrypt(JSON.stringify(data), this.secretKey).toString();
242
+ return encryptedData;
243
+ }
244
+ decryptData(encryptedData) {
245
+ const decryptedData = CryptoJS.AES.decrypt(encryptedData, this.secretKey);
246
+ try {
247
+ const data = decryptedData.toString(CryptoJS.enc.Utf8);
248
+ return JSON.parse(data);
249
+ }
250
+ catch (e) {
251
+ return encryptedData;
252
+ }
253
+ }
254
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: EncryptionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
255
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: EncryptionService, providedIn: 'root' }); }
256
+ }
257
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: EncryptionService, decorators: [{
258
+ type: Injectable,
259
+ args: [{
260
+ providedIn: 'root'
261
+ }]
262
+ }], ctorParameters: () => [] });
263
+
264
+ const TOKEN_KEY$1 = 'token';
265
+ const DEVICE_TOKENS = 'tokens';
266
+ class TokenService {
267
+ constructor(encryptionService) {
268
+ this.encryptionService = encryptionService;
269
+ this.deviceTokens = [];
270
+ }
271
+ // getToken(){
272
+ // return this.token
273
+ // }
274
+ // setToken(token){
275
+ // this.token = token;
276
+ // }
277
+ hasToken() {
278
+ return this.token != undefined ? true : false;
279
+ }
280
+ getAuthToken() {
281
+ const token = localStorage.getItem(TOKEN_KEY$1);
282
+ if (!token)
283
+ return;
284
+ //console.log("[TokenService] getAuthToken()", token);
285
+ const encryptedData = this.encryptionService.decryptData(token);
286
+ return encryptedData;
287
+ }
288
+ setAuthToken(token) {
289
+ const encryptedData = this.encryptionService.encryptData(token);
290
+ localStorage.setItem(TOKEN_KEY$1, encryptedData);
291
+ }
292
+ removeAuthToken() {
293
+ localStorage.removeItem(TOKEN_KEY$1);
294
+ }
295
+ saveAllTokenDevices(token) {
296
+ this.deviceTokens.push(token);
297
+ const encryptedData = this.encryptionService.encryptData(this.deviceTokens);
298
+ console.log("[TokenService] saveAllTokenDevices() ", encryptedData);
299
+ localStorage.setItem(DEVICE_TOKENS, JSON.stringify(encryptedData));
300
+ }
301
+ getAllTokenDevices() {
302
+ let list = JSON.parse(localStorage.getItem(DEVICE_TOKENS));
303
+ if (!list)
304
+ return null;
305
+ console.log("[TokenService] getAllTokenDevices() ", list);
306
+ const decryptedData = this.encryptionService.decryptData(list);
307
+ this.deviceTokens = decryptedData ? decryptedData : [];
308
+ return this.deviceTokens;
309
+ }
310
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: TokenService, deps: [{ token: EncryptionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
311
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: TokenService, providedIn: 'root' }); }
312
+ }
313
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: TokenService, decorators: [{
314
+ type: Injectable,
315
+ args: [{
316
+ providedIn: 'root'
317
+ }]
318
+ }], ctorParameters: () => [{ type: EncryptionService }] });
319
+
320
+ const TOKEN_KEY = 'token';
321
+ const INTRO_KEY = 'intro';
322
+ const TOKENS = 'tokens';
323
+ const TWO_FACTOR_CENTER = 'two-factor-center';
324
+ class User {
325
+ constructor(idUser, secret, name, first_name, image) {
326
+ this.roles = [];
327
+ this.listFamilyUnit = [];
328
+ this.idUser = idUser;
329
+ this.secret = secret;
330
+ this.name = name;
331
+ this.first_name = first_name;
332
+ this.image = image;
333
+ }
334
+ ;
335
+ }
336
+ class AuthenticationService {
337
+ constructor(platformId, http, tokenService, api, platform, firebaseAuth, router, alertController, injector, endpoints) {
338
+ this.platformId = platformId;
339
+ this.http = http;
340
+ this.tokenService = tokenService;
341
+ this.api = api;
342
+ this.platform = platform;
343
+ this.firebaseAuth = firebaseAuth;
344
+ this.router = router;
345
+ this.alertController = alertController;
346
+ this.injector = injector;
347
+ this.endpoints = endpoints;
348
+ this.isAuthenticated = new BehaviorSubject(false);
349
+ this.isRecovery = false;
350
+ this.agendaUser = [];
351
+ this.tokens = [];
352
+ this.showingSignInAlert = false;
353
+ this.setUser();
354
+ }
355
+ getIndexEndPoint() {
356
+ this.indexEndPoint = Number(localStorage.getItem('endpoint'));
357
+ console.log("[AuthService] indexEndPoint: ", this.indexEndPoint);
358
+ }
359
+ getAuthToken() {
360
+ const token = this.tokenService.getAuthToken();
361
+ //console.log("[AuthService] getAuthToken: ", token);
362
+ return token;
363
+ }
364
+ setAuthToken(token) {
365
+ this.tokenService.setAuthToken(token);
366
+ }
367
+ // getAuthToken() {
368
+ // const token = localStorage.getItem(TOKEN_KEY);
369
+ // return token;
370
+ // }
371
+ // setAuthToken(token) {
372
+ // localStorage.setItem(TOKEN_KEY, token);
373
+ // }
374
+ login(credentials) {
375
+ const endpoint = this.api.getEndpoint('patient/login');
376
+ console.log('credentials: ', credentials);
377
+ return this.http.post(endpoint, credentials).pipe(map((res) => {
378
+ console.log("[AuthService] login() OK ");
379
+ console.log("[AuthService] endpoint", endpoint);
380
+ if (!res.success) {
381
+ return res;
382
+ }
383
+ // save user's token
384
+ if (res.token) {
385
+ this.tokenService.setAuthToken(res.token);
386
+ this.setAuthToken(res.token);
387
+ }
388
+ // Set indexEndPoint ios_dev if it is QA
389
+ this.getIndexEndPoint();
390
+ if (Capacitor.isNativePlatform()) {
391
+ //console.log(data);
392
+ let access = true;
393
+ if (this.deviceToken && this.devicePlatform)
394
+ this.registerDevice(this.deviceToken, this.devicePlatform);
395
+ if (this.platform.is('ios')) {
396
+ if (this.voipDeviceToken)
397
+ this.registerDevice(this.voipDeviceToken, this.endpoints._ENVIROMENT.device_ios.ios_voip);
398
+ //this.registerDevice(this.voipDeviceToken, (this.indexEndPoint!==0)?'iosvoipdev':'iosvoip');
399
+ }
400
+ }
401
+ this.user = new User(res.idUser, credentials.password, res.name, res.first_name, res.temporary_url);
402
+ this.id_user = res.idUser;
403
+ this.setUserLocalstorage(this.user);
404
+ this.setTwoFactor(res.twoFactorCenter);
405
+ if (res?.familyUnit.length > 0) {
406
+ this.user.listFamilyUnit = res.familyUnit;
407
+ }
408
+ return res;
409
+ }), tap(_ => {
410
+ this.isAuthenticated.next(true);
411
+ }));
412
+ }
413
+ setUser() {
414
+ if (!this.user) {
415
+ this.getUserLocalstorage().then(user => {
416
+ console.log("[AuthenticationService] setUser()", user);
417
+ if (user)
418
+ this.user = user;
419
+ });
420
+ }
421
+ }
422
+ setUserLocalstorage(user) {
423
+ console.log(`[AuthenticationService] setUserLocalstorage()`, user);
424
+ Preferences.set({
425
+ key: 'user',
426
+ value: JSON.stringify(user)
427
+ });
428
+ }
429
+ setFamilyUnitLocalstorage(familyUnit) {
430
+ familyUnit.forEach(member => {
431
+ let s = member['name'];
432
+ let fullname = s.split(',');
433
+ let u = new User(member['id'], '', fullname[1], fullname[0], member['thumbnail']);
434
+ console.log("familyUnit Local:", u);
435
+ Preferences.set({
436
+ key: String(u.idUser),
437
+ value: JSON.stringify(u)
438
+ });
439
+ });
440
+ }
441
+ getFamilyUnitLocalstorage(id) {
442
+ return Preferences.get({ key: id }).then((val) => {
443
+ console.log(`[AuthenticationService] getFamilyUnitLocalstorage(${id})`, val);
444
+ return JSON.parse(val.value);
445
+ });
446
+ }
447
+ async setFamilyUnit(user) {
448
+ this.isFamily = true;
449
+ let s = user['name'];
450
+ let fullname = s.split(',');
451
+ this.user = new User(user.id, '', fullname[0].replace(',', ''), fullname[1], user.thumbnail);
452
+ this.user.familyUnit = user.id;
453
+ Preferences.set({
454
+ key: String(user.id),
455
+ value: JSON.stringify(this.user)
456
+ });
457
+ }
458
+ getUserLocalstorage() {
459
+ return Preferences.get({ key: 'user' }).then((val) => {
460
+ return JSON.parse(val.value);
461
+ });
462
+ }
463
+ async setUserFamilyId(id) {
464
+ await this.getUserLocalstorage().then(user => {
465
+ console.log(`[AuthenticationService] MEMBER(${id})`, user);
466
+ let s = user['name'];
467
+ let fullname = s.split(',');
468
+ this.user = new User(user['idUser'], '', fullname[0].replace(',', ''), fullname[1], user['image']);
469
+ this.user.familyUnit = id;
470
+ this.setUserLocalstorage(this.user);
471
+ });
472
+ }
473
+ getShowIntroLocalstorage() {
474
+ return Preferences.get({ key: 'showIntro' }).then((val) => {
475
+ return Boolean(val.value);
476
+ });
477
+ }
478
+ async setShowIntroLocalstorage() {
479
+ await Preferences.set({
480
+ key: 'showIntro',
481
+ value: 'true'
482
+ });
483
+ }
484
+ setTwoFactor(tfCenter) {
485
+ localStorage.setItem('two-factor-center', tfCenter);
486
+ }
487
+ async logout1() {
488
+ console.log('logout');
489
+ this.isAuthenticated.next(false);
490
+ const enviroment = this.endpoints._ENVIROMENT;
491
+ //localStorage.removeItem(enviroment?.registered_user)
492
+ await Preferences.remove({ key: 'user' }).then((val) => { });
493
+ return Preferences.remove({ key: TOKEN_KEY });
494
+ }
495
+ logout(allDevices) {
496
+ this.getAllTokenDevices();
497
+ let params = {
498
+ tokens: this.tokens,
499
+ allDevices: allDevices ? allDevices : false
500
+ };
501
+ console.log('logout', params);
502
+ let path = 'patient/logout';
503
+ const endpoint = this.api.getEndpoint(path);
504
+ return this.http.post(endpoint, params).pipe(map((res) => {
505
+ console.log(`[AuthenticationService] logout(${path}) res: `, JSON.stringify(res));
506
+ this.isAuthenticated.next(false);
507
+ const enviroment = this.endpoints._ENVIROMENT;
508
+ //localStorage.removeItem(enviroment?.registered_user)
509
+ Preferences.remove({ key: 'user' }).then((val) => { });
510
+ Preferences.remove({ key: TOKEN_KEY });
511
+ return res;
512
+ }));
513
+ }
514
+ getAllTokenDevices() {
515
+ let list = JSON.parse(localStorage.getItem(TOKENS));
516
+ this.tokens = list ? list : [];
517
+ }
518
+ increaseNumloginFailed() {
519
+ let numFailLogin = 0;
520
+ let num = localStorage.getItem('num-fail-login');
521
+ if (num) {
522
+ let numFailLogin = Number(JSON.parse(num)) + 1;
523
+ localStorage.setItem('num-fail-login', '' + numFailLogin);
524
+ localStorage.setItem('login_request_locked_at', '' + (new Date().getTime()));
525
+ }
526
+ else {
527
+ localStorage.setItem('num-fail-login', '1');
528
+ localStorage.setItem('login_request_locked_at', '' + (new Date().getTime()));
529
+ numFailLogin = 1;
530
+ }
531
+ console.log('[AuthenticationService] increaseNumloginFailed()', numFailLogin);
532
+ }
533
+ increaseNumFPAIOFailed() {
534
+ let num = localStorage.getItem('num-fail-finger-print');
535
+ if (num) {
536
+ localStorage.setItem('num-fail-login', '' + (Number(JSON.parse(num)) + 1));
537
+ localStorage.setItem('login_request_locked_at', '' + (new Date().getTime()));
538
+ }
539
+ else {
540
+ localStorage.setItem('num-fail-login', '1');
541
+ localStorage.setItem('login_request_locked_at', '' + (new Date().getTime()));
542
+ }
543
+ }
544
+ getNumloginFailed() {
545
+ let num = localStorage.getItem('num-fail-login');
546
+ if (num)
547
+ return Number(JSON.parse(num));
548
+ return 0;
549
+ }
550
+ getDateloginFailed() {
551
+ let num = localStorage.getItem('login_request_locked_at');
552
+ if (num)
553
+ return Number(JSON.parse(num));
554
+ return 0;
555
+ }
556
+ getNumFingerPrinterFailed() {
557
+ let num = localStorage.getItem('num-fail-finger-print');
558
+ if (num)
559
+ return Number(JSON.parse(num));
560
+ return 0;
561
+ }
562
+ removeNumloginFailed() {
563
+ localStorage.removeItem('num-fail-login');
564
+ localStorage.removeItem('login_request_locked_at');
565
+ }
566
+ removeNumFirgerPFailed() {
567
+ localStorage.removeItem('num-fail-finger-print');
568
+ localStorage.removeItem('login_request_locked_at');
569
+ }
570
+ get(endpt) {
571
+ const endpoint = this.api.getEndpoint(endpt);
572
+ return this.http.get(endpoint).pipe(map((res) => {
573
+ return res;
574
+ }));
575
+ }
576
+ post(endpt, items) {
577
+ const endpoint = this.api.getEndpoint(endpt);
578
+ return this.http.post(endpoint, items).pipe(map((res) => {
579
+ return res;
580
+ }));
581
+ }
582
+ throwError(error) {
583
+ if (error instanceof HttpErrorResponse)
584
+ throw new HttpErrorResponse(error);
585
+ else
586
+ throw new Error(error);
587
+ }
588
+ registerDevice(token, platform) {
589
+ console.log("response IOSDEV", platform);
590
+ if (platform == 'FCM')
591
+ platform = 'android';
592
+ if (platform == 'APNS')
593
+ platform = this.endpoints._ENVIROMENT.device_ios.ios_push;
594
+ if (platform == 'ios')
595
+ platform = this.endpoints._ENVIROMENT.device_ios.ios_push;
596
+ const postData = {
597
+ token: token,
598
+ platform: platform
599
+ };
600
+ console.log("postData: ", postData);
601
+ return this.post('user/device/register', postData).subscribe(async (data) => {
602
+ let response = data;
603
+ console.log("response user/device/register");
604
+ console.log(response);
605
+ this.saveAllTokenDevices(postData);
606
+ return response;
607
+ }, (error) => {
608
+ // Called when error
609
+ console.log('error user/device/register: ', error);
610
+ throw error;
611
+ });
612
+ }
613
+ saveAllTokenDevices(token) {
614
+ this.tokens.push(token);
615
+ localStorage.setItem(TOKENS, JSON.stringify(this.tokens));
616
+ }
617
+ async showIntro() {
618
+ return Preferences.get({ key: INTRO_KEY }).then(async (data) => {
619
+ let showIntro = Boolean(data.value);
620
+ console.log(`[AuthService] showIntro()`, showIntro);
621
+ return showIntro;
622
+ });
623
+ }
624
+ postAPIbiometric(params) {
625
+ let path = `user/biometric`;
626
+ const endpoint = this.api.getEndpoint(path);
627
+ return this.http.post(endpoint, params).pipe(map((res) => {
628
+ console.log(`[DooleService] postAPIbiometric(${path}) res: `, res);
629
+ return res;
630
+ }));
631
+ }
632
+ putAPIbiometric(id, params) {
633
+ let path = `user/biometric/${id}`;
634
+ const endpoint = this.api.getEndpoint(path);
635
+ return this.http.put(endpoint, params).pipe(map((res) => {
636
+ console.log(`[DooleService] putAPIbiometric(${path}) res: `, res);
637
+ return res;
638
+ }));
639
+ }
640
+ deleteAPIbiometric(id) {
641
+ let path = `user/biometric/${id}`;
642
+ const endpoint = this.api.getEndpoint(path);
643
+ return this.http.delete(endpoint).pipe(map((res) => {
644
+ console.log(`[DooleService] deleteAPIbiometric(${path}) res: ${res}`, JSON.stringify(res));
645
+ return res;
646
+ }));
647
+ }
648
+ redirectLogin() {
649
+ this.router.navigateByUrl('/landing');
650
+ }
651
+ async redirectUnauthenticated() {
652
+ const translateService = this.injector.get(TranslateService);
653
+ const alert = await this.alertController.create({
654
+ cssClass: "alertClass",
655
+ header: translateService.instant('info.title'),
656
+ backdropDismiss: false,
657
+ // subHeader: 'Subtitle',
658
+ message: translateService.instant('landing.login_again'),
659
+ buttons: [
660
+ { text: translateService.instant('button.accept'),
661
+ handler: () => {
662
+ this.router.navigateByUrl(`/landing`);
663
+ }
664
+ }
665
+ ]
666
+ });
667
+ await alert.present();
668
+ }
669
+ getShowGoogleFitLocalstorage() {
670
+ return Preferences.get({ key: 'showGoogleFit' }).then((val) => {
671
+ return Boolean(val.value);
672
+ });
673
+ }
674
+ async setShowGoogleFitLocalstorage() {
675
+ await Preferences.set({
676
+ key: 'showGoogleFit',
677
+ value: 'true'
678
+ });
679
+ }
680
+ setCanceledGoogleFitLocalstorage(mostrar) {
681
+ localStorage.setItem('cancelGoogleFit', mostrar);
682
+ }
683
+ getCanceledGoogleFitLocalstorage() {
684
+ const value = localStorage.getItem('cancelGoogleFit');
685
+ console.log("Booelan: ", value);
686
+ return value !== null ? JSON.parse(value) : false;
687
+ }
688
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: AuthenticationService, deps: [{ token: PLATFORM_ID }, { token: i1.HttpClient }, { token: TokenService }, { token: ApiEndpointsService }, { token: i2.Platform }, { token: i5.AngularFireAuth }, { token: i6.Router }, { token: i2.AlertController }, { token: i0.Injector }, { token: ChangeEndpointsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
689
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: AuthenticationService, providedIn: 'root' }); }
690
+ }
691
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: AuthenticationService, decorators: [{
692
+ type: Injectable,
693
+ args: [{
694
+ providedIn: 'root'
695
+ }]
696
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
697
+ type: Inject,
698
+ args: [PLATFORM_ID]
699
+ }] }, { type: i1.HttpClient }, { type: TokenService }, { type: ApiEndpointsService }, { type: i2.Platform }, { type: i5.AngularFireAuth }, { type: i6.Router }, { type: i2.AlertController }, { type: i0.Injector }, { type: ChangeEndpointsService }], propDecorators: { outlet: [{
700
+ type: ViewChild,
701
+ args: [RouterOutlet]
702
+ }] } });
703
+
704
+ class HttpService {
705
+ constructor(http, httpBackend, authService) {
706
+ this.http = http;
707
+ this.httpBackend = httpBackend;
708
+ this.authService = authService;
709
+ this.httpWithoutInterceptor = new HttpClient(httpBackend);
710
+ }
711
+ async formatErrors(error) {
712
+ return error;
713
+ }
714
+ get(path, params = new HttpParams()) {
715
+ let user = this.authService?.user;
716
+ params = (user?.familyUnit) ? params.append('user', user?.familyUnit) : params;
717
+ return this.http.get(`${path}`, { params })
718
+ .pipe(catchError(this.formatErrors));
719
+ }
720
+ put(path, body = {}, options = {}) {
721
+ let httpOptions = this.setHttpOptions(options);
722
+ //console.log("url: ", path);
723
+ //console.log("body: ", body);
724
+ return this.http.put(`${path}`, JSON.stringify(body), httpOptions).pipe(catchError(this.formatErrors));
725
+ }
726
+ postform(path, body = {}, options = {}) {
727
+ let user = this.authService?.user;
728
+ if (user?.familyUnit !== null)
729
+ body['user'] = user?.familyUnit;
730
+ let httpOptions = this.setHttpOptions(options);
731
+ //console.log("url: ", path);
732
+ //console.log("body: ", body);
733
+ return this.http.post(`${path}`, JSON.stringify(body), httpOptions).pipe(catchError(this.formatErrors));
734
+ }
735
+ post(path, body = {}, options = {}, formData) {
736
+ let user = this.authService?.user;
737
+ if (user?.familyUnit !== undefined && user?.familyUnit !== null)
738
+ body['user'] = user?.familyUnit;
739
+ let httpOptions = this.setHttpOptions(options, formData);
740
+ //console.log("url: ", path);
741
+ //console.log("body: ", body);
742
+ return this.http.post(`${path}`, JSON.stringify(body), httpOptions).pipe(catchError(this.formatErrors));
743
+ }
744
+ postForm(path, body = {}, options = {}, formData) {
745
+ let user = this.authService?.user;
746
+ if (user?.familyUnit !== null)
747
+ body['user'] = user?.familyUnit;
748
+ const httpOptions = {
749
+ headers: new HttpHeaders({
750
+ 'Accept': 'application/json'
751
+ })
752
+ };
753
+ console.log("url: ", path);
754
+ console.log("body: ", body);
755
+ return this.http.post(`${path}`, body, httpOptions).pipe(catchError(this.formatErrors));
756
+ }
757
+ delete(path) {
758
+ return this.http.delete(`${path}`).pipe(catchError(this.formatErrors));
759
+ }
760
+ _get(path, params = new HttpParams()) {
761
+ return this.httpWithoutInterceptor.get(`${path}`, { params })
762
+ .pipe(catchError(this.formatErrors));
763
+ }
764
+ _put(path, body = {}) {
765
+ return this.httpWithoutInterceptor.put(`${path}`, JSON.stringify(body)).pipe(catchError(this.formatErrors));
766
+ }
767
+ _post(path, body = {}, options = {}) {
768
+ let httpOptions = this.setHttpOptions(options);
769
+ let params = this.setHttpParams(body);
770
+ return this.httpWithoutInterceptor.post(`${path}`, JSON.stringify(body), httpOptions).pipe(catchError(error => this.formatErrors(error)));
771
+ }
772
+ _delete(path) {
773
+ return this.httpWithoutInterceptor.delete(`${path}`).pipe(catchError(this.formatErrors));
774
+ }
775
+ setHttpParams(body) {
776
+ let params = new HttpParams();
777
+ if (body != null)
778
+ for (let key in body)
779
+ params = params.append(key, body[key]);
780
+ return params;
781
+ }
782
+ setHttpOptions(options, formData) {
783
+ console.log('** options', options);
784
+ if (formData) {
785
+ const httpOptions = {
786
+ headers: new HttpHeaders({
787
+ 'Accept': 'application/json'
788
+ })
789
+ };
790
+ return httpOptions;
791
+ }
792
+ else if (Object.keys(options).length > 0) {
793
+ const httpOptions = {
794
+ headers: new HttpHeaders({
795
+ 'Content-Type': 'application/json',
796
+ 'Accept': 'application/json',
797
+ options
798
+ })
799
+ };
800
+ return httpOptions;
801
+ }
802
+ else {
803
+ const httpOptions = {
804
+ headers: new HttpHeaders({
805
+ 'Content-Type': 'application/json',
806
+ 'Accept': 'application/json',
807
+ })
808
+ };
809
+ return httpOptions;
810
+ }
811
+ }
812
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: HttpService, deps: [{ token: i1.HttpClient }, { token: i1.HttpBackend }, { token: AuthenticationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
813
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: HttpService, providedIn: 'root' }); }
814
+ }
815
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: HttpService, decorators: [{
816
+ type: Injectable,
817
+ args: [{
818
+ providedIn: 'root'
819
+ }]
820
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: i1.HttpBackend }, { type: AuthenticationService }] });
821
+
822
+ /**
823
+ * A custom Events service just like Ionic 3 Events https://ionicframework.com/docs/v3/api/util/Events/ which got removed in Ionic 5.
824
+ *
825
+ * @author Shashank Agrawal
826
+ */
827
+ class Events {
828
+ constructor() {
829
+ this.channels = {};
830
+ }
831
+ /**
832
+ * Subscribe to a topic and provide a single handler/observer.
833
+ * @param topic The name of the topic to subscribe to.
834
+ * @param observer The observer or callback function to listen when changes are published.
835
+ *
836
+ * @returns Subscription from which you can unsubscribe to release memory resources and to prevent memory leak.
837
+ */
838
+ subscribe(topic, observer) {
839
+ console.log("subscribe topic: ", topic);
840
+ if (!this.channels[topic]) {
841
+ // You can also use ReplaySubject with one concequence
842
+ this.channels[topic] = new Subject();
843
+ }
844
+ return this.channels[topic].subscribe(observer);
845
+ }
846
+ /**
847
+ * Publish some data to the subscribers of the given topic.
848
+ * @param topic The name of the topic to emit data to.
849
+ * @param data data in any format to pass on.
850
+ */
851
+ publish(topic, data) {
852
+ const subject = this.channels[topic];
853
+ if (!subject) {
854
+ // Or you can create a new subject for future subscribers
855
+ return;
856
+ }
857
+ subject.next(data);
858
+ }
859
+ /**
860
+ * When you are sure that you are done with the topic and the subscribers no longer needs to listen to a particular topic, you can
861
+ * destroy the observable of the topic using this method.
862
+ * @param topic The name of the topic to destroy.
863
+ */
864
+ destroy(topic) {
865
+ const subject = this.channels[topic];
866
+ if (!subject) {
867
+ return null;
868
+ }
869
+ subject.complete();
870
+ delete this.channels[topic];
871
+ }
872
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: Events, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
873
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: Events, providedIn: 'root' }); }
874
+ }
875
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: Events, decorators: [{
876
+ type: Injectable,
877
+ args: [{
878
+ providedIn: 'root'
879
+ }]
880
+ }] });
881
+
882
+ class DooleService {
883
+ constructor(authService, transfer, file, http, api, events, platform, router, alertController) {
884
+ this.authService = authService;
885
+ this.transfer = transfer;
886
+ this.file = file;
887
+ this.http = http;
888
+ this.api = api;
889
+ this.events = events;
890
+ this.platform = platform;
891
+ this.router = router;
892
+ this.alertController = alertController;
893
+ }
894
+ uploadFile(image, id) {
895
+ console.log("uploading ", image);
896
+ const token = localStorage.getItem('token');
897
+ let options = {
898
+ fileKey: 'file',
899
+ fileName: 'name.jpg',
900
+ headers: {
901
+ 'Authorization': 'Bearer ' + token,
902
+ 'Accept': 'application/json',
903
+ },
904
+ params: {
905
+ id: id
906
+ }
907
+ };
908
+ const fileTransfer = this.transfer.create();
909
+ // Add files for new or saved diagnostics.
910
+ // uses diagnostic/media when diagnostic is new
911
+ //const endpoint = id ? this.api.getEndpoint('diagnostic/media'):this.api.getDooleEndpoint('media/upload/temp') ;
912
+ const endpoint = this.api.getEndpoint('media/upload/temp');
913
+ //console.log("* uploadFile endpoint", endpoint);
914
+ return new Promise(function (resolve, reject) {
915
+ fileTransfer.upload(image, endpoint, options).then(data => {
916
+ console.log(data);
917
+ resolve(JSON.parse(data.response));
918
+ }, (err) => {
919
+ console.log(err);
920
+ reject(err);
921
+ });
922
+ });
923
+ }
924
+ postAPIAddMedia(params) {
925
+ const endpoint = this.api.getEndpoint('media/add');
926
+ return this.http.postForm(endpoint, params).pipe(map((res) => {
927
+ console.log(`[DooleService] postAPIAddMedia(${endpoint}) res: `, res);
928
+ return res;
929
+ }));
930
+ }
931
+ uploadFileToModel(image, name, params) {
932
+ //console.log("uploading ", image);
933
+ const token = localStorage.getItem('token');
934
+ let options = {
935
+ fileKey: 'file',
936
+ fileName: name,
937
+ headers: {
938
+ 'Authorization': 'Bearer ' + token,
939
+ 'Accept': 'application/json',
940
+ },
941
+ params
942
+ };
943
+ const fileTransfer = this.transfer.create();
944
+ const endpoint = this.api.getEndpoint('media/add');
945
+ return new Promise(function (resolve, reject) {
946
+ fileTransfer.upload(image, endpoint, options).then(data => {
947
+ console.log(JSON.parse(data.response));
948
+ resolve(JSON.parse(data.response));
949
+ }, (err) => {
950
+ console.log(err);
951
+ reject(err);
952
+ });
953
+ });
954
+ }
955
+ uploadMessageImage(idMessageHeader, idUserTo, message, fileUrl, id_usuari_amiq) {
956
+ const token = localStorage.getItem('token');
957
+ let options = {
958
+ fileKey: 'file',
959
+ fileName: 'name.pdf', //TODO: 'name.jpg'
960
+ headers: {
961
+ 'Authorization': 'Bearer ' + token,
962
+ 'Accept': 'application/json',
963
+ },
964
+ params: {
965
+ idUser: id_usuari_amiq,
966
+ secret: token,
967
+ value: "",
968
+ id: idMessageHeader
969
+ }
970
+ };
971
+ //console.log("options: ", options);
972
+ const fileTransfer = this.transfer.create();
973
+ fileTransfer.onProgress((progressEvent) => {
974
+ if (progressEvent.lengthComputable) {
975
+ var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100);
976
+ this.events.publish("uploadMessageImage", { fileUrl, perc });
977
+ }
978
+ else {
979
+ //console.log("progressEvent - ", progressEvent);
980
+ }
981
+ });
982
+ const endpoint = this.api.getEndpoint('message');
983
+ return new Promise(function (resolve, reject) {
984
+ fileTransfer.upload(fileUrl, endpoint, options)
985
+ .then(data => {
986
+ //console.log("success fileTransfer.upload", JSON.parse(data.response));
987
+ resolve(JSON.parse(data.response));
988
+ }, (err) => {
989
+ //console.log("** error ** fileTransfer.upload: ", err);
990
+ reject(fileTransfer.upload);
991
+ });
992
+ });
993
+ }
994
+ b64toBlob(b64Data, contentType = '', sliceSize = 512) {
995
+ const byteCharacters = atob(b64Data);
996
+ const byteArrays = [];
997
+ for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
998
+ const slice = byteCharacters.slice(offset, offset + sliceSize);
999
+ const byteNumbers = new Array(slice.length);
1000
+ for (let i = 0; i < slice.length; i++) {
1001
+ byteNumbers[i] = slice.charCodeAt(i);
1002
+ }
1003
+ const byteArray = new Uint8Array(byteNumbers);
1004
+ byteArrays.push(byteArray);
1005
+ }
1006
+ const blob = new Blob(byteArrays, { type: contentType });
1007
+ return blob;
1008
+ }
1009
+ downloadFile(url, destination) {
1010
+ var result = [];
1011
+ const fileTransfer = this.transfer.create();
1012
+ var path = null;
1013
+ if (this.platform.is('ios')) {
1014
+ path = this.file.documentsDirectory;
1015
+ }
1016
+ else {
1017
+ path = this.file.dataDirectory;
1018
+ }
1019
+ //console.log("downloadFile", url, destination, 'path,destination', path, destination);
1020
+ return new Observable((observer) => {
1021
+ //console.log("before CheckFile", this.file);
1022
+ this.file.checkFile(path, destination).then(res => {
1023
+ //console.log("*res*", res);
1024
+ if (res) {
1025
+ //console.log("exists", res);
1026
+ result["success"] = true;
1027
+ result["downloaded"] = true;
1028
+ result["file"] = path + destination; //normalizeURL(this.file.cacheDirectory + destination);
1029
+ result["fileNormalized"] = Capacitor.convertFileSrc(path + destination);
1030
+ return observer.next(result);
1031
+ }
1032
+ }, error => {
1033
+ //console.log("not exists");
1034
+ fileTransfer.onProgress(event => {
1035
+ if (event.lengthComputable) {
1036
+ //console.log(event.loaded / event.total);
1037
+ result["status"] = "downloading";
1038
+ result["downloaded"] = false;
1039
+ result["percent"] = Math.round((event.loaded / event.total) * 100);
1040
+ return observer.next(result);
1041
+ }
1042
+ });
1043
+ return fileTransfer.download(url, path + destination).then((entry) => {
1044
+ //console.log('*download:* ' + url + " " + entry.toURL());
1045
+ result["success"] = true;
1046
+ result["downloaded"] = true;
1047
+ result["file"] = entry.toURL(); //normalizeURL(this.file.cacheDirectory + destination);
1048
+ result["fileNormalized"] = Capacitor.convertFileSrc(path + destination);
1049
+ return observer.next(result);
1050
+ }, (error) => {
1051
+ //console.log(error);
1052
+ result["success"] = false;
1053
+ result["downloaded"] = false;
1054
+ //console.log("error download " + url);
1055
+ //console.log(result);
1056
+ return observer.next(result);
1057
+ });
1058
+ });
1059
+ });
1060
+ }
1061
+ deleteFile(id) {
1062
+ let path = `media/${id}`;
1063
+ const endpoint = this.api.getEndpoint(path);
1064
+ return this.http.delete(endpoint).pipe(map((res) => {
1065
+ console.log(`[DooleService] deleteFile(${path}) res: ${res}`, JSON.stringify(res));
1066
+ return res;
1067
+ }));
1068
+ }
1069
+ showAlert(message) {
1070
+ return this.alertController.create({
1071
+ header: 'Info',
1072
+ message: message,
1073
+ backdropDismiss: false,
1074
+ buttons: ['OK']
1075
+ });
1076
+ }
1077
+ async showAlertAndReturn(header, message, isDismiss, route) {
1078
+ //console.log(`[DooleService] showAlertAndReturn()`);
1079
+ let dismiss = (isDismiss !== undefined) ? isDismiss : false;
1080
+ const alert = await this.alertController.create({
1081
+ header: header,
1082
+ message: message,
1083
+ backdropDismiss: dismiss,
1084
+ buttons: [
1085
+ {
1086
+ text: 'OK',
1087
+ handler: (blah) => {
1088
+ // console.log('Confirm OK: blah');
1089
+ if (route !== undefined && route !== null)
1090
+ this.router.navigateByUrl(route);
1091
+ }
1092
+ }
1093
+ ]
1094
+ });
1095
+ await alert.present();
1096
+ }
1097
+ async presentAlert(message, button) {
1098
+ let buttonName = (button !== undefined) ? button : 'Ok';
1099
+ const alert = await this.alertController.create({
1100
+ cssClass: 'my-alert-class',
1101
+ message: message,
1102
+ buttons: [buttonName]
1103
+ });
1104
+ await alert.present();
1105
+ }
1106
+ getFamilyUnitID() {
1107
+ let httpParams = new HttpParams();
1108
+ let user = this.authService?.user;
1109
+ return httpParams = (user.familyUnit) ? httpParams.append('user', user.familyUnit) : httpParams;
1110
+ }
1111
+ getAPILegalInformation() {
1112
+ let path = 'user/legalTerm/lastAccepted';
1113
+ const endpoint = this.api.getEndpoint(path);
1114
+ return this.http.get(endpoint).pipe(map((res) => {
1115
+ console.log(`[DooleService] getAPILegalInformation(${path}) res: `, res);
1116
+ return res;
1117
+ }));
1118
+ }
1119
+ postAPILegalConfirmation(params) {
1120
+ let path = 'user/legalTerm/lastAccepted';
1121
+ const endpoint = this.api.getEndpoint(path);
1122
+ return this.http.post(endpoint, params).pipe(map((res) => {
1123
+ //console.log(`[DooleService] postAPIConfirmationLegal(${path}) res: `, res);
1124
+ return res;
1125
+ }));
1126
+ }
1127
+ postAPIRejectLegalConfirmation(params) {
1128
+ let path = 'user/legalTerm/lastDeclined';
1129
+ const endpoint = this.api.getEndpoint(path);
1130
+ return this.http.post(endpoint, params).pipe(map((res) => {
1131
+ //console.log(`[DooleService] postAPIConfirmationLegal(${path}) res: `, res);
1132
+ return res;
1133
+ }));
1134
+ }
1135
+ postAPIpasswordRecovery(params) {
1136
+ let path = 'patient/forgot';
1137
+ const endpoint = this.api.getEndpoint(path);
1138
+ return this.http.post(endpoint, params).pipe(map((res) => {
1139
+ //console.log(`[DooleService] postAPIpasswordRecovery(${path}) res: `, res);
1140
+ return res;
1141
+ }));
1142
+ }
1143
+ getAPIStaffSlots(params) {
1144
+ let path = `staff/${params.id}/availability`;
1145
+ let endpoint;
1146
+ if (params.date !== "") {
1147
+ endpoint = this.api.getEndpointWithParameters(path, (qs) => qs.push('date', params.date));
1148
+ }
1149
+ else {
1150
+ endpoint = this.api.getEndpoint(path);
1151
+ }
1152
+ return this.http.get(endpoint).pipe(map((res) => {
1153
+ //console.log(`[DooleService] getAPIStaffSlots(${path}) res: `, res);
1154
+ return res;
1155
+ }));
1156
+ }
1157
+ getAPIgoals() {
1158
+ let path = 'user/element/goals';
1159
+ const endpoint = this.api.getEndpoint(path);
1160
+ return this.http.get(endpoint).pipe(map((res) => {
1161
+ //console.log(`[DooleService] getAPIhomeInitial(${path}) res: `, res);
1162
+ return res;
1163
+ }));
1164
+ }
1165
+ getAPIvideocall(id) {
1166
+ let path = 'user/agenda/' + id + '/videocallSession';
1167
+ const endpoint = this.api.getEndpoint(path);
1168
+ return this.http.get(endpoint).pipe(map((res) => {
1169
+ console.log(`[DooleService] getAPIvideocall(${path}) res: `, res);
1170
+ return res;
1171
+ }));
1172
+ }
1173
+ postAPIPendingConnect() {
1174
+ let path = 'user/videocall/pendingConnect';
1175
+ const endpoint = this.api.getEndpoint(path);
1176
+ return this.http.post(endpoint).pipe(map((res) => {
1177
+ console.log(`[DooleService] getAPIPendingConnect(${path}) res: `, res);
1178
+ return res;
1179
+ }));
1180
+ }
1181
+ /* getAPIinformationUser(): Observable<any>{
1182
+
1183
+ let path = 'user/informationUser'
1184
+ const endpoint = this.api.getEndpoint(path);
1185
+ return this.http.get(endpoint).pipe(
1186
+ map((res: any) => {
1187
+ //console.log(`[DooleService] getAPIhomeInitial(${path}) res: `, res);
1188
+ return res;
1189
+ })
1190
+ )
1191
+ } */
1192
+ getAPIinformationSummary(params) {
1193
+ let path = 'home';
1194
+ const endpoint = this.api.getEndpoint(path);
1195
+ console.log('home params', params);
1196
+ return this.http.post(endpoint, params).pipe(map(res => res));
1197
+ }
1198
+ getAPIinformationSummaryOld(params) {
1199
+ let path = 'home';
1200
+ const endpoint = this.api.getEndpoint(path);
1201
+ return this.http.post(endpoint, params).pipe(map(res => res));
1202
+ }
1203
+ getAPIuserProfile() {
1204
+ let path = 'v2/user/profile';
1205
+ //let httpParams = this.getFamilyUnitID()
1206
+ const endpoint = this.api.getEndpoint(path);
1207
+ return this.http.get(endpoint).pipe(map((res) => {
1208
+ //console.log(`[DooleService] getAPIhomeInitial(${path}) res: `, res);
1209
+ return res;
1210
+ }));
1211
+ }
1212
+ postAPIChangePassword(params) {
1213
+ let path = 'user/changePassword';
1214
+ let httpParams = this.getFamilyUnitID();
1215
+ const endpoint = this.api.getEndpoint(path);
1216
+ return this.http.post(endpoint, params).pipe(map((res) => {
1217
+ //console.log(`[DooleService] postAPIChangePassword(${path}) res: `, res);
1218
+ return res;
1219
+ }));
1220
+ }
1221
+ getAPInotificationConfigurations() {
1222
+ let path = 'user/configuration';
1223
+ const endpoint = this.api.getEndpoint(path);
1224
+ return this.http.get(endpoint).pipe(map((res) => {
1225
+ //console.log(`[DooleService] getAPInotificationConfigurations(${path}) res: `, res);
1226
+ return res;
1227
+ }));
1228
+ }
1229
+ postAPIConfiguration(params) {
1230
+ let path = 'user/configuration';
1231
+ const endpoint = this.api.getEndpoint(path);
1232
+ return this.http.post(endpoint, params).pipe(map((res) => {
1233
+ //console.log(`[DooleService] postAPIConfiguration(${path}) res: `, res);
1234
+ return res;
1235
+ }));
1236
+ }
1237
+ getAPIlanguagesCenter() {
1238
+ let path = 'center/languages';
1239
+ const endpoint = this.api.getEndpoint(path);
1240
+ return this.http.get(endpoint).pipe(map((res) => {
1241
+ //console.log(`[DooleService] getAPIlanguagesCenter(${path}) res: `, res);
1242
+ return res;
1243
+ }));
1244
+ }
1245
+ getAPIFaqs() {
1246
+ let path = 'center/faq';
1247
+ const endpoint = this.api.getEndpoint(path);
1248
+ return this.http.get(endpoint).pipe(map((res) => {
1249
+ //console.log(`[DooleService] getAPIhomeInitial(${path}) res: `, res);
1250
+ return res;
1251
+ }));
1252
+ }
1253
+ getAPIFamilyUnit() {
1254
+ let path = 'user/familyUnit';
1255
+ const endpoint = this.api.getEndpoint(path);
1256
+ return this.http.get(endpoint).pipe(map((res) => {
1257
+ //console.log(`[DooleService] getAPIFamilyUnit(${path}) res: `, res);
1258
+ return res;
1259
+ }));
1260
+ }
1261
+ getAPIFamilyUnit2() {
1262
+ let path = 'v2/user/familyUnit';
1263
+ const endpoint = this.api.getEndpoint(path);
1264
+ return this.http.get(endpoint).pipe(map((res) => {
1265
+ console.log(`[DooleService] getAPIFamilyUnit(${path}) res: `, res);
1266
+ return res;
1267
+ }));
1268
+ }
1269
+ postAPIReportProblem(params) {
1270
+ let path = 'user/reportProblem'; // 'media/upload/temp'
1271
+ const endpoint = this.api.getEndpoint(path);
1272
+ return this.http.post(endpoint, params).pipe(map((res) => {
1273
+ console.log(`[DooleService] postAPIReportProblem(${path}) res: `, res);
1274
+ return res;
1275
+ }));
1276
+ }
1277
+ postAPIemailVerification(params) {
1278
+ let path = 'user/email_verification';
1279
+ const endpoint = this.api.getEndpoint(path);
1280
+ return this.http.post(endpoint, params).pipe(map((res) => {
1281
+ console.log(`[DooleService] postAPIemailVerification(${path}) res: `, res);
1282
+ return res;
1283
+ }));
1284
+ }
1285
+ getAPICodeByEmail() {
1286
+ let path = 'user/resendTwoFactorCode';
1287
+ const endpoint = this.api.getEndpoint(path);
1288
+ return this.http.get(endpoint).pipe(map((res) => {
1289
+ console.log(`[DooleService] getAPICodeByEmail(${path}) res: `, res);
1290
+ return res;
1291
+ }));
1292
+ }
1293
+ postAPIcodeVerification(params) {
1294
+ let path = 'user/verifyTwoFactor';
1295
+ //let path = 'user/codeVerification';
1296
+ const endpoint = this.api.getEndpoint(path);
1297
+ return this.http.post(endpoint, params).pipe(map((res) => {
1298
+ console.log(`[DooleService] postAPIcodeVerification(${path}) res: `, res);
1299
+ return res;
1300
+ }));
1301
+ }
1302
+ getAPIhealthCardTypes() {
1303
+ let path = 'center/healthCardTypes';
1304
+ const endpoint = this.api.getEndpoint(path);
1305
+ return this.http.get(endpoint).pipe(map((res) => {
1306
+ console.log(`[DooleService] getAPIhealthCardTypes(${path}) res: `, res);
1307
+ return res;
1308
+ }));
1309
+ }
1310
+ getAPIhealthCards() {
1311
+ let path = 'user/healthcards';
1312
+ const endpoint = this.api.getEndpoint(path);
1313
+ return this.http.get(endpoint).pipe(map((res) => {
1314
+ console.log(`[DooleService] getAPhealthCards(${path}) res: `, res);
1315
+ return res;
1316
+ }));
1317
+ }
1318
+ getAPIhealthCardId(id) {
1319
+ let path = `user/healthcard/${id}`;
1320
+ const endpoint = this.api.getEndpoint(path);
1321
+ return this.http.get(endpoint).pipe(map((res) => {
1322
+ console.log(`[DooleService] getAPIhealthCard(${path}) res: `, res);
1323
+ return res;
1324
+ }));
1325
+ }
1326
+ postAPIhealthCards(params) {
1327
+ let path = 'user/healthcard';
1328
+ const endpoint = this.api.getEndpoint(path);
1329
+ return this.http.post(endpoint, params).pipe(map((res) => {
1330
+ console.log(`[DooleService] postAPIReportProblem(${path}) res: `, res);
1331
+ return res;
1332
+ }));
1333
+ }
1334
+ putAPIhealthCard(params) {
1335
+ let path = `user/healthcard/${params.id}`;
1336
+ const endpoint = this.api.getEndpoint(path);
1337
+ return this.http.put(endpoint, params).pipe(map((res) => {
1338
+ console.log(`[DooleService] putAPIhealthCard(${path}) res: `, res);
1339
+ return res;
1340
+ }));
1341
+ }
1342
+ deleteAPIhealthCard(params) {
1343
+ let path = `user/healthcard/${params.id}`;
1344
+ const endpoint = this.api.getEndpoint(path);
1345
+ return this.http.delete(endpoint).pipe(map((res) => {
1346
+ console.log(`[DooleService] deleteAPIhealthCard(${path}) res: ${res}`, JSON.stringify(res));
1347
+ return res;
1348
+ }));
1349
+ }
1350
+ getAPISocialRelationType() {
1351
+ let path = 'center/socialRelationType';
1352
+ const endpoint = this.api.getEndpoint(path);
1353
+ return this.http.get(endpoint).pipe(map((res) => {
1354
+ console.log(`[DooleService] getAPISocialRelationType(${path}) res: `, res);
1355
+ return res;
1356
+ }));
1357
+ }
1358
+ getAPIemergencyContact() {
1359
+ let path = 'user/EmergencyContacts';
1360
+ const endpoint = this.api.getEndpoint(path);
1361
+ return this.http.get(endpoint).pipe(map((res) => {
1362
+ console.log(`[DooleService] getAPIemergencyContact(${path}) res: `, res);
1363
+ return res;
1364
+ }));
1365
+ }
1366
+ getAPIemergencyContactID(id) {
1367
+ let path = `user/EmergencyContact/${id}`;
1368
+ const endpoint = this.api.getEndpoint(path);
1369
+ return this.http.get(endpoint).pipe(map((res) => {
1370
+ console.log(`[DooleService] getAPIemergencyContact(${path}) res: `, res);
1371
+ return res;
1372
+ }));
1373
+ }
1374
+ postAPIemergencyContact(params) {
1375
+ let path = 'user/EmergencyContact';
1376
+ const endpoint = this.api.getEndpoint(path);
1377
+ return this.http.post(endpoint, params).pipe(map((res) => {
1378
+ console.log(`[DooleService] postAPIemergencyContact(${path}) res: `, res);
1379
+ return res;
1380
+ }));
1381
+ }
1382
+ putAPIemergencyContact(id, params) {
1383
+ let path = `user/EmergencyContact/${id}`;
1384
+ console.log('[DooleService] putAPIemergencyContact()', params);
1385
+ const endpoint = this.api.getEndpoint(path);
1386
+ return this.http.put(endpoint, params).pipe(map((res) => {
1387
+ console.log(`[DooleService] putAPIemergencyContact(${path}) res: `, res);
1388
+ return res;
1389
+ }));
1390
+ }
1391
+ deleteAPIemergencyContact(id) {
1392
+ let path = `user/EmergencyContact/${id}`;
1393
+ const endpoint = this.api.getEndpoint(path);
1394
+ return this.http.delete(endpoint).pipe(map((res) => {
1395
+ console.log(`[DooleService] deleteAPIemergencyContact(${path}) res: ${res}`, JSON.stringify(res));
1396
+ return res;
1397
+ }));
1398
+ }
1399
+ getAPIaboutUs() {
1400
+ let path = 'center/about';
1401
+ const endpoint = this.api.getEndpoint(path);
1402
+ return this.http.get(endpoint).pipe(map((res) => {
1403
+ console.log(`[DooleService] getAPIaboutUs(${path}) res: `, res);
1404
+ return res;
1405
+ }));
1406
+ }
1407
+ getAPIappointmentAgenda() {
1408
+ let path = 'user/agenda';
1409
+ const endpoint = this.api.getEndpoint(path);
1410
+ return this.http.get(endpoint).pipe(map((res) => {
1411
+ //console.log(`[DooleService] getAPIappointmentAgenda(${path}) res: `, res);
1412
+ return res;
1413
+ }));
1414
+ }
1415
+ //documents-Tracking
1416
+ getAPIdiagnosticTests() {
1417
+ let path = 'user/diagnosticTests';
1418
+ const endpoint = this.api.getEndpoint(path);
1419
+ return this.http.get(endpoint).pipe(map((res) => {
1420
+ //console.log(`[DooleService] getAPIdiagnosticTests(${path}) res: `, res);
1421
+ return res;
1422
+ }));
1423
+ }
1424
+ getAPIdiagnosticTestTypesAvailable() {
1425
+ let path = 'diagnosticTestTypes/available';
1426
+ const endpoint = this.api.getEndpoint(path);
1427
+ return this.http.get(endpoint).pipe(map((res) => {
1428
+ console.log(`[DooleService] getAPIdiagnosticTestTypesAvailable(${path}) res: `, res);
1429
+ return res;
1430
+ }));
1431
+ }
1432
+ getAPIdiagnosticTestID(id) {
1433
+ let path = 'v2/user/diagnosticTest/' + id;
1434
+ const endpoint = this.api.getEndpoint(path);
1435
+ return this.http.get(endpoint).pipe(map((res) => {
1436
+ console.log(`[DooleService] getAPIdiagnosticTestID(${path}) res: `, res);
1437
+ return res;
1438
+ }));
1439
+ }
1440
+ postAPIdiagnosticTest(params) {
1441
+ let path = 'v2/user/diagnosticTests/';
1442
+ const endpoint = this.api.getEndpoint(path);
1443
+ return this.http.post(endpoint, params).pipe(map((res) => {
1444
+ console.log(`[DooleService] postAPIdiagnosticTest(${path}) res: `, res);
1445
+ return res;
1446
+ }));
1447
+ }
1448
+ putAPIdiagnosticTest(id, params) {
1449
+ let path = `user/diagnosticTest/${id}`;
1450
+ const endpoint = this.api.getEndpoint(path);
1451
+ return this.http.put(endpoint, params).pipe(map((res) => {
1452
+ console.log(`[DooleService] putAPIdiagnosticTest(${path}) res: `, res);
1453
+ return res;
1454
+ }));
1455
+ }
1456
+ deleteAPIdiagnosticTest(id) {
1457
+ let path = `user/diagnosticTest/${id}`;
1458
+ const endpoint = this.api.getEndpoint(path);
1459
+ return this.http.delete(endpoint).pipe(map((res) => {
1460
+ console.log(`[DooleService] deleteAPIdiagnosticTest(${path}) res: ${res}`, JSON.stringify(res));
1461
+ return res;
1462
+ }));
1463
+ }
1464
+ getAPIfilteredDiagnosticTest(params) {
1465
+ let path = 'user/diagnosticTests';
1466
+ const endpoint = this.api.getEndpoint(path);
1467
+ let httpParams = new HttpParams();
1468
+ // Begin assigning parameters
1469
+ if (params !== undefined) {
1470
+ httpParams = (params.start_date) ? httpParams.append('from_date', params.start_date) : httpParams;
1471
+ httpParams = (params.end_date) ? httpParams.append('to_date', params.end_date) : httpParams;
1472
+ if (params.diagnosticTestTypes) {
1473
+ params.diagnosticTestTypes.forEach(element => {
1474
+ httpParams = httpParams.append('diagnostic_test_type_id[]', element);
1475
+ });
1476
+ }
1477
+ }
1478
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1479
+ console.log(`[DooleService] getAPIfilteredDiagnosticTest(${path}) res: `, res);
1480
+ return res;
1481
+ }));
1482
+ }
1483
+ //forms-Tracking
1484
+ getAPIformLists() {
1485
+ let path = 'forms/user';
1486
+ const endpoint = this.api.getEndpoint(path);
1487
+ return this.http.get(endpoint).pipe(map((res) => {
1488
+ console.log(`[DooleService] getAPIformLists(${path}) res: `, res);
1489
+ return res;
1490
+ }));
1491
+ }
1492
+ //graphics-Tracking
1493
+ getAPIelementsList(filter) {
1494
+ let path = 'user/elements'; /* 'user/elementsList/v2' */
1495
+ let httpParams = new HttpParams();
1496
+ httpParams = (filter?.only_with_values) ? httpParams.append('only_with_values', filter?.only_with_values) : httpParams;
1497
+ httpParams = (filter?.grouped) ? httpParams.append('grouped', filter?.grouped) : httpParams;
1498
+ httpParams = (filter?.filter) ? httpParams.append('filter', filter?.filter) : httpParams;
1499
+ const endpoint = this.api.getEndpoint(path);
1500
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1501
+ console.log(`[DooleService] getAPIelementsList(${path}) res: `, res);
1502
+ return res;
1503
+ }));
1504
+ }
1505
+ /** get elements with query by parameter date */
1506
+ getAPIelementsListByDate(params) {
1507
+ let path = 'user/elementsList/v2'; /* 'user/elementsList' */
1508
+ let httpParams = new HttpParams();
1509
+ if (params.filter == '1')
1510
+ httpParams = httpParams.append('filter', '1');
1511
+ const endpoint = this.api.getEndpoint(path);
1512
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1513
+ //console.log(`[DooleService] getAPIelementsListByDate(${path}) res: `, res);
1514
+ return res;
1515
+ }));
1516
+ }
1517
+ postAPIaddElement(id, params) {
1518
+ let path = 'user/element/' + id + '/value/add';
1519
+ const endpoint = this.api.getEndpoint(path);
1520
+ return this.http.post(endpoint, params).pipe(map((res) => {
1521
+ //console.log(`[DooleService] postAPIaddElement(${path}) res: `, res);
1522
+ return res;
1523
+ }));
1524
+ }
1525
+ getAPIgraphicsElement(id, query) {
1526
+ let path = 'user/element/' + id;
1527
+ let httpParams = new HttpParams();
1528
+ httpParams = (query) ? httpParams.append('interval', query) : httpParams;
1529
+ const endpoint = this.api.getEndpoint(path);
1530
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1531
+ //console.log(`[DooleService] getAPIgraphicsElement(${path}) res: `, res);
1532
+ return res;
1533
+ }));
1534
+ }
1535
+ getAPIelementID(id, params) {
1536
+ let path = `v2/user/element/${id}`;
1537
+ let httpParams = new HttpParams();
1538
+ httpParams = (params?.interval) ? httpParams.append('interval', params?.interval) : httpParams;
1539
+ httpParams = (params?.from_date) ? httpParams.append('from_date', params?.from_date) : httpParams;
1540
+ httpParams = (params?.to_date) ? httpParams.append('to_date', params?.to_date) : httpParams;
1541
+ httpParams = (params?.version) ? httpParams.append('version', params?.version) : httpParams;
1542
+ const endpoint = this.api.getEndpoint(path);
1543
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1544
+ //console.log(`[DooleService] getAPIgraphicsElement(${path}) res: `, res);
1545
+ return res;
1546
+ }));
1547
+ }
1548
+ getAPIelementAvailableID(id) {
1549
+ let path = `element/available/${id}`;
1550
+ const endpoint = this.api.getEndpoint(path);
1551
+ return this.http.get(endpoint).pipe(map((res) => {
1552
+ //console.log(`[DooleService] getAPIelementAvailableID(${path}) res: `, res);
1553
+ return res;
1554
+ }));
1555
+ }
1556
+ getAPIcategory() {
1557
+ let path = 'user/element_category';
1558
+ const endpoint = this.api.getEndpoint(path);
1559
+ return this.http.get(endpoint).pipe(map((res) => {
1560
+ //console.log(`[DooleService] getAPIcategory(${path}) res: `, res);
1561
+ return res;
1562
+ }));
1563
+ }
1564
+ getAPIelementGroupID(id, filter) {
1565
+ let path = `center/elementGroup/${id}/elements`;
1566
+ let httpParams = new HttpParams();
1567
+ httpParams = (filter) ? httpParams.append('filter', filter) : httpParams;
1568
+ const endpoint = this.api.getEndpoint(path);
1569
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1570
+ //console.log(`[DooleService] getAPIelementGroupID(${path}) res: `, res);
1571
+ return res;
1572
+ }));
1573
+ }
1574
+ searchAPIelementGroup(params) {
1575
+ let path = 'center/elementGroups';
1576
+ let httpParams = new HttpParams();
1577
+ httpParams = (params?.filter) ? httpParams.append('filter', params?.filter) : httpParams;
1578
+ const endpoint = this.api.getEndpoint(path);
1579
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1580
+ //console.log(`[DooleService] getAPIelementGroup(${path}) res: `, res);
1581
+ return res;
1582
+ }));
1583
+ }
1584
+ /** get diets with query by parameter date */
1585
+ getAPIlistDietsByDate(params) {
1586
+ let path = 'user/diets';
1587
+ const endpoint = this.api.getEndpoint(path);
1588
+ return this.http.get(endpoint).pipe(map((res) => {
1589
+ //console.log(`[DooleService] getAPIlistDietsByDate(${path}) res: `, res);
1590
+ return res;
1591
+ }));
1592
+ }
1593
+ getAPIdietsByDate(params) {
1594
+ let path = `user/dietaryIntakes`;
1595
+ let httpParams = new HttpParams();
1596
+ httpParams = (params?.date) ? httpParams.append('date', params.date) : httpParams;
1597
+ httpParams = (params?.grouped_by_times) ? httpParams.append('grouped_by_times', params.grouped_by_times) : httpParams;
1598
+ const endpoint = this.api.getEndpoint(path);
1599
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1600
+ //console.log(`[DooleService] getAPIdietsByDate(${path}) res: `, res);
1601
+ return res;
1602
+ }));
1603
+ }
1604
+ getAPIdetailDiets(id) {
1605
+ let path = `diet/${id}`;
1606
+ const endpoint = this.api.getEndpoint(path);
1607
+ return this.http.get(endpoint).pipe(map((res) => {
1608
+ //console.log(`[DooleService] getAPIdetailDiets(${path}) res: `, res);
1609
+ return res;
1610
+ }));
1611
+ }
1612
+ getAPIdetailRecipe(id) {
1613
+ let path = `diet/receipt/${id}`;
1614
+ const endpoint = this.api.getEndpoint(path);
1615
+ return this.http.get(endpoint).pipe(map((res) => {
1616
+ //console.log(`[DooleService] getAPIdetailRecipe(${path}) res: `, res);
1617
+ return res;
1618
+ }));
1619
+ }
1620
+ /** get advices **/
1621
+ getAPIlistAdvices(params) {
1622
+ let path = 'user/advices';
1623
+ const endpoint = this.api.getEndpoint(path);
1624
+ let httpParams = new HttpParams()
1625
+ .set('tags', params.tags)
1626
+ .set('interactions', params.interactions)
1627
+ .set('readingTime', params.readingTime);
1628
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1629
+ //console.log(`[DooleService] getAPIlistAdvices(${path}) res: `, res);
1630
+ return res;
1631
+ }));
1632
+ }
1633
+ /** get news **/
1634
+ getAPIlistNews() {
1635
+ let path = 'user/news';
1636
+ const endpoint = this.api.getEndpoint(path);
1637
+ return this.http.get(endpoint).pipe(map((res) => {
1638
+ //console.log(`[DooleService] getAPIlistNews(${path}) res: `, res);
1639
+ return res;
1640
+ }));
1641
+ }
1642
+ getAPIdetailNew(id) {
1643
+ let path = `user/new/${id}`;
1644
+ const endpoint = this.api.getEndpoint(path);
1645
+ return this.http.get(endpoint).pipe(map((res) => {
1646
+ //console.log(`[DooleService] getAPIdetailNew(${path}) res: `, res);
1647
+ return res;
1648
+ }));
1649
+ }
1650
+ getAPISearchNews(query) {
1651
+ let path = 'news';
1652
+ let httpParams = new HttpParams();
1653
+ httpParams = (query) ? httpParams.append('search', query) : httpParams;
1654
+ const endpoint = this.api.getEndpoint(path);
1655
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1656
+ //console.log(`[DooleService] getAPISearchNews(${path}) res: `, res);
1657
+ return res;
1658
+ }));
1659
+ }
1660
+ getAPIAppLatestVersion(version, platform) {
1661
+ let path = 'app/versions/must-update?version=' + version + '&platform=' + platform;
1662
+ console.log(path);
1663
+ const endpoint = this.api.getEndpoint(path);
1664
+ return this.http.get(endpoint).pipe(map((res) => {
1665
+ return res;
1666
+ }));
1667
+ }
1668
+ getAPISearchAdvices(query) {
1669
+ let path = 'advices';
1670
+ let httpParams = new HttpParams();
1671
+ httpParams = (query) ? httpParams.append('search', query) : httpParams;
1672
+ const endpoint = this.api.getEndpoint(path);
1673
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1674
+ //console.log(`[DooleService] getAPISearchAdvices(${path}) res: `, res);
1675
+ return res;
1676
+ }));
1677
+ }
1678
+ getAPIdetailAdvices(id) {
1679
+ let path = `advice/${id}`;
1680
+ const endpoint = this.api.getEndpoint(path);
1681
+ return this.http.get(endpoint).pipe(map((res) => {
1682
+ //console.log(`[DooleService] getAPIdetailAdvices(${path}) res: `, res);
1683
+ return res;
1684
+ }));
1685
+ }
1686
+ getAPIdrugsList(query) {
1687
+ let path = `drugIntake/list`;
1688
+ let httpParams = new HttpParams();
1689
+ httpParams = (query) ? httpParams.append('search', query) : httpParams;
1690
+ const endpoint = this.api.getEndpoint(path);
1691
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1692
+ //console.log(`[DooleService] getAPIdrugsList(${path}) res: `, res);
1693
+ return res;
1694
+ }));
1695
+ }
1696
+ getAPIdrugIntakeByDate(params) {
1697
+ let path = 'user/drugIntake/date';
1698
+ const endpoint = this.api.getEndpoint(path);
1699
+ return this.http.post(endpoint, params).pipe(map((res) => {
1700
+ //console.log(`[DooleService] getAPIdrugIntakeByDate(${path}) res: `, res);
1701
+ return res;
1702
+ }));
1703
+ }
1704
+ // send medication list
1705
+ getAPImedicationList(query) {
1706
+ let path = `sendmedication/list`;
1707
+ let httpParams = new HttpParams();
1708
+ httpParams = (query) ? httpParams.append('search', query) : httpParams;
1709
+ const endpoint = this.api.getEndpoint(path);
1710
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1711
+ console.log(`[DooleService] getAPImedicationList(${path}) res: `, res);
1712
+ return res;
1713
+ }));
1714
+ }
1715
+ getAPIdirectionsList() {
1716
+ let path = `user/addresses`;
1717
+ // let httpParams = new HttpParams();
1718
+ // httpParams = (query) ? httpParams.append('search', query) : httpParams
1719
+ const endpoint = this.api.getEndpoint(path);
1720
+ return this.http.get(endpoint).pipe(map((res) => {
1721
+ console.log(`[DooleService] getAPIdirectionList(${path}) res: `, res);
1722
+ return res;
1723
+ }));
1724
+ }
1725
+ getAPImedicationsList() {
1726
+ let path = `sendmedication/list`;
1727
+ // let httpParams = new HttpParams();
1728
+ // httpParams = (query) ? httpParams.append('search', query) : httpParams
1729
+ const endpoint = this.api.getEndpoint(path);
1730
+ return this.http.get(endpoint).pipe(map((res) => {
1731
+ console.log(`[DooleService] getAPIdirectionList(${path}) res: `, res);
1732
+ return res;
1733
+ }));
1734
+ }
1735
+ postAPIsendDirection(params) {
1736
+ let path = 'user/address';
1737
+ const endpoint = this.api.getEndpoint(path);
1738
+ return this.http.post(endpoint, params).pipe(map((res) => {
1739
+ console.log(`[DooleService] postAPIsendDirection(${path}) res: `, res);
1740
+ return res;
1741
+ }));
1742
+ }
1743
+ putAPIsendDirection(id, params) {
1744
+ let path = `user/address/${id}`;
1745
+ const endpoint = this.api.getEndpoint(path);
1746
+ return this.http.put(endpoint, params).pipe(map((res) => {
1747
+ //console.log(`[DooleService] putAPIdrugIntake(${path}) res: `, res);
1748
+ return res;
1749
+ }));
1750
+ }
1751
+ deleteAPIsendDirection(id) {
1752
+ let path = `user/address/${id}`;
1753
+ const endpoint = this.api.getEndpoint(path);
1754
+ return this.http.delete(endpoint).pipe(map((res) => {
1755
+ //console.log(`[DooleService] deleteAPImedicationPlan(${path}) res: ${res}`, JSON.stringify(res));
1756
+ return res;
1757
+ }));
1758
+ }
1759
+ postAPImedicationSendPetition(params) {
1760
+ let path = 'sendmedication';
1761
+ const endpoint = this.api.getEndpoint(path);
1762
+ return this.http.post(endpoint, params).pipe(map((res) => {
1763
+ console.log(`[DooleService] postAPIsendDirection(${path}) res: `, res);
1764
+ return res;
1765
+ }));
1766
+ }
1767
+ postAPIdrugIntake(params) {
1768
+ let path = 'user/drugIntake';
1769
+ const endpoint = this.api.getEndpoint(path);
1770
+ return this.http.post(endpoint, params).pipe(map((res) => {
1771
+ //console.log(`[DooleService] postAPIdrugIntake(${path}) res: `, res);
1772
+ return res;
1773
+ }));
1774
+ }
1775
+ postAPIchangeStatedrugIntake(id, state) {
1776
+ let path = `user/drugIntake/${id}/set/${state}`;
1777
+ const endpoint = this.api.getEndpoint(path);
1778
+ return this.http.post(endpoint).pipe(map((res) => {
1779
+ //console.log(`[DooleService] postAPIdrugIntake(${path}) res: `, res);
1780
+ return res;
1781
+ }));
1782
+ }
1783
+ postAPImedicationPlan(params) {
1784
+ let path = `user/medicationPlan`;
1785
+ const endpoint = this.api.getEndpoint(path);
1786
+ return this.http.post(endpoint, params).pipe(map((res) => {
1787
+ //console.log(`[DooleService] postAPIdrugIntake(${path}) res: `, res);
1788
+ return res;
1789
+ }));
1790
+ }
1791
+ putAPImedicationPlan(id, params) {
1792
+ let path = `user/medicationPlan/${id}`;
1793
+ const endpoint = this.api.getEndpoint(path);
1794
+ return this.http.put(endpoint, params).pipe(map((res) => {
1795
+ //console.log(`[DooleService] putAPIdrugIntake(${path}) res: `, res);
1796
+ return res;
1797
+ }));
1798
+ }
1799
+ deleteAPImedicationPlan(id) {
1800
+ let path = `user/medicationPlan/${id}`;
1801
+ const endpoint = this.api.getEndpoint(path);
1802
+ return this.http.delete(endpoint).pipe(map((res) => {
1803
+ //console.log(`[DooleService] deleteAPImedicationPlan(${path}) res: ${res}`, JSON.stringify(res));
1804
+ return res;
1805
+ }));
1806
+ }
1807
+ getAPImedicationPlan(id) {
1808
+ let path = `user/medicationPlan/${id}`;
1809
+ const endpoint = this.api.getEndpoint(path);
1810
+ return this.http.get(endpoint).pipe(map((res) => {
1811
+ //console.log(`[DooleService] getAPImedicationPlan(${path}) res: `, res);
1812
+ return res;
1813
+ }));
1814
+ }
1815
+ getAPIgames() {
1816
+ let path = 'user/games';
1817
+ const endpoint = this.api.getEndpoint(path);
1818
+ return this.http.get(endpoint).pipe(map((res) => {
1819
+ //console.log(`[DooleService] getAPIgames(${path}) res: `, res);
1820
+ return res;
1821
+ }));
1822
+ }
1823
+ /** get games with query by parameter date */
1824
+ getAPIgamesByDate(from_date, to_date) {
1825
+ let path = 'user/gamePlays/scheduled';
1826
+ let httpParams = new HttpParams();
1827
+ httpParams = (from_date) ? httpParams.append('from_date', from_date) : httpParams;
1828
+ httpParams = (to_date) ? httpParams.append('to_date', to_date) : httpParams;
1829
+ const endpoint = this.api.getEndpoint(path);
1830
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1831
+ //console.log(`[DooleService] getAPIgames(${path}) res: `, res);
1832
+ return res;
1833
+ }));
1834
+ }
1835
+ getAPIgameId(id) {
1836
+ let path = `user/game/${id}`;
1837
+ const endpoint = this.api.getEndpoint(path);
1838
+ return this.http.get(endpoint).pipe(map((res) => {
1839
+ //console.log(`[DooleService] getAPIgameId(${path}) res: `, res);
1840
+ return res;
1841
+ }));
1842
+ }
1843
+ getAPIagenda() {
1844
+ let path = 'user/agenda';
1845
+ const endpoint = this.api.getEndpoint(path);
1846
+ return this.http.get(endpoint).pipe(map((res) => {
1847
+ //console.log(`[DooleService] getAPIagenda(${path}) res: `, res);
1848
+ return res;
1849
+ }));
1850
+ }
1851
+ getAPIallAgenda(params) {
1852
+ let path = 'user/agenda/v2';
1853
+ let httpParams = new HttpParams();
1854
+ httpParams = params?.from_date ? httpParams.append('from_date', params?.from_date) : httpParams;
1855
+ httpParams = params?.to_date ? httpParams.append('to_date', params?.to_date) : httpParams;
1856
+ httpParams = params?.filter_by_date ? httpParams.append('filter_by_date', params?.filter_by_date) : httpParams;
1857
+ httpParams = (params?.with_medical_procedures != undefined) ? httpParams.append('with_medical_procedures', params?.with_medical_procedures) : httpParams;
1858
+ httpParams = (params?.order != undefined) ? httpParams.append('order', params?.order) : httpParams;
1859
+ const endpoint = this.api.getEndpoint(path);
1860
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1861
+ console.log(`[DooleService] getAPIappointmentAgendaV2(${path}) res: `, res);
1862
+ return res;
1863
+ }));
1864
+ }
1865
+ getAPIagendaID(id) {
1866
+ let path = `user/agenda/${id}`;
1867
+ const endpoint = this.api.getEndpoint(path);
1868
+ return this.http.get(endpoint).pipe(map((res) => {
1869
+ //console.log(`[DooleService] getAPIagendaID(${path}) res: `, res);
1870
+ return res;
1871
+ }));
1872
+ }
1873
+ postAPIaddAgenda(params) {
1874
+ let path = 'user/agenda/';
1875
+ const endpoint = this.api.getEndpoint(path);
1876
+ return this.http.post(endpoint, params).pipe(map((res) => {
1877
+ //console.log(`[DooleService] postAPIaddAgenda(${path}) res: `, res);
1878
+ return res;
1879
+ }));
1880
+ }
1881
+ deleteAPIaddAgenda(id) {
1882
+ let params = { agenda: id };
1883
+ let path = 'user/agenda/delete';
1884
+ const endpoint = this.api.getEndpoint(path);
1885
+ return this.http.post(endpoint, params).pipe(map((res) => {
1886
+ //console.log(`[DooleService] deleteAPIaddAgenda(${path}) res: `, res);
1887
+ return res;
1888
+ }));
1889
+ }
1890
+ putAPIagenda(id, params) {
1891
+ let path = `user/agenda/${id}`;
1892
+ const endpoint = this.api.getEndpoint(path);
1893
+ return this.http.put(endpoint, params).pipe(map((res) => {
1894
+ //console.log(`[DooleService] putAPIagenda(${path}) res: `, res);
1895
+ return res;
1896
+ }));
1897
+ }
1898
+ getAPIallowedContacts() {
1899
+ let path = `user/allowedContacts`;
1900
+ const endpoint = this.api.getEndpoint(path);
1901
+ let httpParams = new HttpParams();
1902
+ httpParams = httpParams.append('withDepartments', '1');
1903
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
1904
+ console.log(`[DooleService] getAPIallowedContacts(${path}) res: `, res);
1905
+ let allowed = res.allowed;
1906
+ if (res.allowed === undefined)
1907
+ allowed = [];
1908
+ return allowed;
1909
+ }));
1910
+ }
1911
+ getAPIstaffId(id) {
1912
+ let path = `staff/${id}`;
1913
+ const endpoint = this.api.getEndpoint(path);
1914
+ return this.http.get(endpoint).pipe(map((res) => {
1915
+ //console.log(`[DooleService] getAPIstaffId(${path}) res: `, res);
1916
+ return res;
1917
+ }));
1918
+ }
1919
+ /** get games with query by parameter date */
1920
+ getAPIUserMessages() {
1921
+ let path = 'message/user';
1922
+ const endpoint = this.api.getEndpoint(path);
1923
+ return this.http.get(endpoint).pipe(map((res) => {
1924
+ console.log(`[DooleService] getAPIUserMessages(${path}) res: `, res);
1925
+ if (res.length == 0)
1926
+ return res;
1927
+ return res.messages;
1928
+ }));
1929
+ }
1930
+ // get the company details, a subset of the user data
1931
+ getUserSubsetData() {
1932
+ let path = 'message/user';
1933
+ const endpoint = this.api.getEndpoint(path);
1934
+ const dataObservable = this.http.get(endpoint);
1935
+ return dataObservable.pipe(map((jsonResponse) => {
1936
+ const filteredData = {
1937
+ ...jsonResponse.messages
1938
+ };
1939
+ return filteredData;
1940
+ }));
1941
+ }
1942
+ /** Reminders */
1943
+ getAPIreminders() {
1944
+ let path = 'user/reminder';
1945
+ const endpoint = this.api.getEndpoint(path);
1946
+ return this.http.get(endpoint).pipe(map((res) => {
1947
+ //console.log(`[DooleService] getAPIreminders(${path}) res: `, res);
1948
+ return res;
1949
+ }));
1950
+ }
1951
+ getAPIreminderID(id) {
1952
+ let path = `user/reminder/${id}`;
1953
+ const endpoint = this.api.getEndpoint(path);
1954
+ return this.http.get(endpoint).pipe(map((res) => {
1955
+ //console.log(`[DooleService] getAPIreminderID(${path}) res: `, res);
1956
+ return res;
1957
+ }));
1958
+ }
1959
+ postAPIaddReminder(params) {
1960
+ let path = 'user/reminder/';
1961
+ const endpoint = this.api.getEndpoint(path);
1962
+ return this.http.post(endpoint, params).pipe(map((res) => {
1963
+ //console.log(`[DooleService] postAPIaddReminder(${path}) res: `, res);
1964
+ return res;
1965
+ }));
1966
+ }
1967
+ deleteAPIReminder(id) {
1968
+ let path = `user/reminder/${id}`;
1969
+ const endpoint = this.api.getEndpoint(path);
1970
+ return this.http.delete(endpoint).pipe(map((res) => {
1971
+ //console.log(`[DooleService] deleteAPIReminder(${path}) res: ${res}`, JSON.stringify(res));
1972
+ return res;
1973
+ }));
1974
+ }
1975
+ updateAPIReminder(id, params) {
1976
+ let path = `user/reminder/${id}`;
1977
+ const endpoint = this.api.getEndpoint(path);
1978
+ return this.http.put(endpoint, params).pipe(map((res) => {
1979
+ //console.log(`[DooleService] updateAPIReminder(${path}) res: `, res);
1980
+ return res;
1981
+ }));
1982
+ }
1983
+ updateAPIuser(params) {
1984
+ let path = `user`;
1985
+ const endpoint = this.api.getEndpoint(path);
1986
+ return this.http.put(endpoint, params).pipe(map((res) => {
1987
+ //console.log(`[DooleService] updateAPIReminder(${path}) res: `, res);
1988
+ return res;
1989
+ }));
1990
+ }
1991
+ updateAPIImageuser(params) {
1992
+ let path = `user/image`;
1993
+ const endpoint = this.api.getEndpoint(path);
1994
+ return this.http.put(endpoint, params).pipe(map((res) => {
1995
+ //console.log(`[DooleService] updateAPIReminder(${path}) res: `, res);
1996
+ return res;
1997
+ }));
1998
+ }
1999
+ deleteAPIImageuser() {
2000
+ let path = `user/image`;
2001
+ const endpoint = this.api.getEndpoint(path);
2002
+ return this.http.delete(endpoint).pipe(map((res) => {
2003
+ //console.log(`[DooleService] updateAPIReminder(${path}) res: `, res);
2004
+ return res;
2005
+ }));
2006
+ }
2007
+ postAPIContentStatus(params) {
2008
+ let path = 'content/status';
2009
+ const endpoint = this.api.getEndpoint(path);
2010
+ return this.http.post(endpoint, params).pipe(map((res) => {
2011
+ //console.log(`[DooleService] postAPIContentStatus(${path}) res: `, res);
2012
+ return res;
2013
+ }));
2014
+ }
2015
+ getAPIpatients() {
2016
+ let path = 'user/patients';
2017
+ const endpoint = this.api.getEndpoint(path);
2018
+ return this.http.get(endpoint).pipe(map((res) => {
2019
+ //console.log(`[DooleService] getAPIreminders(${path}) res: `, res);
2020
+ return res;
2021
+ }));
2022
+ }
2023
+ getAPILevelInfo(challengeId, levelId, params) {
2024
+ let path = 'user/challenge/' + challengeId + '/level/' + levelId + '/goals';
2025
+ const endpoint = this.api.getEndpoint(path);
2026
+ return this.http.get(endpoint).pipe(map((res) => {
2027
+ console.log(`[DooleService] getAPILevelInfo(${path}) res: `, res);
2028
+ return res;
2029
+ }));
2030
+ }
2031
+ getAPIChallenge(challengeId, params) {
2032
+ let path = 'user/challenge/' + challengeId;
2033
+ const endpoint = this.api.getEndpoint(path);
2034
+ return this.http.get(endpoint).pipe(map((res) => {
2035
+ console.log(`[DooleService] getAPIChallenge(${path}) res: `, res);
2036
+ return res;
2037
+ }));
2038
+ }
2039
+ getAPIChallenges(params) {
2040
+ let path = 'user/challenges';
2041
+ const endpoint = this.api.getEndpoint(path);
2042
+ return this.http.get(endpoint).pipe(map((res) => {
2043
+ console.log(`[DooleService] getAPIChallenges(${path}) res: `, res);
2044
+ return res;
2045
+ }));
2046
+ }
2047
+ getAPImessage(id, params) {
2048
+ let path = 'user/message/' + id;
2049
+ let httpParams = new HttpParams();
2050
+ httpParams = params?.page ? httpParams.append('page', params?.page) : httpParams;
2051
+ httpParams = params?.user ? httpParams.append('user', params?.user) : httpParams;
2052
+ const endpoint = this.api.getEndpoint(path);
2053
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
2054
+ //console.log(`[DooleService] getAPIelementsList(${path}) res: `, res);
2055
+ return res;
2056
+ }));
2057
+ }
2058
+ getAPIFormJSON(form, params) {
2059
+ let path = `form/${form}/formFields`;
2060
+ let httpParams = new HttpParams();
2061
+ httpParams = (params?.formAnswer) ? httpParams.append('formAnswer', params?.formAnswer) : httpParams;
2062
+ httpParams = (params?.game_play_id) ? httpParams.append('game_play_id', params?.game_play_id) : httpParams;
2063
+ const endpoint = this.api.getEndpoint(path);
2064
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
2065
+ //console.log(`[DooleService] getAPIreminders(${path}) res: `, res);
2066
+ return res;
2067
+ }));
2068
+ }
2069
+ postAPIFormJSON(form, params) {
2070
+ let path = `formfield/conditional/${form}/field/${params.formField}`;
2071
+ const endpoint = this.api.getEndpoint(path);
2072
+ return this.http.post(endpoint, params).pipe(map((res) => {
2073
+ //console.log(`[DooleService] postAPIContentStatus(${path}) res: `, res);
2074
+ return res;
2075
+ }));
2076
+ }
2077
+ postAPIFormFill(params) {
2078
+ let path = `form/fill/`;
2079
+ const endpoint = this.api.getEndpoint(path);
2080
+ return this.http.post(endpoint, params).pipe(map((res) => {
2081
+ //console.log(`[DooleService] postAPIContentStatus(${path}) res: `, res);
2082
+ return res;
2083
+ }));
2084
+ }
2085
+ getAPINotificationsCount() {
2086
+ let path = 'user/notifications/count';
2087
+ const endpoint = this.api.getEndpoint(path);
2088
+ return this.http.get(endpoint).pipe(map((res) => {
2089
+ //console.log(`[DooleService] getAPINotifications(${path}) res: `, res);
2090
+ return res;
2091
+ }));
2092
+ }
2093
+ getAPINotifications(params) {
2094
+ let path = 'user/notifications';
2095
+ let httpParams = new HttpParams();
2096
+ httpParams = (params?.read) ? httpParams.append('read', params?.read) : httpParams;
2097
+ httpParams = (params?.withPaginate == 1) ? httpParams.append('withPaginate', params?.withPaginate) : httpParams;
2098
+ httpParams = (params?.page > 0) ? httpParams.append('page', params?.page) : httpParams;
2099
+ const endpoint = this.api.getEndpoint(path);
2100
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
2101
+ //console.log(`[DooleService] getAPINotifications(${path}) res: `, res);
2102
+ return res;
2103
+ }));
2104
+ }
2105
+ postAPINotificationRead(id) {
2106
+ let path = `user/notification/read`;
2107
+ const endpoint = this.api.getEndpoint(path);
2108
+ return this.http.post(endpoint, id).pipe(map((res) => {
2109
+ return res;
2110
+ }));
2111
+ }
2112
+ get(endpt) {
2113
+ const endpoint = this.api.getEndpoint(endpt);
2114
+ return this.http.get(endpoint).pipe(map((res) => {
2115
+ return res;
2116
+ }));
2117
+ }
2118
+ post(endpt, items) {
2119
+ const endpoint = this.api.getEndpoint(endpt);
2120
+ return this.http.post(endpoint, items).pipe(map((res) => {
2121
+ return res;
2122
+ }));
2123
+ }
2124
+ setPushNotification(pushNotification) {
2125
+ this.pushNotification = pushNotification;
2126
+ }
2127
+ getPushNotification() {
2128
+ return this.pushNotification;
2129
+ }
2130
+ getAPIUserImage() {
2131
+ let path = 'user/image';
2132
+ const endpoint = this.api.getEndpoint(path);
2133
+ return this.http.get(endpoint).pipe(map((res) => {
2134
+ //console.log(`[DooleService] getAPIgames(${path}) res: `, res);
2135
+ return res;
2136
+ }));
2137
+ }
2138
+ getAPIFormsByDate(params) {
2139
+ let path = `rehabilify/sharedcareplan/forms`;
2140
+ let httpParams = new HttpParams();
2141
+ httpParams = (params?.date) ? httpParams.append('date', params.date) : httpParams;
2142
+ httpParams = (params?.grouped_by_times) ? httpParams.append('grouped_by_times', params.grouped_by_times) : httpParams;
2143
+ const endpoint = this.api.getEndpoint(path);
2144
+ return this.http.get(endpoint, httpParams).pipe(map((res) => {
2145
+ //console.log(`[DooleService] getAPIdietsByDate(${path}) res: `, res);
2146
+ return res;
2147
+ }));
2148
+ }
2149
+ postAPImedicalProcedures(params) {
2150
+ let path = `user/medicalProcedures`;
2151
+ const endpoint = this.api.getEndpoint(path);
2152
+ return this.http.post(endpoint, params).pipe(map((res) => {
2153
+ //console.log(`[DooleService] postAPIdrugIntake(${path}) res: `, res);
2154
+ return res;
2155
+ }));
2156
+ }
2157
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: DooleService, deps: [{ token: AuthenticationService }, { token: i2$1.FileTransfer }, { token: i3.File }, { token: HttpService }, { token: ApiEndpointsService }, { token: Events }, { token: i2.Platform }, { token: i6.Router }, { token: i2.AlertController }], target: i0.ɵɵFactoryTarget.Injectable }); }
2158
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: DooleService, providedIn: 'root' }); }
2159
+ }
2160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: DooleService, decorators: [{
2161
+ type: Injectable,
2162
+ args: [{
2163
+ providedIn: 'root'
2164
+ }]
2165
+ }], ctorParameters: () => [{ type: AuthenticationService }, { type: i2$1.FileTransfer }, { type: i3.File }, { type: HttpService }, { type: ApiEndpointsService }, { type: Events }, { type: i2.Platform }, { type: i6.Router }, { type: i2.AlertController }] });
2166
+
2167
+ class NavigationService {
2168
+ constructor(router, location) {
2169
+ this.router = router;
2170
+ this.location = location;
2171
+ this.history = [];
2172
+ this.router.events.subscribe((event) => {
2173
+ if (event instanceof NavigationEnd) {
2174
+ //console.log("NavigationEnd", event.urlAfterRedirects);
2175
+ this.history.push(event.urlAfterRedirects);
2176
+ }
2177
+ });
2178
+ }
2179
+ back() {
2180
+ this.history.pop();
2181
+ if (this.history?.length > 0)
2182
+ this.location.back();
2183
+ else
2184
+ this.router.navigateByUrl("/home");
2185
+ }
2186
+ async close(modalCtrl) {
2187
+ const modal = await modalCtrl?.getTop();
2188
+ if (modal)
2189
+ await modal.dismiss({ error: null });
2190
+ else
2191
+ this.back();
2192
+ }
2193
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NavigationService, deps: [{ token: i6.Router }, { token: i2$2.Location }], target: i0.ɵɵFactoryTarget.Injectable }); }
2194
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NavigationService, providedIn: 'root' }); }
2195
+ }
2196
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NavigationService, decorators: [{
2197
+ type: Injectable,
2198
+ args: [{
2199
+ providedIn: 'root'
2200
+ }]
2201
+ }], ctorParameters: () => [{ type: i6.Router }, { type: i2$2.Location }] });
2202
+
2203
+ class LanguageService {
2204
+ constructor(translate) {
2205
+ this.translate = translate;
2206
+ this.languages = new Array();
2207
+ this.languages.push({ name: 'Català', code: 'ca' }, { name: 'Español', code: 'es' }, { name: 'English', code: 'en' });
2208
+ }
2209
+ getLanguages() {
2210
+ return this.languages;
2211
+ }
2212
+ changeLanguage(langCode) {
2213
+ console.log("langCode", langCode);
2214
+ this.translate.use(langCode);
2215
+ }
2216
+ getCurrent() {
2217
+ let lang = this.translate.currentLang ? this.translate.currentLang : this.translate.getDefaultLang();
2218
+ return lang;
2219
+ }
2220
+ getLanguageAPI() {
2221
+ let lang = this.translate.currentLang ? this.translate.currentLang : this.translate.getDefaultLang();
2222
+ return lang == 'es' ? 'cs' : lang;
2223
+ }
2224
+ setLenguageLocalstorage(language) {
2225
+ this.changeLanguage(language);
2226
+ localStorage.setItem('language', language);
2227
+ }
2228
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LanguageService, deps: [{ token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2229
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LanguageService, providedIn: 'root' }); }
2230
+ }
2231
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LanguageService, decorators: [{
2232
+ type: Injectable,
2233
+ args: [{
2234
+ providedIn: 'root'
2235
+ }]
2236
+ }], ctorParameters: () => [{ type: i1$1.TranslateService }] });
2237
+
2238
+ class DateService {
2239
+ constructor(datePipe, translate) {
2240
+ this.datePipe = datePipe;
2241
+ this.translate = translate;
2242
+ this.locale = this.getLocale();
2243
+ }
2244
+ getDateFormat() {
2245
+ let lang = this.translate.currentLang;
2246
+ let format = 'DD/MM/YY ';
2247
+ if (lang === 'en')
2248
+ format = 'MM/DD/YY ';
2249
+ return format;
2250
+ }
2251
+ getDateFormat2() {
2252
+ let lang = this.translate.currentLang;
2253
+ let format = 'dd/MM/YY';
2254
+ if (lang === 'en')
2255
+ format = 'MM/dd/YY';
2256
+ return format;
2257
+ }
2258
+ getDateFormat3() {
2259
+ let lang = this.translate.currentLang;
2260
+ let format = 'DD/MM/YYYY';
2261
+ if (lang === 'en')
2262
+ format = 'MM/DD/YYYY';
2263
+ return format;
2264
+ }
2265
+ getLongFormat() {
2266
+ let lang = this.translate.currentLang;
2267
+ let format = 'dddd, MMM yyyy';
2268
+ if (lang === 'en')
2269
+ format = 'MMM, ddd yyyy';
2270
+ return format;
2271
+ }
2272
+ getMonthViewDayHeader(date) {
2273
+ let lang = this.translate.currentLang;
2274
+ let days = ["D", "L", "M", "X", "J", "V", "S"];
2275
+ if (lang === 'ca') {
2276
+ days = ["DG", "DL", "DT", "DC", "DJ", "DV", "DS"];
2277
+ }
2278
+ else if (lang === 'en')
2279
+ days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
2280
+ let num = date.getDay();
2281
+ return days[num];
2282
+ }
2283
+ formatSelectedDate(date) {
2284
+ if (date) {
2285
+ let day = this.transformDate(date, this.getformatSelectedDate());
2286
+ console.log("selected Day", day);
2287
+ return day[0].toUpperCase() + day.slice(1);
2288
+ }
2289
+ return date;
2290
+ }
2291
+ getformatSelectedDate() {
2292
+ let lang = this.translate.currentLang;
2293
+ let format = 'EEEE, d MMMM';
2294
+ if (lang === 'en')
2295
+ format = 'MMMM d, EEEE';
2296
+ return format;
2297
+ }
2298
+ getLocale() {
2299
+ let lang = this.translate.currentLang;
2300
+ let locale = 'es-ES';
2301
+ if (lang === 'ca') {
2302
+ locale = 'ca-ES';
2303
+ }
2304
+ else if (lang === 'en')
2305
+ locale = 'en-US';
2306
+ return locale;
2307
+ }
2308
+ getStartingDayWeek() {
2309
+ let lang = this.translate.currentLang;
2310
+ let day = '1';
2311
+ if (lang == 'en')
2312
+ day = '0';
2313
+ return day;
2314
+ }
2315
+ getStartingDayMonth() {
2316
+ let lang = this.translate.currentLang;
2317
+ let day = 1;
2318
+ if (lang == 'en')
2319
+ day = 0;
2320
+ return day;
2321
+ }
2322
+ ddMMy() {
2323
+ let lang = this.translate.currentLang;
2324
+ let format = 'dd/MM/y';
2325
+ if (lang === 'en')
2326
+ format = 'MM/dd/y';
2327
+ return format;
2328
+ }
2329
+ getShortDateFormat() {
2330
+ let lang = this.translate.currentLang;
2331
+ let format = 'DD/MM/YY';
2332
+ if (lang === 'en')
2333
+ format = 'MM/DD/YY';
2334
+ return format;
2335
+ }
2336
+ ddMMyyyyFormat(date) {
2337
+ let lang = this.translate.currentLang;
2338
+ let format = 'dd/MM/yyyy';
2339
+ if (lang === 'en')
2340
+ format = 'MM/dd/yyyy';
2341
+ let day = this.transformDate(date, format);
2342
+ return day[0].toUpperCase() + day.slice(1);
2343
+ }
2344
+ ddMMyFormat(date) {
2345
+ let lang = this.translate.currentLang;
2346
+ let format = 'dd MMM y';
2347
+ if (lang === 'en')
2348
+ format = 'MMM dd y';
2349
+ let day = this.transformDate(date, format);
2350
+ return day[0].toUpperCase() + day.slice(1);
2351
+ }
2352
+ ddMMMyyyformat(date) {
2353
+ let lang = this.translate.currentLang;
2354
+ let format = 'dd MMM yyy';
2355
+ if (lang === 'en')
2356
+ format = 'MMM dd yyy';
2357
+ let day = this.transformDate(date, format);
2358
+ return day[0].toUpperCase() + day.slice(1);
2359
+ }
2360
+ MMMMyyyyFormat(date) {
2361
+ let format = 'MMMM yyyy';
2362
+ let day = this.transformDate(date, format);
2363
+ return day[0].toUpperCase() + day.slice(1);
2364
+ }
2365
+ getDayMonthYearFormat(date) {
2366
+ let lang = this.translate.currentLang;
2367
+ let format = 'EEEE, d MMMM YYYY';
2368
+ if (lang === 'en')
2369
+ format = 'MMMM, d EEEE YYYY';
2370
+ let day = this.transformDate(date, format);
2371
+ return day[0].toUpperCase() + day.slice(1);
2372
+ }
2373
+ selectedDateFormat(date) {
2374
+ let lang = this.translate.currentLang;
2375
+ let format = 'EEEE, d MMMM';
2376
+ if (lang === 'en')
2377
+ format = 'MMMM d, YYYY';
2378
+ let day = this.transformDate(date, format);
2379
+ return day[0].toUpperCase() + day.slice(1);
2380
+ }
2381
+ ddMMyyyyHHmm(date) {
2382
+ let lang = this.translate.currentLang;
2383
+ let format = 'dd/MM/yyyy HH:mm';
2384
+ if (lang === 'en')
2385
+ format = 'MM/dd/yyyy hh:mm a';
2386
+ let day = this.transformDate(date, format);
2387
+ return day[0].toUpperCase() + day.slice(1);
2388
+ }
2389
+ formatDateLongFormat(date) {
2390
+ if (date) {
2391
+ let day = this.transformDate(date, this.getLongDateFormat());
2392
+ return day[0].toUpperCase() + day.slice(1);
2393
+ }
2394
+ return date;
2395
+ }
2396
+ yyyyMMddHHmm(date) {
2397
+ if (date) {
2398
+ let day = this.transformDate(date, this.yyyyMMddHHmmFormat());
2399
+ console.log("selected Day", day);
2400
+ return day[0].toUpperCase() + day.slice(1);
2401
+ }
2402
+ return date;
2403
+ }
2404
+ yyyyMMddHHmmFormat() {
2405
+ let lang = this.translate.currentLang;
2406
+ let format = 'yyyy-dd-MM HH:mm';
2407
+ if (lang === 'en')
2408
+ format = 'yyyy-MM-dd HH:mm a';
2409
+ return format;
2410
+ }
2411
+ getLongDateFormat() {
2412
+ let lang = this.translate.currentLang;
2413
+ let format = 'EEEE, d MMMM yyyy, HH:mm';
2414
+ if (lang === 'en')
2415
+ format = 'MMMM, d yyyy, hh:mm a';
2416
+ return format;
2417
+ }
2418
+ getDatetimeControlFormat() {
2419
+ let lang = this.translate.currentLang;
2420
+ let format = 'D MMM YYYY HH:mm';
2421
+ if (lang === 'en')
2422
+ format = 'MMM D YY hh:mm a';
2423
+ return format;
2424
+ }
2425
+ getDayMonthFormat() {
2426
+ let lang = this.translate.currentLang;
2427
+ let format = 'd MMM';
2428
+ if (lang === 'en')
2429
+ format = 'MMM d';
2430
+ return format;
2431
+ }
2432
+ getDayDotMonthFormat() {
2433
+ let lang = this.translate.currentLang;
2434
+ let format = 'd. MMM';
2435
+ if (lang === 'en')
2436
+ format = 'MMM. d';
2437
+ return format;
2438
+ }
2439
+ getSelectedWeek(date) {
2440
+ let lang = this.translate.currentLang;
2441
+ let format = 'E d MMM';
2442
+ if (lang === 'en')
2443
+ format = 'MMM d, E';
2444
+ let day = this.transformDate(date, format);
2445
+ return day[0].toUpperCase() + day.slice(1);
2446
+ }
2447
+ getSelectedWeekFullDay(date) {
2448
+ let lang = this.translate.currentLang;
2449
+ let format = 'EEE d MMM';
2450
+ if (lang === 'en')
2451
+ format = 'MMM d, EEE';
2452
+ let day = this.transformDate(date, format);
2453
+ return day[0].toUpperCase() + day.slice(1);
2454
+ }
2455
+ formatDate(date) {
2456
+ if (date) {
2457
+ date = new Date(date);
2458
+ if (this.isToday(date))
2459
+ return this.datePipe.transform(date, this.getTimeFormat());
2460
+ else {
2461
+ let format = this.getDateFormat2();
2462
+ return this.transformDate(date, format);
2463
+ }
2464
+ }
2465
+ return date;
2466
+ }
2467
+ ddMMyyyy(date) {
2468
+ let lang = this.translate.currentLang;
2469
+ let format = 'dd-MM-yyyy';
2470
+ if (lang === 'en')
2471
+ format = 'MM-dd-yyyy';
2472
+ let day = this.transformDate(date, format);
2473
+ return day[0].toUpperCase() + day.slice(1);
2474
+ }
2475
+ highchartsDatesFornmat() {
2476
+ let lang = this.translate.currentLang;
2477
+ let format = {};
2478
+ if (lang == 'en') {
2479
+ // %b: Short month, like 'Jan',%e Day of the month, 1 through 31
2480
+ format = {
2481
+ millisecond: '%H:%M:%S.%L',
2482
+ second: '%l:%M:%S %P',
2483
+ minute: '%l:%M %p',
2484
+ hour: '%l:%M %p',
2485
+ day: '%b. %e',
2486
+ week: '%b. %e',
2487
+ month: '%b \'%y',
2488
+ year: '%Y'
2489
+ };
2490
+ }
2491
+ else {
2492
+ format = {
2493
+ millisecond: '%H:%M:%S.%L',
2494
+ second: '%H:%M:%S',
2495
+ minute: '%H:%M',
2496
+ hour: '%H:%M',
2497
+ day: '%e. %b',
2498
+ week: '%e. %b',
2499
+ month: '%b \'%y',
2500
+ year: '%Y'
2501
+ };
2502
+ }
2503
+ return format;
2504
+ }
2505
+ yyyyMMddFormat(date) {
2506
+ console.log("DATE date: ", date);
2507
+ let lang = this.translate.currentLang;
2508
+ console.log("DATE lang: ", lang);
2509
+ let format = 'yyyy-MM-dd';
2510
+ if (lang == 'en')
2511
+ format = 'yyyy-dd-MM';
2512
+ console.log("DATE format: ", format);
2513
+ let day = this.transformDate(date, format);
2514
+ console.log("DATE day: ", day);
2515
+ return day[0].toUpperCase() + day.slice(1);
2516
+ }
2517
+ yyyyMMddTHHmmssSSSZFormat(date) {
2518
+ const fechaFormateada = this.datePipe.transform(date, 'yyyy-MM-ddTHH:mm:ss.SSS\'Z\'');
2519
+ return fechaFormateada;
2520
+ }
2521
+ convert12to24format(time) {
2522
+ console.log("TIME 12to24: ", time);
2523
+ var hours = Number(time.match(/^(\d+)/)[1]);
2524
+ var minutes = Number(time.match(/:(\d+)/)[1]);
2525
+ var AMPM = time.match(/\s(.*)$/)[1];
2526
+ if (AMPM == "PM" && hours < 12)
2527
+ hours = hours + 12;
2528
+ if (AMPM == "AM" && hours == 12)
2529
+ hours = hours - 12;
2530
+ var sHours = hours.toString();
2531
+ var sMinutes = minutes.toString();
2532
+ if (hours < 10)
2533
+ sHours = "0" + sHours;
2534
+ if (minutes < 10)
2535
+ sMinutes = "0" + sMinutes;
2536
+ let h = sHours + ":" + sMinutes;
2537
+ console.log("HOURS: ", h);
2538
+ return h;
2539
+ }
2540
+ format24h(time) {
2541
+ let lang = this.translate.currentLang;
2542
+ if (lang === 'en') {
2543
+ // Check correct time format and split into components
2544
+ time = time.toString().match(/^([01]\d|2[0-3])(:)([0-5]\d)(:[0-5]\d)?$/) || [time];
2545
+ if (time.length > 1) { // If time format correct
2546
+ time = time.slice(1); // Remove full string match value
2547
+ time[5] = +time[0] < 12 ? ' AM' : ' PM'; // Set AM/PM
2548
+ time[0] = +time[0] % 12 || 12; // Adjust hours
2549
+ }
2550
+ return time.join(''); // return adjusted time or original string
2551
+ }
2552
+ return time;
2553
+ }
2554
+ isAmericanFormat() {
2555
+ return this.translate.currentLang === 'en';
2556
+ }
2557
+ getTimeFormat() {
2558
+ let lang = this.translate.currentLang;
2559
+ let format = 'HH:mm';
2560
+ if (lang === 'en')
2561
+ format = 'hh:mm a';
2562
+ return format;
2563
+ }
2564
+ isToday(mDate) {
2565
+ let date = new Date();
2566
+ if (date.getDate() === mDate.getDate() && date.getMonth() === mDate.getMonth() && date.getFullYear() === mDate.getFullYear())
2567
+ return true;
2568
+ return false;
2569
+ }
2570
+ transformDate(date, format) {
2571
+ const datePipe = new DatePipe(this.getLocale());
2572
+ return datePipe.transform(date, format);
2573
+ }
2574
+ getCalendarDay(epoch) {
2575
+ if (!epoch) {
2576
+ return null;
2577
+ }
2578
+ let timeString = 'h:mm A';
2579
+ const today = this.translate.instant('agenda.today');
2580
+ const yesterday = this.translate.instant('agenda.yesterday');
2581
+ return moment(epoch).calendar(null, {
2582
+ sameDay: `[${today}] ` + timeString,
2583
+ lastDay: `[${yesterday}] ` + timeString,
2584
+ lastWeek: 'DD/MM/YY ' + timeString,
2585
+ sameElse: 'DD/MM/YY ' + timeString,
2586
+ nextDay: 'DD/MM/YY ' + timeString,
2587
+ });
2588
+ }
2589
+ getCalendarDay2(epoch) {
2590
+ if (!epoch) {
2591
+ return null;
2592
+ }
2593
+ let timeString = this.getTimeFormat();
2594
+ let dateString = this.getShortDateFormat();
2595
+ const today = this.translate.instant('agenda.today');
2596
+ const yesterday = this.translate.instant('agenda.yesterday');
2597
+ return moment(epoch).calendar(null, {
2598
+ sameDay: `[${today}] ` + timeString,
2599
+ lastDay: `[${yesterday}] ` + timeString,
2600
+ sameElse: dateString + ' ' + timeString,
2601
+ lastWeek: dateString + ' ' + timeString,
2602
+ nextDay: dateString + ' ' + timeString
2603
+ });
2604
+ }
2605
+ getCalendarDayTime(epoch) {
2606
+ if (!epoch) {
2607
+ return null;
2608
+ }
2609
+ let timeString = this.getTimeFormat();
2610
+ let dateString = this.getLongFormat();
2611
+ let lang = this.translate.currentLang;
2612
+ const today = this.translate.instant('agenda.today');
2613
+ const yesterday = this.translate.instant('agenda.yesterday');
2614
+ const to = this.translate.instant('agenda.to');
2615
+ const m = moment;
2616
+ m.locale(lang);
2617
+ return m(epoch).calendar(null, {
2618
+ sameDay: `[${today}] ` + `[${to}] ` + timeString,
2619
+ lastDay: `[${yesterday}] ` + `[${to}] ` + timeString,
2620
+ sameElse: dateString + ' ' + `[${to}] ` + timeString,
2621
+ lastWeek: dateString + ' ' + `[${to}] ` + timeString,
2622
+ nextDay: dateString + ' ' + `[${to}] ` + timeString
2623
+ });
2624
+ }
2625
+ // return epoch string as specified format
2626
+ formatEpoch(epoch) {
2627
+ return this.getCalendarDay(epoch);
2628
+ }
2629
+ getToday() {
2630
+ const tzoffset = (new Date()).getTimezoneOffset() * 60000; // offset in milliseconds
2631
+ const localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1);
2632
+ let date = localISOTime; // this.dateService.selectedDateFormat(localISOTime);
2633
+ return date;
2634
+ }
2635
+ getCurrentTime() {
2636
+ const tzoffset = (new Date()).getTimezoneOffset() * 60000; // offset in milliseconds
2637
+ const localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1);
2638
+ let date = localISOTime; // this.dateService.selectedDateFormat(localISOTime);
2639
+ return new Date(Date.now() - tzoffset).getTime().toLocaleString();
2640
+ }
2641
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: DateService, deps: [{ token: i2$2.DatePipe }, { token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2642
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: DateService, providedIn: 'root' }); }
2643
+ }
2644
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: DateService, decorators: [{
2645
+ type: Injectable,
2646
+ args: [{
2647
+ providedIn: 'root',
2648
+ }]
2649
+ }], ctorParameters: () => [{ type: i2$2.DatePipe }, { type: i1$1.TranslateService }] });
2650
+
2651
+ highchartsMore(HighCharts);
2652
+ class HighchartsService {
2653
+ constructor(languageService) {
2654
+ this.languageService = languageService;
2655
+ this.weekdaysES = ['Domingo', 'Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sábado'];
2656
+ this.weekdaysCA = ['Diumenge', 'Dilluns', 'Dimarts', 'Dimecres', 'Dijous', 'Divendres', 'Dissabte'];
2657
+ this.graphData = [];
2658
+ this.series = [];
2659
+ this.withTooltip = false;
2660
+ this.scrollMinWidth = 550;
2661
+ }
2662
+ setTitle(title) {
2663
+ this.title = title;
2664
+ }
2665
+ setUnits(units) {
2666
+ this.units = units;
2667
+ }
2668
+ setLocale() {
2669
+ return this.languageService.getCurrent();
2670
+ }
2671
+ setPointWidth(interval) {
2672
+ switch (interval) {
2673
+ case '1d':
2674
+ return 12;
2675
+ case '1w':
2676
+ return 12;
2677
+ case '1m':
2678
+ return 8;
2679
+ case '1y':
2680
+ return 12;
2681
+ default:
2682
+ return 20;
2683
+ }
2684
+ }
2685
+ setScrollMinWidth(interval) {
2686
+ switch (interval) {
2687
+ case '1d':
2688
+ this.scrollMinWidth = 600;
2689
+ break;
2690
+ case '1w':
2691
+ this.scrollMinWidth = 500;
2692
+ break;
2693
+ case '1m':
2694
+ this.scrollMinWidth = 600;
2695
+ break;
2696
+ case '1y':
2697
+ this.scrollMinWidth = 500;
2698
+ break;
2699
+ default:
2700
+ this.scrollMinWidth = 500;
2701
+ break;
2702
+ }
2703
+ }
2704
+ addTooltip(interval) {
2705
+ switch (interval) {
2706
+ case '1d':
2707
+ this.withTooltip = false;
2708
+ break;
2709
+ case '1w':
2710
+ this.withTooltip = false;
2711
+ break;
2712
+ case '1m':
2713
+ this.withTooltip = true;
2714
+ break;
2715
+ case '1y':
2716
+ this.withTooltip = false;
2717
+ break;
2718
+ default:
2719
+ this.withTooltip = false;
2720
+ break;
2721
+ }
2722
+ }
2723
+ getWeekday() {
2724
+ return (this.setLocale() == 'es') ? this.weekdaysES : this.weekdaysCA;
2725
+ }
2726
+ setSeries(name, data, pointWidth, lineWidth, color, colorKey, colorByPoint) {
2727
+ const serie_name = name ? name : this.units;
2728
+ const serie_data = (data && data.length > 0) ? data : this.graphData;
2729
+ const serie_pointWidth = pointWidth ? pointWidth : this.pointWidth;
2730
+ const serie_colorByPoint = colorByPoint ? true : false;
2731
+ let serie = { name: serie_name, data: serie_data, pointWidth: serie_pointWidth, colorByPoint: serie_colorByPoint };
2732
+ //if (pointWidth != undefined) serie['pointWidth'] = pointWidth
2733
+ if (lineWidth)
2734
+ serie['lineWidth'] = lineWidth;
2735
+ if (color)
2736
+ serie['color'] = color;
2737
+ if (colorKey)
2738
+ serie['colorKey'] = colorKey;
2739
+ this.series = [];
2740
+ this.series.push(serie);
2741
+ }
2742
+ // type: this.typeChart,
2743
+ // maxRange: this.min.getTime(),
2744
+ // categories: this.withTooltip? this.graphDates: null
2745
+ setXAxis(type, categories, maxRange) {
2746
+ this.xAxis = { type: type, maxRange: maxRange, categories: categories, crosshair: true };
2747
+ }
2748
+ setYAxis(minY, maxY, ranges, text) {
2749
+ console.log('[ActivityGoalPage] generateChart() maxY: ', maxY);
2750
+ //Solo para HPC requieren que el valor mínimo de gráfica sea 0, aquí valido que si no hay valores negativos se el minY = 0;
2751
+ const y_min = minY; // (minY > 0) ? 0 : minY;
2752
+ const y_max = (maxY) ? maxY : this.maxY;
2753
+ const y_title = { text: text, align: 'high' };
2754
+ this.yAxis = { min: y_min, max: y_max, alignTicks: false, tickInterval: null, startOnTick: false, title: y_title, opposite: true, plotBands: ranges };
2755
+ }
2756
+ setMinY(valuesA, valuesB) {
2757
+ if (valuesA && valuesB && valuesB.length > 0) {
2758
+ const A = Math.min.apply(null, valuesA);
2759
+ const B = Math.min.apply(null, valuesB);
2760
+ this.minY = A > B ? B : A;
2761
+ return this.minY;
2762
+ }
2763
+ else {
2764
+ this.minY = Math.min.apply(null, valuesA);
2765
+ return this.minY;
2766
+ }
2767
+ }
2768
+ setMaxY(valuesA, valuesB) {
2769
+ if (valuesA && valuesB && valuesB.length > 0) {
2770
+ const A = Math.max.apply(null, valuesA);
2771
+ const B = Math.max.apply(null, valuesB);
2772
+ this.maxY = A > B ? A : B;
2773
+ return this.maxY;
2774
+ }
2775
+ else {
2776
+ this.maxY = Math.max.apply(null, valuesA);
2777
+ return this.maxY;
2778
+ }
2779
+ }
2780
+ getOptionsChart(graphBaseOn) {
2781
+ //console.log('[ActivityGoalPage] generateChart() graphBaseOn: ', graphBaseOn);
2782
+ let charts; //= HighCharts
2783
+ switch (graphBaseOn) {
2784
+ case 'avg':
2785
+ //charts.chart('container', {
2786
+ charts = {
2787
+ chart: {
2788
+ renderTo: 'container',
2789
+ type: 'column',
2790
+ zoomType: 'x',
2791
+ scrollablePlotArea: {
2792
+ minWidth: this.scrollMinWidth,
2793
+ scrollPositionX: 1
2794
+ }
2795
+ },
2796
+ title: {
2797
+ text: this.title
2798
+ },
2799
+ xAxis: this.xAxis,
2800
+ yAxis: this.yAxis,
2801
+ rangeSelector: {
2802
+ enabled: true
2803
+ },
2804
+ plotOptions: {
2805
+ series: {
2806
+ allowPointSelect: true,
2807
+ borderWidth: 1,
2808
+ dataLabels: {
2809
+ enabled: true,
2810
+ format: '{point.y}'
2811
+ },
2812
+ }
2813
+ },
2814
+ legend: {
2815
+ enabled: false
2816
+ },
2817
+ credits: {
2818
+ enabled: false
2819
+ },
2820
+ series: this.series,
2821
+ tooltip: {
2822
+ valueSuffix: ` ${this.units}`
2823
+ },
2824
+ lang: {
2825
+ weekdays: this.getWeekday()
2826
+ }
2827
+ };
2828
+ //);
2829
+ break;
2830
+ case 'range':
2831
+ //charts.chart('container', {
2832
+ charts = {
2833
+ chart: {
2834
+ renderTo: 'container',
2835
+ type: 'arearange',
2836
+ zoomType: 'x',
2837
+ scrollablePlotArea: {
2838
+ minWidth: this.scrollMinWidth,
2839
+ scrollPositionX: 1
2840
+ }
2841
+ },
2842
+ title: {
2843
+ text: this.title
2844
+ },
2845
+ xAxis: this.xAxis,
2846
+ yAxis: this.yAxis,
2847
+ legend: {
2848
+ enabled: false
2849
+ },
2850
+ credits: {
2851
+ enabled: false
2852
+ },
2853
+ series: this.series,
2854
+ tooltip: {
2855
+ valueSuffix: ` ${this.units}`
2856
+ },
2857
+ lang: {
2858
+ weekdays: this.getWeekday()
2859
+ }
2860
+ };
2861
+ //);
2862
+ break;
2863
+ case 'lasValue': //barra o punto valor de 0 al inicio
2864
+ default:
2865
+ //charts.chart('container', {
2866
+ charts = {
2867
+ chart: {
2868
+ renderTo: 'container',
2869
+ type: 'column',
2870
+ zoomType: 'x',
2871
+ scrollablePlotArea: {
2872
+ minWidth: this.scrollMinWidth,
2873
+ scrollPositionX: 1
2874
+ }
2875
+ },
2876
+ title: {
2877
+ text: this.title
2878
+ },
2879
+ xAxis: this.xAxis,
2880
+ yAxis: this.yAxis,
2881
+ rangeSelector: {
2882
+ enabled: true
2883
+ },
2884
+ plotOptions: {
2885
+ series: {
2886
+ allowPointSelect: true,
2887
+ borderWidth: 1,
2888
+ dataLabels: {
2889
+ enabled: true,
2890
+ format: '{point.y}'
2891
+ },
2892
+ }
2893
+ },
2894
+ legend: {
2895
+ enabled: false
2896
+ },
2897
+ credits: {
2898
+ enabled: false
2899
+ },
2900
+ series: this.series,
2901
+ tooltip: {
2902
+ valueSuffix: ` ${this.units}`
2903
+ },
2904
+ lang: {
2905
+ weekdays: this.getWeekday()
2906
+ }
2907
+ };
2908
+ //);
2909
+ break;
2910
+ }
2911
+ if (this.withTooltip) {
2912
+ let tool = `<table><tr><th colspan="1">{point.key} ${this.extraTooltip}</th></tr>`; //
2913
+ HighCharts.setOptions({
2914
+ tooltip: {
2915
+ headerFormat: tool,
2916
+ },
2917
+ });
2918
+ }
2919
+ return charts;
2920
+ }
2921
+ groupByCategory(interval, element) {
2922
+ //console.log('[HighchartsService] groupByCategory ', element.date_value);
2923
+ let elementDate = new Date(element.date_value);
2924
+ let groupByDate = "";
2925
+ let tooltip = "";
2926
+ //console.log('[HighchartsService] groupByCategory ', element.date_value);
2927
+ switch (interval) {
2928
+ case '1d': // group by day
2929
+ let hour = element.date?.split(' ')[1];
2930
+ groupByDate = hour;
2931
+ // let isAllValue = (this.graphBaseOn == 'lasValue' || this.graphBaseOn == 'range')? true:false
2932
+ // groupByDate = isAllValue? hour : hour.split(':')[0] + ':' + hour.split(':')[1];
2933
+ tooltip = moment(elementDate, "YYYY-MM-DD").locale('es').date() + '/' + elementDate.toLocaleString(this.returnShortDate(), { month: 'short' }) + '/' + elementDate.getFullYear() + ' ' + groupByDate;
2934
+ break;
2935
+ case '1w':
2936
+ let date = this.formatSelectedDate(element.date_value);
2937
+ let day = date.toLocaleString(this.returnShortDate(), { weekday: 'short' });
2938
+ groupByDate = this.titleCase(day) + ' ' + this.formatSelectedDate2(element.date_value, 'd');
2939
+ tooltip = moment(elementDate, "YYYY-MM-DD").locale('es').date() + '/' + elementDate.toLocaleString(this.returnShortDate(), { month: 'short' }) + '/' + elementDate.getFullYear();
2940
+ break;
2941
+ case '1m':
2942
+ //let month = elementDate.toLocaleString('es-ES', { month: 'short' });
2943
+ groupByDate = this.formatSelectedDate2(element.date_value, 'd'); //+ ' ' + month
2944
+ tooltip = moment(elementDate, "YYYY-MM-DD").locale('es').date() + '/' + elementDate.toLocaleString(this.returnShortDate(), { month: 'short' }) + '/' + elementDate.getFullYear();
2945
+ break;
2946
+ case '1y':
2947
+ let month = new Date();
2948
+ month.setMonth(Number(element.date_value) - 1);
2949
+ groupByDate = month.toLocaleString(this.returnShortDate(), { month: 'short' });
2950
+ groupByDate = this.titleCase(groupByDate);
2951
+ tooltip = month.toLocaleString(this.returnShortDate(), { month: 'short' }) + '/' + month.getFullYear();
2952
+ break;
2953
+ default:
2954
+ break;
2955
+ }
2956
+ return { groupByDate: groupByDate, tooltip: tooltip };
2957
+ }
2958
+ returnShortDate() {
2959
+ const idioma = this.setLocale();
2960
+ switch (idioma) {
2961
+ case 'es':
2962
+ return 'es-ES';
2963
+ case 'en':
2964
+ return 'en-US';
2965
+ case 'ca':
2966
+ return 'ca-ES';
2967
+ case 'fr':
2968
+ return 'fr-FR';
2969
+ default:
2970
+ return idioma;
2971
+ }
2972
+ }
2973
+ formatSelectedDate2(d, format) {
2974
+ var auxdate = d.split(' ');
2975
+ d = d.replace(' ', 'T');
2976
+ let date0 = new Date(d).toUTCString();
2977
+ let date = new Date(date0);
2978
+ let time = auxdate[1];
2979
+ date.setHours(time.substring(0, 2));
2980
+ date.setMinutes(time.substring(3, 5));
2981
+ let language = this.languageService.getCurrent();
2982
+ const datePipe = new DatePipe('en');
2983
+ return datePipe.transform(date, format);
2984
+ }
2985
+ formatSelectedDate(d) {
2986
+ var auxdate = d.split(' ');
2987
+ d = d.replace(' ', 'T');
2988
+ let date0 = new Date(d).toUTCString();
2989
+ let date = new Date(date0);
2990
+ let time = auxdate[1];
2991
+ date.setHours(time.substring(0, 2));
2992
+ date.setMinutes(time.substring(3, 5));
2993
+ return date;
2994
+ }
2995
+ titleCase(word) {
2996
+ return word.charAt(0).toUpperCase() + word.slice(1);
2997
+ }
2998
+ getGroupedData(json, interval, withoToltip) {
2999
+ let withTooltip = false;
3000
+ let tooltip = [];
3001
+ let groupData;
3002
+ let groups = [];
3003
+ let valuesA = [];
3004
+ let valuesB = [];
3005
+ let datesA = [];
3006
+ let graphData = [];
3007
+ let graphBaseOn = json.graphBaseOn;
3008
+ this.graphBaseOn = json.graphBaseOn;
3009
+ switch (graphBaseOn) {
3010
+ case 'average':
3011
+ case 'avg':
3012
+ groups = json.values.reduce((groups, element) => {
3013
+ const value = Number(element.avg);
3014
+ const group = this.groupByCategory(interval, element);
3015
+ // If date doesn't exist in array, then create it
3016
+ if (!groups[group.groupByDate]) {
3017
+ groups[group.groupByDate] = [];
3018
+ groups[group.groupByDate].value = 0;
3019
+ }
3020
+ groups[group.groupByDate].value += value;
3021
+ groups[group.groupByDate].tooltip = group.tooltip;
3022
+ return groups;
3023
+ }, {});
3024
+ //console.log('[HighchartsService] rangeGraph', groups);
3025
+ Object.keys(groups).map((date) => {
3026
+ datesA.push(date);
3027
+ valuesA.push(groups[date].value);
3028
+ // if(withTooltip)
3029
+ // graphData.push({y: groups[date].total, tooltip: groups[date].tooltip});
3030
+ // else
3031
+ if (withTooltip)
3032
+ tooltip.push(groups[date].tooltip);
3033
+ graphData.push([date, groups[date].value]);
3034
+ });
3035
+ //console.log('[HighchartsService] graphData', graphData);
3036
+ groupData = { dates: datesA, valuesA: valuesA, graphData: graphData };
3037
+ break;
3038
+ case 'range':
3039
+ groups = json.values.reduce((groups, element) => {
3040
+ const valueMax = Number(element.max);
3041
+ const valueMin = Number(element.min);
3042
+ const group = this.groupByCategory(interval, element);
3043
+ // If date doesn't exist in array, then create it
3044
+ if (!groups[group.groupByDate]) {
3045
+ groups[group.groupByDate] = [];
3046
+ groups[group.groupByDate].valueMax = 0;
3047
+ groups[group.groupByDate].valueMin = 0;
3048
+ }
3049
+ groups[group.groupByDate].valueMax += valueMax;
3050
+ groups[group.groupByDate].valueMin += valueMin;
3051
+ groups[group.groupByDate].tooltip = group.tooltip;
3052
+ return groups;
3053
+ }, {});
3054
+ //console.log('[HighchartsService] rangeGraph', groups);
3055
+ Object.keys(groups).map((date) => {
3056
+ datesA.push(date);
3057
+ valuesA.push(groups[date].valueMax);
3058
+ valuesB.push(groups[date].valueMin);
3059
+ // if(withTooltip)
3060
+ // graphData.push({y: groups[date].total, tooltip: groups[date].tooltip});
3061
+ // else
3062
+ if (withTooltip)
3063
+ tooltip.push(groups[date].tooltip);
3064
+ graphData.push([date, groups[date].valueMin, groups[date].valueMax]);
3065
+ });
3066
+ //console.log('[HighchartsService] graphData', graphData);
3067
+ groupData = { dates: datesA, valuesA: valuesA, valuesB: valuesB, graphData: graphData };
3068
+ break;
3069
+ case 'sum':
3070
+ groups = json.values.reduce((groups, element) => {
3071
+ const value = Number(element.value);
3072
+ const group = this.groupByCategory(interval, element);
3073
+ // If date doesn't exist in array, then create it
3074
+ if (!groups[group.groupByDate]) {
3075
+ groups[group.groupByDate] = [];
3076
+ groups[group.groupByDate].value = 0;
3077
+ }
3078
+ groups[group.groupByDate].value += value;
3079
+ groups[group.groupByDate].tooltip = group.tooltip;
3080
+ return groups;
3081
+ }, {});
3082
+ //console.log('[HighchartsService] rangeGraph', groups);
3083
+ Object.keys(groups).map((date) => {
3084
+ datesA.push(date);
3085
+ valuesA.push(groups[date].value);
3086
+ // if(withTooltip)
3087
+ // graphData.push({y: groups[date].total, tooltip: groups[date].tooltip});
3088
+ // else
3089
+ if (withTooltip)
3090
+ tooltip.push(groups[date].tooltip);
3091
+ graphData.push([date, groups[date].value]);
3092
+ });
3093
+ //console.log('[HighchartsService] graphData', graphData);
3094
+ groupData = { dates: datesA, valuesA: valuesA, graphData: graphData };
3095
+ break;
3096
+ case 'lasValue':
3097
+ default:
3098
+ json.values.forEach(element => {
3099
+ const value = Number(element.value);
3100
+ const group = this.groupByCategory(interval, element);
3101
+ // If date doesn't exist in array, then create it
3102
+ // Con este codigo solo se hace sumatoria de los pasos en los dias. los demas atributos solo muestra el ultimo valor
3103
+ if (element.element_id !== 38) { //aca es 38
3104
+ if (!groups[group.groupByDate]) {
3105
+ groups[group.groupByDate] = [];
3106
+ groups[group.groupByDate].value = value;
3107
+ groups[group.groupByDate].tooltip = group.tooltip;
3108
+ }
3109
+ // }
3110
+ }
3111
+ else {
3112
+ groups[group.groupByDate].value += value;
3113
+ groups[group.groupByDate].tooltip = group.tooltip;
3114
+ }
3115
+ });
3116
+ /* if (!groups[group.groupByDate]) {
3117
+ groups[group.groupByDate] = [];
3118
+ groups[group.groupByDate].value = 0;
3119
+ }
3120
+ groups[group.groupByDate].value += value;
3121
+ groups[group.groupByDate].tooltip = group.tooltip
3122
+ })*/
3123
+ //console.log('[HighchartsService] rangeGraph', groups);
3124
+ Object.keys(groups).map((date) => {
3125
+ datesA.push(date);
3126
+ valuesA.push(groups[date].value);
3127
+ // if(withTooltip)
3128
+ // graphData.push({y: groups[date].total, tooltip: groups[date].tooltip});
3129
+ // else
3130
+ if (withTooltip)
3131
+ tooltip.push(groups[date].tooltip);
3132
+ graphData.push([date, groups[date].value]);
3133
+ });
3134
+ //console.log('[HighchartsService] graphData', graphData);
3135
+ groupData = { dates: datesA, valuesA: valuesA, graphData: graphData };
3136
+ break;
3137
+ }
3138
+ return groupData;
3139
+ }
3140
+ getRanges(element, min, max) {
3141
+ let normalValue = [];
3142
+ let outRangeValue = [];
3143
+ let dangerValue = [];
3144
+ let value = [];
3145
+ let ranges = element.ranges;
3146
+ ranges.forEach(range => {
3147
+ var r = [];
3148
+ var color;
3149
+ /*
3150
+ * No toma en cuenta los decimales con coma (,)
3151
+ */
3152
+ range.value1 = parseFloat(range.value1?.replace(",", "."));
3153
+ range.value2 = parseFloat(range.value2?.replace(",", "."));
3154
+ if (range.rangeCondition == '>' || range.rangeCondition == '=>') {
3155
+ r["from"] = range.value1;
3156
+ //const maxValue = this.getMaxRange(range.value1, max) ;
3157
+ //console.log('[ActivityGoalPage] maxValue ', maxValue);
3158
+ r["to"] = this.getMaxRange(range.value1, max);
3159
+ }
3160
+ if (range.rangeCondition == '<' || range.rangeCondition == '<=') {
3161
+ r["from"] = min;
3162
+ r["to"] = range.value1;
3163
+ }
3164
+ if (range.rangeCondition == 'a<x<b') {
3165
+ r["from"] = range.value1;
3166
+ r["to"] = range.value2;
3167
+ }
3168
+ if (range.rangeType == "success")
3169
+ color = 'rgba(96, 173, 121, 0.1)';
3170
+ else if (range.rangeType == "warning")
3171
+ color = 'rgba(245, 157, 24, 0.1)'; //'rgb(243, 156, 18, 0.1)'
3172
+ else if (range.rangeType == "danger")
3173
+ color = 'rgba(245, 46, 24, 0.1)'; //'rgb(231, 76, 60, 0.1)'
3174
+ r["color"] = color;
3175
+ value.push(r);
3176
+ if (range.rangeType === "success") {
3177
+ normalValue.push(range.conditionString);
3178
+ }
3179
+ else if (range.rangeType == "warning") {
3180
+ outRangeValue.push(range.conditionString);
3181
+ }
3182
+ else if (range.rangeType == "danger") {
3183
+ dangerValue.push(range.conditionString);
3184
+ }
3185
+ });
3186
+ if (value?.length > 0) {
3187
+ let rangesElement = {
3188
+ name: element.name,
3189
+ description: element.description,
3190
+ value: value,
3191
+ normalValue: normalValue,
3192
+ outRangeValue: outRangeValue,
3193
+ dangerValue: dangerValue
3194
+ };
3195
+ console.log('[ActivityGoalPage] getRanges() ranges: ', rangesElement);
3196
+ return rangesElement;
3197
+ }
3198
+ else
3199
+ return undefined;
3200
+ }
3201
+ //Aqui se setea el valor max en Y sumando el rango máximo y valor máximo ingresado divdido entre 2
3202
+ getMaxRange(rangeMax, max) {
3203
+ let value1 = Number(rangeMax);
3204
+ let value2 = Number(max);
3205
+ if (value2 <= value1)
3206
+ this.maxY = value1 + value2 / 2;
3207
+ else
3208
+ this.maxY = value2;
3209
+ return this.maxY;
3210
+ }
3211
+ setHighchartsOptions(json, params) {
3212
+ let opt = json?.graphBaseOn;
3213
+ let interval = params.interval;
3214
+ let name = json?.name;
3215
+ let typeChart = '';
3216
+ let valuesA = [];
3217
+ let valuesB = [];
3218
+ let datesA = [];
3219
+ let graphData = [];
3220
+ let ranges;
3221
+ let minY;
3222
+ let maxY;
3223
+ let pointWidth = 20;
3224
+ let units = json?.units;
3225
+ this.units = json.units;
3226
+ const data = this.getGroupedData(json, interval);
3227
+ graphData = data?.graphData;
3228
+ valuesA = data?.valuesA;
3229
+ valuesB = data?.valuesB;
3230
+ datesA = data?.dates;
3231
+ minY = this.setMinY(valuesA, valuesB);
3232
+ maxY = this.setMaxY(valuesA, valuesB);
3233
+ ranges = this.getRanges(json, minY, maxY);
3234
+ this.ranges = ranges;
3235
+ pointWidth = this.setPointWidth(interval);
3236
+ console.log("* valuesA: ", valuesA);
3237
+ console.log("* valuesB: ", valuesB);
3238
+ console.log("* dates: ", datesA);
3239
+ console.log("* graphic: ", graphData);
3240
+ switch (opt) {
3241
+ case 'range':
3242
+ typeChart = 'arearange';
3243
+ break;
3244
+ case 'sum':
3245
+ case 'avg':
3246
+ case 'lasValue':
3247
+ default:
3248
+ typeChart = 'category';
3249
+ break;
3250
+ }
3251
+ this.setXAxis(typeChart, datesA);
3252
+ this.setYAxis(minY, maxY, ranges, units);
3253
+ this.setSeries(name, graphData, pointWidth);
3254
+ }
3255
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: HighchartsService, deps: [{ token: LanguageService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3256
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: HighchartsService, providedIn: 'root' }); }
3257
+ }
3258
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: HighchartsService, decorators: [{
3259
+ type: Injectable,
3260
+ args: [{
3261
+ providedIn: 'root'
3262
+ }]
3263
+ }], ctorParameters: () => [{ type: LanguageService }] });
3264
+
3265
+ class ComponentsApp {
3266
+ constructor(goal, advices, news, agenda, reminder, diet, drug, game, element, form, chat, doc_diagnostic, contacta) {
3267
+ this.goal = goal;
3268
+ this.advices = advices;
3269
+ this.news = news;
3270
+ this.agenda = agenda;
3271
+ this.reminder = reminder;
3272
+ this.diet = diet;
3273
+ this.drug = drug;
3274
+ this.game = game;
3275
+ this.element = element;
3276
+ this.form = form;
3277
+ this.chat = chat;
3278
+ this.doc_diagnostic = doc_diagnostic;
3279
+ this.contacta = contacta;
3280
+ }
3281
+ }
3282
+ class RolesService {
3283
+ constructor() {
3284
+ this.setProfessional(false);
3285
+ this.activatedAllComponents(true);
3286
+ //this.customAllComponents(true,false,true,false,false,false,false,true,true,true,true, false, true)
3287
+ }
3288
+ activatedAllComponents(enable) {
3289
+ this.component = new ComponentsApp(enable, enable, enable, enable, enable, enable, enable, enable, enable, enable, enable, enable, enable);
3290
+ }
3291
+ customAllComponents(goal, advices, news, agenda, reminder, diet, drug, game, element, form, chat, doc_diagnostic, contacta) {
3292
+ this.component = new ComponentsApp(goal, advices, news, agenda, reminder, diet, drug, game, element, form, chat, doc_diagnostic, contacta);
3293
+ }
3294
+ setProfessional(professional) {
3295
+ this.isProfessional = professional ? true : false;
3296
+ }
3297
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: RolesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3298
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: RolesService, providedIn: 'root' }); }
3299
+ }
3300
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: RolesService, decorators: [{
3301
+ type: Injectable,
3302
+ args: [{
3303
+ providedIn: 'root'
3304
+ }]
3305
+ }], ctorParameters: () => [] });
3306
+
3307
+ class StorageService {
3308
+ constructor() {
3309
+ Preferences.migrate();
3310
+ }
3311
+ saveFirstTimeLoad(val) {
3312
+ Preferences.set({ key: 'firstTime', value: val });
3313
+ }
3314
+ saveFirstTimeLoad2(val) {
3315
+ Preferences.set({ key: 'firstTime2', value: val });
3316
+ }
3317
+ async isFirstTimeLoad() {
3318
+ const result = await Preferences.get({ key: 'firstTime' });
3319
+ if (result == null) { //si no hay valor previo
3320
+ return true; //retornamos true
3321
+ }
3322
+ return JSON.parse(result.value);
3323
+ }
3324
+ async isFirstTimeLoad2() {
3325
+ const result = await Preferences.get({ key: 'firstTime2' });
3326
+ if (result == null) { //si no hay valor previo
3327
+ return true; //retornamos true
3328
+ }
3329
+ return JSON.parse(result.value);
3330
+ }
3331
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3332
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: StorageService, providedIn: 'root' }); }
3333
+ }
3334
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: StorageService, decorators: [{
3335
+ type: Injectable,
3336
+ args: [{
3337
+ providedIn: 'root'
3338
+ }]
3339
+ }], ctorParameters: () => [] });
3340
+
3341
+ var NotificationsType;
3342
+ (function (NotificationsType) {
3343
+ NotificationsType["ADVICES"] = "advices";
3344
+ NotificationsType["AGENDA"] = "agenda";
3345
+ NotificationsType["COMMUNICATIONS"] = "communications";
3346
+ NotificationsType["DIETS"] = "diets";
3347
+ NotificationsType["EXERCISES"] = "exercises";
3348
+ NotificationsType["FORMS"] = "forms";
3349
+ NotificationsType["GAMES"] = "games";
3350
+ NotificationsType["GOALS"] = "goals";
3351
+ NotificationsType["MEDICATIONS"] = "medication_plans";
3352
+ NotificationsType["MESSAGES"] = "messages";
3353
+ NotificationsType["NEWS"] = "news";
3354
+ NotificationsType["OFFERS"] = "offers";
3355
+ NotificationsType["PROMOTE_CONTENT"] = "promote-content";
3356
+ NotificationsType["PROCEDURES"] = "medical_procedures";
3357
+ NotificationsType["REMINDERS"] = "reminder";
3358
+ //Shared care plan
3359
+ NotificationsType["MONITORING"] = "monitoring";
3360
+ NotificationsType["INFORMED_CONSENT"] = "informed_consent";
3361
+ NotificationsType["LIFE_STILE_HABITS"] = "life_style_habits";
3362
+ NotificationsType["SHARED_CARE_PLAN"] = "shared_care_plan";
3363
+ NotificationsType["AddButtonMedicalTest"] = "add_document";
3364
+ NotificationsType["TESTIMONIALS"] = "testimonials";
3365
+ NotificationsType["AddButtonTodayDrug"] = "drugs-detail";
3366
+ NotificationsType["AddButtonHealthCharts"] = "activity-goal";
3367
+ })(NotificationsType || (NotificationsType = {}));
3368
+ var NotificationsTypeBO;
3369
+ (function (NotificationsTypeBO) {
3370
+ NotificationsTypeBO["ADVICES"] = "App\\Advice";
3371
+ NotificationsTypeBO["AGENDA"] = "App\\Agenda";
3372
+ NotificationsTypeBO["CHALLENGE_LEVEL"] = "App\\LevelAccomplishment";
3373
+ NotificationsTypeBO["DIAGNOSTIC_TEST"] = "App\\DiagnosticTest";
3374
+ NotificationsTypeBO["DIETS"] = "App\\Diet";
3375
+ NotificationsTypeBO["DRUG"] = "App\\DrugIntake";
3376
+ NotificationsTypeBO["EXERCISES"] = "App\\Exercise";
3377
+ NotificationsTypeBO["FORMS"] = "App\\FormAnswer";
3378
+ NotificationsTypeBO["GAMES"] = "App\\Game";
3379
+ NotificationsTypeBO["GAME_PLAY"] = "App\\GamePlay";
3380
+ //GOALS = "App\\Goalable",
3381
+ NotificationsTypeBO["MEDICAL_PROCEDURE"] = "App\\MedicalProcedure";
3382
+ NotificationsTypeBO["MEDICATIONS"] = "App\\MedicationPlan";
3383
+ NotificationsTypeBO["MESSAGES"] = "App\\Message";
3384
+ NotificationsTypeBO["NEWS"] = "App\\News";
3385
+ NotificationsTypeBO["PROGRAMABLE_PLAY"] = "App\\ProgramablePlay";
3386
+ NotificationsTypeBO["REMINDERS"] = "App\\Reminder";
3387
+ NotificationsTypeBO["REMINDERS_EXECUTION"] = "App\\ReminderExecution";
3388
+ NotificationsTypeBO["SHARED_CARE_PLAN"] = "App\\ShareCarePlan";
3389
+ })(NotificationsTypeBO || (NotificationsTypeBO = {}));
3390
+ var NOTIFICATIONS_TYPE_BO;
3391
+ (function (NOTIFICATIONS_TYPE_BO) {
3392
+ NOTIFICATIONS_TYPE_BO["AGENDA"] = "App\\Notifications\\AgendaCreated";
3393
+ NOTIFICATIONS_TYPE_BO["APPOINTMENTS_VISIT"] = "App\\Notifications\\VisitOnlineNotification";
3394
+ NOTIFICATIONS_TYPE_BO["ADVICES"] = "App\\Notifications\\AdviceCreated";
3395
+ NOTIFICATIONS_TYPE_BO["CHALLENGE_LEVEL"] = "App\\Notifications\\LevelAccomplishmentCompletedNotification";
3396
+ NOTIFICATIONS_TYPE_BO["DIETS"] = "App\\Notifications\\DietCreated";
3397
+ NOTIFICATIONS_TYPE_BO["DRUG"] = "App\\Notifications\\DrugIntakeTime";
3398
+ NOTIFICATIONS_TYPE_BO["EXERCISES"] = "App\\Notifications\\ExerciseCreated";
3399
+ NOTIFICATIONS_TYPE_BO["EXERCISES_PLAY"] = "App\\Notifications\\ExercisePlaySchedule";
3400
+ NOTIFICATIONS_TYPE_BO["FORMS"] = "App\\Notifications\\FormAnswerSchedule";
3401
+ NOTIFICATIONS_TYPE_BO["GAMES"] = "App\\Notifications\\GamePlaySchedule";
3402
+ NOTIFICATIONS_TYPE_BO["MESSAGES"] = "App\\Notifications\\MessageNotification";
3403
+ NOTIFICATIONS_TYPE_BO["NEWS"] = "App\\Notifications\\NewsNotification";
3404
+ NOTIFICATIONS_TYPE_BO["REMINDERS"] = "App\\Notifications\\ReminderTime";
3405
+ NOTIFICATIONS_TYPE_BO["SHARED_CARE_PLAN"] = "App\\Notifications\\SharedCarePlanAddContentNotification";
3406
+ // MEDICATIONS = "",
3407
+ // GOALS = "",
3408
+ // MEDICAL_PROCEDURE = "",
3409
+ // DIAGNOSTIC_TEST = "",
3410
+ // PROGRAMABLE_PLAY = "",
3411
+ })(NOTIFICATIONS_TYPE_BO || (NOTIFICATIONS_TYPE_BO = {}));
3412
+ var NotificationsTypeColor;
3413
+ (function (NotificationsTypeColor) {
3414
+ NotificationsTypeColor["ADVICES"] = "#2356f9";
3415
+ NotificationsTypeColor["AGENDA"] = "#6950ce";
3416
+ NotificationsTypeColor["CHALLENGE_LEVEL"] = "#BDC3C7";
3417
+ NotificationsTypeColor["DIAGNOSTIC_TEST"] = "#1A8E92";
3418
+ NotificationsTypeColor["DIETS"] = "#E67E22";
3419
+ NotificationsTypeColor["DRUG"] = "#5AC445";
3420
+ NotificationsTypeColor["EXERCISES"] = "#f53d3d";
3421
+ NotificationsTypeColor["FORMS"] = "#2356f9";
3422
+ NotificationsTypeColor["GAMES"] = "#9B59B6";
3423
+ NotificationsTypeColor["GAME_PLAY"] = "#9B59B6";
3424
+ //GOALS = '#1A8E92',
3425
+ NotificationsTypeColor["MEDICAL_PROCEDURE"] = "#EC7579";
3426
+ NotificationsTypeColor["MEDICATIONS"] = "#25CAD0";
3427
+ NotificationsTypeColor["MESSAGES"] = "#25CAD0";
3428
+ NotificationsTypeColor["NEWS"] = "#2356f9";
3429
+ NotificationsTypeColor["PROGRAMABLE_PLAY"] = "#7F8C8D";
3430
+ NotificationsTypeColor["REMINDERS"] = "#6950ce";
3431
+ NotificationsTypeColor["REMINDERS_EXECUTION"] = "#6950ce";
3432
+ NotificationsTypeColor["SHARED_CARE_PLAN"] = "#BA0186";
3433
+ })(NotificationsTypeColor || (NotificationsTypeColor = {}));
3434
+ class NotificationOptions {
3435
+ constructor() {
3436
+ this.agenda = { type: NotificationsType.AGENDA, mail: 'agendaNotificationMail', app: 'agendaNotificationApp', old: null };
3437
+ this.reminder = { type: NotificationsType.REMINDERS, mail: 'reminderNotificationMail', app: 'reminderNotificationApp', old: null };
3438
+ this.diets = { type: NotificationsType.DIETS, mail: 'dietsNotificationMail', app: 'dietsNotificationApp', old: 'dietsNotificaton' };
3439
+ this.medication = { type: NotificationsType.MEDICATIONS, mail: ['drugIntakeNotificationMail', 'medicationPlanExpiredNotificationEmail'], app: ['drugIntakeNotificationApp', 'medicationPlanExpiredNotificationApp'], old: null };
3440
+ this.goals = { type: NotificationsType.GOALS, mail: 'goalsNotificationMail', app: 'goalsNotificationApp', old: 'goalsNotificaton' };
3441
+ this.advices = { type: NotificationsType.ADVICES, mail: 'advicesNotificationMail', app: 'advicesNotificationApp', old: 'advicesNotificaton' };
3442
+ this.forms = { type: NotificationsType.FORMS, mail: 'formNotificationMail', app: 'formNotificationApp', old: 'formNotificaton' };
3443
+ this.messages = { type: NotificationsType.MESSAGES, mail: 'messagesNotificationMail', app: 'messagesNotificationApp', old: 'messagesNotificaton' };
3444
+ this.news = { type: NotificationsType.NEWS, mail: 'newsNotificationMail', app: 'newsNotificationApp', old: null };
3445
+ this.games = { type: NotificationsType.GAMES, mail: 'gamePlayNotificationMail', app: 'gamePlayNotificationApp', old: null };
3446
+ this.exercises = { type: NotificationsType.EXERCISES, mail: 'exercisePlayNotificationMail', app: 'exercisePlayNotificationApp', old: null };
3447
+ this.list_options = [];
3448
+ //Aqui se añaden todas las notificaciones que queremos que aparezca en setting.page
3449
+ this.options = [this.agenda, this.reminder, this.diets, this.medication, this.goals, this.advices, this.forms, this.messages, this.news, this.games, this.exercises];
3450
+ this.setAllNotifications();
3451
+ }
3452
+ setAllNotifications() {
3453
+ const ItembyRole = JSON.parse(localStorage.getItem('showItembyRole'));
3454
+ const showItembyRole = Object.keys(ItembyRole);
3455
+ showItembyRole.forEach(element => {
3456
+ // resultado = this.options.filter(animal => animal != element);
3457
+ for (let index = 0; index < this.options.length; index++) {
3458
+ if (element === this.options[index].type) {
3459
+ // delete(this.options[index])
3460
+ this.options.splice(index, 1);
3461
+ index--;
3462
+ }
3463
+ }
3464
+ });
3465
+ this.options.forEach(opt => {
3466
+ opt['translate'] = this.setTranslate(opt);
3467
+ opt['on_mail'] = false;
3468
+ opt['on_app'] = false;
3469
+ const notification = opt;
3470
+ this.list_options.push(notification);
3471
+ });
3472
+ }
3473
+ getListOptions() {
3474
+ return this.list_options;
3475
+ }
3476
+ setTranslate(opt) {
3477
+ switch (opt?.type) {
3478
+ case NotificationsType.COMMUNICATIONS:
3479
+ return 'setting.subtitle_communications';
3480
+ case NotificationsType.AGENDA:
3481
+ return 'setting.subtitle_appointment';
3482
+ case NotificationsType.REMINDERS:
3483
+ return 'setting.subtitle_reminders';
3484
+ case NotificationsType.DIETS:
3485
+ return 'setting.subtitle_diets';
3486
+ case NotificationsType.MEDICATIONS:
3487
+ return 'setting.subtitle_medication';
3488
+ case NotificationsType.GOALS:
3489
+ return 'setting.subtitle_goals';
3490
+ case NotificationsType.ADVICES:
3491
+ return 'setting.subtitle_advices';
3492
+ case NotificationsType.NEWS:
3493
+ return 'setting.subtitle_release';
3494
+ case NotificationsType.PROCEDURES:
3495
+ return 'setting.subtitle_procedure';
3496
+ case NotificationsType.OFFERS:
3497
+ return 'setting.subtitle_offers';
3498
+ case NotificationsType.FORMS:
3499
+ return 'setting.subtitle_form';
3500
+ case NotificationsType.MESSAGES:
3501
+ return 'setting.subtitle_messages';
3502
+ case NotificationsType.GAMES:
3503
+ return 'setting.subtitle_games';
3504
+ case NotificationsType.PROMOTE_CONTENT:
3505
+ return 'setting.subtitle_release'; // return 'setting.subtitle_promoteContent';
3506
+ case NotificationsType.EXERCISES:
3507
+ return 'setting.subtitle_exercises';
3508
+ default:
3509
+ return '';
3510
+ }
3511
+ }
3512
+ setAppMailField(list, json) {
3513
+ list.forEach(opt => {
3514
+ opt.on_app = this.isOnApp(opt, json);
3515
+ opt.on_mail = this.isOnMail(opt, json);
3516
+ });
3517
+ return list;
3518
+ }
3519
+ isOnApp(opt, json) {
3520
+ if (typeof opt.app === 'string')
3521
+ return json[opt.app] == '1' ? true : false;
3522
+ else
3523
+ return json[opt.app[0]] == '1' ? true : false;
3524
+ }
3525
+ isOnMail(opt, json) {
3526
+ if (typeof opt.mail === 'string')
3527
+ return json[opt.mail] == '1' ? true : false;
3528
+ else
3529
+ return json[opt.mail[0]] == '1' ? true : false;
3530
+ }
3531
+ }
3532
+ var ContentTypePath;
3533
+ (function (ContentTypePath) {
3534
+ //ADVICES
3535
+ ContentTypePath["Advices"] = "/advices";
3536
+ ContentTypePath["AdvicesDetail"] = "/advices-detail";
3537
+ //AGENDA
3538
+ ContentTypePath["Agenda"] = "/agenda";
3539
+ ContentTypePath["AgendaAppointment"] = "/agenda/list-appointment";
3540
+ ContentTypePath["AgendaDetail"] = "/agenda/detail";
3541
+ //CHALLENGES
3542
+ ContentTypePath["Challenges"] = "/profile/challenges";
3543
+ ContentTypePath["ChallengesDetail"] = "/home/health-path/detail";
3544
+ //DIETS
3545
+ ContentTypePath["Diets"] = "/journal";
3546
+ ContentTypePath["DietsDetail"] = "/journal/diets-detail";
3547
+ //EXERCISE
3548
+ ContentTypePath["Exercises"] = "/exercices";
3549
+ ContentTypePath["ExercisesDetail"] = "/exercices/exercices-detail";
3550
+ //FORM
3551
+ ContentTypePath["Forms"] = "/tracking";
3552
+ ContentTypePath["FormDetail"] = "/tracking/form";
3553
+ //GAME
3554
+ ContentTypePath["Games"] = "/journal";
3555
+ ContentTypePath["GamesDetail"] = "/journal/games-detail";
3556
+ //GOALS
3557
+ ContentTypePath["Goals"] = "/profile/goals";
3558
+ //HOME
3559
+ ContentTypePath["Home"] = "/home";
3560
+ //MEDICAL PROCEDURES
3561
+ ContentTypePath["MedicalProcedure"] = "/procedures";
3562
+ //MEDICAL TEST
3563
+ ContentTypePath["MedicalTest"] = "/document-detail";
3564
+ //MEDICATION
3565
+ ContentTypePath["Medication"] = "/jounal/";
3566
+ ContentTypePath["MedicationDetail"] = "/drugs-detail";
3567
+ //MESSAGE
3568
+ ContentTypePath["Message"] = "/contact/chat/conversation";
3569
+ //GRAPHIS
3570
+ ContentTypePath["Monitoring"] = "/activity-goal";
3571
+ //NEWS
3572
+ ContentTypePath["News"] = "/news";
3573
+ ContentTypePath["NewsDetail"] = "/new-detail";
3574
+ //REMINDERS
3575
+ ContentTypePath["ReminderDetail"] = "/agenda/reminder/";
3576
+ //TRACKING OR FOLLOW UP
3577
+ ContentTypePath["Tracking"] = "/tracking";
3578
+ //INFORMED COSENT
3579
+ ContentTypePath["InformedConsent"] = "/informed-consent";
3580
+ //medical-directory
3581
+ ContentTypePath["MedicalDirectory"] = "/medical-directory";
3582
+ //AgenderCIta
3583
+ ContentTypePath["Bookings"] = "/bookings";
3584
+ })(ContentTypePath || (ContentTypePath = {}));
3585
+
3586
+ class NotificationService {
3587
+ constructor(snackBar, zone, alertCtrl, translate, toastController, _zone, platform, router) {
3588
+ this.snackBar = snackBar;
3589
+ this.zone = zone;
3590
+ this.alertCtrl = alertCtrl;
3591
+ this.translate = translate;
3592
+ this.toastController = toastController;
3593
+ this._zone = _zone;
3594
+ this.platform = platform;
3595
+ this.router = router;
3596
+ }
3597
+ showSuccess(message) {
3598
+ // Had an issue with the snackbar being ran outside of angular's zone.
3599
+ this.zone.run(() => {
3600
+ // The second parameter is the text in the button.
3601
+ // In the third, we send in the css class for the snack bar.
3602
+ const config = new MatSnackBarConfig();
3603
+ config.panelClass = ['custom-class'];
3604
+ config.verticalPosition = 'bottom';
3605
+ config.horizontalPosition = 'center';
3606
+ config.duration = 3000;
3607
+ this.snackBar.open(message, '', config);
3608
+ });
3609
+ }
3610
+ showError(error) {
3611
+ let message;
3612
+ if (error.includes('ERR_INTERNET_DISCONNECTED') || error.toLowerCase().includes('network error') || error.toLowerCase().includes('unknown error'))
3613
+ message = this.translate.instant('commons.error-network');
3614
+ else if (error.includes('Timeout has occurred'))
3615
+ message = this.translate.instant('commons.error-timeout');
3616
+ else
3617
+ message = error;
3618
+ this.zone.run(() => {
3619
+ const config = new MatSnackBarConfig();
3620
+ config.panelClass = ['example-pizza-party'];
3621
+ config.verticalPosition = 'bottom';
3622
+ config.horizontalPosition = 'center';
3623
+ config.duration = 3000;
3624
+ this.snackBar.open(message, 'X', config);
3625
+ console.log("NotificationService", message);
3626
+ });
3627
+ }
3628
+ //Toast
3629
+ displayToastSuccessful() {
3630
+ try {
3631
+ this.toastController.dismiss().then(() => {
3632
+ }).catch(() => {
3633
+ }).finally(() => {
3634
+ console.log('Closed');
3635
+ });
3636
+ }
3637
+ catch (e) { }
3638
+ this.toastController.create({
3639
+ position: 'middle', //'middle', 'bottom'
3640
+ cssClass: 'toast-custom-class',
3641
+ animated: true,
3642
+ duration: 2000,
3643
+ }).then((toast) => {
3644
+ toast.present();
3645
+ });
3646
+ }
3647
+ displayToastPusher(message) {
3648
+ try {
3649
+ this.toastController.dismiss().then(() => {
3650
+ }).catch(() => {
3651
+ }).finally(() => {
3652
+ console.log('Closed');
3653
+ });
3654
+ }
3655
+ catch (e) { }
3656
+ this.toastController.create({
3657
+ position: 'middle', //'middle', 'bottom'
3658
+ cssClass: 'toast-pusher-class',
3659
+ message: message,
3660
+ animated: true,
3661
+ duration: 30000,
3662
+ buttons: [{
3663
+ text: 'Cerrar',
3664
+ icon: 'close',
3665
+ role: 'cancel',
3666
+ handler: () => {
3667
+ console.log('Cancel clicked');
3668
+ }
3669
+ }
3670
+ ]
3671
+ }).then((toast) => {
3672
+ toast.present();
3673
+ });
3674
+ }
3675
+ async confirmAllNotification(message) {
3676
+ const alert = await this.alertCtrl.create({
3677
+ cssClass: 'my-alert-class',
3678
+ message: message,
3679
+ buttons: [
3680
+ {
3681
+ text: this.translate.instant("button.ok"),
3682
+ handler: (data) => {
3683
+ }
3684
+ }
3685
+ ]
3686
+ });
3687
+ await alert.present();
3688
+ }
3689
+ redirecPushNotification(data, notification) {
3690
+ switch (data.action) {
3691
+ case "SHARECAREPLAN":
3692
+ this._zone.run(() => {
3693
+ this.router.navigate([ContentTypePath.Home], { state: { data: data, openNotificationAlertDialog: true } });
3694
+ });
3695
+ break;
3696
+ case "MESSAGE":
3697
+ let staff;
3698
+ // Different payloads for ios and android
3699
+ if (this.platform.is('ios'))
3700
+ staff = data?.origin;
3701
+ else
3702
+ staff = data?.origin ? JSON.parse(data?.origin) : null;
3703
+ console.log('staff: ', staff);
3704
+ this._zone.run(() => {
3705
+ this.router.navigate([ContentTypePath.Message], { state: { data: data, chat: data.id, staff: staff, customData: data?.user_id } });
3706
+ });
3707
+ break;
3708
+ case "FORM":
3709
+ this._zone.run(() => {
3710
+ this.router.navigate([ContentTypePath.Forms, { id: data.id }], { state: { data: data } });
3711
+ });
3712
+ break;
3713
+ case "DRUGINTAKE":
3714
+ this._zone.run(() => {
3715
+ this.router.navigate([ContentTypePath.Medication], { state: { data: data, segment: 'medication' } });
3716
+ });
3717
+ break;
3718
+ case "VIDEOCALL":
3719
+ //return "VIDEOCALL";
3720
+ break;
3721
+ case "ADVICE":
3722
+ this._zone.run(() => {
3723
+ this.router.navigateByUrl('/home').then(() => {
3724
+ this.router.navigate([ContentTypePath.AdvicesDetail], { state: { data: data, id: data.id } });
3725
+ });
3726
+ });
3727
+ break;
3728
+ case "NEWS":
3729
+ this._zone.run(() => {
3730
+ this.router.navigateByUrl('/home').then(() => {
3731
+ this.router.navigate([ContentTypePath.NewsDetail], { state: { data: data, id: data.id } });
3732
+ });
3733
+ });
3734
+ break;
3735
+ case "DIET":
3736
+ this._zone.run(() => {
3737
+ this.router.navigate([ContentTypePath.DietsDetail], { state: { data: data, id: data.id } });
3738
+ });
3739
+ break;
3740
+ case "AGENDA":
3741
+ this._zone.run(() => {
3742
+ this.router.navigate([ContentTypePath.AgendaDetail], { state: { data: data, id: data.id } });
3743
+ });
3744
+ break;
3745
+ case "REMINDER":
3746
+ this._zone.run(() => {
3747
+ this.router.navigate([ContentTypePath.ReminderDetail], { state: { data: data, id: data.id } });
3748
+ });
3749
+ break;
3750
+ case "GAME":
3751
+ this._zone.run(() => {
3752
+ if (data.type == 'form') {
3753
+ this.router.navigate([ContentTypePath.FormDetail, { id: data.form_id }], { state: { data: data, game_play_id: data?.game_play_id } });
3754
+ }
3755
+ else
3756
+ this.router.navigate([ContentTypePath.GamesDetail], { state: { data: data, id: data.id, server_url: data?.server_url } });
3757
+ });
3758
+ break;
3759
+ case "EXERCISE":
3760
+ this._zone.run(() => {
3761
+ this.router.navigate([ContentTypePath.Exercises], { state: { data: data, id: data.id, programable_id: data.programable_play_id } });
3762
+ });
3763
+ break;
3764
+ default:
3765
+ console.error('Action on localNotificationActionPerformed not found, redirecting to videocall: ');
3766
+ // this.redirecToVideocall(notification)
3767
+ break;
3768
+ }
3769
+ }
3770
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NotificationService, deps: [{ token: i1$2.MatSnackBar }, { token: i0.NgZone }, { token: i2.AlertController }, { token: i1$1.TranslateService }, { token: i2.ToastController }, { token: i0.NgZone }, { token: i2.Platform }, { token: i6.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
3771
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NotificationService, providedIn: 'root' }); }
3772
+ }
3773
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NotificationService, decorators: [{
3774
+ type: Injectable,
3775
+ args: [{
3776
+ providedIn: 'root'
3777
+ }]
3778
+ }], ctorParameters: () => [{ type: i1$2.MatSnackBar }, { type: i0.NgZone }, { type: i2.AlertController }, { type: i1$1.TranslateService }, { type: i2.ToastController }, { type: i0.NgZone }, { type: i2.Platform }, { type: i6.Router }] });
3779
+
3780
+ class NetworkService {
3781
+ constructor(network, platform) {
3782
+ this.network = network;
3783
+ this.platform = platform;
3784
+ this.online$ = undefined;
3785
+ this.online$ = new Observable(observer => {
3786
+ observer.next(true);
3787
+ }).pipe(mapTo(true));
3788
+ if (Capacitor.isNativePlatform()) {
3789
+ // on Device
3790
+ console.log('on Device');
3791
+ this.online$ = merge(this.network.onConnect().pipe(mapTo(true)), this.network.onDisconnect().pipe(mapTo(false)));
3792
+ }
3793
+ else {
3794
+ // on Browser
3795
+ console.log('on Browser');
3796
+ this.online$ = merge(of(navigator.onLine), fromEvent(window, 'online').pipe(mapTo(true)), fromEvent(window, 'offline').pipe(mapTo(false)));
3797
+ }
3798
+ }
3799
+ getNetworkType() {
3800
+ return this.network.type;
3801
+ }
3802
+ getNetworkStatus() {
3803
+ return this.online$;
3804
+ }
3805
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NetworkService, deps: [{ token: i1$3.Network }, { token: i2.Platform }], target: i0.ɵɵFactoryTarget.Injectable }); }
3806
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NetworkService, providedIn: 'root' }); }
3807
+ }
3808
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NetworkService, decorators: [{
3809
+ type: Injectable,
3810
+ args: [{
3811
+ providedIn: 'root'
3812
+ }]
3813
+ }], ctorParameters: () => [{ type: i1$3.Network }, { type: i2.Platform }] });
3814
+
3815
+ class LoadingService {
3816
+ constructor() {
3817
+ this.loadingSub = new BehaviorSubject(false);
3818
+ /**
3819
+ * Contains in-progress loading requests
3820
+ */
3821
+ this.loadingMap = new Map();
3822
+ }
3823
+ /**
3824
+ * Sets the loadingSub property value based on the following:
3825
+ * - If loading is true, add the provided url to the loadingMap with a true value, set loadingSub value to true
3826
+ * - If loading is false, remove the loadingMap entry and only when the map is empty will we set loadingSub to false
3827
+ * This pattern ensures if there are multiple requests awaiting completion, we don't set loading to false before
3828
+ * other requests have completed. At the moment, this function is only called from the @link{HttpRequestInterceptor}
3829
+ * @param loading {boolean}
3830
+ * @param url {string}
3831
+ */
3832
+ setLoading(loading, url) {
3833
+ if (!url) {
3834
+ throw new Error('The request URL must be provided to the LoadingService.setLoading function');
3835
+ }
3836
+ if (loading === true) {
3837
+ this.loadingMap.set(url, loading);
3838
+ this.loadingSub.next(true);
3839
+ }
3840
+ else if (loading === false && this.loadingMap.has(url)) {
3841
+ this.loadingMap.delete(url);
3842
+ }
3843
+ if (this.loadingMap.size === 0) {
3844
+ this.loadingSub.next(false);
3845
+ }
3846
+ }
3847
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LoadingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3848
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LoadingService, providedIn: 'root' }); }
3849
+ }
3850
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LoadingService, decorators: [{
3851
+ type: Injectable,
3852
+ args: [{
3853
+ providedIn: 'root'
3854
+ }]
3855
+ }], ctorParameters: () => [] });
3856
+
3857
+ class LoggingService {
3858
+ constructor(platform) {
3859
+ this.platform = platform;
3860
+ }
3861
+ logError(message) {
3862
+ // Send errors to be saved here
3863
+ if (Capacitor.isNativePlatform()) {
3864
+ console.error("Error log: ", message);
3865
+ }
3866
+ else {
3867
+ console.error("Error log: ", message);
3868
+ }
3869
+ return;
3870
+ }
3871
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LoggingService, deps: [{ token: i2.Platform }], target: i0.ɵɵFactoryTarget.Injectable }); }
3872
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LoggingService, providedIn: 'root' }); }
3873
+ }
3874
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: LoggingService, decorators: [{
3875
+ type: Injectable,
3876
+ args: [{
3877
+ providedIn: 'root'
3878
+ }]
3879
+ }], ctorParameters: () => [{ type: i2.Platform }] });
3880
+
3881
+ class ErrorService {
3882
+ constructor() { }
3883
+ getClientMessage(error) {
3884
+ if (error.constructor == Array) {
3885
+ return error.toString();
3886
+ }
3887
+ else if (error.constructor == Object) {
3888
+ return JSON.stringify(error);
3889
+ }
3890
+ else if (typeof error == 'object') {
3891
+ return error.message ? error.message : 'error';
3892
+ }
3893
+ else {
3894
+ return error;
3895
+ }
3896
+ }
3897
+ getClientStack(error) {
3898
+ return error.stack;
3899
+ }
3900
+ getServerMessage(error) {
3901
+ if (error.constructor == Array) {
3902
+ return error;
3903
+ }
3904
+ else if (error.constructor == Object) {
3905
+ return JSON.stringify(error);
3906
+ }
3907
+ else if (typeof error == 'object') {
3908
+ return error.message;
3909
+ }
3910
+ else {
3911
+ return error;
3912
+ }
3913
+ }
3914
+ getServerStack(error) {
3915
+ // handle stack trace
3916
+ return 'stack';
3917
+ }
3918
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3919
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ErrorService, providedIn: 'root' }); }
3920
+ }
3921
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: ErrorService, decorators: [{
3922
+ type: Injectable,
3923
+ args: [{
3924
+ providedIn: 'root'
3925
+ }]
3926
+ }], ctorParameters: () => [] });
3927
+
3928
+ class OpentokService {
3929
+ constructor() {
3930
+ this.callEventSubject = new Subject();
3931
+ this.callEvent$ = this.callEventSubject.asObservable();
3932
+ CallCapacitor.addListener('disconnected-call', () => {
3933
+ this.emitCallEvent({ type: "hangup" });
3934
+ });
3935
+ }
3936
+ emitCallEvent(data) {
3937
+ this.callEventSubject.next(data);
3938
+ }
3939
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: OpentokService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3940
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: OpentokService, providedIn: 'root' }); }
3941
+ }
3942
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: OpentokService, decorators: [{
3943
+ type: Injectable,
3944
+ args: [{
3945
+ providedIn: 'root'
3946
+ }]
3947
+ }], ctorParameters: () => [] });
3948
+
3949
+ class AnalyticsService {
3950
+ constructor(environment, platform) {
3951
+ this.environment = environment;
3952
+ this.platform = platform;
3953
+ this.analyticsEnabled = true;
3954
+ this.initFb();
3955
+ }
3956
+ async initFb() {
3957
+ if (this.platform.is('mobileweb')) {
3958
+ console.log("initializeFirebase: ", this.environment.firebase);
3959
+ await FirebaseAnalytics.initializeFirebase(this.environment.firebase);
3960
+ }
3961
+ this.toggleAnalytics();
3962
+ }
3963
+ setUserId(userId) {
3964
+ const setUserId = async () => {
3965
+ await FirebaseAnalytics.setUserId({
3966
+ userId: userId,
3967
+ });
3968
+ };
3969
+ return setUserId;
3970
+ }
3971
+ setProperty(property, value) {
3972
+ const setUserProperty = async () => {
3973
+ await FirebaseAnalytics.setUserProperty({
3974
+ name: property,
3975
+ value: value,
3976
+ });
3977
+ };
3978
+ return setUserProperty;
3979
+ }
3980
+ logEvent(name, params) {
3981
+ const logEvent = async () => {
3982
+ await FirebaseAnalytics.logEvent({
3983
+ name: name,
3984
+ params: params
3985
+ });
3986
+ };
3987
+ return logEvent;
3988
+ }
3989
+ async setScreenName(screenName, nameOverride) {
3990
+ await FirebaseAnalytics.setScreenName({
3991
+ screenName: screenName,
3992
+ nameOverride: nameOverride,
3993
+ });
3994
+ }
3995
+ async toggleAnalytics() {
3996
+ const setCollectionEnabled = async () => {
3997
+ await FirebaseAnalytics.setCollectionEnabled({
3998
+ enabled: this.analyticsEnabled,
3999
+ });
4000
+ };
4001
+ return setCollectionEnabled;
4002
+ }
4003
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: AnalyticsService, deps: [{ token: FIREBASE_CONFIG_TOKEN }, { token: i2.Platform }], target: i0.ɵɵFactoryTarget.Injectable }); }
4004
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: AnalyticsService, providedIn: 'root' }); }
4005
+ }
4006
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: AnalyticsService, decorators: [{
4007
+ type: Injectable,
4008
+ args: [{
4009
+ providedIn: 'root'
4010
+ }]
4011
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4012
+ type: Inject,
4013
+ args: [FIREBASE_CONFIG_TOKEN]
4014
+ }] }, { type: i2.Platform }] });
4015
+
4016
+ /*
4017
+ * Public API Surface of service-lib
4018
+ */
4019
+
4020
+ /**
4021
+ * Generated bundle index. Do not edit.
4022
+ */
4023
+
4024
+ export { AnalyticsService, ApiEndpointsService, AuthenticationService, ChangeEndpointsService, ComponentsApp, DateService, DooleService, EncryptionService, ErrorService, Events, HighchartsService, HttpService, LanguageService, LoadingService, LoggingService, NavigationService, NetworkService, NotificationService, OpentokService, RolesService, ServiceLibComponent, ServiceLibModule, StorageService, TokenService, User, _INDEX_ENPOINT };
4025
+ //# sourceMappingURL=doolehealth-service-lib.mjs.map