Produces the formal PDF of a Colombian medical invoice glosa (claim denial) from the consolidated audit output, with institutional header, executive summary, per-causal (Anexo 6, Res. 3047) findings table, legal and clinical justification, evidence cited by file and page, and a legal footer with the 15 business-day response deadline. Supports incremental versions (v1, v2, ...) when fix-review requests changes. Use it when the case is consolidated (label `auto-denial` or post human-review) and needs the formal document that will be sent to the IPS.
Generates the formal glosa (claim denial) PDF, ready to be sent to the IPS. Supports versioning — the first run produces v1, later edits driven by fix-review produce v2, v3, without overwriting earlier versions.
The question it answers: how do I turn the consolidated output into a legal, traceable, professional document that the IPS can answer within 15 business days?
auto-denial and the initial glosa must be produced.fix-review applied changes and asks to regenerate the PDF (v2, v3, ...).Do not use: if the case has no consolidated_findings published; if the current label is auto-approve (no glosa needed).
Read the consolidated output and case data.
GET {DEST_SOFTWARE_BASE_URL}/cases/{case_id}
GET {DEST_SOFTWARE_BASE_URL}/cases/{case_id}/consolidated
Retrieve: ips_razon_social, ips_nit, rad, invoice_number, invoice_cuv, patient_name, patient_document, service_date, issue_date, invoice_total, consolidated_findings[], case_summary.
Determine the next version.
GET {DEST_SOFTWARE_BASE_URL}/cases/{case_id}/documents?tipo=claim_denial
List existing versions. New version = max(version) + 1, default v1.
Load the template. If EPS_INSTITUTIONAL_TEMPLATE_PATH exists, use it. Otherwise use a generic template with the required structure:
┌─────────────────────────────────────────┐
│ [EPS LOGO] GLOSA FORMAL │
│ Res. 3047/2008 Art. 5 │
├─────────────────────────────────────────┤
│ Notification date: 2026-04-15 │
│ RAD: 20260415-0023 │
│ Version: v2 │
├─────────────────────────────────────────┤
│ PROVIDER (IPS) │
│ Legal name: Clínica ABC S.A.S. │
│ NIT: 900.123.456-7 │
│ Notification email: ... │
│ │
│ PAYER (EPS) │
│ EPS XYZ │
│ │
│ DISPUTED INVOICE │
│ Number: FE-A-45678 │
│ CUV: abc123... │
│ Issue date: 2026-03-20 │
│ Service date: 2026-03-10 │
│ Patient: Juan Pérez, CC 123456 │
│ Total billed: $8,500,000 │
├─────────────────────────────────────────┤
│ EXECUTIVE SUMMARY │
│ Total billed: $8,500,000 │
│ Total disputed: $3,200,000 │
│ Total to pay: $5,300,000 │
│ │
│ Causales applied: │
│ • 2 No pertinencia clínica: 1 item │
│ • 5 Tarifa incorrecta: 3 items │
│ • 6 Agotamiento cobertura: 1 item │
├─────────────────────────────────────────┤
│ DETAILED FINDINGS │
│ │
│ #1 — Causal 6.1 Agotamiento cobertura │
│ Item: CUPS 890201 "Specialty cons." │
│ Disputed amount: $1,200,000 │
│ │
│ Legal justification: │
│ Res. 3047/2008 Anexo 6, causal 6.1│
│ ... │
│ │
│ Clinical/technical justification: │
│ ... │
│ │
│ Evidence: │
│ • autorizacion.pdf p.2: │
│ "annual cap $5,000,000 reached" │
│ • factura XML <cbc:PayableAmount> │
│ $1,200,000 exceeds available │
│ │
│ Evaluated rules: ADMIN.15, FIN.20 │
│ Confidence: 0.92 │
│ │
│ #2 — ... │
├─────────────────────────────────────────┤
│ RIGHT OF RESPONSE │
│ The IPS has 15 business days to │
│ respond per Art. 6 of Res. 3047/2008. │
│ After that, the glosa stands. │
├─────────────────────────────────────────┤
│ SIGNATURE │
│ [Lead auditor name] │
│ [Title] │
│ [Professional registration if any] │
└─────────────────────────────────────────┘
Render the PDF. Recommended stack (in order of preference):
typst compile template.typ output.pdf (fast, professional typography).Inject dynamic data from the consolidated output. Colombian number formatting: thousands with ., decimals with , ($8.500.000) — switch locale accordingly.
Save on the case with versioning.
POST {DEST_SOFTWARE_BASE_URL}/cases/{case_id}/documents
Content-Type: multipart/form-data
file=claim_denial.v2.pdf
tipo=claim_denial
version=v2
metadata={"findings_count": 5, "total_objetado": 3200000, "generated_at": "..."}
Do not overwrite earlier versions — the destination software must keep history.
Update the case status.
PATCH {DEST_SOFTWARE_BASE_URL}/cases/{case_id}
{ "status": "claim_denial_draft", "latest_claim_denial_version": "v2" }
Return the reference.
{
"document_id": "...",
"version": "v2",
"pdf_url": "https://.../cases/{id}/documents/{doc_id}/content",
"case_id": "...",
"estado_caso": "claim_denial_draft",
"findings_count": 5,
"total_objetado": 3200000
}
encoding=utf-8 in the template.v1 overwritten when generating v2. Cause: hardcoded filename. Fix: filename must include version: claim_denial.{version}.pdf, and the software must accept the version parameter without replacing the existing record.word-break: break-word / break-anywhere: true for evidence cells.total_objetado > invoice_total). Cause: findings with the same invoice_item summed multiple times. Fix: this skill does NOT sum — use case_summary.total_objetado directly from the consolidator.GET /cases/{id}/labels — abort if auto-approve is present.EPS_LEGAL_REPRESENTATIVE unset. Fix: required variable; fail loudly if empty (do not publish unsigned PDFs).v2 regeneration does not reflect fix-review changes. Cause: skill read a stale consolidated (cached). Fix: always re-fetch GET /cases/{id}/consolidated at start; never trust in-memory state.GET /cases/{case_id}/documents?tipo=claim_denial lists the new version without deleting previous ones.causal, valor_objetado, evidencia, rule_ids, confianza.case_summary exactly (to the cent).claim_denial_draft (not claim_denial_sent — that is skill 9).