A Python utility that converts MyChart health record exports (C-CDA XML format) into clean, LLM-friendly Markdown files — ideal for uploading to a Claude Project as context.
MyChart exports your health records as a zip file containing an IHE_XDM folder with XML documents in the C-CDA (Consolidated Clinical Document Architecture) format. This script:
- Finds all
DOC*.XMLfiles in the export folder structure - Parses each C-CDA document
- Extracts clinical sections into readable Markdown
- Writes one Markdown file per person (subfolder)
The converter handles a wide range of standard clinical sections, including:
- Allergies & Intolerances
- Medications (with dose, route, and frequency)
- Problems / Active Conditions (with onset dates)
- Procedures
- Lab Results (with reference ranges and abnormal flags)
- Vital Signs
- Social History
- Family History
- Immunizations
- Encounters / Visits
- Plan of Care, Assessment & Plan
- Discharge Medications, Discharge Diagnosis
- And more (any LOINC-coded C-CDA section)
For each section, it first tries to extract structured entry data, then falls back to the narrative text block if no structured entries are found.
Note: This converter does not include MyChart-based Test Results. Test results viewed directly in the MyChart portal are not part of the C-CDA export and will not appear in the generated Markdown files.
# Basic usage — output goes to <input_folder>/markdown_output/
python mychartToMarkdown.py ~/Downloads/MyChartExport
# Specify a custom output folder
python mychartToMarkdown.py ~/Downloads/MyChartExport ~/Desktop/health_recordsPoint the script at the unzipped MyChart export folder. It expects the standard IHE_XDM subfolder structure but will also search the folder directly if that structure isn't present.
One .md file per person found in the export (named <PersonFolder>_health_record.md). If multiple XML files exist for the same person, their sections are merged and deduplicated into a single file.
- Python 3.9+
- No third-party dependencies — uses only the standard library (
xml.etree.ElementTree,pathlib,re,datetime)
# Jane Smith
**Document Type:** Continuity of Care Document
**Date:** March 15, 2024
**Source:** Example Health System
**Date of Birth:** January 01, 1980
**Sex:** Female
---
## Medications
- **Lisinopril** — 10 mg via Oral (daily)
- **Metformin** — 500 mg via Oral (every 12 hourly)
## Allergies & Intolerances
- **Penicillin** → Rash (severity: Moderate)
## Problems / Active Conditions
- **Type 2 diabetes mellitus** (onset: June 01, 2018)
- **Essential hypertension** (onset: March 10, 2015)