> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.emtelligent.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.emtelligent.com/_mcp/server.

# Introduction

CCDs are used to summarize the most relevant facts about a patient’s healthcare, covering one or multiple encounters. They provide a means for one provider to aggregate data about the patient and forward it to another provider to support continuity of care within the system. The primary use case is to provide a snapshot in time containing the relevant clinical, demographic and administrative data for a specific patient. CCD document standard is one of the document types in the consolidated CDA document architecture. CDA (Clinical Document Architecture) is a widely-adopted application of HL7 v3 Reference Information Model (RIM). The CDA standard defines a universal XML schema for defining many clinical document templates. It forms the basis for many standards-based information systems.

## Overview of the CCD Document Structure

The CCD (Continuity of Care Documents) document standard was developed as a joint effort of HL7 and ASTM. It maps the functionality of the ASTM Continuity of Care Record (CCR) into the HL7 v3 CDA format. CCDs are sometimes also referred to as CEDs (Clinical Exchange Documents). CCDs typically contain these sections:

![CCD Sections](/_fern-img/f6358dfb9965945a60e9a6330c28f281129ccfe6da4ff399e9e793bd44494181.webp)

The CDA standard specifies templates for documents, sections and entries. A document template specifies a set of required and optional section templates, and section templates specify the format of the content for presentation and the entry templates that the section may contain.

A C-CDA section has 2 major parts:

* **HTML content** - These are narrative blocks intended to contain information for human interpretation and for rendering to human-readable form. These are authored as HTML content which may include unstructured narrative text (in the form of paragraphs, lists containing comments or whole embedded reports). This content may also be provide semi-structured data in the form of HTML tables.
* **CDA entries or coded entries** - These are blocks enclosed by the `entry` XML element tag. These machine-readable blocks contain information intended for automated processing.

The following is an excerpt of a CCD document showing the HTML content in the **Past Medical History** section. This information is rendered as follows:

![Problem List](/_fern-img/8c1cf4e3db52dbac853e43039783c13ab270f565a2ed3726cabeef967265ad30.webp)

This shows the corresponding HTML markup for the row containing `Current nicotine user`. Notice that the content element has an ID and that the information is presented in tabular form:

![Textual element](/_fern-img/b2670fdd0c45ec79899ea2a9e65c74eff3ed2bd51774a6eade476ed9d283ff5d.webp)

### NLP API performs Entity Extraction from Text Content

The NLP API extracts entities from the human-readable text content of the CCD document. The entities extracted are stored in the **foundentities** table. Each row in this table represents an entity extracted from the text content of the document.

Text ID references such as the one shown above `ID="ID0E3MAC"` are used to link coded entries to the human-readable text content. The structured data is contained in the coded-entries, which are XML elements that contain coded information.

### NLP API retains but does not process CDA entries

The following is an example of a CDA or coded-entry in a CCD document:

```xml
<entry>
   <observation classCode="OBS" moodCode="EVN">
      <code code="722494001" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT"/>
      <statusCode code="completed"/>
      <value xsi:type="CD" code="305.1" codeSystem="2.16.840.1.113883.6.103" codeSystemName="ICD-9"/>
      <value xsi:type="CD" code="Z72.0" codeSystem="2.16.840.1.113883.6.103" codeSystemName="ICD-10-CM"/>
      <text>Current nicotine use (305.1, Z72.0) Status: Active</text>
   </observation>
</entry>
```

Note that coded entries encode information using multiple coding systems, and have a type or class code. The above entry encodes information about an Observation.

They may also encode relationships between related coded entries. For example a problem observation, has a coded element (e.g. `Current nicotine use`), and a coded status. Other relationships exist between coded entries, for example between a vaccine drug mention and a vaccine administration event. These relationships can be challenging to navigate and are not the primary focus of medical language extraction systems like the NLP API. However, NLP API client does comprehensively retain a many types of information from the XML coded parts of a CCD document:

* Document-level context: record target (patient information), document tye identifiers, and associated datetime values
* Section-level context: LOINC section code, identifiers and display names
* Coded information: code value, code translations, coding system used, as well as effective times and values (e.g. reference ranges, physical quantities, status etc )
* Entry relationships

Moreover, the NLP API preserves the association with the the human-readable text (via a Text-ID reference)

## NLP API CCD Support

For this project, our main objective was to extract coded clinical terms and values from body sections (and not administrative information, demographic and other information also present in the CCD headers). We extracted medical terms from the human-readable sections such as the Functional Status, Problems, Past Medical History, and from structured data (or coded-entries).

You can submit CDA documents (as XML files) to the NLP API for processing using the NLP API Python SDK and client. If you have specific data ingestion requirements, please contact support. Due to variability of CCD documents, some customization may be required.

In addition to performing NLP on the text data of CCDs, the NLP API Client extracts, transforms and stores the pre-structured/coded XML entries as JSON objects. This information is uploaded to the **documentstructuredmetadata** table in the Output Database. Using JSON query capabilities in PostgreSQL and Snowflake you can retrieve useful information from this data. Several sample queries are provided in this section. Note, however that this is an advanced use case, and you are encouraged to contact us for support and guidance as needed at [support@emtelligent.com](mailto:support@emtelligent.com).

### Documentstructuredmetadata table

The structured XML data present in CCD is extracted and stored in the **documentstructuredmetadata** table. Each row in this table represents an instance of a coded value. The table has 4 columns:

* **id** - unique identifier for the entry
* **document_id** - a foreign key that references document(id)
* **key** - a static string value set to `structured_data`
* **value** - JSON object representing one coded entry

The following is an example of a JSON object stored in the **value** column:

```json
{
   "display_name": "Current nicotine use",
   "text_id": "ID0E3MAC",
   "class_code": "OBS",
   "mood_code": "EVN",
   "code": "722494001",
   "code_system": "2.16.840.1.113883.6.96",
   "code_system_name": "SNOMED CT",
   "code_system_version": null,
   "relation_type_code": null,
   "text_source": "reference",
   "value": null
   "effective_time": [
      {
         "event": null,
         "high": null,
         "institution_specified": null,
         "low": {
         "unit": null,
         "value": null
         },
         "offset": null,
         "operator": null,
         "period": null,
         "phase": null,
         "unit": null,
         "value": null,
         "width": null
      }
   ],
   "status_code": {
      "code": "completed",
      "null_flavor": null
   },
   "label": "c351a852-9085-4727-b857-21f8fa598c6e",
   "parent_reference": "f1b030d8-c1c8-45b9-a54a-48ffc651c267",
   "section": "f98d7b9e-1c9b-43f2-8cd9-68a0101f1f41",
   "for_elt_tag": "observation",
   "code_elt_tag": "value",
   "text": "Current nicotine use (305.1, Z72.0)\tStatus: Active",
   "text_spans": [
      {
         "end": 405,
         "start": 355
      }
   ],
   "translation_of": null,
}
```

Note that in addition to storing information from standard CDA template elements such `effective time`, `code`, `code_system_name`, `status_code` etc., the NLP API has added additional JSON key-value pairs needed to provide context for the coded element. The observation XML element refers to the HTML-formatted text element via the **text_id** field.

A coded-entry is to a Section via the **section** field. This field provides the label of the section entry for the code-entry. Hence, you can retrieve coded-entries by section if desired.

Any child elements contained in an observation element (for example its coded values, and statuses) are extracted as separate JSON objects that are linked together using ID references: the `parent_references` in the child object refers to the `label` field in its parent's JSON object. Likewise the `section` field links the observation and its child objects to the coded sections, thus preserving context about the extracted coded data.

The following queries show how to get the JSON data for coded entries from the **documentstructuredmetadata** table using database-specific JSON operators and functions:

* Query: Retrieve Coded-Entries JSON for one CCD document
* Query: Find SNOMED CT coded concepts and their text spans

### Query: Retrieve Coded-Entries JSON for a CCD document

#### SQL

```sql
SELECT 
   value 
FROM documentstructuredmetadata dm
JOIN document d ON dm.document_id=d.id
WHERE d.filename LIKE '%oncology-alice-newman.xml';
```

### Query: Find SNOMED CT coded concepts and their text spans

#### PostgreSQL

```sql
SELECT dm.id, regexp_replace(d.filename, '.*/', '') AS filename,
      value::jsonb ->> 'code' AS code,
      value::json ->> 'code_system_name' AS coding_system,
      SUBSTRING(value::jsonb ->> 'display_name', 1, 40) AS display_name,
      SUBSTRING(value::jsonb ->> 'text', 1, 256) AS sentence
FROM documentstructuredmetadata dm
      JOIN document d ON dm.document_id = d.id
WHERE value::jsonb ->> 'code_system' IN
      ('2.16.840.1.113883.6.96','2.16.840.1.113883.6.5'); -- 'SNOMED'
```

#### Snowflake

```sql
SELECT dm.id,
      regexp_replace(d.filename, '.*/', '') AS filename,
      PARSE_JSON(dm.value):code_system_name::string as coding_system,
      PARSE_JSON(dm.value):code::string as code,
      PARSE_JSON(dm.value):display_name::string as display_name,
      PARSE_JSON(dm.value):text::string as sentence
FROM documentstructuredmetadata dm
   JOIN document d ON d.id = dm.document_id
WHERE
   PARSE_JSON(dm.value):code_system::string IN 
   ('2.16.840.1.113883.6.96','2.16.840.1.113883.6.5'); -- SNOMED
```

| id  | filename               | code      | display_name | text                                                                |
| --- | ---------------------- | --------- | ------------ | ------------------------------------------------------------------- |
| 51  | emerge-patient-1.xml   | 404684003 | Finding      | Coronary arteriosclerosis \| 03-31-2010 10:00:00 \| Active          |
| 56  | emerge-patient-1.xml   | 404684003 | Finding      | Diabetes mellitus type 2 \| 03-31-2010 10:00:00 \| Active           |
| 61  | emerge-patient-1.xml   | 404684003 | Finding      | Essential hypertension \| 03-31-2010 10:00:00 \| Active             |
| 68  | emerge-patient-1.xml   | 404684003 | Finding      | Coronary arteriosclerosis \| 03-31-2010 10:00:00 \| Active          |
| 249 | vitera-labs-vitals.xml | 55607006  | Problem      | COMN MIGRNE WO NTRC MGRN \| 12/02/2002 \| David E Ford MD \| Active |

### Processing Requirements

This query assumes that at least the following `emtellipro-db-client` processing options were enabled:

* `--store-sections-and-sentences`

For this query, Continuity of Care Documents were processed with the following document type:

* `--category Clinical`
* `--subcategory CCD`

> **Note**
>
> Ensure that you have installed the NLP API CCD reader plugin v1.6 or later.

### Next steps

Because emtellipro extracts data from narrative blocks as well as the XML coded-entries, you have the option of querying data from the text elements (as the NLP API entities) or the coded-entries (in JSON objects).

Sample query for entities extracted for text elements: The [Smoking status query](/nlp/database/cookbook/advanced-queries/ccd/smoking-status)

Sample JSON queries for retrieving coded data:

* [Find CCD Document-level Metadata](/nlp/database/cookbook/advanced-queries/ccd/document-metadata)
* [Find Entities Extracted from Embedded Reports](/nlp/database/cookbook/advanced-queries/ccd/embedded-reports)
* [Find Problems with Statuses in Coded Entries](/nlp/database/cookbook/advanced-queries/ccd/problem-status)
* [Find Hypertension using Hierarchical Concept Search in Coded Entries](/nlp/database/cookbook/advanced-queries/ccd/hypertension-hierarchical)
* [Find Vaccines & Dates of Administration](/nlp/database/cookbook/advanced-queries/ccd/vaccination-dates)
* [Find coded Physical Quantities in CCDs](/nlp/database/cookbook/advanced-queries/ccd/labs-and-vitals)

Sample query that utilizies both coded data and entities from text elements:

* [Find Entities in CCD Sections which have no Coded data](/nlp/database/cookbook/advanced-queries/ccd/sections-without-coded-data)