paperclip-plugin-autopilot-ops 0.1.48 → 0.1.50
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 +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/worker.js +22 -5
- package/package.json +1 -1
package/dist/manifest.js
CHANGED
package/dist/ui/index.js
CHANGED
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.
|
|
39935
|
+
var PLUGIN_VERSION = "0.1.50";
|
|
39936
39936
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
39937
39937
|
var PAGE_ROUTE = "autopilot";
|
|
39938
39938
|
var TOOL_NAMES = {
|
|
@@ -44849,7 +44849,7 @@ function mapCaso(r) {
|
|
|
44849
44849
|
estado: String(r.estado),
|
|
44850
44850
|
referencia: r.referencia ?? null,
|
|
44851
44851
|
titulo: String(r.titulo),
|
|
44852
|
-
datos: jsonb2(r.datos),
|
|
44852
|
+
datos: conMarcasMatricula(String(r.workflow), jsonb2(r.datos), String(r.titulo)),
|
|
44853
44853
|
abiertoPorTipo: String(r.abierto_por_tipo),
|
|
44854
44854
|
abiertoPorId: r.abierto_por_id ?? null,
|
|
44855
44855
|
agenteId: r.agente_id ?? null,
|
|
@@ -44860,6 +44860,10 @@ function mapCaso(r) {
|
|
|
44860
44860
|
cerradoAt: r.cerrado_at ? iso2(r.cerrado_at) : null
|
|
44861
44861
|
};
|
|
44862
44862
|
}
|
|
44863
|
+
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] ?? "")) };
|
|
44866
|
+
}
|
|
44863
44867
|
function mapTransicion(r) {
|
|
44864
44868
|
return {
|
|
44865
44869
|
id: String(r.id),
|
|
@@ -44976,6 +44980,11 @@ function opcionesCostos(op) {
|
|
|
44976
44980
|
function opcionesRentabilidad(op) {
|
|
44977
44981
|
return { umbral: enteroEntre(op.umbral_margen, 0, 90) ?? UMBRAL_MARGEN_POR_DEFECTO, mesesPrecio: enteroEntre(op.meses_precio, 1, 36) ?? MESES_PRECIO_POR_DEFECTO };
|
|
44978
44982
|
}
|
|
44983
|
+
function pareceNoProfesional(nombre) {
|
|
44984
|
+
const n = nombre.trim();
|
|
44985
|
+
const [apellido = "", nombres = ""] = n.split(",").map((x) => x.trim().toLowerCase());
|
|
44986
|
+
return /^[^a-záéíóúñü]/i.test(n) || /\d/.test(n) || apellido !== "" && apellido === nombres || /\b(admin|administrador|prueba|test|sistema|usuario)\b/i.test(n);
|
|
44987
|
+
}
|
|
44979
44988
|
async function evaluarRentabilidades(ctx, companyId, lecturas) {
|
|
44980
44989
|
if (!Array.isArray(lecturas)) throw new OpsError("validacion", "lecturas: tiene que ser una lista");
|
|
44981
44990
|
if (lecturas.length > 2e3) throw new OpsError("validacion", "lecturas: como m\xE1ximo 2000 por llamada");
|
|
@@ -45479,12 +45488,14 @@ async function transicionar(ctx, input2) {
|
|
|
45479
45488
|
const lecturaId = str2(datos.lectura_id);
|
|
45480
45489
|
if (lecturaId) {
|
|
45481
45490
|
const rows = await ctx.db.query(
|
|
45482
|
-
`SELECT id, caso_id, tipo, resultado, created_at FROM ${t3(ctx, "accion")} WHERE company_id = $1 AND id = $2 LIMIT 1`,
|
|
45491
|
+
`SELECT id, caso_id, tipo, resultado, evidencia, created_at FROM ${t3(ctx, "accion")} WHERE company_id = $1 AND id = $2 LIMIT 1`,
|
|
45483
45492
|
[input2.companyId, lecturaId]
|
|
45484
45493
|
);
|
|
45485
45494
|
const lectura = rows[0];
|
|
45495
|
+
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;
|
|
45486
45497
|
let vieja = false;
|
|
45487
|
-
if (lectura && (resultado.via === "comprobar" || (caso.workflow === "circular_aranceles" || caso.workflow === "ajuste_convenio") && resultado.via === "verificar")) {
|
|
45498
|
+
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")) {
|
|
45488
45499
|
const ultima = await ctx.db.query(
|
|
45489
45500
|
`SELECT max(created_at) AS ultima FROM ${t3(ctx, "transicion")} WHERE company_id = $1 AND caso_id = $2`,
|
|
45490
45501
|
[input2.companyId, caso.id]
|
|
@@ -45492,7 +45503,7 @@ async function transicionar(ctx, input2) {
|
|
|
45492
45503
|
const desde = ultima[0]?.ultima ? Date.parse(iso2(ultima[0].ultima)) : NaN;
|
|
45493
45504
|
vieja = Number.isFinite(desde) && Date.parse(iso2(lectura.created_at)) <= desde;
|
|
45494
45505
|
}
|
|
45495
|
-
const problema = !lectura ? `lectura_id ${lecturaId} no existe en esta instituci\xF3n` : String(lectura.caso_id) !== caso.id ? `la lectura ${lecturaId} pertenece a otro caso` : !["lectura", "verificacion"].includes(String(lectura.tipo)) ? `la acci\xF3n ${lecturaId} es de tipo ${String(lectura.tipo)}; hace falta una lectura o verificaci\xF3n` : String(lectura.resultado) !== "ok" ? `la lectura ${lecturaId} termin\xF3 con resultado ${String(lectura.resultado)}` : vieja ? `la lectura ${lecturaId} es anterior al \xFAltimo cambio del caso: volver a leer
|
|
45506
|
+
const problema = !lectura ? `lectura_id ${lecturaId} no existe en esta instituci\xF3n` : String(lectura.caso_id) !== caso.id ? `la lectura ${lecturaId} pertenece a otro caso` : !["lectura", "verificacion"].includes(String(lectura.tipo)) ? `la acci\xF3n ${lecturaId} es de tipo ${String(lectura.tipo)}; hace falta una lectura o verificaci\xF3n` : String(lectura.resultado) !== "ok" ? `la lectura ${lecturaId} termin\xF3 con resultado ${String(lectura.resultado)}` : vieja ? `la lectura ${lecturaId} es anterior al \xFAltimo cambio del caso: volver a leer y registrar esa lectura` : distinta;
|
|
45496
45507
|
if (problema) {
|
|
45497
45508
|
throw new OpsError("validacion", `lectura_registrada: ${problema}`, { validaciones: [{ regla: "lectura_registrada", ok: false, detalle: problema }], estado: caso.estado });
|
|
45498
45509
|
}
|
|
@@ -45819,6 +45830,12 @@ async function transicionar(ctx, input2) {
|
|
|
45819
45830
|
datos.observacion = observacionDe(r);
|
|
45820
45831
|
datos.verificada_el = contexto.hoy ?? null;
|
|
45821
45832
|
}
|
|
45833
|
+
if (caso.estado === "corregida") {
|
|
45834
|
+
const antes = [caso.datos.matricula_nacional, caso.datos.matricula_provincial].map((v) => String(v ?? "").replace(/\D/g, ""));
|
|
45835
|
+
const ahora = [datos.matricula_nacional ?? caso.datos.matricula_nacional, datos.matricula_provincial ?? caso.datos.matricula_provincial].map((v) => String(v ?? "").replace(/\D/g, ""));
|
|
45836
|
+
datos.ficha_sin_cambios = datos.observacion !== null && antes.join("|") === ahora.join("|");
|
|
45837
|
+
} else delete datos.ficha_sin_cambios;
|
|
45838
|
+
datos.posible_no_profesional = pareceNoProfesional(String(datos.profesional ?? caso.datos.profesional ?? caso.titulo.split(" \xB7 ")[0] ?? ""));
|
|
45822
45839
|
const ag = datos.agenda && typeof datos.agenda === "object" ? datos.agenda : null;
|
|
45823
45840
|
if (ag) {
|
|
45824
45841
|
const proximo = typeof ag.proximo_turno === "string" && /^\d{4}-\d{2}-\d{2}( \d{2}:\d{2})?$/.test(ag.proximo_turno) ? ag.proximo_turno : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paperclip-plugin-autopilot-ops",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
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": [
|