Runs the administrative audit of a filed Colombian medical invoice (patient identity, BDUA affiliation, IPS contract, RIPS structure, DIAN invoice, prior authorization, signed clinical history, cross-document consistency, and filing timeliness). Emits findings with traceable evidence and publishes them to the destination software. Use it when the user asks to audit the administrative side of a case, resume a failed audit, or run the admin sub-agent of the pipeline.
Administrative sub-agent of the pipeline. Evaluates ~27 rules (DAMA-UK + DOE-FT-01x) on identity, documentary completeness, RIPS structure, authorizations, and timeliness. Runs independently of the medical and financial auditors — it does not see their results.
The question it answers: is the expediente formally complete and consistent enough to be paid? It does not evaluate clinical pertinence or tariff — that belongs to the other two.
received → parallel audits).admin_audit ended up in error or incomplete.Do not use: if the case is not yet filed (skill 1 missing); if the case already has admin_audit published and a re-audit was not requested.
Read the case from the destination software.
GET {DEST_SOFTWARE_BASE_URL}/cases/{case_id}
Authorization: Bearer {DEST_SOFTWARE_API_KEY}
Retrieve: ips_nit, invoice_number, service_date, patient_document, attachments[], cups_principales[].
Download the necessary attachments.
invoice_xml (DIAN invoice)rips (flat file or JSON)clinical_history (PDF)authorization (if any)epicrisis, operative_note (if applicable given the CUPS)GET {DEST_SOFTWARE_BASE_URL}/cases/{case_id}/attachments/{name}
Load ref_data.
$REF_DATA_PATH/bdua.json — affiliation state.$REF_DATA_PATH/contratos_ips.json — active IPS contracts.Run the rule checklist (each rule emits a finding).
US.txt), clinical history, and BDUA.contratos_ips.json).US+AF always; AC for consultations, AP for procedures, AH for hospitalization, AM for medications, AN for newborns, AT for other services, AU for ER).numFactura in AF.txt exists in the detail files.US.txt.Assemble the admin_audit object.
{
"audit_type": "admin",
"score": <total weight lost>,
"zona": "verde|amarilla|roja",
"opinion": "<2-3 line summary>",
"findings": [
{
"rule_id": "ADMIN.07",
"severidad": "critica|mayor|media|baja",
"peso": 3,
"resultado": "pass|fail|conditional",
"evidencia": "contratos_ips.json: NIT 900... is not active as of 2026-03-15",
"valor_objetado": 0,
"nota": "IPS billed without an active contract"
}
]
}
Zone calculation:
Publish the result to the destination software.
POST {DEST_SOFTWARE_BASE_URL}/cases/{case_id}/audits
{ ...admin_audit }
Publish each finding individually as well, so humans can comment on each:
POST {DEST_SOFTWARE_BASE_URL}/cases/{case_id}/audits/{audit_id}/findings
Emit detailed evidence.
Each finding.evidencia must be citable: file + section/line/page.
Valid example: "US.txt line 1, field 3: document=CC12345678; BDUA: document=CC87654321".
Invalid example: "identity mismatch" (no citation).
JOSE vs JOSÉ). Cause: RIPS handles accents inconsistently. Fix: normalize with unicodedata.normalize('NFKD', s).encode('ascii','ignore') before comparing.contratos_ips.json has dates in DD/MM/YYYY while the service uses ISO. Fix: explicitly parse with datetime.strptime — never trust implicit parsing.numFactura has leading zeros in AF but not in AC. Cause: inconsistent padding by the IPS. Fix: normalize (lstrip('0')) before comparing./Sig dictionary in addition to text OCR.resultado=conditional and let human-review query BDUA online.resultado=fail.GET {DEST_SOFTWARE_BASE_URL}/cases/{case_id}/audits?type=admin returns exactly one record with all 27 rules evaluated (each with a resultado).evidencia.Σ peso × (1 if fail else 0) matches score.resultado=fail coexists with zona=verde|amarilla (invariant).medical_audit nor financial_audit (independence is verifiable in logs).