DEV Community

Mediavox
Mediavox

Posted on

Building a Document Intelligence Pipeline with Person Correlation in n8n (LATAM-ready)

The Problem

You have thousands of documents: medical records, contracts, invoices, IDs. Each contains a person — but they're isolated. Upload a patient's history today, their lab results tomorrow, and their insurance claim next week — and there's no automatic way to say "these all belong to the same person."

In Latin America this is worse: the same person might appear as CC 1006702172 (Colombia), or with dots (1.006.702.172), or prefixed ("CC 1006702172"), or in a different document type altogether (NIT for companies, RUT in Chile, CURP in Mexico).

The Solution: Person Correlation in n8n

We built a document intelligence pipeline that:

  1. Classifies any document automatically (30+ types: medical records, contracts, invoices, IDs, insurance forms)
  2. Extracts structured entities via template NER (not just generic — specific fields per document type)
  3. Identifies the main person and normalizes their ID across LATAM formats
  4. Correlates all documents by person — automatically

How it works in n8n

Install the community node:

Settings > Community Nodes > n8n-nodes-mediavox
Enter fullscreen mode Exit fullscreen mode

Then build your workflow:

Step 1: Upload document

{
  "product": "DocumentPower",
  "method": "document.analyze",
  "params": {
    "file": "{{$binary.data.data}}",
    "file_name": "{{$binary.data.fileName}}",
    "post_process": "health"
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Check the response

{
  "document_type": "epicrisis",
  "persona": {
    "id": "1006702172",
    "tipo_id": "CC",
    "nombre": "LAURA VANESSA OROZCO DAZA",
    "total_documentos": 5,
    "tipos_documento": {"epicrisis": 2, "incapacidad": 1, "receta": 1, "laboratorio": 1}
  },
  "documentos_relacionados": [
    {"id": 25, "tipo": "epicrisis", "fecha": "2026-02-15"},
    {"id": 30, "tipo": "incapacidad", "fecha": "2026-02-20"}
  ],
  "health": {
    "servicio_id": 56,
    "diagnostico": "K35.0",
    "confidence": 1.0
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Get the full patient record

{
  "product": "HealthPower",
  "method": "health.patient_record",
  "params": {
    "tipoId": "CC",
    "id": "1006702172"
  }
}
Enter fullscreen mode Exit fullscreen mode

Returns ALL documents + clinical services for that person, chronologically ordered.

Multi-Country ID Normalization

The PersonIdExtractor handles:

Country ID Types Format variations
Colombia CC, TI, CE, NIT With/without dots, with/without prefix
Mexico CURP, RFC 18-char alphanumeric
Chile RUT With/without dots and dash
Peru DNI 8 digits
Brazil CPF With/without dots and dash

All normalized to a clean string before correlation. "1.006.702.172" and "CC 1006702172" and "1006702172" all resolve to the same person.

force_reanalyze: Re-process Without Duplicates

Templates improve over time. When you add new extraction fields, you want to re-process existing documents without creating duplicates:

{
  "params": {
    "file": "...",
    "file_name": "historia_clinica.pdf",
    "force_reanalyze": true
  }
}
Enter fullscreen mode Exit fullscreen mode

Response: vault_status: "reanalyzed" — the existing document is UPDATED with fresh NER results.

Ready-to-Use Workflow Templates

We have 13 templates ready to import:

  • Patient Record Lookup — Input patient ID → full correlated record
  • Clinical Document Ingest + Risk Score — Upload PDF → classify → extract → risk
  • Invoice Analysis — Extract NIT, items, totals, ask follow-up questions
  • Phishing Detection — Analyze messages → resolve URLs → route by verdict
  • KYC Onboarding — Sanctions + ID validation → approve/review/reject

Download them at: https://mediavox.co/mvdevportal/integrations/n8n

Links

Top comments (0)