Agent skill

Parsing Hl7v2 Messages

by maziyarpanahi in maziyarpanahi/openmed

Decodes pipe-delimited HL7 v2.x messages (ADT, ORU, MDM, ORM) into structured segments/fields/components and surfaces OBX-5 and NTE-3 free-text narrative for OpenMed.

Apache-2.0Auto-check passedDatabases

Install Parsing Hl7v2 Messages

skills CLI
$ npx skills add maziyarpanahi/openmed --skill parsing-hl7v2-messages -a claude-code

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

GitHub CLI
$ gh skill install maziyarpanahi/openmed parsing-hl7v2-messages --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/parsing-hl7v2-messages .claude/skills/parsing-hl7v2-messages && 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
parsing-hl7v2-messages
GitHub stars
5.5k
Token cost
~1.8k tokens
SKILL.md length
580 words
Files
1
Skills in repo
74
Repo updated
First seen
Licence
Apache-2.0

At a glance

Decodes pipe-delimited HL7 v2.x messages (ADT, ORU, MDM, ORM) into structured segments/fields/components and surfaces OBX-5 and NTE-3 free-text narrative for OpenMed.

  • Works in 5 steps: Frame-split safely. Real feeds use \r,… → Read encoding from MSH — never assume… → Locate narrative. OBX-5 (gated by OBX-2… → …
  • Interface engine
  • SKILL.md covers When to use, HL7 v2 structure in one minute, Quick start and Whole-message segment-aware…, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Parsing Hl7v2 Messages is an agent skill from maziyarpanahi/openmed. Decodes pipe-delimited HL7 v2.x messages (ADT, ORU, MDM, ORM) into structured segments/fields/components and surfaces OBX-5 and NTE-3 free-text narrative for OpenMed. Use before OpenMed processing when ingesting HL7 v2 feeds from an interface engine, lab/results system, or ADT stream and you need the embedded clinical note text de-identified and analyzed. Flatten OBX/NTE text then call openmed.deidentify and openmed.analyzetext; segment-aware redaction is available via openmed.interop.hl7v2. Trigger keywords…

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering ORMs and data access. The repository describes itself as: Local-first healthcare AI: clinical NER and HIPAA PII de-identification on hardware you control. 2,200+ medical models, 35 model-backed PII languages, and Python, MLX, Android… The licence is Apache-2.0.

When your agent uses it

  • Interface engine
  • Tasks that involve ORMs and data access

Example prompts

  • “Use the parsing-hl7v2-messages skill to decode pipe-delimited HL7 v2.x messages (ADT, ORU, MDM, ORM) into structured segments/fields/components and…”
  • “/parsing-hl7v2-messages”

Requirements

  • Python 3

Workflow steps

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

  1. Frame-split safely. Real feeds use \r, \r\n, or MLLP framing
  2. Read encoding from MSH — never assume |^~\&. The adapter derives the
  3. Locate narrative. OBX-5 (gated by OBX-2 value type), NTE-3, and
  4. De-identify, then analyze with OpenMed.
  5. Rejoin results to the patient/encounter via PID-3 (patient id) and

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

    Links to these hosts (documentation or services it may open):

    • hl7.org
    • hl7-definition.caristix.com

    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

Parsing Hl7v2 Messages loads about 1.8k tokens when it runs. Until then it costs about 158 tokens; SKILL.md has 580 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~158
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

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). 580 words, ~1,759 tokens.

Download SKILL.mdSave it as .claude/skills/parsing-hl7v2-messages/SKILL.md (or your agent's skills folder).
name
parsing-hl7v2-messages
description
Decodes pipe-delimited HL7 v2.x messages (ADT, ORU, MDM, ORM) into structured segments/fields/components and surfaces OBX-5 and NTE-3 free-text narrative for OpenMed. Use before OpenMed processing when ingesting HL7 v2 feeds from an interface engine, lab/results system, or ADT stream and you need the embedded clinical note text de-identified and analyzed. Flatten OBX/NTE text then call openmed.deidentify and openmed.analyze_text; segment-aware redaction is available via openmed.interop.hl7v2. Trigger keywords: HL7, HL7 v2, ADT, ORU, OBX, MSH, PID, pipe-delimited, interface engine, Mirth, lab results.
license
Apache-2.0
metadata.project
OpenMed
metadata.category
data-ingestion
metadata.pairs
before
metadata.version
1.0

Parsing HL7 v2 Messages for OpenMed

HL7 v2.x is the workhorse of hospital interfacing — ADT (admit/discharge/ transfer), ORU (observation results), MDM (document management), and ORM (orders) messages flow continuously between EHR, lab, radiology, and ancillary systems. The clinical narrative you want for NLP is buried in OBX-5 (observation value) and NTE-3 (notes/comments) fields, wrapped in a pipe-and-caret encoding. This skill decodes that envelope and hands the free text to OpenMed.

When to use

  • You receive HL7 v2 messages from an interface engine (Mirth/NextGen Connect, Rhapsody, Cloverleaf) and want to mine embedded note/result text.
  • A lab feed (ORU^R01) carries impression/comment narrative in OBX/NTE.
  • An MDM^T02 transcription message carries a full report in OBX-5.
  • You need a de-identified, structured feed into openmed.analyze_text.

HL7 v2 structure in one minute

A message is segments separated by \r (carriage return). Each segment is 3-letter-named, then fields split by |, components by ^, repetitions by ~, sub-components by &, with \ as escape. The encoding characters are declared in **MSH-1** (the field separator) and **MSH-2** (^~\&). Field positions are one-based, and MSH is special: MSH-1 is the separator, so MSH-2 is the first real field.

MSH|^~\&|LAB|HOSP|EHR|HOSP|20240302101500||ORU^R01|MSG0001|P|2.5
PID|1||MRN12345^^^HOSP^MR||DOE^JANE^Q||19700115|F|||1 FAKE ST^^SPRINGFIELD^IL^62704
OBR|1||ORD9|CBC^Complete Blood Count
OBX|1|TX|IMPRESSION||Mild leukocytosis; clinically correlate.||||||F
NTE|1||Patient reports fatigue x1 week. Dr. Smith notified.

Quick start

Parse the envelope and pull narrative from OBX-5 / NTE-3, then hand off:

python
import openmed
from openmed.interop.hl7v2 import parse_hl7v2

raw = open("results.hl7", encoding="utf-8").read()
msg = parse_hl7v2(raw)               # -> HL7Message (segments preserved)

narrative_chunks = []
for seg in msg.segments:
    if seg.name == "OBX":
        # OBX-2 is the value type; OBX-5 is the observation value.
        value_type = seg.get_field(2)
        if value_type in {"TX", "FT", "CE", "ST"}:
            narrative_chunks.append(seg.get_field(5) or "")
    elif seg.name == "NTE":
        narrative_chunks.append(seg.get_field(3) or "")

# Decode component delimiters into plain text before NLP.
flat = "\n".join(c.replace("^", " ").replace("&", " ") for c in narrative_chunks if c)

# Hand the narrative to OpenMed.
deid = openmed.deidentify(flat, method="replace", policy="hipaa_safe_harbor")
result = openmed.analyze_text(deid.text, output_format="dict")

HL7Segment.get_field(position) uses one-based HL7 positions and returns None for absent fields. HL7Message.segment_names() lists segments in order.

Whole-message segment-aware de-identification

When you need to redact the entire message (structured PID/NK1/GT1 fields and OBX/NTE free text) while preserving HL7 framing, use the bundled redactor instead of hand-rolling it:

python
from openmed.interop.hl7v2 import redact_hl7v2

safe = redact_hl7v2("results.hl7")   # path or message text
# PID-3 hashed, PID-5 name surrogated, PID-7 DOB date-shifted, OBX-5/NTE-3
# free text masked via openmed.deidentify — delimiters and segment order kept.

redact_hl7v2 applies DEFAULT_FIELD_MAP (PID, PD1, NK1, GT1, IN1/IN2, OBX, NTE). Extend or override it with field_map={("ZPS", 4): {"action": "hash"}} for site-specific Z-segments, and pass date_shift_days= for a fixed, interval-preserving shift.

Workflow

  1. Frame-split safely. Real feeds use \r, \r\n, or MLLP framing (\x0b…\x1c\r). parse_hl7v2 auto-detects the segment separator; strip MLLP control bytes before parsing.
  2. Read encoding from MSH — never assume |^~\&. The adapter derives the delimiter set from MSH-1/MSH-2 (HL7V2Encoding.from_msh_segment).
  3. Locate narrative. OBX-5 (gated by OBX-2 value type), NTE-3, and report-bearing segments. Concatenate repetitions (~) and components (^).
  4. De-identify, then analyze with OpenMed.
  5. Rejoin results to the patient/encounter via PID-3 (patient id) and PV1-19 (visit number) — but redact those identifiers in anything you persist.
Show full SKILL.md (222 more words)Show less

Hand-off to / from OpenMed

  • To OpenMed: flattened OBX-5/NTE-3 text → openmed.deidentify → openmed.analyze_text.
  • Adapter: openmed.interop.hl7v2 provides parse_hl7v2, redact_hl7v2, HL7Message, HL7Segment, HL7V2Encoding, HL7FieldRule, and DEFAULT_FIELD_MAP for segment-aware de-id that preserves message framing. It is parse-and-redact only — not a conformance validator.
  • Re-link by id, not by PHI: carry PID-3/PV1-19 as keys, but store hashed or surrogate values (the default redact_hl7v2 hashes PID-3).

Edge cases & gotchas

  • MLLP wrapper. Messages off a TCP MLLP listener are framed with \x0b (start) and \x1c\r (end). Strip these before parse_hl7v2.
  • Escape sequences. \F\, \S\, \T\, \R\, \E\ encode literal delimiters, and \.br\ is a line break inside OBX text. Unescape before NLP.
  • Repeating OBX. A single result can span many OBX segments (one line each); reassemble in order before summarizing.
  • Value types matter. Only treat OBX-5 as narrative when OBX-2 is a text type (TX, FT, ST, CE); numeric (NM) and coded-only values are not free text. The default redactor restricts free-text redaction to FT/TX.
  • Z-segments. Site-defined Z* segments often carry extra PHI; add explicit field_map rules — they are not in the default map.
  • Versions vary. v2.3 through v2.8 differ in field cardinality; resolve positions against MSH-12 (version id), don't hardcode across versions.

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

Just SKILL.md in skills/parsing-hl7v2-messages of maziyarpanahi/openmed.

Open the folder on GitHubat commit 34d7b8c

Compare with similar skills

Parsing Hl7v2 Messages 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.

Parsing Hl7v2 Messages compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Parsing Hl7v2 Messages this skillmaziyarpanahi/openmed5.5k—~1.8kAutomated safety check: PassApache-2.0
Content Create Hero Imageprisma/web1.1k—~6.9kAutomated safety check: PassNone
Sea Orm 2FlyinPancake/yoink112—~2.9kAutomated safety check: PassApache-2.0
Prisma Client APIcurvenote/curvenote1702 repos~1.6kAutomated safety check: PassMIT
DB Migratesimstudioai/sim30k—~2kAutomated safety check: PassApache-2.0
Specromeerez/orchid-orm543—~2kAutomated safety check: PassMIT

Similar skills

  • Official

    A skill your agent uses when the operator wants a hero or meta image for a Prisma blog post; asks to create or generate a blog hero, cover, social card, Open Graph, or YouTube image; mentions cover…

    1.1k GitHub stars~6.9k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Sea Orm 2

    FlyinPancake/yoink

    Expert guidance for SeaORM 2.0, Rust's async ORM with strongly-typed columns, nested ActiveModels, Entity Loader API, and entity-first workflow.

    112 GitHub stars~2.9k tokensUpdated 6 days ago
    DatabasesAuto-check passed
  • Prisma Client API

    curvenote/curvenote

    Prisma Client API reference covering model queries, filters, operators, and client methods.

    170 GitHub starsUsed in 2 repos~1.6k tokens
    DatabasesAuto-check passed
  • DB Migrate

    simstudioai/sim

    Author or review a Drizzle DB migration for zero-downtime safety — expand/contract phasing, backward-compatibility with the deployed app version, and writing the -- migration-safe acknowledgment the…

    30k GitHub stars~2k tokensUpdated today
    DatabasesAuto-check passed
  • Spec

    romeerez/orchid-orm

    A skill your agent uses when the user prompts "write spec" or "make spec".

    543 GitHub stars~2k tokensUpdated yesterday
    DatabasesAuto-check passed
  • DB Migrations

    kurealnum/dotfiles

    A skill your agent uses when generating or regenerating Drizzle migration files, changing database schema tables or columns, resolving migration sequence conflicts after rebase, reviewing migration…

    290 GitHub stars~820 tokensUpdated 6 mo ago
    DatabasesAuto-check passed

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
  • Extracting SDOH and Z-Codes

    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.

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

Categories

Questions about Parsing Hl7v2 Messages

What does Parsing Hl7v2 Messages do?

Decodes pipe-delimited HL7 v2.x messages (ADT, ORU, MDM, ORM) into structured segments/fields/components and surfaces OBX-5 and NTE-3 free-text narrative for OpenMed. Parsing Hl7v2 Messages is an agent skill from maziyarpanahi/openmed.x messages (ADT, ORU, MDM, ORM) into structured segments/fields/components and surfaces OBX-5 and NTE-3 free-text narrative for OpenMed.

When should I use Parsing Hl7v2 Messages?

Parsing Hl7v2 Messages fits situations like: interface engine; tasks that involve ORMs and data access.

How do I install Parsing Hl7v2 Messages in Claude Code?

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

How do I install Parsing Hl7v2 Messages in Codex?

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

Can I use Parsing Hl7v2 Messages 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 parsing-hl7v2-messages -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/parsing-hl7v2-messages, .gemini/skills/parsing-hl7v2-messages, .github/skills/parsing-hl7v2-messages and .opencode/skills/parsing-hl7v2-messages in your project.

What does Parsing Hl7v2 Messages need to run?

SKILL.md names no scripts, command-line tools or credentials: Parsing Hl7v2 Messages is instructions for the agent only. Our summary lists: Python 3.

Does Parsing Hl7v2 Messages access the network?

SKILL.md names 2 domains. As links in the text: hl7.org and hl7-definition.caristix.com. This is read from the text; nothing was executed.

Is Parsing Hl7v2 Messages 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 Parsing Hl7v2 Messages use?

Parsing Hl7v2 Messages 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 Parsing Hl7v2 Messages use?

About 1.8k tokens (SKILL.md is roughly 7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Parsing Hl7v2 Messages?

Skills that share tags, products or a category with Parsing Hl7v2 Messages: Content Create Hero Image (prisma/web, 1.1k stars), Sea Orm 2 (FlyinPancake/yoink, 112 stars), Prisma Client API (curvenote/curvenote, 170 stars) and DB Migrate (simstudioai/sim, 30k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Parsing Hl7v2 Messages?

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.