Agent skill

Extracting SDOH and Z-Codes

by maziyarpanahi in maziyarpanahi/openmed

Finds social risks such as housing instability or food insecurity in clinical notes and proposes matching ICD-10-CM Z-codes for a coder to confirm.

Apache-2.0Auto-check passedResearch & Science

Install Extracting SDOH and Z-Codes

skills CLI
$ npx skills add maziyarpanahi/openmed --skill extracting-sdoh -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install maziyarpanahi/openmed extracting-sdoh --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/maziyarpanahi/openmed.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/extracting-sdoh .claude/skills/extracting-sdoh && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
extracting-sdoh
GitHub stars
5.5k
Token cost
~1.9k tokens
SKILL.md length
725 words
Files
2 (incl. references)
Skills in repo
74
Repo updated
First seen
Licence
Apache-2.0

At a glance

Finds social risks such as housing instability or food insecurity in clinical notes and proposes matching ICD-10-CM Z-codes for a coder to confirm.

  • Works in 5 steps: De-identify the note with… → Extract entities with… → Map spans to Z-codes using a curated… → …
  • Turning social risks documented in clinical notes into structured, coded data
  • SKILL.md covers When to use, Quick start, Workflow and Hand-off to / from OpenMed, plus 2 more sections
  • Reaches hl7.org

What it does

Run after OpenMed named-entity recognition, this skill pulls social determinants of health out of free-text clinical notes and links each finding to a code in the ICD-10-CM Z55–Z65 range. Covered topics are housing instability, food insecurity, unemployment, transportation barriers, social isolation and financial strain.

The workflow de-identifies the note with openmed.deidentify, extracts entities with openmed.analyze_text (adding a zero-shot pass when the model lacks social labels), and maps spans to codes with a lookup in references/sdoh_zcode_map.md. Offsets and confidence stay attached so each suggestion traces back to its source text. Results are staged for human review: the skill proposes codes, a person assigns them, and individual inferences are kept out of coverage and pricing decisions.

When your agent uses it

  • Turning social risks documented in clinical notes into structured, coded data
  • Building health-equity dashboards that need SDOH as discrete fields
  • Finding SDOH that is written in the chart but was never given a Z-code

Example prompts

  • “Extract SDOH from these de-identified discharge notes and suggest Z-codes with source spans.”
  • “List every note in ./notes that mentions housing instability so a coder can check for missing Z-codes.”
  • “Find transportation barriers in the dialysis clinic notes and map them to Z-codes.”

Requirements

  • The OpenMed Python package
  • Clinical notes that have been de-identified first

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. De-identify the note with openmed.deidentify (HIPAA Safe Harbor or a
  2. Extract entities with openmed.analyze_text. Pick a model whose label
  3. Map spans to Z-codes using a curated lookup keyed by label
  4. Stage for confirmation. Emit (span, label, suggested_code, confidence)
  5. Normalize to value sets. Align labels to the Gravity Project SDOH

What it can do on your machine

Read from SKILL.md and the folder at commit 34d7b8c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • hl7.org

    Also links to:

    • cdc.gov
    • confluence.hl7.org
    • n2c2.dbmi.hms.harvard.edu
    • cms.gov
    • healthit.gov

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Extracting SDOH and Z-Codes loads about 1.9k tokens when it runs, and up to ~2.9k if it reads all its reference files. Until then it costs about 165 tokens; SKILL.md has 725 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~165
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from maziyarpanahi/openmed at commit 34d7b8c, republished under its Apache-2.0 licence (© maziyarpanahi). 725 words, ~1,860 tokens.

Download SKILL.mdSave it as .claude/skills/extracting-sdoh/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
extracting-sdoh
description
Extracts social determinants of health (SDOH) — housing instability, food insecurity, unemployment, transportation barriers, social isolation, financial strain — from clinical narrative and maps the spans to ICD-10-CM Z-codes (Z55–Z65). Use after running OpenMed NER when the user wants SDOH surfacing, Z-code suggestion, health-equity analytics, or to recover SDOH that is documented in free text but not coded. Pairs with OpenMed analyze_text output. Standards: ICD-10-CM Z55–Z65, Gravity Project value sets, n2c2 2022 SDOH track. Trigger keywords: SDOH, social determinants, Z-codes, housing, food insecurity, health equity, Gravity Project.
license
Apache-2.0
metadata.project
OpenMed
metadata.category
clinical-nlp
metadata.pairs
after
metadata.version
1.0

Extracting SDOH and Mapping to ICD-10-CM Z-Codes

Social determinants of health (SDOH) — the conditions in which people live, work, and age — drive an estimated 80% of health outcomes, yet they live almost entirely in free-text narrative. Multiple chart-review studies find SDOH documented in notes but coded with a Z-code under ~2% of the time. The information is there; the structured signal is not. This skill recovers it: run OpenMed NER over de-identified notes, then map the resulting spans to the ICD-10-CM Z55–Z65 family.

When to use

  • A note clearly describes a social risk ("lives in her car", "skips meals to afford insulin", "no ride to dialysis") and you want a coded, queryable signal.
  • You are building health-equity dashboards, risk stratification, or closed-loop referral feeds and need SDOH as discrete data.
  • You want to reconcile what the chart says against what was coded, and flag Z-code gaps for a coder or care team to confirm.

This is a decision-support step. It proposes Z-codes; a human assigns them. SDOH coding is sensitive — never expose individual SDOH inferences outside the care/coding workflow, and never feed them to coverage or pricing decisions.

Quick start

De-identify first, run NER, then map spans to Z-codes:

python
import openmed
from sdoh_zcode_map import SDOH_ZCODES  # see references/sdoh_zcode_map.md

note = (
    "62F with CHF. Reports she lost her apartment last month and is "
    "staying in a shelter. Often runs out of food before month-end. "
    "No car; misses appointments because the bus does not run to clinic."
)

# 1) Strip PHI before any downstream processing or storage.
deid = openmed.deidentify(note, method="replace", policy="hipaa_safe_harbor")

# 2) Run clinical NER. Use an SDOH/clinical model from the registry; discover
#    available keys with openmed.get_models_by_category(...).
result = openmed.analyze_text(deid.text, output_format="dict")

# 3) Map each entity span to a candidate Z-code.
for ent in result["entities"]:
    code = SDOH_ZCODES.get(ent["label"].lower())
    if code:
        print(f"{ent['text']!r:40}  {ent['label']:18}  -> {code}")

analyze_text returns entities shaped as {"text", "label", "confidence", "start", "end", "metadata"}. The start/end offsets index into the text you passed in, so you can anchor every suggested Z-code back to its exact source span for human review.

Workflow

  1. De-identify the note with openmed.deidentify (HIPAA Safe Harbor or a stricter policy). SDOH text is dense with PHI (addresses, employer names).
  2. Extract entities with openmed.analyze_text. Pick a model whose label set covers social concepts; if your model only emits clinical findings, run a second pass with a zero-shot model (openmed zero) using SDOH labels such as housing_instability, food_insecurity, unemployment, transportation_barrier, social_isolation, financial_strain.
  3. Map spans to Z-codes using a curated lookup keyed by label (references/sdoh_zcode_map.md). Keep the span offsets and the model confidence on every suggestion.
  4. Stage for confirmation. Emit (span, label, suggested_code, confidence) tuples for a coder or the Gravity Project pipeline to accept or reject. Do not auto-bill a Z-code from an inference alone.
  5. Normalize to value sets. Align labels to the Gravity Project SDOH domains so codes are interoperable with FHIR (Condition, Observation, Goal) and USCDI v3 SDOH elements.
Z-code families you will hit most (ICD-10-CM Z55–Z65)
DomainRangeExample
Education / literacyZ55Z55.0 illiteracy
EmploymentZ56Z56.0 unemployment
Occupational exposureZ57—
Housing / economicZ59Z59.0 homelessness, Z59.41 food insecurity, Z59.82 transportation insecurity
Social environmentZ60Z60.2 living alone, Z60.4 social exclusion
UpbringingZ62—
Family / support circumstancesZ63Z63.4 disappearance/death of family member
Psychosocial circumstancesZ64–Z65Z65.1 imprisonment

The full curated label→code table lives in references/sdoh_zcode_map.md.

Show full SKILL.md (275 more words)Show less

Hand-off to / from OpenMed

  • From OpenMed: this skill consumes openmed.analyze_text(...) output (PredictionResult dict). Each entity["start"]/["end"] anchors a Z-code suggestion to source text.
  • To OpenMed: always run openmed.deidentify upstream so no raw PHI reaches the SDOH store, logs, or coder queue.
  • Onward: emit suggestions into a FHIR Condition/Observation with the Z-code as code.coding (system http://hl7.org/fhir/sid/icd-10-cm). OpenMed's openmed.clinical.exporters.fhir helpers (to_bundle, to_operation_outcome) assemble the envelope; ICD-10-CM itself is public-domain in the US release.

Edge cases & gotchas

  • Negation and history. "Denies food insecurity" or "previously homeless, now housed" must not produce an active Z-code. Run negation/temporality resolution (openmed.clinical, resolving-clinical-context) before mapping.
  • Hypotheticals and screening prompts. Template text ("Do you have stable housing?") and family-member SDOH ("his mother is unhoused") are common false positives — check the subject and modality.
  • One span, one domain. Do not stack multiple Z-codes onto one phrase; map to the most specific single code and let the coder add others.
  • Granularity drift. ICD-10-CM adds SDOH codes most fiscal years (e.g. Z59.4x food, Z59.82 transportation). Pin your code set to a release year and re-validate annually.
  • Do not infer protected attributes. Surface only what the note states; never derive race, immigration status, or income bracket as an SDOH "finding".
  • Restricted terminology. SNOMED CT SDOH refsets and LOINC SDOH panels are licensed separately — OpenMed does not bundle them; load the user's own copy out-of-process if you cross-map beyond ICD-10-CM.

Standards & references

© maziyarpanahi, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in skills/extracting-sdoh of maziyarpanahi/openmed.

  • SKILL.md
  • references/sdoh_zcode_map.md

Open the folder on GitHubat commit 34d7b8c

Compare with similar skills

Extracting SDOH and Z-Codes next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Extracting SDOH and Z-Codes compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Extracting SDOH and Z-Codes this skillmaziyarpanahi/openmed5.5k—~1.9kAutomated safety check: PassApache-2.0
pydicom DICOM Toolkitdavila7/claude-code-templates33k11 repos~3.3kAutomated safety check: PassMIT
Histolab Whole Slide Image Tilingdavila7/claude-code-templates33k11 repos~5.1kAutomated safety check: PassMIT
NeuroKit2 Biosignal Processingdavila7/claude-code-templates33k11 repos~3kAutomated safety check: PassMIT
PyHealth Clinical ML Toolkitdavila7/claude-code-templates33k11 repos~4.4kAutomated safety check: PassMIT
Topic Model ConsolidationTyrealQ/q-skills108—~1kAutomated safety check: PassMIT

Similar skills

  • pydicom DICOM Toolkit

    davila7/claude-code-templates

    Reads, edits, anonymizes and converts DICOM medical imaging files with pydicom, including pixel data extraction and compressed transfer syntaxes.

    33k GitHub starsUsed in 11 repos~3.3k tokens
    Research & ScienceAuto-check passed
  • Histolab Whole Slide Image Tiling

    davila7/claude-code-templates

    Processes digital pathology whole slide images with histolab: tissue detection, mask creation, tile extraction and dataset preparation for deep learning.

    33k GitHub starsUsed in 11 repos~5.1k tokens
    Research & ScienceAuto-check passed
  • NeuroKit2 Biosignal Processing

    davila7/claude-code-templates

    Processes physiological signals with NeuroKit2 in Python: ECG, PPG, EEG, EDA, respiration, EMG and EOG, including HRV, events and complexity measures.

    33k GitHub starsUsed in 11 repos~3k tokens
    Research & ScienceAuto-check passed
  • PyHealth Clinical ML Toolkit

    davila7/claude-code-templates

    Builds machine learning pipelines on clinical data with PyHealth: EHR datasets, prediction tasks, medical code mapping, healthcare models and evaluation.

    33k GitHub starsUsed in 11 repos~4.4k tokens
    Research & ScienceAuto-check passed
  • Consolidates BERTopic, LDA or NMF topic output into a theory-driven classification framework and writes the final labels back to an Excel file.

    108 GitHub stars~1k tokensUpdated 17 days ago
    Research & ScienceAuto-check passed
  • Gtars

    K-Dense-AI/scientific-agent-skills

    Supports Gtars for local genomic interval models and set algebra, overlaps and counts, consensus and coverage, tokenization, fragment processing, and refget/BEDbase planning across Python, Rust, and…

    48k GitHub starsUsed in 1 repo~3.8k tokens
    Research & ScienceAuto-check: notes

More from maziyarpanahi/openmed

All 74 skills in this repo
  • Checks OpenMed de-identified clinical text against the 18 HIPAA Safe Harbor identifier categories and reports gaps and residual re-identification risk.

    5.5k GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • OpenMed Model Card Writer

    maziyarpanahi/openmed

    Fills in a model card for an OpenMed clinical NER or de-identification model from its evaluation reports: intended use, metrics, subgroups and limitations.

    5.5k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Walks a data pipeline against the HIPAA Privacy and Security Rule checklist and produces a gap report before it processes patient data.

    5.5k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • ICD-10 Coding Assistant

    maziyarpanahi/openmed

    Suggests candidate ICD-10-CM diagnosis and ICD-10-PCS procedure codes for clinical text extracted by OpenMed, with rationale for a certified coder to review.

    5.5k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • OpenMed ETL to OMOP CDM

    maziyarpanahi/openmed

    Maps OpenMed-extracted, terminology-coded conditions, drugs and measurements into OMOP CDM v5.4 tables for OHDSI and ATLAS analytics.

    5.5k GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Clinical Document Ingestion

    maziyarpanahi/openmed

    Converts scanned faxes, images, CSV/TSV exports and C-CDA XML into clean text on-device, ready for OpenMed de-identification and named-entity recognition.

    5.5k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Questions about Extracting SDOH and Z-Codes

What does Extracting SDOH and Z-Codes do?

Finds social risks such as housing instability or food insecurity in clinical notes and proposes matching ICD-10-CM Z-codes for a coder to confirm. Run after OpenMed named-entity recognition, this skill pulls social determinants of health out of free-text clinical notes and links each finding to a code in the ICD-10-CM Z55–Z65 range. Covered topics are housing instability, food insecurity, unemployment, transportation barriers, social isolation and financial strain.

When should I use Extracting SDOH and Z-Codes?

Extracting SDOH and Z-Codes fits situations like: turning social risks documented in clinical notes into structured, coded data; building health-equity dashboards that need SDOH as discrete fields; finding SDOH that is written in the chart but was never given a Z-code.

How do I install Extracting SDOH and Z-Codes in Claude Code?

Run `npx skills add maziyarpanahi/openmed --skill extracting-sdoh -a claude-code`. Or copy the skill folder (skills/extracting-sdoh in maziyarpanahi/openmed) into .claude/skills/extracting-sdoh in your project. Claude Code loads it when a task matches its description.

How do I install Extracting SDOH and Z-Codes in Codex?

Run `npx skills add maziyarpanahi/openmed --skill extracting-sdoh -a codex`. Or copy the skill folder (skills/extracting-sdoh in maziyarpanahi/openmed) into .agents/skills/extracting-sdoh in your project. Codex loads it when a task matches its description.

Can I use Extracting SDOH and Z-Codes in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add maziyarpanahi/openmed --skill extracting-sdoh -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/extracting-sdoh, .gemini/skills/extracting-sdoh, .github/skills/extracting-sdoh and .opencode/skills/extracting-sdoh in your project.

What does Extracting SDOH and Z-Codes need to run?

SKILL.md names no scripts, command-line tools or credentials: Extracting SDOH and Z-Codes is instructions for the agent only. Our summary lists: The OpenMed Python package; Clinical notes that have been de-identified first.

Does Extracting SDOH and Z-Codes access the network?

SKILL.md names 6 domains. In commands or code: hl7.org; the agent is likely to contact it when it follows the instructions. As links in the text: cdc.gov, confluence.hl7.org, n2c2.dbmi.hms.harvard.edu, cms.gov and healthit.gov. This is read from the text; nothing was executed.

Is Extracting SDOH and Z-Codes safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Extracting SDOH and Z-Codes use?

Extracting SDOH and Z-Codes is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Extracting SDOH and Z-Codes use?

About 1.9k tokens (SKILL.md is roughly 7.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1k tokens, read only when the agent opens those files.

What are the alternatives to Extracting SDOH and Z-Codes?

Skills that share tags, products or a category with Extracting SDOH and Z-Codes: pydicom DICOM Toolkit (davila7/claude-code-templates, 33k stars), Histolab Whole Slide Image Tiling (davila7/claude-code-templates, 33k stars), NeuroKit2 Biosignal Processing (davila7/claude-code-templates, 33k stars) and PyHealth Clinical ML Toolkit (davila7/claude-code-templates, 33k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Extracting SDOH and Z-Codes?

maziyarpanahi (a GitHub user) maintains it in maziyarpanahi/openmed, which has 5,506 GitHub stars. The repository holds 74 skills in this directory. The repository was last updated on October 11, 2026.

Source: maziyarpanahi/openmed on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.