@phenyxhealth/sdk 1.1.0 → 1.1.3
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/.claude/phenyx-sdk.md +3 -7
- package/README.md +5 -7
- package/package.json +1 -1
- package/src/PhenyxApi.js +23 -19
- package/types/index.d.ts +9 -9
package/.claude/phenyx-sdk.md
CHANGED
|
@@ -88,7 +88,7 @@ await api.retrieveOars(): Promise<any[]>
|
|
|
88
88
|
api.getGlobalInfo(globalType: GlobalType): GlobalInfo | undefined
|
|
89
89
|
|
|
90
90
|
// Obtener elemento especifico de info global
|
|
91
|
-
api.getGlobalInfoElement(globalType: GlobalType, elementName: string): GlobalInfoElement | undefined
|
|
91
|
+
api.getGlobalInfoElement(globalType: GlobalType, field: string, elementName: string): GlobalInfoElement | undefined
|
|
92
92
|
|
|
93
93
|
// Obtener ID de elemento global por nombre
|
|
94
94
|
api.getGlobalInfoElementId(globalType: GlobalType, elementName: string): string | null
|
|
@@ -156,8 +156,8 @@ await api.createResource({ name, author?, typeId, agenda }): Promise<void>
|
|
|
156
156
|
|
|
157
157
|
```typescript
|
|
158
158
|
api.getSendingDepartmentIdByName(name: string): string // throws si no existe
|
|
159
|
-
api.getCei9IdByName(name: string): string // throws si no existe
|
|
160
159
|
api.getCie10IdByName(name: string): string // throws si no existe
|
|
160
|
+
api.getCie10ByCode(code: string): GlobalInfoElement // throws si no existe
|
|
161
161
|
api.getCie10CodeExists(name: string): boolean
|
|
162
162
|
api.getElementIdByName(type: string, name: string): string | null
|
|
163
163
|
```
|
|
@@ -180,7 +180,6 @@ await api.updateSectionQaStatus(qa: any, formDataId: string): Promise<void>
|
|
|
180
180
|
```javascript
|
|
181
181
|
api.globalTypes.humanResources
|
|
182
182
|
api.globalTypes.sendingDepartment
|
|
183
|
-
api.globalTypes.cei9 // Codigos CEI-9
|
|
184
183
|
api.globalTypes.cie10 // Codigos CIE-10
|
|
185
184
|
api.globalTypes.treatmentClass
|
|
186
185
|
api.globalTypes.treatmentSubClass
|
|
@@ -285,7 +284,6 @@ interface PatientData {
|
|
|
285
284
|
name: string;
|
|
286
285
|
birthDate: string;
|
|
287
286
|
sendingDepartmentId?: string;
|
|
288
|
-
cei9Id?: string;
|
|
289
287
|
cie10Id?: string;
|
|
290
288
|
[key: string]: any;
|
|
291
289
|
}
|
|
@@ -294,7 +292,6 @@ interface CreatePatientData {
|
|
|
294
292
|
name: string;
|
|
295
293
|
birthDate: string;
|
|
296
294
|
sendingDepartmentId?: string;
|
|
297
|
-
cei9Id?: string;
|
|
298
295
|
cie10Id?: string;
|
|
299
296
|
[key: string]: any;
|
|
300
297
|
}
|
|
@@ -377,7 +374,6 @@ const patientId = await api.createPatient({
|
|
|
377
374
|
name: 'Juan Perez',
|
|
378
375
|
birthDate: '1975-03-15',
|
|
379
376
|
sendingDepartmentId: api.getSendingDepartmentIdByName('Oncologia'),
|
|
380
|
-
cei9Id: api.getCei9IdByName('C78.9'),
|
|
381
377
|
cie10Id: api.getCie10IdByName('C78.9'),
|
|
382
378
|
});
|
|
383
379
|
|
|
@@ -473,7 +469,7 @@ for (const status of [
|
|
|
473
469
|
- `PhenyxSDK` es un alias de `PhenyxApi` (se exporta como default y como named export `PhenyxSDK`)
|
|
474
470
|
- `login()` inicializa automaticamente: `globalInfo`, `activeTables`, `doctors`, `defaultDuration`, `defaultCompatibleLinacs`, y `oars`
|
|
475
471
|
- Los metodos `get*ByName` buscan en los datos ya cargados en memoria (no hacen llamadas HTTP)
|
|
476
|
-
- Los metodos `getSendingDepartmentIdByName`, `
|
|
472
|
+
- Los metodos `getSendingDepartmentIdByName`, `getCie10IdByName`, `getCie10ByCode` lanzan Error si no encuentran el elemento
|
|
477
473
|
- `getContrastingColor()` y `newId()` son metodos estaticos - se usan sin instancia: `PhenyxSDK.newId()`
|
|
478
474
|
- **IDs en GlobalInfo**: Al hacer `push` de un elemento nuevo a `globalInfo.elements`, debes enviar un `id` (el servidor da error si no lo envias), pero el servidor lo ignora y asigna su propio ID. Siempre haz `getGlobalInfo()` despues de `updateGlobalInfo()` si necesitas referenciar los elementos creados
|
|
479
475
|
- Las funciones de validacion (`beSureDoctorExists`, `beSureLinacsExists`, `checkGlobals`) crean automaticamente los recursos que no existan
|
package/README.md
CHANGED
|
@@ -244,11 +244,11 @@ const color = getContrastingColor(); // '244, 67, 54' (formato RGB)
|
|
|
244
244
|
// Obtener ID de departamento emisor
|
|
245
245
|
const deptId = api.getSendingDepartmentIdByName("Oncología");
|
|
246
246
|
|
|
247
|
-
// Obtener ID de código
|
|
248
|
-
const
|
|
247
|
+
// Obtener ID de código CIE10 por nombre
|
|
248
|
+
const cie10Id = api.getCie10IdByName("Neoplasia maligna");
|
|
249
249
|
|
|
250
|
-
// Obtener
|
|
251
|
-
const
|
|
250
|
+
// Obtener elemento CIE10 por código
|
|
251
|
+
const cie10 = api.getCie10ByCode("C78.9");
|
|
252
252
|
```
|
|
253
253
|
|
|
254
254
|
## Funciones de Validación
|
|
@@ -354,7 +354,6 @@ const processPatient = async () => {
|
|
|
354
354
|
name: "Juan Pérez",
|
|
355
355
|
birthDate: "1980-01-15",
|
|
356
356
|
sendingDepartmentId: api.getSendingDepartmentIdByName("Oncología"),
|
|
357
|
-
cei9Id: api.getCei9IdByName("C78.9"),
|
|
358
357
|
cie10Id: api.getCie10IdByName("C78.9"),
|
|
359
358
|
});
|
|
360
359
|
|
|
@@ -388,10 +387,9 @@ try {
|
|
|
388
387
|
}
|
|
389
388
|
|
|
390
389
|
try {
|
|
391
|
-
const cei9Id = api.getCei9IdByName("C00.0");
|
|
392
390
|
const cie10Id = api.getCie10IdByName("C00.0");
|
|
393
391
|
} catch (error) {
|
|
394
|
-
console.error("Código
|
|
392
|
+
console.error("Código CIE10 no encontrado:", error.message);
|
|
395
393
|
}
|
|
396
394
|
```
|
|
397
395
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phenyxhealth/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
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
|
@@ -62,10 +62,6 @@ class PhenyxApi {
|
|
|
62
62
|
type: 'Global',
|
|
63
63
|
name: 'Sending Department',
|
|
64
64
|
},
|
|
65
|
-
cei9: {
|
|
66
|
-
type: 'Global',
|
|
67
|
-
name: 'CEI9',
|
|
68
|
-
},
|
|
69
65
|
cie10: {
|
|
70
66
|
type: 'Global',
|
|
71
67
|
name: 'CIE10',
|
|
@@ -336,16 +332,16 @@ class PhenyxApi {
|
|
|
336
332
|
?.find(item => item.name === globalType.name);
|
|
337
333
|
}
|
|
338
334
|
|
|
339
|
-
getGlobalInfoElement = (globalType, elementName) => {
|
|
335
|
+
getGlobalInfoElement = (globalType, field, elementName) => {
|
|
340
336
|
return this.getGlobalInfo(globalType)
|
|
341
337
|
?.elements
|
|
342
|
-
?.find(item => item
|
|
338
|
+
?.find(item => item[field]?.toLowerCase() === elementName.toLowerCase());
|
|
343
339
|
}
|
|
344
340
|
|
|
345
341
|
getGlobalInfoElementId = (globalType, elementName) => {
|
|
346
342
|
if (!elementName) return null;
|
|
347
343
|
|
|
348
|
-
return this.getGlobalInfoElement(globalType, elementName)?.id;
|
|
344
|
+
return this.getGlobalInfoElement(globalType, 'name', elementName)?.id;
|
|
349
345
|
}
|
|
350
346
|
|
|
351
347
|
/**
|
|
@@ -421,21 +417,13 @@ class PhenyxApi {
|
|
|
421
417
|
}
|
|
422
418
|
|
|
423
419
|
getSendingDepartmentIdByName = (name) => {
|
|
424
|
-
const sendingDepartment = this.getGlobalInfoElement(this.globalTypes.sendingDepartment, name);
|
|
420
|
+
const sendingDepartment = this.getGlobalInfoElement(this.globalTypes.sendingDepartment, 'name', name);
|
|
425
421
|
if (!sendingDepartment) {
|
|
426
422
|
throw new Error(`Sending Department ${name} not found`);
|
|
427
423
|
}
|
|
428
424
|
return sendingDepartment.id;
|
|
429
425
|
}
|
|
430
426
|
|
|
431
|
-
getCei9IdByName = (name) => {
|
|
432
|
-
const cei9 = this.getGlobalInfoElement(this.globalTypes.cei9, name);
|
|
433
|
-
if (!cei9) {
|
|
434
|
-
throw new Error(`CEI9 ${name} not found`);
|
|
435
|
-
}
|
|
436
|
-
return cei9.id;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
427
|
/**
|
|
440
428
|
* Obtiene el ID de un CIE10 por nombre
|
|
441
429
|
* @param {string} name - Nombre del CIE10
|
|
@@ -445,15 +433,31 @@ class PhenyxApi {
|
|
|
445
433
|
* const cie10Id = api.getCie10IdByName('C78.9');
|
|
446
434
|
*/
|
|
447
435
|
getCie10IdByName = (name) => {
|
|
448
|
-
const cie10 = this.getGlobalInfoElement(this.globalTypes.cie10, name);
|
|
436
|
+
const cie10 = this.getGlobalInfoElement(this.globalTypes.cie10, 'name', name);
|
|
449
437
|
if (!cie10) {
|
|
450
438
|
throw new Error(`CIE10 ${name} not found`);
|
|
451
439
|
}
|
|
452
440
|
return cie10.id;
|
|
453
441
|
}
|
|
454
442
|
|
|
455
|
-
|
|
456
|
-
|
|
443
|
+
/**
|
|
444
|
+
* Obtiene un elemento CIE10 por su código
|
|
445
|
+
* @param {string} code - Código CIE10 (ej: 'C78.9')
|
|
446
|
+
* @returns {Object} Elemento CIE10
|
|
447
|
+
* @throws {Error} Si no se encuentra el código
|
|
448
|
+
* @example
|
|
449
|
+
* const cie10 = api.getCie10ByCode('C78.9');
|
|
450
|
+
*/
|
|
451
|
+
getCie10ByCode = (code) => {
|
|
452
|
+
const cie10 = this.getGlobalInfoElement(this.globalTypes.cie10, 'code', code);
|
|
453
|
+
if (!cie10) {
|
|
454
|
+
throw new Error(`CIE10 code ${code} not found`);
|
|
455
|
+
}
|
|
456
|
+
return cie10;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
getCie10CodeExists = (code) => {
|
|
460
|
+
return !!this.getGlobalInfoElement(this.globalTypes.cie10, 'code', code);
|
|
457
461
|
}
|
|
458
462
|
|
|
459
463
|
/**
|
package/types/index.d.ts
CHANGED
|
@@ -36,7 +36,6 @@ declare module "@phenyxhealth/sdk" {
|
|
|
36
36
|
name: string;
|
|
37
37
|
birthDate: string;
|
|
38
38
|
sendingDepartmentId?: string;
|
|
39
|
-
cei9Id?: string;
|
|
40
39
|
cie10Id?: string;
|
|
41
40
|
[key: string]: any;
|
|
42
41
|
}
|
|
@@ -90,6 +89,7 @@ declare module "@phenyxhealth/sdk" {
|
|
|
90
89
|
export interface GlobalInfoElement {
|
|
91
90
|
id: string;
|
|
92
91
|
name: string;
|
|
92
|
+
code?: string;
|
|
93
93
|
color: string;
|
|
94
94
|
createdAt: string;
|
|
95
95
|
updatedAt: string;
|
|
@@ -127,7 +127,6 @@ declare module "@phenyxhealth/sdk" {
|
|
|
127
127
|
name: string;
|
|
128
128
|
birthDate: string;
|
|
129
129
|
sendingDepartmentId?: string;
|
|
130
|
-
cei9Id?: string;
|
|
131
130
|
cie10Id?: string;
|
|
132
131
|
[key: string]: any;
|
|
133
132
|
}
|
|
@@ -220,7 +219,6 @@ declare module "@phenyxhealth/sdk" {
|
|
|
220
219
|
globalTypes: {
|
|
221
220
|
humanResources: GlobalType;
|
|
222
221
|
sendingDepartment: GlobalType;
|
|
223
|
-
cei9: GlobalType;
|
|
224
222
|
cie10: GlobalType;
|
|
225
223
|
treatmentClass: GlobalType;
|
|
226
224
|
treatmentSubClass: GlobalType;
|
|
@@ -278,11 +276,13 @@ declare module "@phenyxhealth/sdk" {
|
|
|
278
276
|
/**
|
|
279
277
|
* Obtiene un elemento específico de información global
|
|
280
278
|
* @param globalType Tipo global
|
|
281
|
-
* @param
|
|
279
|
+
* @param field Campo por el que buscar (ej: 'name', 'code')
|
|
280
|
+
* @param elementName Valor a buscar en el campo indicado
|
|
282
281
|
* @returns Elemento global o undefined
|
|
283
282
|
*/
|
|
284
283
|
getGlobalInfoElement(
|
|
285
284
|
globalType: GlobalType,
|
|
285
|
+
field: string,
|
|
286
286
|
elementName: string,
|
|
287
287
|
): GlobalInfoElement | undefined;
|
|
288
288
|
|
|
@@ -417,12 +417,12 @@ declare module "@phenyxhealth/sdk" {
|
|
|
417
417
|
getCie10IdByName(name: string): string;
|
|
418
418
|
|
|
419
419
|
/**
|
|
420
|
-
* Obtiene
|
|
421
|
-
* @param
|
|
422
|
-
* @returns
|
|
423
|
-
* @throws Error si no se encuentra el
|
|
420
|
+
* Obtiene un elemento CIE10 por su código
|
|
421
|
+
* @param code Código CIE10 (ej: 'C78.9')
|
|
422
|
+
* @returns Elemento CIE10
|
|
423
|
+
* @throws Error si no se encuentra el código
|
|
424
424
|
*/
|
|
425
|
-
|
|
425
|
+
getCie10ByCode(code: string): GlobalInfoElement;
|
|
426
426
|
|
|
427
427
|
/**
|
|
428
428
|
* Obtiene el estado de peer review formateado
|