parsing-ccda-documents
O que ela faz
Esta skill ensina um agente a abrir arquivos C-CDA, que são exportações XML de sistemas de prontuário médico. Ela encontra a narrativa legível de cada seção para que possa ser verificada ou analisada.
Quando usar
- ✓Quando um usuário tem uma exportação de prontuário no formato C-CDA ou CCD e precisa das notas escritas.
- ✓Quando um usuário quer o texto do resumo de alta ou do histórico de um arquivo XML clínico, separado por seção.
- ✓Quando um usuário precisa que o texto das notas esteja preparado para desidentificação antes da análise.
Link da skill
https://github.com/maziyarpanahi/openmed/blob/master/skills/parsing-ccda-documents/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Você pode extrair as notas escritas do arquivo C-CDA que o meu hospital exportou, seção por seção?”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente lê a estrutura XML do arquivo, encontra cada seção e devolve o texto legível dela. Os registros codificados são mantidos separados.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
- Confirm it's CDA.
is_cda_document(...)checks for aClinicalDocumentroot. Reject XML withDOCTYPE/ENTITYdeclarations (XXE risk) — the adapter does this for you. - Read the header for context: patient, author,
effectiveTime,documentType(ClinicalDocument/codeLOINC). Treat all header values as PHI. - Walk sections by
templateIdor sectioncode(LOINC). Map to your section vocabulary. - Flatten narrative
<text>withitertext(); preserve the secti
Perguntas frequentes
Preciso saber XML para usar isto?
Não. O agente cuida do formato do arquivo, então você só precisa fornecer o arquivo exportado.
Com quais tipos de documento isto funciona?
Foi feito para documentos C-CDA R2.1, como CCD, resumos de alta, históricos e exames físicos, e notas de consulta.
Esta skill substitui a desidentificação?
Não. A skill indica que o texto das seções deve seguir em seguida para a etapa de desidentificação do OpenMed, de modo que as duas funcionem juntas.
Detalhes
Descrição original do autor
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
Popularidade
- Estrelas no GitHub
- 5,8 mil
- Posição no ranking
- #14715
- Licença
- Apache-2.0
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
annotating-variants
5,8 milAjuda seu agente a prever o efeito de variantes genéticas, converter nomes HGVS em posições do genoma e incluir frequências populacionais, com anotadores gratuitos.
ask-openmed
5,8 milAjuda seu agente a escolher o fluxo de trabalho certo do OpenMed para um pedido de texto clínico, começando por uma verificação de privacidade sempre que houver dados de pacientes.
assembling-fhir-bundles
5,8 milAgrupa vários registros de saúde FHIR em um único Bundle de transação pronto para ser enviado a um prontuário eletrônico, com as referências internas ligadas corretamente.
auditing-deid-leakage
5,8 milProcura em textos clínicos desidentificados identificadores que sobraram, como SSN, números de cartão, e-mails e datas, e bloqueia a liberação se restar algum.
Skills parecidas
gitcrawl
394 milPermite que seu agente pesquise um arquivo salvo de issues e pull requests do GitHub, agrupe os duplicados e verifique o status atual deles no GitHub.
slacrawl
394 milPermite que seu agente pesquise e conte mensagens em um arquivo local do Slack, verifique quão atualizado ele está e o atualize quando necessário.
goplaces
394 milAjuda seu agente a buscar lugares, obter detalhes e avaliações e identificar nomes de lugares usando o Google Places, com saída em JSON para scripts.