Skip to content

ericpullen/mychartMarkdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MyChart to Markdown Converter

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.

What It Does

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:

  1. Finds all DOC*.XML files in the export folder structure
  2. Parses each C-CDA document
  3. Extracts clinical sections into readable Markdown
  4. Writes one Markdown file per person (subfolder)

Extracted Sections

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.

Usage

# 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_records

Input

Point 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.

Output

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.

Requirements

  • Python 3.9+
  • No third-party dependencies — uses only the standard library (xml.etree.ElementTree, pathlib, re, datetime)

Example Output

# 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)

About

Convert Epic MyChart download (exports) to Markdown

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages