본문으로 건너뛰기
Skillpedia
분석 및 스프레드시트5.8k · #14715

parsing-ccda-documents

하는 일

이 스킬은 에이전트에게 C-CDA 파일을 여는 방법을 가르칩니다. C-CDA는 의무기록 시스템에서 내보낸 XML 파일입니다. 각 섹션에서 읽을 수 있는 서술 내용을 찾아 검토하거나 분석할 수 있게 합니다.

사용하는 경우

  • ✓사용자가 C-CDA 또는 CCD 형식의 환자 차트 내보내기를 가지고 있고 작성된 노트가 필요할 때.
  • ✓임상 XML 파일에서 섹션별로 나뉜 퇴원 요약이나 병력 텍스트를 얻고 싶을 때.
  • ✓분석 전에 비식별화를 위해 노트 텍스트를 준비해야 할 때.

스킬 링크

https://github.com/maziyarpanahi/openmed/blob/master/skills/parsing-ccda-documents/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/maziyarpanahi/openmed/blob/master/skills/parsing-ccda-documents/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“병원에서 내보낸 C-CDA 파일에서 작성된 노트를 섹션별로 뽑아 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 파일의 XML 구조를 읽고, 각 섹션을 찾아 사람이 읽을 수 있는 텍스트를 돌려줍니다. 코드화된 항목은 따로 유지합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Parsing C-CDA / CCD Documents for OpenMed

C-CDA (Consolidated Clinical Document Architecture) is the XML document standard behind Meaningful Use / ONC certification — the CCD, Discharge Summary, History & Physical, and Consultation Note you get when an EHR "exports a chart". Each document is a ClinicalDocument with a header (patient, authors, encounter) and a structuredBody of sections. Every section has two representations: a human-readable narrative <text> block and machine-readable coded entries. The narrative is what you feed to clinical NLP. This skill extracts it and hands it to OpenMed.

When to use

  • You receive C-CDA R2.1 / CCD documents (Direct messaging, patient portal export, HIE) and want the free-text section narrative for de-id and NER.
  • You need to pair narrative spans with the section they came from (problems, meds, allergies, results, plan, H&P narrative).
  • You want XML-safe de-identification that keeps the document parseable.

C-CDA structure in one minute

<ClinicalDocument xmlns="urn:hl7-org:v3">
  <recordTarget><patientRole>
    <id extension="12345" root="..."/>
    <patient><name><given>Jane</given><family>Doe</family></name>
      <birthTime value="19700115"/></patient>
  </patientRole></recordTarget>
  <component><structuredBody>
    <component><section>
      <templateId root="2.16.840.1.113883.10.20.22.2.5.1"/>   <!-- Problems -->
      <code code="11450-4" codeSystem="2.16.840.1.113883.6.1"/> <!-- LOINC -->
      <title>Problems</title>
      <text>Active problems: Type 2 diabetes, hypertension.</text>  <!-- narrative -->
      <entry>...coded SNOMED/ICD entries...</entry>
    </section></component>
  </structuredBody></component>
</ClinicalDocument>

Sections are identified by templateId/@root and by section code (LOINC). The CDA namespace is urn:hl7-org:v3.

Quick start

Extract section narrative by LOINC code, then hand off to OpenMed:

import openmed
from xml.etree import ElementTree as ET

NS = {"hl7": "urn:hl7-org:v3"}
SECTION_LOINC = {
    "11450-4": "problems", "10160-0": "medications", "48765-2": "allergies",
    "30954-2": "results",  "18776-5": "plan",        "10164-2": "hpi",
    "8648-8": "hospital_course", "11488-4": "consult_note",
}

root = ET.parse("ccd.xml").getroot()
for section in root.findall(".//hl7:section", NS):
    code_el = section.find("hl7:code", NS)
    loinc = code_el.get("code") if code_el is not None else None
    text_el = section.find("hl7:text", NS)
    if text_el is None:
        continue
    narrative = "".join(text_el.itertext()).strip()       # flatten narrative block
    if not narrative:
        continue

    deid = openmed.deidentify(narrative, method="replace", policy="hipaa_safe_harbor")
    result = openmed.analyze_text(deid.text, output_format="dict")
    section_name = SECTION_LOINC.get(loinc, loinc)
    # attach (section_name, result) for downstream consumers

"".join(text_el.itertext()) flattens the narrative block (which may contain <paragraph>, <list>, <table>, <content> markup) into plain text.

XML-aware whole-document de-identification

When you need to redact PHI from the document (header ids, names, addresses, dates) while keeping the CDA XML valid and parseable, use the bundled adapter rather than regexing the raw XML:

from openmed.interop.cda import redact_cda, is_cda_document

if is_cda_document("ccd.xml"):
    safe_xml = redact_cda("ccd.xml")     # returns redacted XML string

redact_cda applies DEFAULT_PHI_ELEMENT_MAP (patient id hashed, name/address/ telecom null-flavored, birthTime and effectiveTime date-shifted) to header elements and sweeps section narrative text — operating on text nodes only so surrounding markup stays intact. Pass text_redactor= to plug an extra free-text callback (e.g. an openmed.deidentify wrapper), date_shift_days= for a fixed shift, and keep_year=True to preserve years.

Workflow

  1. Confirm it's CDA. is_cda_document(...) checks for a ClinicalDocument root. Reject XML with DOCTYPE/ENTITY declarations (XXE risk) — the adapter does this for you.
  2. Read the header for context: patient, author, effectiveTime, documentType (ClinicalDocument/code LOINC). Treat all header values as PHI.
  3. Walk sections by templateId or section code (LOINC). Map to your section vocabulary.
  4. Flatten narrative <text> with itertext(); preserve the secti
자주 묻는 질문

이것을 쓰려면 XML을 알아야 하나요?

아니요. 에이전트가 파일 형식을 처리하므로 내보낸 파일만 주면 됩니다.

어떤 종류의 문서와 함께 쓸 수 있나요?

C-CDA R2.1 문서, 즉 CCD, 퇴원 요약, 병력 및 신체 검진 노트, 진료 의뢰 노트를 위해 작성되었습니다.

이 스킬이 비식별화를 대신하나요?

아니요. 스킬은 다음 단계로 섹션 텍스트를 OpenMed 비식별화 단계에 넘기라고 안내하므로, 두 가지가 함께 작동합니다.

상세 정보

작성자의 원본 설명

Parses C-CDA / CCD XML clinical documents to extract human-readable section narrative plus coded entries, keyed by section LOINC codes and templateIds. Use before OpenMed processing when ingesting C-CDA R2.1 documents (CCD, Discharge Summary, H&P, Consultation Note) exported from an EHR and you need the narrative section text de-identified and analyzed. Hand section narrative to openmed.deidentify and openmed.analyze_text; XML-aware de-identification that preserves CDA markup is available via openmed.interop.cda. Trigger keywords: C-CDA, CCD, CDA, clinical document, templateId, LOINC section,

repo: maziyarpanahi/openmed

인기도

GitHub 스타
5.8k
순위
#14715
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬