मुख्य सामग्री पर जाएँ
Skillpedia
एनालिसिस और स्प्रेडशीट5.8k · #14716

parsing-hl7v2-messages

यह क्या करती है

यह स्किल एजेंट को सिखाती है कि HL7 v2 संदेश कैसे पढ़ें, जो पाइप से अलग किया गया वह फ़ॉर्मैट है जिसे अस्पताल लैब नतीजों और मरीज़ घटनाओं के लिए इस्तेमाल करते हैं। यह फ़्री-टेक्स्ट नोट निकालती है ताकि उनकी समीक्षा हो सके।

कब इस्तेमाल करें

  • ✓जब उपयोगकर्ता को इंटरफ़ेस फ़ीड से लैब या अस्पताल संदेश मिलते हैं और उनके अंदर का नोट टेक्स्ट चाहिए।
  • ✓जब उपयोगकर्ता लैब रिपोर्ट संदेश की नतीजा टिप्पणियाँ पढ़ने योग्य टेक्स्ट में चाहता है।
  • ✓जब उपयोगकर्ता को MDM संदेश से ट्रांसक्राइब की गई रिपोर्ट उसके कोड से अलग चाहिए।

Skill का लिंक

https://github.com/maziyarpanahi/openmed/blob/master/skills/parsing-hl7v2-messages/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/maziyarpanahi/openmed/blob/master/skills/parsing-hl7v2-messages/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“क्या आप मेरे अस्पताल फ़ीड के HL7 संदेशों से लैब टिप्पणियाँ और नोट्स निकाल सकते हैं?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट हर संदेश को सेगमेंट और फ़ील्ड में बाँटता है, फिर OBX और NTE नामक नोट फ़ील्ड पढ़ता है। उनमें मिला सादा टेक्स्ट लौटाता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

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:

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:

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.

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, `HL7
अक्सर पूछे जाने वाले सवाल

HL7 v2 क्या है?

यह एक आम संदेश फ़ॉर्मैट है, जिसे अस्पताल सिस्टम लैब नतीजे, भर्ती और ऑर्डर के आदान-प्रदान के लिए इस्तेमाल करते हैं।

क्या मुझे फ़ील्ड कोड जानने होंगे?

नहीं। एजेंट लेआउट जानता है और टेक्स्ट फ़ील्ड को सरल भाषा में बताता है।

कौन-से संदेश प्रकार कवर होते हैं?

स्किल ADT, ORU, MDM और ORM जैसे आम प्रकार कवर करती है।

जानकारी

लेखक का मूल विवरण

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 r

repo: maziyarpanahi/openmed

लोकप्रियता

GitHub स्टार
5.8k
रैंकिंग में स्थान
#14716
लाइसेंस
Apache-2.0
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

annotating-variants

5.8k

आपके एजेंट को मुफ़्त सार्वजनिक एनोटेटर से जेनेटिक वेरिएंट का असर बताने, HGVS नामों को जीनोम पोज़िशन में बदलने और जनसंख्या आवृत्ति जोड़ने में मदद करती है।

डेटाएनालिसिस और स्प्रेडशीट

ask-openmed

5.8k

आपके एजेंट को क्लिनिकल टेक्स्ट अनुरोध के लिए सही OpenMed वर्कफ़्लो चुनने में मदद करती है, जहाँ मरीज़ का डेटा हो सकता है वहाँ पहले गोपनीयता जाँच से शुरू करके।

अन्यविविध

assembling-fhir-bundles

5.8k

कई FHIR स्वास्थ्य रिकॉर्ड को एक ट्रांज़ैक्शन Bundle में पैक करती है, जो EHR को भेजने के लिए तैयार हो और आंतरिक संदर्भ सही जुड़े हों।

डेटाडेटाबेस

auditing-deid-leakage

5.8k

डी-आइडेंटिफ़ाइड क्लिनिकल टेक्स्ट में बचे पहचानकर्ता जैसे SSN, कार्ड नंबर, ईमेल और तारीखें खोजती है, और कुछ बचा हो तो रिलीज़ रोक देती है।

कोडिंगसिक्योरिटी

मिलती-जुलती skills