paperclip-plugin-autopilot-ops 0.1.15 → 0.1.17

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/dist/manifest.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/manifest.ts
2
2
  var PLUGIN_ID = "alephoo.autopilot-ops";
3
- var PLUGIN_VERSION = "0.1.15";
3
+ var PLUGIN_VERSION = "0.1.17";
4
4
  var DB_NAMESPACE_SLUG = "autopilot_ops";
5
5
  var PAGE_ROUTE = "autopilot";
6
6
  var TOOL_NAMES = {
package/dist/ui/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
 
9
9
  // src/manifest.ts
10
10
  var PLUGIN_ID = "alephoo.autopilot-ops";
11
- var PLUGIN_VERSION = "0.1.15";
11
+ var PLUGIN_VERSION = "0.1.17";
12
12
  var DB_NAMESPACE_SLUG = "autopilot_ops";
13
13
  var PAGE_ROUTE = "autopilot";
14
14
  var TOOL_NAMES = {
package/dist/worker.js CHANGED
@@ -39932,7 +39932,7 @@ function startWorkerRpcHost(options) {
39932
39932
 
39933
39933
  // src/manifest.ts
39934
39934
  var PLUGIN_ID = "alephoo.autopilot-ops";
39935
- var PLUGIN_VERSION = "0.1.15";
39935
+ var PLUGIN_VERSION = "0.1.17";
39936
39936
  var DB_NAMESPACE_SLUG = "autopilot_ops";
39937
39937
  var PAGE_ROUTE = "autopilot";
39938
39938
  var TOOL_NAMES = {
@@ -41354,6 +41354,7 @@ import { randomUUID } from "node:crypto";
41354
41354
  var ESTADOS_REGLA = ["borrador", "activa", "pausada"];
41355
41355
  var LIMITES_REGLA = {
41356
41356
  dias_desde: [1, 365, 30],
41357
+ dias_hasta: [2, 3650, 0],
41357
41358
  cada_meses: [1, 60, 12],
41358
41359
  max_intentos: [1, 5, 2],
41359
41360
  dias_entre_intentos: [1, 30, 7],
@@ -41444,6 +41445,97 @@ function poblacion(problemas, p) {
41444
41445
  }
41445
41446
  return out;
41446
41447
  }
41448
+ var TODOS = ["orden_sin_turno", "solicitud_pendiente", "control_periodico"];
41449
+ var CAMPOS_CONDICION = {
41450
+ edad: { nombre: "Edad (a\xF1os)", tipo: "numero", operadores: ["mayor_que", "menor_que", "entre"], en: TODOS },
41451
+ sexo: { nombre: "Sexo", tipo: "opcion", operadores: ["es"], opciones: ["F", "M"], en: TODOS },
41452
+ obra_social: { nombre: "Obra social", tipo: "texto", operadores: ["contiene", "no_contiene"], en: ["orden_sin_turno", "control_periodico"] },
41453
+ estudio: { nombre: "Estudio", tipo: "texto", operadores: ["contiene", "no_contiene"], en: ["orden_sin_turno"] },
41454
+ especialidad: { nombre: "Especialidad", tipo: "texto", operadores: ["contiene", "no_contiene"], en: TODOS },
41455
+ profesional: { nombre: "Profesional", tipo: "texto", operadores: ["contiene", "no_contiene"], en: ["orden_sin_turno", "control_periodico"] },
41456
+ prioridad: { nombre: "Prioridad de la solicitud", tipo: "texto", operadores: ["contiene"], en: ["solicitud_pendiente"] },
41457
+ diagnostico: { nombre: "Diagn\xF3stico (CIE-10)", tipo: "codigo", operadores: ["empieza_con"], en: ["orden_sin_turno", "control_periodico"] },
41458
+ dias: { nombre: "D\xEDas pendiente", tipo: "numero", operadores: ["mayor_que", "menor_que", "entre"], en: TODOS }
41459
+ };
41460
+ var MAX_CONDICIONES = 10;
41461
+ function condiciones(problemas, tipo, p) {
41462
+ if (p.condiciones === void 0 || p.condiciones === null) return [];
41463
+ if (!Array.isArray(p.condiciones)) {
41464
+ problemas.push("condiciones: debe ser una lista");
41465
+ return [];
41466
+ }
41467
+ if (p.condiciones.length > MAX_CONDICIONES) problemas.push(`condiciones: como m\xE1ximo ${MAX_CONDICIONES}`);
41468
+ const out = [];
41469
+ p.condiciones.slice(0, MAX_CONDICIONES).forEach((cruda, i) => {
41470
+ const c = jsonb(cruda);
41471
+ const ref = `condiciones[${i + 1}]`;
41472
+ const campo = str(c.campo)?.toLowerCase() ?? "";
41473
+ const def2 = CAMPOS_CONDICION[campo];
41474
+ if (!def2) {
41475
+ problemas.push(`${ref}: campo desconocido \xAB${campo || "(vac\xEDo)"}\xBB; posibles: ${Object.keys(CAMPOS_CONDICION).join(", ")}`);
41476
+ return;
41477
+ }
41478
+ if (tipo && !def2.en.includes(tipo)) {
41479
+ problemas.push(`${ref}: \xAB${def2.nombre}\xBB no existe para el tipo ${tipo}`);
41480
+ return;
41481
+ }
41482
+ const operador = str(c.operador)?.toLowerCase() ?? "";
41483
+ if (!def2.operadores.includes(operador)) {
41484
+ problemas.push(`${ref}: \xAB${def2.nombre}\xBB admite ${def2.operadores.join(", ")}`);
41485
+ return;
41486
+ }
41487
+ if (def2.tipo === "numero") {
41488
+ const v2 = entero(c.valor);
41489
+ if (v2 === null || v2 < 0 || v2 > 3650) {
41490
+ problemas.push(`${ref}: \xAB${def2.nombre}\xBB necesita un n\xFAmero entero entre 0 y 3650`);
41491
+ return;
41492
+ }
41493
+ if (operador === "entre") {
41494
+ const v22 = entero(c.valor2);
41495
+ if (v22 === null || v22 <= v2 || v22 > 3650) {
41496
+ problemas.push(`${ref}: \xAB${def2.nombre}\xBB entre necesita un segundo valor mayor que ${v2}`);
41497
+ return;
41498
+ }
41499
+ out.push({ campo, operador: "entre", valor: v2, valor2: v22 });
41500
+ return;
41501
+ }
41502
+ out.push({ campo, operador, valor: v2 });
41503
+ return;
41504
+ }
41505
+ if (def2.tipo === "opcion") {
41506
+ const v2 = str(c.valor)?.toUpperCase() ?? "";
41507
+ if (!(def2.opciones ?? []).includes(v2)) {
41508
+ problemas.push(`${ref}: \xAB${def2.nombre}\xBB debe ser ${(def2.opciones ?? []).join(" o ")}`);
41509
+ return;
41510
+ }
41511
+ out.push({ campo, operador: "es", valor: v2 });
41512
+ return;
41513
+ }
41514
+ if (def2.tipo === "codigo") {
41515
+ const v2 = str(c.valor)?.toUpperCase() ?? "";
41516
+ if (!/^[A-Z][0-9]{1,2}(\.[0-9A-Z]{1,2})?$/.test(v2)) {
41517
+ problemas.push(`${ref}: \xAB${def2.nombre}\xBB espera un c\xF3digo CIE-10 o su prefijo (p. ej. E11)`);
41518
+ return;
41519
+ }
41520
+ out.push({ campo, operador: "empieza_con", valor: v2 });
41521
+ return;
41522
+ }
41523
+ const v = str(c.valor);
41524
+ if (!v || v.length > 80) {
41525
+ problemas.push(`${ref}: \xAB${def2.nombre}\xBB necesita un texto de hasta 80 caracteres`);
41526
+ return;
41527
+ }
41528
+ out.push({ campo, operador, valor: v });
41529
+ });
41530
+ return out;
41531
+ }
41532
+ function diasHasta(problemas, parametros, p) {
41533
+ if (p.dias_hasta === void 0 || p.dias_hasta === null || p.dias_hasta === "") return;
41534
+ const hasta = numeroEn(problemas, "dias_hasta", p.dias_hasta);
41535
+ const desde = typeof parametros.dias_desde === "number" ? parametros.dias_desde : 0;
41536
+ if (hasta <= desde) problemas.push(`dias_hasta: tiene que ser mayor que dias_desde (${desde})`);
41537
+ else parametros.dias_hasta = hasta;
41538
+ }
41447
41539
  function validarRegla(input2) {
41448
41540
  const problemas = [];
41449
41541
  const nombre = textoCorto(problemas, "nombre", input2.nombre, 80, true) ?? "";
@@ -41453,10 +41545,13 @@ function validarRegla(input2) {
41453
41545
  if (!tipo) problemas.push(`tipo: debe ser ${TIPOS_REGLA_DEMANDA.join(", ")}`);
41454
41546
  const p = jsonb(input2.parametros);
41455
41547
  const parametros = poblacion(problemas, p);
41548
+ const conds = condiciones(problemas, tipo, p);
41549
+ if (conds.length > 0) parametros.condiciones = conds;
41456
41550
  if (tipo === "orden_sin_turno") {
41457
41551
  const estudio = textoCorto(problemas, "estudio", p.estudio, 80, false);
41458
41552
  if (estudio) parametros.estudio = estudio;
41459
41553
  parametros.dias_desde = numeroEn(problemas, "dias_desde", p.dias_desde);
41554
+ diasHasta(problemas, parametros, p);
41460
41555
  const sin = Array.isArray(p.sin) ? p.sin.map((x) => String(x).trim().toLowerCase()) : [...SIN_QUE];
41461
41556
  if (sin.length === 0 || sin.some((x) => !SIN_QUE.includes(x))) problemas.push(`sin: lista con ${SIN_QUE.join(" y/o ")}`);
41462
41557
  parametros.sin = [...new Set(sin)].filter((x) => SIN_QUE.includes(x));
@@ -41466,6 +41561,7 @@ function validarRegla(input2) {
41466
41561
  const prioridad = textoCorto(problemas, "prioridad", p.prioridad, 40, false);
41467
41562
  if (prioridad) parametros.prioridad = prioridad;
41468
41563
  parametros.dias_desde = numeroEn(problemas, "dias_desde", p.dias_desde);
41564
+ diasHasta(problemas, parametros, p);
41469
41565
  } else if (tipo === "control_periodico") {
41470
41566
  const diagnostico = textoCorto(problemas, "diagnostico", p.diagnostico, 10, false);
41471
41567
  if (diagnostico) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-plugin-autopilot-ops",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "type": "module",
5
5
  "description": "Autopilot Care · operación autónoma gobernada para instituciones de salud: workflows determinísticos, validaciones, registro de negocio, políticas (observa/propone/ejecuta/corte) y tablero del director, como plugin de Paperclip.",
6
6
  "files": [