# Parse any healthcare document into clean, structured text

> Healthcare documents are some of the messiest inputs in any pipeline. A single patient's file might include a handwritten intake form, a scanned chart with checkboxes and body diagrams, a casualty card filled out under pressure, and a lab report full of dense tables, each laid out differently and often photographed or faxed. Retyping that by hand is slow, error prone, and does not scale. Reducto parses the entire document in one call and returns it as clean, structured text, handwriting transcribed and tables preserved, so your code or your model works with the data instead of the scan.

Canonical: https://reducto.ai/cookbooks/reducto-parse-healthcare-documents

## What you'll build

Healthcare document (handwritten form, scanned chart, lab report, PDF)

- Reducto Parse with dynamic table output
- Handwriting, form fields, and tables read in one pass
- A single structured document you can load into code or an LLM

## Setup

Grab an API key from <a href="https://studio.reducto.ai" rel="noopener noreferrer" target="_blank">studio.reducto.ai</a> -> API Keys -> Create new API key, then set it and install the SDK:

```bash
  export REDUCTO_API_KEY="your-api-key-here"
  pip install reducto
```

Use any [healthcare](https://reducto.ai/industries/healthcare) document: a handwritten intake form, a scanned chart, a casualty card, or a lab report, as a PDF or an image. No template setup or per-form tuning required. Need a sample? In Reducto Studio open the _**Healthcare Parse**_ template, where a sample document is already loaded. Run it there for a no-code preview, or download the PDF from the pipeline and follow the API steps below.

## Step 1: Parse the document

The setting that matters most here is `table_output_format: "dynamic"`, which lets Reducto pick the cleanest layout for each table instead of forcing one format across a mixed document. Chunking is disabled so the whole record comes back as one document, and the spreadsheet options apply when a record arrives as a spreadsheet export.

```python
  from pathlib import Path
  from reducto import Reducto

  client = Reducto()

  upload = client.upload(file=Path("healthcare_document.pdf"))

  parse_result = client.parse.run(
      input=upload.file_id,
      formatting={
          "table_output_format": "dynamic",   # let Reducto pick the cleanest layout per table
      },
      settings={
          "ocr_system": "standard",
      },
      spreadsheet={
          "clustering": "accurate",            # applies when the record is a spreadsheet export
          "split_large_tables": {"enabled": True, "size": 50},
      },
      retrieval={
          "chunking": {"chunk_mode": "disabled"},  # keep the whole document in one result
      },
  )

  print(f"Parsed {parse_result.usage.num_pages} pages. Review it in Studio: {parse_result.studio_link}")
```

Many healthcare forms are handwritten or low-quality scans. If characters come back garbled, add agentic text enhancement `(enhance={"agentic": [{"scope": "text"}]})` so a vision model re-reads the handwriting before you get the output.

## Step 2: Get the full parsed document

Longer records come back as a result URL to keep the response light. Fetch it and stitch the chunks together so you have the whole document as one string.

```python
  import json
  import urllib.request

  result = parse_result.result
  if result.type == "url":
      with urllib.request.urlopen(result.url) as response:
          data = json.load(response)
      full_content = "\n".join(c.get("content", "") for c in data.get("chunks", []))
  else:
      full_content = "\n".join(c.content for c in result.chunks)

  print(f"{len(full_content):,} characters of structured content")
```

`full_content` is the entire document as clean, structured text, handwriting transcribed and tables preserved, ready to hand to your code, a database, or an LLM prompt.

## Try it with curl

The same job as one request, tested on a sample file (a synthetic scanned claim form):

```bash
# 1. Upload the file (or pass a public URL as "input" and skip this step)
curl -s https://platform.reducto.ai/upload \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -F file=@claim-form.pdf
# => {"file_id": "reducto://..."}

# 2. Run extract
curl -s https://platform.reducto.ai/extract \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "reducto://FILE_ID",
  "instructions": {
    "schema": {
      "type": "object",
      "properties": {
        "payer": {"type": "string", "description": "Insurance payer."},
        "patient_name": {"type": "string", "description": "Patient name."},
        "patient_dob": {"type": "string", "description": "Patient date of birth, YYYY-MM-DD."},
        "member_id": {"type": "string", "description": "Member or insured ID."},
        "billing_provider": {"type": "string", "description": "Billing provider name."},
        "billing_npi": {"type": "string", "description": "Billing provider NPI."},
        "diagnosis_codes": {
          "type": "array",
          "items": {"type": "string", "description": "ICD-10 code."},
          "description": "Diagnosis codes in pointer order."
        },
        "service_lines": {
          "type": "array",
          "description": "Every service line.",
          "items": {
            "type": "object",
            "properties": {
              "date_of_service": {"type": "string", "description": "YYYY-MM-DD."},
              "procedure_code": {"type": "string", "description": "CPT or HCPCS code."},
              "modifier": {"type": "string", "description": "Modifier, empty if none."},
              "diagnosis_pointer": {"type": "string", "description": "Diagnosis pointer letters."},
              "units": {"type": "number", "description": "Units."},
              "charge": {"type": "number", "description": "Line charge."}
            }
          }
        },
        "total_charge": {"type": "number", "description": "Total charge."}
      }
    }
  },
  "parsing": {"settings": {"model": "r-1"}}
}'
```

The part of the response that matters for this job:

```json
{
  "payer": "Fernvale Health Plan",
  "billing_provider": "Cedarbrook Family Clinic",
  "diagnosis_codes": [
    "J06.9",
    "R50.9"
  ],
  "service_lines": [
    {
      "date_of_service": "2026-09-14",
      "procedure_code": "99214",
      "modifier": "25",
      "diagnosis_pointer": "A",
      "units": 1,
      "charge": 185
    },
    {
      "date_of_service": "2026-09-14",
      "procedure_code": "87880",
      "modifier": "",
      "diagnosis_pointer": "A",
      "units": 1,
      "charge": 32
    }
  ],
  "total_charge": 241.6
}
```

[Full response format ->](https://docs.reducto.ai/extract/response-format)

## Prefer no code?

Want to see it run first? In Reducto Studio, open the _**Healthcare Parse**_ template and press Run. To build your own, upload a healthcare document, leave the table output format on Dynamic, and Run. Review the parsed output side by side with the source, then Deploy the config as an API endpoint for the rest of your documents.

## Where this goes next

Parse turns the document into clean, structured text. Chain the rest of the toolkit onto the same pipeline:

- Pull typed fields with <a href="https://docs.reducto.ai/extract/overview" rel="noopener noreferrer" target="_blank">Extract</a>: turn the parsed record into a schema (patient name, date of birth, vitals, medications) for direct loading.
- Sort first with <a href="https://docs.reducto.ai/classify/overview" rel="noopener noreferrer" target="_blank">Classify</a>: route intake forms, lab reports, and discharge summaries to the right pipeline.
- Break apart packets with <a href="https://docs.reducto.ai/split" rel="noopener noreferrer" target="_blank">Split</a>: divide a multi-document patient file into one record per document type.
- Hand clean data to an LLM or agent: the structured text drops straight into a clinical model, a RAG index, or an intake agent.
