FHIR (Fast Health Interoperability Resources)旨在数据交换,能够支撑医疗领域的多种流程。该标准基于Restful的最佳实践,能够实现跨团队的医疗系统的集成。
FHIR 所支持的范围很广泛,包括人、兽医、临床、公共卫生、临床试验、管理和财务等方面。全球通用且支持多种架构和场景。
FHIR 是基于 资源
这一通用组件. 每个资源都有如下 通用特征:
资源要么是 XML ,要么是 JSON格式的. 目前已经定义了99种资源类型
如何用JSON来表示patient。 标准中也定义了XML的表达方式。
{
"resourceType": "Patient",
"id" : "23434",
"meta" : {
"versionId" : "12",
"lastUpdated" : "2014-08-18T01:43:30Z"
}
"text": {
"status": "generated",
"div": "<!-- Snipped for Brevity -->"
},
"extension": [
{
"url": "http://example.org/consent#trials",
"valueCode": "renal"
}
],
"identifier": [
{
"use": "usual",
"label": "MRN",
"system": "http://www.goodhealth.org/identifiers/mrn",
"value": "123456"
}
],
"name": [
{
"family": [
"Levin"
],
"given": [
"Henry"
],
"suffix": [
"The 7th"
]
}
],
"gender": {
"text": "Male"
},
"birthDate": "1932-09-24",
"active": true
}
`
每个资源包括如下内容:
备注 尽管标准中总是以所定义的顺序来显示JSON中数据的顺序,但很多JSON库有其他排序标准。
为了操作数据,FHIR 定义了REST API:
除了RESTful API之外,FHIR 中还定义了其他的数据交换方式,包括 文档, 消息和其他类型的服务.
医疗行业的一大特点就是不同地区和细分行业都存在很大的差异性,并不存在一个集中式的权威机构来定义通用的行业规范。鉴于此, FHIR 中定义了通用扩展框架和 管理多样性的框架.
为了新增资源, 需要发送一个 HTTP 的 POST 请求到某个资源节点(也就是某个URL).如下所示
POST https://example.com/path/{resourceType}
`
POST {some base path}/Patient HTTP/1.1
Authorization: Bearer 37CC0B0E-C15B-4578-9AC1-D83DCED2B2F9
Accept: application/json+fhir
Content-Type: application/json+fhir
Content-Length: 1198
{
"resourceType": "Patient",
...
}
`
向服务器提交一条患者记录, 服务器可以根据自己的情况分配ID来存储该患者记录。备注:
响应中包含HTTP 201,表示服务器已经成功新建该条记录。location header 属性中包含了访问该资源的URL。响应中亦可包含OperationOutcome 资源来表达处理的一些细节,并不做硬性要求。
HTTP/1.1 201 Created
Content-Length: 161
Content-Type: application/json+fhir
Date: Mon, 18 Aug 2014 01:43:30 GMT
ETag: "1"
Location: http://example.com/Patient/347
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">The operation was successful</div>"
}
}
`
Notes:
出于多种原因,服务器会返回一个错误信息,FHIR 内容相关的一些错误信息以HTTP 状态码加一个OperationOutcome来表达. 如下是一个不满足服务器端业务规则时的返回信息:
HTTP/1.1 422 Unprocessable Entity
Content-Length: 161
Content-Type: application/json+fhir
Date: Mon, 18 Aug 2014 01:43:30 GMT
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">MRN conflict
- the MRN 123456 is already assigned to a different patient</div>"
},
}
`
Notes:
读取资源内容是通过HTTP GET请求来实现的.
GET https://example.com/path/{resourceType}/{id}
`
GET /Patient/347?_format=xml HTTP/1.1
Host: example.com
Accept: application/xml+fhir
Cache-Control: no-cache
`
Notes:
读取单个资源内容GET请求的响应是单独的一个资源.
HTTP/1.1 200 OK
Content-Length: 729
Content-Type: application/xml+fhir
Last-Modified: Sun, 17 Aug 2014 15:43:30 GMT
ETag: "1"
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<id value="347"/>
<meta>
<versionId value="1"/>
<lastUpdated value="2014-08-18T01:43:30Z"/>
</meta>
<!-- content as shown above for patient -->
</Patient>
`
Notes:
除了读取单个资源内容之外,也可以通过查询参数和变量 查询资源内容,形式一般如下:
GET https://example.com/path/{resourceType}?criteria
The criteria is a set of http parameters that specify which resources to return. The search operation
https://example.com/base/MedicationPrescription?patient=347
会返回该患者的所有处方信息.
查询请求返回的对象是一个bundle: 如未明确要求,只返回满足查询参数要求的资源元数据:
{
"resourceType": "Bundle",
"id" : "eceb4882-5c7e-4ca4-af62-995dfb8cef01"
"meta" : {
"lastUpdated" : "2014-08-19T15:43:30Z"
},
"base": "http://example.com/base",
"total": "3",
"link": [
{
"relation" : "next",
"url" : "https://example.com/base/MedicationPrescription?patient=347&searchId=ff15fd40-ff71-4b48-b366-09c706bed9d0&page=2"
}, {
"relation" : "self",
"url" : "https://example.com/base/MedicationPrescription?patient=347"
}
],
"entry": [
{
"resource" : {
"resourceType": "MedicationPrescription",
"id" : "3123",
"meta" : {
"versionId" : "1",
"lastUpdated" : "2014-08-16T05:31:17Z"
},
... content of resource ...
},
},
... 2 additional resources ....
]
}
`
Notes:
客户端用新版本的资源记录替换服务器中的老版本.
PUT https://example.com/path/{resourceType}/{id}
`
Note that there does not need to be a resource already existing at {id} - the server may elect to automatically create the resource at the specified address. Here is an example of updating a patient:
PUT /Patient/347 HTTP/1.1
Host: example.com
Content-Type: application/json+fhir
Content-Length: 1435
Accept: application/json+fhir
If-Match: 1
{
"resourceType": "Patient",
"id" : "347",
"meta" : {
"versionId" : "1",
"lastUpdated" : "2014-08-18T01:43:30Z"
},
...
}
`
Notes:
更新请求的响应包括了元数据、状态和OperationOutcome(可选):
HTTP/1.1 200 OK
Content-Length: 161
Content-Type: application/json+fhir
Date: Mon, 18 Aug 2014 01:43:30 GMT
ETag: "2"
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">The operation was successful</div>"
}
}
`
Notes:
所有资源都会包含的基础信息:
{
"resourceType" : "X",
"id" : "12",
"meta" : {
"versionId" : "12",
"lastUpdated" : "2014-08-18T01:43:30Z",
"profile" : ["http://example-consortium.org/fhir/profile/patient"],
"security" : [{
"system" : "http://hl7.org/fhir/v3/ActCode",
"code" : "EMP"
}],
"tag" : [{
"system" : "http://example.com/codes/workflow",
"code" : "needs-review"
}]
},
"implicitRules" : "http://example-consortium.org/fhir/ehr-plugins",
"language" : "X"
}
`
Implementers notes:
© © HL7.org 2011+. FHIR DSTU (v0.5.0-5149) generated on Fri, Apr 3, 2015 14:36+1100. 链接:试行版是什么 |版本更新情况 | 许可协议 |提交变更建议