@phenyxhealth/sdk 1.0.4 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -8
- package/package.json +1 -1
- package/src/PhenyxApi.js +16 -0
- package/src/controllers/doctors.js +1 -1
- package/src/controllers/global.js +2 -2
- package/src/controllers/linacs.js +1 -1
- package/src/index.js +3 -3
- package/types/index.d.ts +20 -8
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@ npm install @phenyxhealth/sdk
|
|
|
14
14
|
## Inicio Rápido
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
|
-
import {
|
|
17
|
+
import { PhenyxSDK } from "@phenyxhealth/sdk";
|
|
18
18
|
|
|
19
|
-
const api = new
|
|
19
|
+
const api = new PhenyxSDK();
|
|
20
20
|
|
|
21
21
|
// Autenticación
|
|
22
22
|
await api.login({
|
|
@@ -238,6 +238,19 @@ import { getContrastingColor } from "@phenyxhealth/sdk";
|
|
|
238
238
|
const color = getContrastingColor(); // '244, 67, 54' (formato RGB)
|
|
239
239
|
```
|
|
240
240
|
|
|
241
|
+
### Obtener IDs de Elementos Globales
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
// Obtener ID de departamento emisor
|
|
245
|
+
const deptId = api.getSendingDepartmentIdByName("Oncología");
|
|
246
|
+
|
|
247
|
+
// Obtener ID de código CEI9
|
|
248
|
+
const cei9Id = api.getCei9IdByName("C78.9");
|
|
249
|
+
|
|
250
|
+
// Obtener ID de código CEI10
|
|
251
|
+
const cei10Id = api.getCei10IdByName("C78.9");
|
|
252
|
+
```
|
|
253
|
+
|
|
241
254
|
## Funciones de Validación
|
|
242
255
|
|
|
243
256
|
### Validar Médicos
|
|
@@ -287,14 +300,14 @@ const token = api.getToken(); // Obtiene el token JWT actual
|
|
|
287
300
|
|
|
288
301
|
```javascript
|
|
289
302
|
import {
|
|
290
|
-
|
|
303
|
+
PhenyxSDK,
|
|
291
304
|
beSureDoctorExists,
|
|
292
305
|
beSureLinacsExists,
|
|
293
306
|
checkGlobals,
|
|
294
307
|
} from "@phenyxhealth/sdk";
|
|
295
308
|
|
|
296
309
|
const setupClinic = async () => {
|
|
297
|
-
const api = new
|
|
310
|
+
const api = new PhenyxSDK();
|
|
298
311
|
|
|
299
312
|
// Autenticación
|
|
300
313
|
await api.login({
|
|
@@ -328,10 +341,10 @@ setupClinic();
|
|
|
328
341
|
### Ejemplo 2: Crear y Procesar Paciente
|
|
329
342
|
|
|
330
343
|
```javascript
|
|
331
|
-
import {
|
|
344
|
+
import { PhenyxSDK, today } from "@phenyxhealth/sdk";
|
|
332
345
|
|
|
333
346
|
const processPatient = async () => {
|
|
334
|
-
const api = new
|
|
347
|
+
const api = new PhenyxSDK();
|
|
335
348
|
await api.login({
|
|
336
349
|
/* credentials */
|
|
337
350
|
});
|
|
@@ -342,6 +355,7 @@ const processPatient = async () => {
|
|
|
342
355
|
birthDate: "1980-01-15",
|
|
343
356
|
sendingDepartmentId: api.getSendingDepartmentIdByName("Oncología"),
|
|
344
357
|
cei9Id: api.getCei9IdByName("C78.9"),
|
|
358
|
+
cei10Id: api.getCei10IdByName("C78.9"),
|
|
345
359
|
});
|
|
346
360
|
|
|
347
361
|
// Cambiar estado del paciente
|
|
@@ -372,6 +386,13 @@ try {
|
|
|
372
386
|
} catch (error) {
|
|
373
387
|
console.error("Departamento no encontrado:", error.message);
|
|
374
388
|
}
|
|
389
|
+
|
|
390
|
+
try {
|
|
391
|
+
const cei9Id = api.getCei9IdByName("C00.0");
|
|
392
|
+
const cei10Id = api.getCei10IdByName("C00.0");
|
|
393
|
+
} catch (error) {
|
|
394
|
+
console.error("Código CEI no encontrado:", error.message);
|
|
395
|
+
}
|
|
375
396
|
```
|
|
376
397
|
|
|
377
398
|
## TypeScript Support
|
|
@@ -379,9 +400,9 @@ try {
|
|
|
379
400
|
El SDK incluye definiciones TypeScript completas:
|
|
380
401
|
|
|
381
402
|
```typescript
|
|
382
|
-
import {
|
|
403
|
+
import { PhenyxSDK, PatientData, HumanResourceData } from "@phenyxhealth/sdk";
|
|
383
404
|
|
|
384
|
-
const api:
|
|
405
|
+
const api: PhenyxSDK = new PhenyxSDK();
|
|
385
406
|
|
|
386
407
|
const patient: PatientData = await api.getPatient("id");
|
|
387
408
|
const doctors: HumanResourceData[] = await api.getHumanResources();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phenyxhealth/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "SDK oficial para PhenyxHealth - Sistema integral de gestión de radioterapia. Incluye gestión de pacientes, recursos humanos, equipos médicos y configuración global.",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/PhenyxApi.js
CHANGED
|
@@ -435,6 +435,22 @@ class PhenyxApi {
|
|
|
435
435
|
return cei9.id;
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Obtiene el ID de un CEI10 por nombre
|
|
440
|
+
* @param {string} name - Nombre del CEI10
|
|
441
|
+
* @returns {string} ID del CEI10
|
|
442
|
+
* @throws {Error} Si no se encuentra el CEI10
|
|
443
|
+
* @example
|
|
444
|
+
* const cei10Id = api.getCei10IdByName('C78.9');
|
|
445
|
+
*/
|
|
446
|
+
getCei10IdByName = (name) => {
|
|
447
|
+
const cei10 = this.getGlobalInfoElement(this.globalTypes.cei10, name);
|
|
448
|
+
if (!cei10) {
|
|
449
|
+
throw new Error(`CEI10 ${name} not found`);
|
|
450
|
+
}
|
|
451
|
+
return cei10.id;
|
|
452
|
+
}
|
|
453
|
+
|
|
438
454
|
/**
|
|
439
455
|
* Crea un nuevo paciente
|
|
440
456
|
* @param {Object} data - Datos del paciente
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Valida que los médicos especificados existan en el sistema
|
|
3
3
|
* Si no existen, los crea automáticamente
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {PhenyxSDK} apiInstance - Instancia autenticada de PhenyxSDK
|
|
5
5
|
* @param {Array} toBe - Array de objetos médico con {name, hrGroup}
|
|
6
6
|
* @param {string} toBe[].name - Nombre del médico
|
|
7
7
|
* @param {string} toBe[].hrGroup - Grupo de recursos humanos ('RadOnc' o 'MedPhys')
|
|
@@ -3,7 +3,7 @@ import { getContrastingColor } from '../utils/colors.js';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Valida que los valores globales especificados existan en el sistema
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {PhenyxSDK} apiInstance - Instancia autenticada de PhenyxSDK
|
|
7
7
|
* @param {Object} mustBe - Configuración global requerida
|
|
8
8
|
* @param {string} mustBe.name - Nombre del tipo global
|
|
9
9
|
* @param {Object} [mustBe.values={}] - Valores que deben existir
|
|
@@ -43,7 +43,7 @@ const checkGlobals = async (apiInstance, mustBe, extraValues = []) => {
|
|
|
43
43
|
/**
|
|
44
44
|
* Asegura que elementos específicos existan en una lista global
|
|
45
45
|
* Si no existen, los crea automáticamente
|
|
46
|
-
* @param {
|
|
46
|
+
* @param {PhenyxSDK} apiInstance - Instancia autenticada de PhenyxSDK
|
|
47
47
|
* @param {Object} currentList - Lista global actual
|
|
48
48
|
* @param {string} currentList.id - ID de la lista global
|
|
49
49
|
* @param {string} currentList.name - Nombre de la lista global
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Valida que los LINACs especificados existan en el sistema
|
|
3
3
|
* Si no existen, los crea automáticamente
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {PhenyxSDK} apiInstance - Instancia autenticada de PhenyxSDK
|
|
5
5
|
* @param {Array<string>} toBe - Array con nombres de LINACs que deben existir
|
|
6
6
|
* @returns {Promise<Array>} Lista actualizada de LINACs
|
|
7
7
|
* @example
|
package/src/index.js
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* // Importar las funciones principales
|
|
13
|
-
* import {
|
|
13
|
+
* import { PhenyxSDK, beSureDoctorExists, today } from '@phenyxhealth/sdk';
|
|
14
14
|
*
|
|
15
15
|
* // Crear instancia y autenticar
|
|
16
|
-
* const api = new
|
|
16
|
+
* const api = new PhenyxSDK();
|
|
17
17
|
* await api.login({
|
|
18
18
|
* apiHost: 'https://demo.phenyxhealth.com',
|
|
19
19
|
* user: 'admin',
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
// Exportaciones principales
|
|
30
|
-
export { default as
|
|
30
|
+
export { default as PhenyxSDK } from './PhenyxApi.js';
|
|
31
31
|
|
|
32
32
|
// Controladores de validación
|
|
33
33
|
export { checkGlobals, beSureGlobalExists } from './controllers/global.js';
|
package/types/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ declare module "@phenyxhealth/sdk" {
|
|
|
37
37
|
birthDate: string;
|
|
38
38
|
sendingDepartmentId?: string;
|
|
39
39
|
cei9Id?: string;
|
|
40
|
+
cei10Id?: string;
|
|
40
41
|
[key: string]: any;
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -127,6 +128,7 @@ declare module "@phenyxhealth/sdk" {
|
|
|
127
128
|
birthDate: string;
|
|
128
129
|
sendingDepartmentId?: string;
|
|
129
130
|
cei9Id?: string;
|
|
131
|
+
cei10Id?: string;
|
|
130
132
|
[key: string]: any;
|
|
131
133
|
}
|
|
132
134
|
|
|
@@ -219,6 +221,7 @@ declare module "@phenyxhealth/sdk" {
|
|
|
219
221
|
humanResources: GlobalType;
|
|
220
222
|
sendingDepartment: GlobalType;
|
|
221
223
|
cei9: GlobalType;
|
|
224
|
+
cei10: GlobalType;
|
|
222
225
|
treatmentClass: GlobalType;
|
|
223
226
|
treatmentSubClass: GlobalType;
|
|
224
227
|
treatmentTechnique: GlobalType;
|
|
@@ -413,6 +416,14 @@ declare module "@phenyxhealth/sdk" {
|
|
|
413
416
|
*/
|
|
414
417
|
getCei9IdByName(name: string): string;
|
|
415
418
|
|
|
419
|
+
/**
|
|
420
|
+
* Obtiene el ID de un CEI10 por nombre
|
|
421
|
+
* @param name Nombre del CEI10
|
|
422
|
+
* @returns ID del CEI10
|
|
423
|
+
* @throws Error si no se encuentra el CEI10
|
|
424
|
+
*/
|
|
425
|
+
getCei10IdByName(name: string): string;
|
|
426
|
+
|
|
416
427
|
/**
|
|
417
428
|
* Obtiene el estado de peer review formateado
|
|
418
429
|
* @param status Estado a formatear
|
|
@@ -483,54 +494,55 @@ declare module "@phenyxhealth/sdk" {
|
|
|
483
494
|
|
|
484
495
|
/**
|
|
485
496
|
* Valida que los médicos existan en el sistema, los crea si no existen
|
|
486
|
-
* @param apiInstance Instancia de
|
|
497
|
+
* @param apiInstance Instancia de PhenyxSDK autenticada
|
|
487
498
|
* @param toBe Array de médicos a validar
|
|
488
499
|
* @returns Promise con array de recursos humanos actualizados
|
|
489
500
|
*/
|
|
490
501
|
export function beSureDoctorExists(
|
|
491
|
-
apiInstance:
|
|
502
|
+
apiInstance: PhenyxSDK,
|
|
492
503
|
toBe: DoctorValidation[],
|
|
493
504
|
): Promise<HumanResourceData[]>;
|
|
494
505
|
|
|
495
506
|
/**
|
|
496
507
|
* Valida que los LINACs existan en el sistema, los crea si no existen
|
|
497
|
-
* @param apiInstance Instancia de
|
|
508
|
+
* @param apiInstance Instancia de PhenyxSDK autenticada
|
|
498
509
|
* @param toBe Array de nombres de LINACs
|
|
499
510
|
* @returns Promise con array de LINACs actualizados
|
|
500
511
|
*/
|
|
501
512
|
export function beSureLinacsExists(
|
|
502
|
-
apiInstance:
|
|
513
|
+
apiInstance: PhenyxSDK,
|
|
503
514
|
toBe: string[],
|
|
504
515
|
): Promise<ResourceData[]>;
|
|
505
516
|
|
|
506
517
|
/**
|
|
507
518
|
* Valida información global, añade valores faltantes
|
|
508
|
-
* @param apiInstance Instancia de
|
|
519
|
+
* @param apiInstance Instancia de PhenyxSDK autenticada
|
|
509
520
|
* @param mustBe Configuración global requerida
|
|
510
521
|
* @param extraValues Valores adicionales opcionales
|
|
511
522
|
* @returns Promise que resuelve cuando se valida
|
|
512
523
|
*/
|
|
513
524
|
export function checkGlobals(
|
|
514
|
-
apiInstance:
|
|
525
|
+
apiInstance: PhenyxSDK,
|
|
515
526
|
mustBe: GlobalType,
|
|
516
527
|
extraValues?: string[],
|
|
517
528
|
): Promise<void>;
|
|
518
529
|
|
|
519
530
|
/**
|
|
520
531
|
* Asegura que elementos globales existan
|
|
521
|
-
* @param apiInstance Instancia de
|
|
532
|
+
* @param apiInstance Instancia de PhenyxSDK autenticada
|
|
522
533
|
* @param currentList Lista actual de elementos
|
|
523
534
|
* @param toBeList Lista de elementos que deben existir
|
|
524
535
|
* @returns Promise que resuelve cuando se valida
|
|
525
536
|
*/
|
|
526
537
|
export function beSureGlobalExists(
|
|
527
|
-
apiInstance:
|
|
538
|
+
apiInstance: PhenyxSDK,
|
|
528
539
|
currentList: GlobalInfo,
|
|
529
540
|
toBeList: string[],
|
|
530
541
|
): Promise<void>;
|
|
531
542
|
|
|
532
543
|
// ==================== EXPORT DEFAULT ====================
|
|
533
544
|
|
|
545
|
+
export { PhenyxApi as PhenyxSDK };
|
|
534
546
|
export default PhenyxApi;
|
|
535
547
|
}
|
|
536
548
|
|