@phenyxhealth/sdk 1.1.2 → 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 -3
- package/README.md +5 -2
- package/package.json +1 -1
- package/src/PhenyxApi.js +23 -7
- package/types/index.d.ts +12 -1
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
|
```
|
|
@@ -469,7 +469,7 @@ for (const status of [
|
|
|
469
469
|
- `PhenyxSDK` es un alias de `PhenyxApi` (se exporta como default y como named export `PhenyxSDK`)
|
|
470
470
|
- `login()` inicializa automaticamente: `globalInfo`, `activeTables`, `doctors`, `defaultDuration`, `defaultCompatibleLinacs`, y `oars`
|
|
471
471
|
- Los metodos `get*ByName` buscan en los datos ya cargados en memoria (no hacen llamadas HTTP)
|
|
472
|
-
- Los metodos `getSendingDepartmentIdByName`, `
|
|
472
|
+
- Los metodos `getSendingDepartmentIdByName`, `getCie10IdByName`, `getCie10ByCode` lanzan Error si no encuentran el elemento
|
|
473
473
|
- `getContrastingColor()` y `newId()` son metodos estaticos - se usan sin instancia: `PhenyxSDK.newId()`
|
|
474
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
|
|
475
475
|
- Las funciones de validacion (`beSureDoctorExists`, `beSureLinacsExists`, `checkGlobals`) crean automaticamente los recursos que no existan
|
package/README.md
CHANGED
|
@@ -244,8 +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 CIE10
|
|
248
|
-
const cie10Id = api.getCie10IdByName("
|
|
247
|
+
// Obtener ID de código CIE10 por nombre
|
|
248
|
+
const cie10Id = api.getCie10IdByName("Neoplasia maligna");
|
|
249
|
+
|
|
250
|
+
// Obtener elemento CIE10 por código
|
|
251
|
+
const cie10 = api.getCie10ByCode("C78.9");
|
|
249
252
|
```
|
|
250
253
|
|
|
251
254
|
## Funciones de Validación
|
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
|
@@ -332,16 +332,16 @@ class PhenyxApi {
|
|
|
332
332
|
?.find(item => item.name === globalType.name);
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
getGlobalInfoElement = (globalType, elementName) => {
|
|
335
|
+
getGlobalInfoElement = (globalType, field, elementName) => {
|
|
336
336
|
return this.getGlobalInfo(globalType)
|
|
337
337
|
?.elements
|
|
338
|
-
?.find(item => item
|
|
338
|
+
?.find(item => item[field]?.toLowerCase() === elementName.toLowerCase());
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
getGlobalInfoElementId = (globalType, elementName) => {
|
|
342
342
|
if (!elementName) return null;
|
|
343
343
|
|
|
344
|
-
return this.getGlobalInfoElement(globalType, elementName)?.id;
|
|
344
|
+
return this.getGlobalInfoElement(globalType, 'name', elementName)?.id;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
/**
|
|
@@ -417,7 +417,7 @@ class PhenyxApi {
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
getSendingDepartmentIdByName = (name) => {
|
|
420
|
-
const sendingDepartment = this.getGlobalInfoElement(this.globalTypes.sendingDepartment, name);
|
|
420
|
+
const sendingDepartment = this.getGlobalInfoElement(this.globalTypes.sendingDepartment, 'name', name);
|
|
421
421
|
if (!sendingDepartment) {
|
|
422
422
|
throw new Error(`Sending Department ${name} not found`);
|
|
423
423
|
}
|
|
@@ -433,15 +433,31 @@ class PhenyxApi {
|
|
|
433
433
|
* const cie10Id = api.getCie10IdByName('C78.9');
|
|
434
434
|
*/
|
|
435
435
|
getCie10IdByName = (name) => {
|
|
436
|
-
const cie10 = this.getGlobalInfoElement(this.globalTypes.cie10, name);
|
|
436
|
+
const cie10 = this.getGlobalInfoElement(this.globalTypes.cie10, 'name', name);
|
|
437
437
|
if (!cie10) {
|
|
438
438
|
throw new Error(`CIE10 ${name} not found`);
|
|
439
439
|
}
|
|
440
440
|
return cie10.id;
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
|
|
444
|
-
|
|
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);
|
|
445
461
|
}
|
|
446
462
|
|
|
447
463
|
/**
|
package/types/index.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ declare module "@phenyxhealth/sdk" {
|
|
|
89
89
|
export interface GlobalInfoElement {
|
|
90
90
|
id: string;
|
|
91
91
|
name: string;
|
|
92
|
+
code?: string;
|
|
92
93
|
color: string;
|
|
93
94
|
createdAt: string;
|
|
94
95
|
updatedAt: string;
|
|
@@ -275,11 +276,13 @@ declare module "@phenyxhealth/sdk" {
|
|
|
275
276
|
/**
|
|
276
277
|
* Obtiene un elemento específico de información global
|
|
277
278
|
* @param globalType Tipo global
|
|
278
|
-
* @param
|
|
279
|
+
* @param field Campo por el que buscar (ej: 'name', 'code')
|
|
280
|
+
* @param elementName Valor a buscar en el campo indicado
|
|
279
281
|
* @returns Elemento global o undefined
|
|
280
282
|
*/
|
|
281
283
|
getGlobalInfoElement(
|
|
282
284
|
globalType: GlobalType,
|
|
285
|
+
field: string,
|
|
283
286
|
elementName: string,
|
|
284
287
|
): GlobalInfoElement | undefined;
|
|
285
288
|
|
|
@@ -413,6 +416,14 @@ declare module "@phenyxhealth/sdk" {
|
|
|
413
416
|
*/
|
|
414
417
|
getCie10IdByName(name: string): string;
|
|
415
418
|
|
|
419
|
+
/**
|
|
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
|
+
*/
|
|
425
|
+
getCie10ByCode(code: string): GlobalInfoElement;
|
|
426
|
+
|
|
416
427
|
/**
|
|
417
428
|
* Obtiene el estado de peer review formateado
|
|
418
429
|
* @param status Estado a formatear
|