paperclip-plugin-autopilot-ops 0.1.50 → 0.1.52

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.50";
3
+ var PLUGIN_VERSION = "0.1.52";
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.50";
11
+ var PLUGIN_VERSION = "0.1.52";
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.50";
39935
+ var PLUGIN_VERSION = "0.1.52";
39936
39936
  var DB_NAMESPACE_SLUG = "autopilot_ops";
39937
39937
  var PAGE_ROUTE = "autopilot";
39938
39938
  var TOOL_NAMES = {
@@ -42502,6 +42502,23 @@ function observacionDe(r) {
42502
42502
  if (r.situacion !== "habilitado") return "inhabilitada";
42503
42503
  return null;
42504
42504
  }
42505
+ function matriculaInvalida(cargada, tipo) {
42506
+ const crudo = String(cargada ?? "").trim();
42507
+ if (!crudo) return false;
42508
+ if (/[^0-9\s.\-/]/.test(crudo)) return true;
42509
+ const d = crudo.replace(/\D/g, "");
42510
+ if (d.length < (tipo === "provincial" ? 3 : 4)) return true;
42511
+ if (/^(\d)\1+$/.test(d)) return true;
42512
+ return "01234567890".includes(d) || "9876543210".includes(d);
42513
+ }
42514
+ function tienePropiaHabilitada(enRegistro) {
42515
+ return Array.isArray(enRegistro) && enRegistro.some((m) => m && typeof m === "object" && m.situacion === "habilitado" && m.sancion !== true);
42516
+ }
42517
+ function observacionMatricula(r, ficha) {
42518
+ const obs = observacionDe(r);
42519
+ if ((obs === "otra_persona" || obs === "no_figura") && (matriculaInvalida(ficha.cargada, ficha.tipo) || tienePropiaHabilitada(ficha.enRegistro))) return "numero_mal_cargado";
42520
+ return obs;
42521
+ }
42505
42522
  var GRAVES_MATRICULA = ["inhabilitada", "sancion", "otra_persona"];
42506
42523
  var credencialProfesional = {
42507
42524
  clave: "credencial_profesional",
@@ -42564,6 +42581,8 @@ var credencialProfesional = {
42564
42581
  descripcion: "La matr\xEDcula est\xE1 de verdad inhabilitada, con sanci\xF3n o a nombre de otra persona: la instituci\xF3n suspendi\xF3 la agenda del profesional hasta que lo regularice. Queda registrado qui\xE9n lo decidi\xF3 y por qu\xE9.",
42565
42582
  validar: (caso, datos) => [
42566
42583
  GRAVES_MATRICULA.includes(texto4(caso.datos.observacion) ?? "") ? ok("observacion_grave") : falla("observacion_grave", "suspender la agenda es para una matr\xEDcula inhabilitada, con sanci\xF3n o a nombre de otra persona"),
42584
+ // A nombre de otra persona: solo con la búsqueda por nombre hecha (sin ella puede ser un número mal cargado).
42585
+ caso.datos.observacion !== "otra_persona" || Array.isArray(caso.datos.en_registro) ? ok("busqueda_por_nombre") : falla("busqueda_por_nombre", "a nombre de otra persona sin buscar al profesional por su nombre en el registro: volver a verificarlo antes de suspender"),
42567
42586
  texto4(datos.motivo) ? ok("motivo_presente") : falla("motivo_presente", "suspender_agenda requiere motivo")
42568
42587
  ]
42569
42588
  },
@@ -44860,9 +44879,30 @@ function mapCaso(r) {
44860
44879
  cerradoAt: r.cerrado_at ? iso2(r.cerrado_at) : null
44861
44880
  };
44862
44881
  }
44882
+ function resultadoDistinto(leido, informado) {
44883
+ const l = leerResultadoRegistro(leido);
44884
+ const i = leerResultadoRegistro(informado);
44885
+ if (!l || !i) return null;
44886
+ for (const k of ["sin_matricula", "encontrada", "coincide_nombre", "situacion", "sancion"]) {
44887
+ if (l[k] !== i[k]) return `${k} le\xEDdo ${String(l[k])}, informado ${String(i[k])}`;
44888
+ }
44889
+ return null;
44890
+ }
44891
+ function fichaMatricula(d) {
44892
+ const tipo = String(d.tipo_matricula ?? "");
44893
+ const cargada = tipo === "provincial" ? d.matricula_provincial : tipo === "nacional" ? d.matricula_nacional : void 0;
44894
+ return { cargada: cargada ?? d.matricula, tipo: tipo || null, enRegistro: d.en_registro };
44895
+ }
44863
44896
  function conMarcasMatricula(workflow, datos, titulo) {
44864
- if (workflow !== "credencial_profesional" || typeof datos.posible_no_profesional === "boolean") return datos;
44865
- return { ...datos, posible_no_profesional: pareceNoProfesional(String(datos.profesional ?? titulo.split(" \xB7 ")[0] ?? "")) };
44897
+ if (workflow !== "credencial_profesional") return datos;
44898
+ let d = datos;
44899
+ if (typeof d.posible_no_profesional !== "boolean") d = { ...d, posible_no_profesional: pareceNoProfesional(String(d.profesional ?? titulo.split(" \xB7 ")[0] ?? "")) };
44900
+ const r = leerResultadoRegistro(d.resultado);
44901
+ if (r && (d.observacion === "otra_persona" || d.observacion === "no_figura")) {
44902
+ const obs = observacionMatricula(r, fichaMatricula(d));
44903
+ if (obs !== d.observacion) d = { ...d, observacion: obs, mal_cargado_por: matriculaInvalida(fichaMatricula(d).cargada, fichaMatricula(d).tipo) ? "formato" : "propia_en_registro" };
44904
+ }
44905
+ return d;
44866
44906
  }
44867
44907
  function mapTransicion(r) {
44868
44908
  return {
@@ -45493,7 +45533,7 @@ async function transicionar(ctx, input2) {
45493
45533
  );
45494
45534
  const lectura = rows[0];
45495
45535
  const evidencia = lectura && lectura.evidencia && typeof lectura.evidencia === "object" ? lectura.evidencia : null;
45496
- const distinta = lectura && caso.workflow === "credencial_profesional" && resultado.via === "verificar" && evidencia ? evidencia.profesional_id !== void 0 && String(evidencia.profesional_id) !== String(datos.profesional_id ?? caso.datos.profesional_id ?? "") ? `la lectura ${lecturaId} es de otro profesional (${String(evidencia.profesional_id)})` : evidencia.matricula !== void 0 && datos.matricula !== void 0 && datos.matricula !== null && String(evidencia.matricula) !== String(datos.matricula) ? `la lectura ${lecturaId} es de la matr\xEDcula ${String(evidencia.matricula)} y se informa la ${String(datos.matricula)}` : null : null;
45536
+ const distinta = lectura && caso.workflow === "credencial_profesional" && resultado.via === "verificar" && evidencia ? evidencia.profesional_id !== void 0 && String(evidencia.profesional_id) !== String(datos.profesional_id ?? caso.datos.profesional_id ?? "") ? `la lectura ${lecturaId} es de otro profesional (${String(evidencia.profesional_id)})` : evidencia.matricula !== void 0 && datos.matricula !== void 0 && datos.matricula !== null && String(evidencia.matricula) !== String(datos.matricula) ? `la lectura ${lecturaId} es de la matr\xEDcula ${String(evidencia.matricula)} y se informa la ${String(datos.matricula)}` : leerResultadoRegistro(evidencia.resultado) === null ? `la lectura ${lecturaId} no guard\xF3 el resultado del registro (evidencia.resultado): sin eso no se puede comprobar lo que se informa` : evidencia.matricula === void 0 && leerResultadoRegistro(datos.resultado)?.sin_matricula !== true ? `la lectura ${lecturaId} no guard\xF3 qu\xE9 matr\xEDcula se consult\xF3 (evidencia.matricula)` : resultadoDistinto(evidencia.resultado, datos.resultado) ? `lo que se informa no es lo que devolvi\xF3 el registro en la lectura ${lecturaId}: ${resultadoDistinto(evidencia.resultado, datos.resultado)}` : null : null;
45497
45537
  let vieja = false;
45498
45538
  if (lectura && (resultado.via === "comprobar" || (caso.workflow === "circular_aranceles" || caso.workflow === "ajuste_convenio") && resultado.via === "verificar" || caso.workflow === "credencial_profesional" && resultado.via === "verificar" && caso.estado === "corregida")) {
45499
45539
  const ultima = await ctx.db.query(
@@ -45827,7 +45867,8 @@ async function transicionar(ctx, input2) {
45827
45867
  const r = leerResultadoRegistro(datos.resultado);
45828
45868
  if (r) {
45829
45869
  datos.resultado = r;
45830
- datos.observacion = observacionDe(r);
45870
+ datos.observacion = observacionMatricula(r, fichaMatricula({ ...caso.datos, ...datos }));
45871
+ datos.mal_cargado_por = datos.observacion === "numero_mal_cargado" ? ((f) => matriculaInvalida(f.cargada, f.tipo) ? "formato" : "propia_en_registro")(fichaMatricula({ ...caso.datos, ...datos })) : null;
45831
45872
  datos.verificada_el = contexto.hoy ?? null;
45832
45873
  }
45833
45874
  if (caso.estado === "corregida") {
@@ -46801,7 +46842,7 @@ async function casosQueEsperan(ctx, companyId, workflows) {
46801
46842
  const out = [];
46802
46843
  for (const [workflow, estados] of Object.entries(ESPERAN_PERSONA)) {
46803
46844
  if (workflows && workflows.length > 0 && !workflows.includes(workflow)) continue;
46804
- out.push(...await listarCasos(ctx, { companyId, workflow, estados, limit: 100 }));
46845
+ out.push(...await listarCasos(ctx, { companyId, workflow, estados, limit: 500 }));
46805
46846
  }
46806
46847
  return out;
46807
46848
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-plugin-autopilot-ops",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
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": [