paperclip-plugin-autopilot-ops 0.1.49 → 0.1.51

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.49";
3
+ var PLUGIN_VERSION = "0.1.51";
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.49";
11
+ var PLUGIN_VERSION = "0.1.51";
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.49";
39935
+ var PLUGIN_VERSION = "0.1.51";
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) {
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 < 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) || 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",
@@ -44849,7 +44866,7 @@ function mapCaso(r) {
44849
44866
  estado: String(r.estado),
44850
44867
  referencia: r.referencia ?? null,
44851
44868
  titulo: String(r.titulo),
44852
- datos: jsonb2(r.datos),
44869
+ datos: conMarcasMatricula(String(r.workflow), jsonb2(r.datos), String(r.titulo)),
44853
44870
  abiertoPorTipo: String(r.abierto_por_tipo),
44854
44871
  abiertoPorId: r.abierto_por_id ?? null,
44855
44872
  agenteId: r.agente_id ?? null,
@@ -44860,6 +44877,31 @@ function mapCaso(r) {
44860
44877
  cerradoAt: r.cerrado_at ? iso2(r.cerrado_at) : null
44861
44878
  };
44862
44879
  }
44880
+ function resultadoDistinto(leido, informado) {
44881
+ const l = leerResultadoRegistro(leido);
44882
+ const i = leerResultadoRegistro(informado);
44883
+ if (!l || !i) return null;
44884
+ for (const k of ["sin_matricula", "encontrada", "coincide_nombre", "situacion", "sancion"]) {
44885
+ if (l[k] !== i[k]) return `${k} le\xEDdo ${String(l[k])}, informado ${String(i[k])}`;
44886
+ }
44887
+ return null;
44888
+ }
44889
+ function fichaMatricula(d) {
44890
+ const tipo = String(d.tipo_matricula ?? "");
44891
+ const cargada = tipo === "provincial" ? d.matricula_provincial : tipo === "nacional" ? d.matricula_nacional : void 0;
44892
+ return { cargada: cargada ?? d.matricula, enRegistro: d.en_registro };
44893
+ }
44894
+ function conMarcasMatricula(workflow, datos, titulo) {
44895
+ if (workflow !== "credencial_profesional") return datos;
44896
+ let d = datos;
44897
+ if (typeof d.posible_no_profesional !== "boolean") d = { ...d, posible_no_profesional: pareceNoProfesional(String(d.profesional ?? titulo.split(" \xB7 ")[0] ?? "")) };
44898
+ const r = leerResultadoRegistro(d.resultado);
44899
+ if (r && (d.observacion === "otra_persona" || d.observacion === "no_figura")) {
44900
+ const obs = observacionMatricula(r, fichaMatricula(d));
44901
+ if (obs !== d.observacion) d = { ...d, observacion: obs, mal_cargado_por: matriculaInvalida(fichaMatricula(d).cargada) ? "formato" : "propia_en_registro" };
44902
+ }
44903
+ return d;
44904
+ }
44863
44905
  function mapTransicion(r) {
44864
44906
  return {
44865
44907
  id: String(r.id),
@@ -45489,7 +45531,7 @@ async function transicionar(ctx, input2) {
45489
45531
  );
45490
45532
  const lectura = rows[0];
45491
45533
  const evidencia = lectura && lectura.evidencia && typeof lectura.evidencia === "object" ? lectura.evidencia : null;
45492
- 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;
45534
+ 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)}` : 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;
45493
45535
  let vieja = false;
45494
45536
  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")) {
45495
45537
  const ultima = await ctx.db.query(
@@ -45823,7 +45865,8 @@ async function transicionar(ctx, input2) {
45823
45865
  const r = leerResultadoRegistro(datos.resultado);
45824
45866
  if (r) {
45825
45867
  datos.resultado = r;
45826
- datos.observacion = observacionDe(r);
45868
+ datos.observacion = observacionMatricula(r, fichaMatricula({ ...caso.datos, ...datos }));
45869
+ datos.mal_cargado_por = datos.observacion === "numero_mal_cargado" ? matriculaInvalida(fichaMatricula({ ...caso.datos, ...datos }).cargada) ? "formato" : "propia_en_registro" : null;
45827
45870
  datos.verificada_el = contexto.hoy ?? null;
45828
45871
  }
45829
45872
  if (caso.estado === "corregida") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-plugin-autopilot-ops",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
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": [