PHPackages                             uhin/ccda-parser-library - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. uhin/ccda-parser-library

ActiveLibrary

uhin/ccda-parser-library
========================

A library providing data objects to interact with Consolidated Clinical Document Architecture (C-CDA) data.

0.1.1(6y ago)318.4k4[1 PRs](https://github.com/UHIN/ccda-parser-library/pulls)MITPHPPHP ^7.2

Since May 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/UHIN/ccda-parser-library)[ Packagist](https://packagist.org/packages/uhin/ccda-parser-library)[ RSS](/packages/uhin-ccda-parser-library/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Consolidated Clinical Document Architecture (C-CDA) Data Library
================================================================

[](#consolidated-clinical-document-architecture-c-cda-data-library)

Intended Use
------------

[](#intended-use)

This library provides a *(read-only)* data object for HL7 v3 XML data which can be converted to a PHP `array`, `\stdClass` object, or JSON string. It is not intended for modifying the data structure or exporting XML.

Supported Versions/Formats
--------------------------

[](#supported-versionsformats)

*&lt;Insert documentation about which HL7 v3 *(i.e. C-CDA)* implementations are supported here&gt;*

Library Installation Requirements
---------------------------------

[](#library-installation-requirements)

- [**PHP 7** *(or greater)*](https://www.php.net/)
- [**Simple XML** *(PHP Extension)*](https://www.php.net/manual/en/book.simplexml.php)
- [**JSON** *(PHP Extension)*](https://www.php.net/manual/en/book.json.php)

How to Use
----------

[](#how-to-use)

#### Including the Library in your Project with Composer

[](#including-the-library-in-your-project-with-composer)

You can manually add the library to your project's `composer.json` file or use the following command:

```
composer require uhin/ccda-parser
```

Then be sure to include the Composer bootstrap file:

```
include_once('vendor/autoload.php');
```

#### Instantiating a Data Object

[](#instantiating-a-data-object)

There are factory methods for creating the data object from a *(valid)* XML file:

```
$ccdaDocument = \Uhin\Ccda\Models\CcdaDocument::getDocumentFromFilepath('/path/to/ccda.xml');
```

from a *(valid)* XML string:

```
$ccdaDocument = \Uhin\Ccda\Models\CcdaDocument::getDocumentFromXmlString('');
```

and from a `\SimpleXMLElement` object:

```
$ccdaDocument = \Uhin\Ccda\Models\CcdaDocument::getDocumentFromSimpleXmlElement($simpleXmlElement);
```

#### Accessing the Data Object's Properties

[](#accessing-the-data-objects-properties)

Once you have created the `\Uhin\Ccda\Models\CcdaDocument` object, you can access its attributes directly:

```
// The XML data is stored as a \SimpleXMLElement object
$ccdaDocument->simpleXmlElement

// The data object converts that XML data into an array (i.e. dictionary)
$ccdaDocument->data
```

#### Converting the Data Object into Desired Formats

[](#converting-the-data-object-into-desired-formats)

You can use the data object's conversion methods to get the XML data in different formats:

```
// Get the data as an array (i.e. dictionary)
$ccdaDocument->toArray()

// Get the data as a \stdClass object
$ccdaDocument->toStdClass()

// Get the data as a JSON-encoded string
$ccdaDocument->toJson()

// Also returns a JSON-encoded string (used for type-casting to a string)
$ccdaDocument->__toString()
(string) $ccdaDocument
```

#### Notes about Structure

[](#notes-about-structure)

This basic XML data:

```

    global child value
    namespaced child value

```

will be converted into this JSON object:

```
{
	"ClinicalDocument": {
		"randomNamespace": {
			"namespacedChild": {
				"randomNamespace": {
					"attribute:namespacedAttribute": "random value 3"
				},
				"attribute:globalAttribute": "random value 4",
				"value": "namespaced child value"
			}
		},
		"globalChild": {
			"randomNamespace": {
				"attribute:namespacedAttribute": "random value 1"
			},
			"attribute:globalAttribute": "random value 2",
			"value": "global child value"
		}
	}
}
```

Because attribute names can conflict with the names of child elements *(or there can be a `value` attribute which would conflict with the way the XML element value is parsed)*, attributes are prepended with a prefix and a prefix delimiter. The default prefix is `attribute` and the default prefix delimiter is `:` *(colon)*. If you would like to use a different prefix and/or delimiter, simply set the following attributes:

```
$ccdaDocument->elementAttributePrefix = 'differentAttributePrefix'
$ccdaDocument->elementAttributePrefixDelimiter = '-'
```

And the data attribute and conversion methods will all be updated with the new structure:

```
{
	"ClinicalDocument": {
		"randomNamespace": {
			"namespacedChild": {
				"randomNamespace": {
					"differentAttributePrefix-namespacedAttribute": "random value 3"
				},
				"differentAttributePrefix-globalAttribute": "random value 4",
				"value": "namespaced child value"
			}
		},
		"globalChild": {
			"randomNamespace": {
				"differentAttributePrefix-namespacedAttribute": "random value 1"
			},
			"differentAttributePrefix-globalAttribute": "random value 2",
			"value": "global child value"
		}
	}
}
```

Additional Information
----------------------

[](#additional-information)

- [HL7 Standard: CDA® Release 2](http://www.hl7.org/implement/standards/product_brief.cfm?product_id=7)
- [Consolidated CDA® Overview](https://www.healthit.gov/topic/standards-technology/consolidated-cda-overview)
- [Clinical Document Architecture (CDA®) Wikipedia Entry](https://en.wikipedia.org/wiki/Clinical_Document_Architecture)

About Us
--------

[](#about-us)

Utah Health Information Network *(UHIN)* is a non-profit organization in the healthcare industry with goals of improving patient outcomes and reducing healthcare costs. If you are using any of our open source projects or would like to know more about us, we would love to hear from you.

[www.uhin.org](https://www.uhin.org/)

[Email UHIN Customer Service](mailto:customerservice@uhin.org)

Phone: 801-716-5901

Toll Free: 877-693-3071

Address: 1226 E 6600 S Murray, UT 84121

Also, be sure to [check out our other projects on GitHub](https://github.com/uhin) and our [knowledge center](https://uhin.org/knowledge-center/) for more information about healthcare.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

2

Last Release

2545d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/899e507c69e61ef15d5532164afe29452d9e06075de3eb1a6265e538c32ac21d?d=identicon)[rmclellanduhin](/maintainers/rmclellanduhin)

---

Top Contributors

[![markguyver](https://avatars.githubusercontent.com/u/3242128?v=4)](https://github.com/markguyver "markguyver (32 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uhin-ccda-parser-library/health.svg)

```
[![Health](https://phpackages.com/badges/uhin-ccda-parser-library/health.svg)](https://phpackages.com/packages/uhin-ccda-parser-library)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
