HL7 FHIR库
项目描述
# 版权 (C) 2014 Luis Falcon <lfalcon@gnusolidario.org>
# 版权 (C) 2014 GNU Solidario <health@gnusolidario.org>
# 版权 (C) 2014 Chris Zimmerman <siv@riseup.net>
# 本程序是自由软件:您可以重新分配和/或修改
# 它在自由软件基金会发布的GNU通用公共许可证的条款下,
# 许可证的版本3,或者
# (根据您的选择)任何较新版本的许可证。
# 本程序旨在发布时具有实用性,
# 但没有任何保证;甚至没有关于其可销售性或
# 适用于特定目的的隐含保证。有关详细信息,请参阅
# GNU通用公共许可证。
# 您应该已收到与此程序一起的GNU通用公共许可证副本。
# 如果没有,请参阅 <https://gnu.ac.cn/licenses/>。
关于FHIR Python包的更多信息
------------------------------
FHIR的目标是在Python中实现HL7 FHIR[1]参考
该项目是为了为GNU Health[2] FHIR模块提供后端,但它应该适用于其他EMR和客户端。
您可以在Savannah[3]的Mercurial服务器上获取最新开发版本
1.- http://www.hl7.org/fhir
2.- http://health.gnu.org
3.- http://hg.savannah.gnu.org/hgweb/health/
示例用途
1) 搜索交互
2) 读取交互
3) 创建交互
1) #### 搜索交互 ####
>>> from fhir import *
>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open', 'xml')
>>> params = {'identifier': 55567890}
>>> query = rest.search('Patient', params)
>>> print query
<Response [200]>
>>> print query.text
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>搜索资源类型为Patient的结果</title>
<id>urn:uuid:8b018fb9-7df4-4e1b-9f4b-8a34955d86</id>
<link href="http://fhir.healthintersections.com.au/open/" rel="fhir-base" />
<link href="http://fhir.healthintersections.com.au/open/Patient/_search?search-id=49f23df4-3b9a-4117-9726-41d2aa3256&identifier=55567890&search-sort=_id" rel="self" />
<updated>2014-03-30T03:51:25Z</updated>
<totalResults xmlns="http://a9.com/-/spec/opensearch/1.1/">1</totalResults>
<entry xmlns="http://www.w3.org/2005/Atom">
<title>Patient "1046" 版本 "1"</title>
<id>http://fhir.healthintersections.com.au/open/Patient/1046</id>
<link href="http://fhir.healthintersections.com.au/open/Patient/1046/_history/1" rel="self" />
<updated>2014-03-30T03:47:37Z</updated>
<author>
<name>190.195.19.13</name>
</author>
<published>2014-03-30T03:51:25Z</published>
<content type="text/xml">
<Patient xmlns="http://hl7.org/fhir">
<identifier>
<use value="usual"/>
<label value="SSN"/>
<value value="55567890"/>
</identifier>
<name>
<use value="official"/>
<family value="Ana"/>
<given value="Betz"/>
</name>
<gender>
<coding>
<system value="http://hl7.org/fhir/v3/AdministrativeGender"/>
<code value="F"/>
<display value="Female"/>
</coding>
</gender>
<birthDate value="1985-10-04"/>
<deceasedBoolean value="false"/>
<active value="true"/>
</Patient>
</content>
<summary type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">--此资源无摘要--</div>
</summary>
</entry>
</feed>
######################################################################
2) ###### 读取交互 ##############
>>> from fhir import *
>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open', 'xml')
>>> query = rest.read('Patient', 1046)
>>> print query
<Response [200]>
>>> print query.text
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<identifier>
<use value="usual"/>
<label value="SSN"/>
<value value="55567890"/>
</identifier>
<name>
<use value="official"/>
<family value="Ana"/>
<given value="Betz"/>
</name>
<gender>
<coding>
<system value="http://hl7.org/fhir/v3/AdministrativeGender"/>
<code value="F"/>
<display value="Female"/>
</coding>
</gender>
<birthDate value="1985-10-04"/>
<deceasedBoolean value="false"/>
<active value="true"/>
</Patient>
如果资源ID不存在,将生成404响应
假设我们尝试访问不存在的ID 210834
>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open', 'xml')
>>> query = rest.read('Patient', 210834)
>>> print query
<Response [404]>
>>> print query.text
<?xml version="1.0" encoding="UTF-8"?>
<OperationOutcome xmlns="http://hl7.org/fhir">
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>资源ID "Patient/210834"不存在</p>
</div>
</text>
<issue>
<severity value="error"/>
<details value="资源ID "Patient/210834"不存在"/>
</issue>
</OperationOutcome>
### 在Patient配置文件上创建交互 ###
>>> from fhir import *
>>> import json
# Patient资源的XML数据元素
#>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open', 'xml')
#>>> body = "<Patient xmlns=\"http://hl7.org/fhir\">" \
# "<name><family>John</family></name></Patient>"
# Patient资源的JSON数据元素
>>> body = json.dumps({"resourceType":"Patient",
"name":[{"use":"official", "family":["Doe"], "given":["John"]}]})
>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open')
>>> query = rest.create('Patient', body)
>>> print query
<Response [201]>
>>> print query.text
{
"resourceType" : "OperationOutcome",
"text" : {
"status" : "generated",
"div" : "\r\n<div xmlns=\"http://www.w3.org/1999/xhtml\">操作成功</div>"
}
}
########################################################################
# 版权 (C) 2014 GNU Solidario <health@gnusolidario.org>
# 版权 (C) 2014 Chris Zimmerman <siv@riseup.net>
# 本程序是自由软件:您可以重新分配和/或修改
# 它在自由软件基金会发布的GNU通用公共许可证的条款下,
# 许可证的版本3,或者
# (根据您的选择)任何较新版本的许可证。
# 本程序旨在发布时具有实用性,
# 但没有任何保证;甚至没有关于其可销售性或
# 适用于特定目的的隐含保证。有关详细信息,请参阅
# GNU通用公共许可证。
# 您应该已收到与此程序一起的GNU通用公共许可证副本。
# 如果没有,请参阅 <https://gnu.ac.cn/licenses/>。
关于FHIR Python包的更多信息
------------------------------
FHIR的目标是在Python中实现HL7 FHIR[1]参考
该项目是为了为GNU Health[2] FHIR模块提供后端,但它应该适用于其他EMR和客户端。
您可以在Savannah[3]的Mercurial服务器上获取最新开发版本
1.- http://www.hl7.org/fhir
2.- http://health.gnu.org
3.- http://hg.savannah.gnu.org/hgweb/health/
示例用途
1) 搜索交互
2) 读取交互
3) 创建交互
1) #### 搜索交互 ####
>>> from fhir import *
>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open', 'xml')
>>> params = {'identifier': 55567890}
>>> query = rest.search('Patient', params)
>>> print query
<Response [200]>
>>> print query.text
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>搜索资源类型为Patient的结果</title>
<id>urn:uuid:8b018fb9-7df4-4e1b-9f4b-8a34955d86</id>
<link href="http://fhir.healthintersections.com.au/open/" rel="fhir-base" />
<link href="http://fhir.healthintersections.com.au/open/Patient/_search?search-id=49f23df4-3b9a-4117-9726-41d2aa3256&identifier=55567890&search-sort=_id" rel="self" />
<updated>2014-03-30T03:51:25Z</updated>
<totalResults xmlns="http://a9.com/-/spec/opensearch/1.1/">1</totalResults>
<entry xmlns="http://www.w3.org/2005/Atom">
<title>Patient "1046" 版本 "1"</title>
<id>http://fhir.healthintersections.com.au/open/Patient/1046</id>
<link href="http://fhir.healthintersections.com.au/open/Patient/1046/_history/1" rel="self" />
<updated>2014-03-30T03:47:37Z</updated>
<author>
<name>190.195.19.13</name>
</author>
<published>2014-03-30T03:51:25Z</published>
<content type="text/xml">
<Patient xmlns="http://hl7.org/fhir">
<identifier>
<use value="usual"/>
<label value="SSN"/>
<value value="55567890"/>
</identifier>
<name>
<use value="official"/>
<family value="Ana"/>
<given value="Betz"/>
</name>
<gender>
<coding>
<system value="http://hl7.org/fhir/v3/AdministrativeGender"/>
<code value="F"/>
<display value="Female"/>
</coding>
</gender>
<birthDate value="1985-10-04"/>
<deceasedBoolean value="false"/>
<active value="true"/>
</Patient>
</content>
<summary type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">--此资源无摘要--</div>
</summary>
</entry>
</feed>
######################################################################
2) ###### 读取交互 ##############
>>> from fhir import *
>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open', 'xml')
>>> query = rest.read('Patient', 1046)
>>> print query
<Response [200]>
>>> print query.text
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<identifier>
<use value="usual"/>
<label value="SSN"/>
<value value="55567890"/>
</identifier>
<name>
<use value="official"/>
<family value="Ana"/>
<given value="Betz"/>
</name>
<gender>
<coding>
<system value="http://hl7.org/fhir/v3/AdministrativeGender"/>
<code value="F"/>
<display value="Female"/>
</coding>
</gender>
<birthDate value="1985-10-04"/>
<deceasedBoolean value="false"/>
<active value="true"/>
</Patient>
如果资源ID不存在,将生成404响应
假设我们尝试访问不存在的ID 210834
>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open', 'xml')
>>> query = rest.read('Patient', 210834)
>>> print query
<Response [404]>
>>> print query.text
<?xml version="1.0" encoding="UTF-8"?>
<OperationOutcome xmlns="http://hl7.org/fhir">
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>资源ID "Patient/210834"不存在</p>
</div>
</text>
<issue>
<severity value="error"/>
<details value="资源ID "Patient/210834"不存在"/>
</issue>
</OperationOutcome>
### 在Patient配置文件上创建交互 ###
>>> from fhir import *
>>> import json
# Patient资源的XML数据元素
#>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open', 'xml')
#>>> body = "<Patient xmlns=\"http://hl7.org/fhir\">" \
# "<name><family>John</family></name></Patient>"
# Patient资源的JSON数据元素
>>> body = json.dumps({"resourceType":"Patient",
"name":[{"use":"official", "family":["Doe"], "given":["John"]}]})
>>> rest = RestfulFHIR('http://fhir.healthintersections.com.au/open')
>>> query = rest.create('Patient', body)
>>> print query
<Response [201]>
>>> print query.text
{
"resourceType" : "OperationOutcome",
"text" : {
"status" : "generated",
"div" : "\r\n<div xmlns=\"http://www.w3.org/1999/xhtml\">操作成功</div>"
}
}
########################################################################
项目详情
关闭
fhir-0.0.4.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 02053927719c783e44886c8f77e996dae3bcdee3bc971f504118e61e95eca71b |
|
MD5 | 77bcfeeea62c92bd8e569cf7624c0bd4 |
|
BLAKE2b-256 | 163af48dfee1c24ccedf1187cd6dabe86da39ca65495c463625dce7c1435fc9d |