uhin/ccda-parser-library

提供数据对象以与综合临床文档架构(C-CDA)数据交互的库。

0.1.1 2019-05-21 15:54 UTC

This package is auto-updated.

Last update: 2024-09-22 04:42:10 UTC


README

预期用途

此库提供了一种(只读)数据对象,用于HL7 v3 XML数据,该数据可以被转换为PHP array\stdClass对象或JSON字符串。它不用于修改数据结构或导出XML。

支持的版本/格式

<在此处插入关于支持的HL7 v3 (即C-CDA)实现的相关文档>

库安装要求

如何使用

使用Composer将库包含到您的项目中

您可以手动将库添加到项目的composer.json文件中,或使用以下命令

composer require uhin/ccda-parser

然后请确保包含Composer引导文件

include_once('vendor/autoload.php');

实例化数据对象

有用于从(有效) XML文件、(有效) XML字符串以及\SimpleXMLElement对象创建数据对象的工厂方法

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

$ccdaDocument = \Uhin\Ccda\Models\CcdaDocument::getDocumentFromXmlString('<ClinicalDocument />');

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

访问数据对象的属性

创建\Uhin\Ccda\Models\CcdaDocument对象后,您可以直接访问其属性

// 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

将数据对象转换为所需的格式

您可以使用数据对象的转换方法获取不同格式的XML数据

// 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

关于结构的说明

此基本XML数据

<ClinicalDocument xmlns:randomNamespace="http://www.w3.org/2001/XMLSchema-instance">
    <globalChild randomNamespace:namespacedAttribute="random value 1" globalAttribute="random value 2">global child value</globalChild>
    <randomNamespace:namespacedChild randomNamespace:namespacedAttribute="random value 3" globalAttribute="random value 4">namespaced child value</randomNamespace:namespacedChild>
</ClinicalDocument>

将被转换为此JSON对象

{
	"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"
		}
	}
}

因为属性名称可能与子元素的名称冲突(或者可能有一个value属性,这会与XML元素值的解析方式冲突),所以属性前面会添加一个前缀和前缀分隔符。默认前缀是attribute,默认前缀分隔符是: (冒号)。如果您想使用不同的前缀和/或分隔符,只需设置以下属性

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

然后,数据属性和转换方法都将更新为新结构

{
	"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"
		}
	}
}

附加信息

关于我们

犹他州健康信息网络(UHIN)是一家非营利性医疗机构,旨在提高患者结果和降低医疗保健成本。如果您正在使用我们的任何开源项目或想了解更多关于我们的信息,我们非常乐意听到您的意见。

www.uhin.org

联系UHIN客户服务

电话:801-716-5901

免长途话费:877-693-3071

地址:1226 E 6600 S Murray, UT 84121

此外,请务必查看我们在GitHub上的其他项目以及我们的知识中心,了解更多关于医疗保健的信息。