Extracting Sdoh logo

Extracting Sdoh

CommunityPopular
maziyarpanahi
extracting-sdoh

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.

Overview

Publishermaziyarpanahi
Repositoryopenmed
Skill nameextracting-sdoh
Stars
5.3K
Forks
677
Bundled files
1
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by maziyarpanahi on GitHub. Read the source before you install it.

Installation

Install the Extracting Sdoh AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/maziyarpanahi/openmed.git /tmp/openmed
mkdir -p .claude/skills
cp -r /tmp/openmed/skills/extracting-sdoh .claude/skills/extracting-sdoh
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Extracting Sdoh in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Extracting Sdoh on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Extracting Sdoh is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Extracting Sdoh AI skill do?

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, f...

Why use Extracting Sdoh on TypingMind?

Because you install it once and use it with any model. Extracting Sdoh is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Extracting Sdoh in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/maziyarpanahi/openmed/tree/master/skills/extracting-sdoh. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Extracting Sdoh?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Extracting Sdoh?

As many as you like. As long as a model supports skills, you can use Extracting Sdoh with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Extracting Sdoh AI skill free?

Yes. It is published on GitHub by maziyarpanahi under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇