1.  [](/)
2.  [Code examples](/recipes)
3.  Clinical Documentation Structuring

Back to code examples

EnhancedSimilar

# Clinical Documentation Structuring

Production-grade pipeline for ingesting clinical documents, scanned charts, EHR exports, wound photos, and therapy notes, and structuring them into coded fields aligned with MDS 3.0, PDPM, and CMS audit requirements. Combines OCR, clinical NER, taxonomy classification, and hybrid retrieval to turn unstructured bedside documentation into queryable, auditable data.

text

image

Production

[Run in Builder](/build?recipe=clinical-documentation-structuring)

### Why This Matters

Nurses spend up to 40% of their time on documentation instead of patient care. Clinical data lives in free-text notes, scanned forms, and photos that are invisible to billing and compliance systems. This recipe bridges the gap, extracting structured clinical data from every modality so MDS coordinators, billers, and surveyors can work from a single source of truth.

Python

cURL

from mixpeek import Mixpeek

client \= Mixpeek(api\_key\="YOUR\_API\_KEY", namespace\="facility-clinical-docs")

\# 1. A bucket for chart exports, and a collection that splits pages into layout

\#    blocks with OCR and a confidence tag

bucket \= client.buckets.create(

    bucket\_name\="patient-charts",

    bucket\_schema\={"properties": {"chart": {"type": "pdf"}}},

)

collection \= client.collections.create(

    collection\_name\="patient-charts",

    source\={"type": "bucket", "bucket\_ids": \[bucket\["bucket\_id"\]\]},

    feature\_extractor\={

        "feature\_extractor\_name": "document\_graph\_extractor",

        "version": "v1",

        "parameters": {

            "use\_vlm\_correction": True,

        },

    },

)

\# 2. Upload and process

client.buckets.upload(

    bucket\["bucket\_id"\],

    blobs\=\[{"property": "chart", "type": "pdf", "data": "s3://facility-ehr-export/patient-charts/resident-0142.pdf"}\],

)

client.collections.trigger(collection\["collection\_id"\])

\# 3. Dense and BM25 search for clinical terms, then a cross-encoder rerank

retriever \= client.retrievers.create(

    retriever\_name\="mds-documentation",

    collection\_identifiers\=\["patient-charts"\],

    input\_schema\={"query": {"type": "text", "required": True}},

    stages\=\[

        {

            "stage\_name": "search",

            "stage\_id": "feature\_search",

            "parameters": {

                "searches": \[

                    {

                        "feature\_uri": "mixpeek://document\_graph\_extractor@v1/intfloat\_\_multilingual\_e5\_large\_instruct",

                        "query": {"input\_mode": "text", "value": "{{INPUT.query}}"},

                        "top\_k": 50,

                    },

                    {

                        "feature\_uri": "mixpeek://document\_graph\_extractor@v1/intfloat\_\_multilingual\_e5\_large\_instruct",

                        "query": {"input\_mode": "text", "value": "{{INPUT.query}}"},

                        "top\_k": 50,

                        "lexical": True,

                    },

                \],

                "fusion": "rrf",

                "final\_top\_k": 50,

            },

        },

        {

            "stage\_name": "rerank",

            "stage\_id": "rerank",

            "parameters": {

                "inference\_name": "BAAI\_\_bge\_reranker\_v2\_m3",

                "query": "{{INPUT.query}}",

                "document\_field": "text\_raw",

                "top\_k": 10,

            },

        },

    \],

)

results \= client.retrievers.execute(retriever\["retriever\_id"\], inputs\={"query": "functional mobility and ADL performance for Section G"})

for doc in results\["documents"\]:

    print(doc\["page\_number"\], doc\["confidence\_tag"\], doc\["text\_raw"\]\[:120\])

### Feature Extractors

Document Graph Extractor

Decompose PDFs into spatial blocks (paragraphs, tables, forms, headers) with layout classification and E5 text embeddings.

### Retriever Stages

feature search

Search and filter documents by vector similarity using feature embeddings

filter

rerank

Rerank documents using cross-encoder models for accurate relevance

sort

### Resources Used

Taxonomy

## Frequently asked questions

### Which MDS sections does this cover?

The taxonomy maps to all core MDS 3.0 sections including G (Functional Status), J (Health Conditions), K (Swallowing/Nutritional Status), M (Skin Conditions), N (Medications), O (Special Treatments), and Q (Participation in Assessment). Custom sections can be added to the taxonomy.

### Can it process wound photographs?

Yes. The image captioning extractor analyzes wound photos and generates structured descriptions including wound type, approximate dimensions, tissue characteristics, and healing stage, feeding directly into MDS Section M (Skin Conditions).

### How does it integrate with our EHR?

Use the FHIR R4 connector to pull clinical resources (DocumentReference, Observation, Condition) from your EHR into the Mixpeek pipeline. Alternatively, export documents to an S3-compatible bucket for batch processing.

### Is patient data protected?

Mixpeek can be deployed within your own VPC or on-premise environment. PHI never leaves your infrastructure. The pipeline supports BAA agreements and HIPAA-compliant deployment configurations.

## Use Cases Using This Recipe

Advanced

8 min

### SNF Documentation Intelligence

Automate MDS assessments and clinical documentation for skilled nursing facilities

40% less time on charting

Documentation time reduction

[

healthcare

](/solutions/healthcare)

Who It's For

SNF operators, MDS coordinators, directors of nursing, and post-acute care organizations managing clinical documentation across skilled nursing facilities

[View Details](/use-cases/snf-documentation-intelligence)

## Related code examples and resources

Pages on the same stages, extractors and patterns.

[

Extractor

### Document Graph Extractor

Decompose PDFs into spatial blocks (paragraphs, tables, forms, headers) with layout classification and E5 text embeddings.

Learn more





](/extractors/document-graph)[

Recipe

### Document Intelligence Search

Extract and search through PDFs, presentations, and documents. Combines OCR, layout analysis, and semantic search for comprehensive document retrieval.

Learn more





](/recipes/document-search-pipeline)[

Recipe

### BYO Embeddings Vector Search

Bring pre-computed embeddings from any provider (OpenAI, Cohere, Together, etc.) and upsert them directly into MVS for instant vector search. No feature extractors, no pipelines -- just embeddings in, results out.

Learn more





](/recipes/mvs-byo-embeddings-search)[

Recipe

### Multimodal Hybrid Search Pipeline

Combine vector search with keyword search (BM25) across text, images, and video for the most comprehensive multimodal retrieval system.

Learn more





](/recipes/multimodal-hybrid-search)[

Recipe

### Multimodal RAG Pipeline

Build a retrieval-augmented generation system that works with text, images, and video. Feed relevant multimodal context to LLMs for grounded responses.

Learn more





](/recipes/multimodal-rag-pipeline)[

Recipe

### Taxonomy Enrichment Pipeline

Automatically classify and tag content using custom taxonomies. Map your content to IAB categories, custom hierarchies, or industry-specific classifications.

Learn more





](/recipes/taxonomy-enrichment-pipeline)