开发人员fhir教程 fhirfordevelopersfhir for...

159
开发人员FHIR教程 开发人员FHIR教程 FHIR for Developers FHIR for Developers Ewout Kramer Ewout Kramer 201454中文翻译基于Revision 2626 (Jul 10 14:28:31 2014 UTC) © 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Upload: others

Post on 12-Jul-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

开发人员FHIR教程开发人员FHIR教程FHIR for DevelopersFHIR for Developers

Ewout KramerEwout Kramer2014年5月4日

中文翻译基于Revision 2626 (Jul 10 14:28:31 2014 UTC)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 2: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

前言

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 3: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

自我介绍自我介绍

姓名: Ewout Kramer公司 F A t d 公司: Furore, Amsterdam

背景:背景 FHIR核心团队, RIMBAA 软件开发人员 & 医疗保健架构设计师 软件开发人员 & 医疗保健架构设计师

联系方式: [email protected] www.thefhirplace.com

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

3

Page 4: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

请大家自我介绍一下请大家自我介绍一下

关于贵组织机构……HL7 ( 2/ 3) 背景? HL7 (v2/v3) 背景?

您当时是怎么听说FHIR的?当 是 听说 的

平台选择(.NET, Java, Ruby, …)?熟悉HTTP XML JSON REST吗? 熟悉HTTP、XML、JSON、REST吗?

所使用的持久性技术?

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 5: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

本教程的内容概要本教程的内容概要

解构 FHIR FHIR RESTful 服务接口 FHIR RESTful 服务接口

除了 REST 以外

搜索

线上的FHIR线 的 FHIR on the Wire

适合于开发人员的分发形式 适合于开发人员的分发形式 Distribution for developers

构建 FHIR 服务器

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

构建 FHIR 服务器

Page 6: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

您是什么样的视角?您是什么样的视角?

v3 App

v2 FHIR

FHIR

Broker

PHRFHIR

Comm.Interface

FHIR DB

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 7: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

从软件工程的视角审视FHIR数据建模概念

解构FHIRDECONSTRUCTING FHIR

从软件工程的视角审视FHIR数据建模概念

DECONSTRUCTING FHIR

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 8: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源 Resources (回顾!)资源 Resources (回顾!)

“资源” :是逻辑上离散的小型交换单元 是逻辑上离散的小型交换单元

具有定义明确的行为和含义

有 识 具有已知的标识/位置

医疗保健领域所关心的最小交易单元

类似于V2的区段(Segment,段)和V3的公共消息元素类型(CMET)

三个组成部分:分立部分、叙述部分及扩展部分

共计100-150 种资源

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

共计 种资源

8

Page 9: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源结构资源结构

元数据

叙述

资源

元素

扩展 扩展

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 10: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

组合与引用组合与引用Composition versus reference

FHIR 使组合与引用得以明确:引用位于资源之间 不存在跨越引用的语境传导/传 引用位于资源之间:不存在跨越引用的语境传导/传递——可以作为单独的资源加以安全获取

组合位于特定资源内部 组件资源在相应资源外部 组合位于特定资源内部:组件资源在相应资源外部没有任何含义,没有标识,且除了通过相应资源之外 没有另外的访问途径外,没有另外的访问途径

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 11: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源的组合资源的组合

资源根节点 Resource Root

资源组件 Resource Component

简单或复杂元素(可以重复

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 12: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

组合 Composition组合 Composition

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 13: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

全都是关于资源的组合全都是关于资源的组合……

观察结果

http://lab.hospitalA.org/Observation/3ff27

观察结果

诊断报告诊断报告诊断报告患者

组织机构 http://lab.hospitalA.org/DiagRep/444

执业人员http://moh.govt.nz/hpi/Organization/1

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

http://moh.govt.nz/hpi/Practitioner/87

Page 14: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

诊断报告诊断报告诊断报告

患者患者

执业人员

观察结果

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 15: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源引用资源引用Resource Reference

示例:诊断报告资源DiagnosticReport的组成部分

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 16: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源聚合资源聚合Resource Aggregate

“How do we know where an object made up of other objects begins“How do we know where an object made up of other objects beginsmade up of other objects begins and ends?”made up of other objects begins and ends?”

“In any system with persistent storageof data there must be a scope for a“In any system with persistent storageof data there must be a scope for aof data, there must be a scope for a transaction that changes data and a way of maintaining the consistency of the data”

of data, there must be a scope for a transaction that changes data and a way of maintaining the consistency of the data”

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

16

maintaining the consistency of the datamaintaining the consistency of the data

Page 17: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

“业务” 标识符业务 标识符“Business” identifiers

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 18: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源标识资源标识

实际上是一个URL资源类型

http://server.org/fhir/Patient/1

端点 标识符

注释 该URL将解析到特定资源的当前版本注释:该URL将解析到特定资源的当前版本

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 19: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源元数据资源元数据Resource metadata

元数据

Patient

MRN 22234

资源标识http://fhir.hl7.org/Patient/23E455A3Bhtt //fhi hl7 /P ti t/23E455A3B/ hi t /4MRN 22234

“Ewout Kramer”30-11-1972Amsterdam

http://fhir.hl7.org/Patient/23E455A3B/_history/4

最后更新于2013-12-23T23:33:01+01:002013-12-23T23:33:01+01:00

http://hl7.org/fhir/taghttp://example org/fhir/Status#Test

http://hl7.org/fhir/tag/profilehttp://hl7.org/fhir/Profile/us-core

http://example.org/fhir/Status#Test

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 20: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 元素元素FHIR Elements

元数据 复合型数据类型(H N

经过约束的类型

叙述

(HumanName, Quantity, Period,Address, Identifier )

的类型(Quantity:

Distance, Count, Duration, Money)

采用资源

元素 采用

采用

扩展 扩展原始数据类型(integer boolean 派生型的

采用

(integer, boolean, string, instant) 原始数据类型

(oid, uuid, code, id)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 21: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

从底部开始:原始数据类型从底部开始 原始数据类型Start at the bottom: Primitives

boolean xs:boolean Values can be either true or falseinteger xs:int A signed 32-bit integer

decimal xs:decimal A rational number. A true decimal, with i b ilt i i ( J Bi D i l)decimal xs:decimal inbuilt precision (e.g. Java BigDecimal)

base64Binary xs:base64Binary A stream of bytes, base64 encoded

instant xs:dateTimeAn instant in time - known at least to the second and always includes ainstant xs:dateTime second and always includes a timezone.

string xs:string A sequence of Unicode characters. uri xs:anyURI A Uniform Resource Identifier Referenceuri xs:anyURI A Uniform Resource Identifier Reference.

dateunion of xs:date, xs:gYearMonth, xs:gYear

A date, or partial date as used in human communication. No time zone. xs:gYear

dateTime

union of xs:dateTime, xs:date, xs:gYearMonth

A date, date-time or partial date as used in human communication. If hours and minutes are specified a time zone must

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

xs:gYearMonth, xs:gYear

minutes are specified, a time zone must be populated.

Page 22: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

派生型原始数据类型派生型原始数据类型Derived primitives

采用带有时区的 ISO 日期/时间“1951” “1951 06” 和 “1951 06 04” “1951”、“1951-06” 和 “1951-06-04”

“1951-06-04T10:57:34.0321+01” “1951-06-04T10:57:34.0321Z”

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 23: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

派生型原始数据类型Derived primitives

基于uri(!): OID 和 UUIDurn:oid:1 2 3 4 5 urn:oid:1.2.3.4.5

urn:uuid:a5afddf4-e880-459b-876e-e4591b0acc11

基于字串符:字 符 代码(字符序列,可含有单个的空格) - “4548-4”、

“active”、“not known” 、

id ([a-z0-9\-\.]{1,36})

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 24: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

接着往上:复合型数据类型接着往上 复合型数据类型Composite Datatypes

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 25: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

数据类型数据类型

现在,咱们来看看FHIR技术规范的数据类型“Data Types” :

http://www.hl7.org/implement/standards/fhir/datatypes.html

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 26: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

代码类数据类型代码类数据类型Coded types

Codes are defined in code systems代码是在代码系统之中定义的

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

代码是在代码系统之中定义的

Page 27: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

代码类数据类型代码类数据类型Coded types

在用于资源当中时,都会包括绑定Bindings一节

绑定规定的是究竟可以使用哪些代码 绑定规定的是究竟可以使用哪些代码

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 28: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 29: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

找些有意思的取值集合看看

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 30: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

• 关于发布的元数据• 来自一部或多部已有来自 部或多部已有代码系统的概念

• 其他额外的概念其他额外的概念

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

30

Page 31: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

上一层 资源上一层:资源

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 32: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

选项属性“Choice”选项属性 Choice

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 33: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

引用 References引用 References

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 34: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

快速查看一下扩展快速查看一下扩展

元数据

叙述

资源

元素

扩展扩展

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 35: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

扩展 Extensions扩展 Extensions

PatientMRN 22234

+ Haircolor BROWNMRN 22234“Ewout Kramer”30‐11‐1972Amsterdam

可以扩展:- 资源

资 之中的

头发颜色:棕色

Organization“ACME H it l”

- 资源之中的元素- FHIR数据类型

“ACME Hospital”National Drive 322Orlando, FL

++ Taxoffice Id NLOB33233

税务局: NLOB33233

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 36: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

多胎分娩扩展多胎分娩扩展

键标 Key = 正式定义的位置键标 Key = 正式定义的位置

值取值 Value = 符合定义的取值

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 37: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

复杂的扩展复杂的扩展

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

37

Page 38: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

快速查看一下叙述部分快速查看一下叙述部分

元数据

叙述

资源

元素

扩展扩展

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 39: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

叙述 Narrative叙述 Narrative

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 40: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 如何利用 RESTful 原理来进行资源的通讯传输

REST 服务接口REST SERVICE INTERFACE

FHIR 如何利用 RESTful 原理来进行资源的通讯传输

REST SERVICE INTERFACE

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 41: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

范式 Paradigms范式 Paradigms

FHIR 支持 4 种互操作性范式

REST 消息

文档 服务

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 42: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

REST?REST?

“REpresentational State Transfer”表达状态传输 表达状态传输

将您的数据表示为“资源”

让“资源”URI 便于寻址

利用HTTP 来进行 CRUD 操作 利用HTTP 来进行 CRUD 操作

可以利用不同的表达方法来交换资源

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 43: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

可能是分布式的可能是分布式的…

FHIR server @ lab.hospitalA.orgDiagnosticReport/4445 Observation/3ff27

FHIR server @ pat.registry.org

Patient/223

诊断报告

g p

观察结果

/

患者

Patient/223

主体对象

h i lFHIR server @ hospitalA.org

执业人员

Practitioner/87组织机构

Organization/1

执业人员组织机构

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 44: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

http://fhirblog.com/2014/01/24/modelling-encounters-with-fhir/

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 45: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

医疗保健服务的“存储库”模型医疗保健服务的 存储库 模型“Repository” model of healthcare

实验室信息系统医院信息系统

创建查询创建创建

查询 订阅创建更新

查询创建更新

创建更新

查询 订阅

Patient ObservationPatient患者 Observation

观察结果

诊断报告诊断报告诊断报告组织机构

FHIR 服务器

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 46: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

快捷的获取操作GET快捷的获取操作GET

GET /fhir/Patient/1 HTTP/1.1 HTTP 动词 + 路径

HTTP/1.1 200 OKContent‐Type: application/xml+fhir;charset=utf‐8Content‐Length: 787gContent‐Location: 

http://fhir.furore.com/fhir/Patient/1/_history/1Last Modified: Tue 29 May 2012 23:45:32 GMTLast‐Modified: Tue, 29 May 2012 23:45:32 GMT

<?xml version="1.0" encoding="UTF-8"?><Patient xmlns="http://hl7.org/fhir"><identifier><label>SSN</label><identifier><system>

UTF-8编码型

<Patient xmlns http://hl7.org/fhir ><identifier><label>SSN</label><identifier><system>http://hl7.org/fhir/sid/usssn</system><id>444222222</id></identifier></identifier><name><use>official</use><family>Everywoman</family><given>Eve</given></name><telecom><system>phone</system><value>555-555 2003</value><use>work</use></telecom><gender><system>http://hl7.org/fhir/sid/v2-0001</system><code>F</code></gender><birthDate>1973-05-31</birthDate><address><use>home</use><line>2222 Home Street</line></address><text><status>generated</status><div l "htt // 3 /1999/ ht l" E E SSN 444222222 /di /t t /P ti t

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

xmlns="http://www.w3.org/1999/xhtml">Everywoman, Eve. SSN:444222222</div></text></Patient>看到这个 BOM(字节顺序标记)了吗?

Page 47: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源的 REST 标识资源的 REST 标识

实际上是一个URL资源类型

http://server.org/fhir/Patient/1

端点 标识符

注释 该URL将解析到特定资源的当前版本注释:该URL将解析到特定资源的当前版本

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 48: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

还记得资源元数据吗?还记得资源元数据吗Resource metadata

元数据

Patient

MRN 22234

资源标识http://fhir.hl7.org/Patient/23E455A3Bhtt //fhi hl7 /P ti t/23E455A3B/ hi t /4MRN 22234

“Ewout Kramer”30-11-1972Amsterdam

http://fhir.hl7.org/Patient/23E455A3B/_history/4

最后更新于2013-12-23T23:33:01+01:002013-12-23T23:33:01+01:00

http://hl7.org/fhir/taghttp://example org/fhir/Status#Test

http://hl7.org/fhir/tag/profilehttp://hl7.org/fhir/Profile/us-core

http://example.org/fhir/Status#Test

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 49: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

标签元数据标签元数据Tag metadata

GET /fhir/Patient/1 HTTP/1.1

HTTP/1.1 200 OKContent‐Location: http://sever.om/fhir/Patient/1/_history/12Last‐Modified: Tue 29 May 2012 23:45:32 GMTLast‐Modified: Tue, 29 May 2012 23:45:32 GMTCategory: http://example.org/fhir/Status#Test; scheme=" http://hl7.org/fhir/tag"; label="Our test tag" 

http://hl7.org/fhir/tag 通用标签

概貌标签:关于当前资源符合其术语特http://hl7.org/fhir/tag/profile 概貌标签:关于当前资源符合其术语特征属性term之中所标识概貌的声明

http://hl7.org/fhir/tag/security 安全性标签

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 50: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

将(元)数据映射到HTTP将(元)数据映射到Mapping (meta)data to HTTP

Resource data http body Resource data Resource id

http body Url

Resource version Last update date

Content-Location header Last-Modified header

Tags Category header

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 51: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

再来看一下标头再来看 下标头One more look at the header

GET /fhir/Patient/1 HTTP/1.1

HTTP/1.1 200 OKContent‐Type: application/xml+fhir;charset=utf‐8Content‐Length: 787g

Content‐Location:  http://fhir.furore.com/fhir/Patient/1/_history/12Last‐Modified: Tue, 29 May 2012 23:45:32 GMT

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

51

Page 52: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

对于某个具体的版本对于某个具体的版本……

我们还备有版本专用 URL

基础路径

http://server.org/fhir/ (接下一行)资源类型

Patient/1/_history/4

版本标识符标识符 版本标识符

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 53: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

对于多版本的支持对于多版本的支持

33, v12 – 2012-12-04

33, v13 – 2012-12-05

/server.org/fhir/Patient/33/_history/12

/server.org/fhir/Patient/33/_history/13

33, v14 – 2012-12-08

33, v15 – 2012-12-09

/server.org/fhir/Patient/33/_history/14

/server org/fhir/Patient/33/ history/15/server.org/fhir/Patient/33/_history/15

/server.org/fhir/Patient/33

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 54: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

REST “表达方法”REST 表达方法

GET /fhir/Patient/1?_format=json HTTP/1.1

HTTP/1.1 200 OKContent‐Type: application/json+fhir;charset=utf‐8C t t L th 787Content‐Length: 787

GET /fhir/Patient/1 HTTP/1.1

接受:application/json+fhir

HTTP/1.1 200 OKContent‐Type: application/json+fhir;charset=utf‐8

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

yp pp jContent‐Length: 787

Page 55: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

疑问疑问

我真的不得不实施版本支持吗?

不需要,并不要求您保留历史,因而,针对任何要求既不需要,并不要求您保留历史,因而,针对任何要求既

往版本而不是当前版本的请求的读取版本操作“vread”,都可以返回410错误(不存在)

我真的需要支持此前的那些XML东西吗?

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 56: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

符合性符合性Conformance

• 哪个版本的FHIR?• 有哪些资源?• 有什么样的搜索操作?• 有什么样的格式?

这是不是测试服务器• 这是不是测试服务器?

• 我能联系谁?软件的名称是什么?• 软件的名称是什么?

• 您是否支持历史功能?• 您是否支持XML/JSON?• 您是否支持XML/JSON?

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

http://www.hl7.org/fhir/conformance.htm

Page 57: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR技术规范中的RESTFHIR技术规范中的REST

咱们先看看FHIR技术规范当中的那些操作……那些操作

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 58: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

与动词的映射关系与动词的映射关系Mapping to verbs

创建 create 2.1.10 创建交互create 将在服务器所指定的某个位置上创建一个新的资源。它是利用如下所示的HTTP POST操作来完成的:作来完成的:

POST [service‐url]/[resourcetype] (?_format=mimeType) 

读取 read 2.1.6 读取交互read将访问特定资源的现行内容。它是利用如下所示的HTTP GET操作来完成的:读取交 将访问特定资源的现行内容 是利用如下所示的 操作来完成的

GET [service‐url]/[resourcetype]/{id} (?_format=mimeType) 

更新 update 2.1.8 交互update将为某个已有资源创建一个新的现行版本,或者如果所指定id的资源尚不存在,则创建一个p新的资源。它是利用如下所示的HTTP PUT操作来完成的:

PUT [service‐url]/[resourcetype]/{id} (?_format=mimeType) 

删除 delete 2.1.9 交互read将删除某个已有的资源。它是利用如下所示的HTTP DELETE操作来完成的:

DELETE [service‐url]/[resourcetype]/{id} 

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 59: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

创建资源创建资源

可将相应的内容POST到某个表示相应资源类型的URL型的URL: 比如,http://server.org/fhir/Patient

在内容类型标头Content-Type当中提供正文body的格式y

服务器返回代码为 201 (已创建).并在位置标头L ti 之中仅仅返回所新指 并在位置标头Location 之中仅仅返回所新指定的版本标识符URL

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 60: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

更新资源更新资源

对相应资源的URL运用PUT操作,并在正文body中带上新的内容body中带上新的内容

在内容类型标头Content-Type中告诉服务器其正文body的格式(xml/json)

服务器将在内容位置标头Content-Location之 服务器将在内容位置标头Content Location之中返回代码200及新版本的URL

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 61: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

利用PUT创建资源利用PUT创建资源

服务器可能允许/不允许PUT 到一个尚不存在的标识符id的标识符id

若其允许:服务器将返回代码201,并在该位置上创建相应的资源 这样,就是由客户端来确定资源的标识符id!样,就是由客户端 确定资源的标识符

若不允许:服务器则返回代码405 (方法未经允许的)允许的)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 62: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

版本知晓型更新版本知晓型更新Version-aware updates

服务器需要客户端发送带有版本专用URL的内容位置标头Content Location内容位置标头Content-Location

服务器将利用该信息来检查您是不是要更新最新的版本

如果同时别人已经进行了更新 服务器将返 如果同时别人已经进行了更新,服务器将返回代码409 (冲突)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 63: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

何谓“已删除的”资源何谓 已删除的 资源What’s a ‘deleted’ Resource?

尝试读取操作时,将返回错误代码410 (不复存在) 而不是404 (未找到)存在),而不是404 (未找到)

搜索操作将不会返回这种资源

可以采用新的内容进行更新,来“恢复删除”

仅仅是资源历史当中的一个“标记”而已 仅仅是资源历史当中的一个 标记 而已

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 64: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

版本历史 – 删除版本历史 删除Version history - deletions

33, v12 – 2012-12-04

33, v13 – 2012-12-05

/server.org/fhir/Patient/33/_history/12

/server.org/fhir/Patient/33/_history/13

33, v14 – 2012-12-08/server.org/fhir/Patient/33/_history/14

/server.org/fhir/Patient/33/_history/1533, v15 – 2012-12-09

33, v16 – 2012-12-10

DELETION

/server.org/fhir/Patient/33/_history/16

DELETION

/server.org/fhir/Patient/33

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 65: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

版本历史 – 复活/恢复删除版本历史 复活/恢复删除Version history - revival

33, v13 – 2012-12-05

33, v14 – 2012-12-08/server.org/fhir/Patient/33/_history/14

/server.org/fhir/Patient/33/_history/13

/server.org/fhir/Patient/33/_history/1533, v15 – 2012-12-09

33, v16 – 2012-12-10/server.org/fhir/Patient/33/_history/16

33, v17 – 2012-12-11/server.org/fhir/Patient/33/_history/17

/server.org/fhir/Patient/33

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 66: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

在所提供的参考实施项目里,究竟是如何把资源变为类的

程序代码之中的资源RESOURCES IN CODE

在所提供的参考实施项目里,究竟是如何把资源变为类的

RESOURCES IN CODE

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 67: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

参考实施项目参考实施项目Reference implementations

- 内容模型:利用FHIR技术规范生成类- 模型:利用FHIR技术规范生成类

- 解析器:利用FHIR技术规范生成解析器

串行化程序:利用FHIR技术规范生成串行化程序- 串行化程序:利用FHIR技术规范生成串行化程序

- FhirClient:FHIR客户端

- 验证:当前仅有Java- 验证:当前仅有Java

Java:下载页面上一应俱全- Java:下载页面上 应俱全

- .NET:NuGet “FHIR”,或者 GitHub “fhir-net-api”

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 68: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

对象模型对象模型[FhirResource("DiagnosticReport")]public partial class DiagnosticReport : Resource{      

public Code<ObservationStatus> Status {…}

bli I t t I d { }public Instant Issued {…}

public ResourceReference Subject {…}

public ResourceReference Performer {…}

public Identifier ReportId { }public Identifier ReportId {… }

publicList<DiagnosticReportRequestDetailComponent>List<DiagnosticReportRequestDetailComponent> 

RequestDetail { …}

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

68

Page 69: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

利用C#进行解析/串行化利用C#进行解析/串行化

// Create a file‐based reader for XmlXmlReader xr = XmlReader.Create(

new StreamReader(@"publish\observation example xml"));new StreamReader(@ publish\observation‐example.xml ));

// Parse the Observation from the streamar obs (Obser ation)FhirParser ParseReso rce( r);var obs = (Observation)FhirParser.ParseResource(xr);

// Modify some fields of the observationb St t Ob ti Ob ti St t A d dobs.Status = Observation.ObservationStatus.Amended;obs.Value = new Quantity() { Value = 40, Units = "g" };

i i i i// Serialize the in‐memory observation to Jsonvar jsonText = FhirSerializer.SerializeResourceToJson(obs);

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 70: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

利用Java进行解析/串行化利用Java进行解析/串行化

XmlParser xml = new XmlParser();

Observation obs = (Observation)xml parse(newObservation obs = (Observation)xml.parse(newFileInputStream(“observation.xml"));

obs.setStatusSimple(ObservationStatus.amended);obs.setStatusSimple(ObservationStatus.amended);

Quantity newValue = new Quantity();newValue.setValueSimple(new BigDecimal(40));   p ( g ( ));newValue.setUnitsSimple("g");obs.setValue( newValue );

ByteArrayOutputStream bos = new ByteArrayOutputStream();JsonComposer comp = new JsonComposer();comp.compose(bos, obs, true);

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

String json = bos.toString("UTF8");

Page 71: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

C#中利用FHIR客户端C#中利用FHIR客户端

var client = new FhirClient( new Uri("http://fhir.com/svc/fhir"));new Uri( http://fhir.com/svc/fhir ));

var patEntry = client.Read<Patient>("1");var pat = patEntry.Resource;var restId = patEntry.Id;var tags patEntry Tags;var tags = patEntry.Tags;

pat.Name.Add(HumanName.ForFamily("Kramer")pat.Name.Add(HumanName.ForFamily( Kramer ).WithGiven("Ewout"));

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

client.Update<Patient>(patEntry);

Page 72: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

Java中利用FHIR客户端Java中利用FHIR客户端

FHIRClient client = new FHIRSimpleClient();client.initialize("http://spark.furore.com/fhir");( p p );

AtomEntry<Patient> pe = client.read(Patient.class, "1");P ti t tR ()Patient p = pe.getResource();

HumanName hn = new HumanName();HumanName hn = new HumanName();hn.getFamily().add(Factory.newString_("Kramer"));hn.getGiven().add(Factory.newString_("Ewout"));g () ( y g_( ))p.getName().add(hn);

li t d t (P ti t l "1")

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

client.update(Patient.class, p, "1");

Page 73: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 如何利用 Atom 来进行资源集合的通讯传输

捆束 BUNDLESFHIR 如何利用 Atom 来进行资源集合的通讯传输

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 74: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

列表的通讯传输列表的通讯传输Communicating lists

我们需要对资源列表进行通讯传输搜索结果 搜索结果

历史

文 或消息 文档或消息

多资源插入(“批处理”)

因此,我们需要一项用来表示列表的行业标准,以及一个用来放置元数据的地方准,以及 个用来放置元数据的地方

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 75: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

捆束 Bundle资源 Resource捆束 Bundle资源 Resource

元数据元数据

叙述资源资源

元素

捆束 Bundle 资源

扩展扩展

资源

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 76: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

捆束 Bundles捆束 Bundles

Atom RFC 4287 + Tombstones RFC 6721

基于Poll的协议:用于随时跟踪最新的新闻来的 议 随 跟踪 新的新闻源 (RSS 和 Atom)

您可以通过“订阅”某个FHIR feed,来获得更新

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 77: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

电子邮件之中新的检验报告电子邮件之中新的检验报告

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

77

Page 78: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

捆束示例捆束示例Example Bundle

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 79: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源元数据资源元数据Resource metadata

元数据

Patient

MRN 22234

资源标识http://fhir.hl7.org/Patient/23E455A3Bhtt //fhi hl7 /P ti t/23E455A3B/ hi t /4MRN 22234

“Ewout Kramer”30-11-1972Amsterdam

http://fhir.hl7.org/Patient/23E455A3B/_history/4

最后更新于2013-12-23T23:33:01+01:002013-12-23T23:33:01+01:00

http://hl7.org/fhir/taghttp://example org/fhir/Status#Test

http://hl7.org/fhir/tag/profilehttp://hl7.org/fhir/Profile/us-core

http://example.org/fhir/Status#Test

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 80: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源条目资源条目Resource Entry

资源标识符

最后修改日期/时间最后修改日期/时间

标签

版本专用标识符

资源内容

人工可读形式

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

人工可读形式,正如资源文本元素Resource.text

Page 81: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

Multiple versions of entriesMultiple versions of entries

Id相同!

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 82: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

Atom Tombstones – 删除to o bsto es 删除Atom Tombstones - Deletions

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 83: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

JSON格式的AtomJSON格式的Atom

目前,还没有采用JSON呈现Atom的方法,尽管现在有很多倡议 但全都不好看/ ugly尽管现在有很多倡议,但全都不好看/ ugly

因此,我们不得不自力更生(抱歉)…… ……非常简单明了,且用途单一的

Atom JSON 解决方案 Atom JSON 解决方案

(注:MIME 类型目前仍是application/json!)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 84: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

Json Atom 示例Json Atom – 示例

{"title": "Search result","updated": "2012-09-20T12:04:45Z",p ,"id": "urn:uuid:50ea3e5e-b6a7-4f55-956c-caef491bbc08","link": [ { "rel": "self", "href": "http://server.org/fhir/Patient?format=json" } ],"entry": [

{ "title": "Resource of type Patient, with id = 1 and version = 1","link": [ { "rel": "self", "href": "http://server.org/fhir/Patient/1/_history/1" } ],"id": "http://fhir.furore.com/fhir/Patient/1","updated": "2012 05 29T23:45:32Z"updated : 2012-05-29T23:45:32Z ,"published": "2012-09-20T12:04:47Z","author": [ { "name": "Grahame Grieve / HL7 publishing committee" } ],"content":

{ "Patient": { } }}

]

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

}

Page 85: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

捆束 Bundles捆束 Bundles

对于Java和C#,参考实施项目备有自制的Atom解析器Atom解析器

对于.NET,您可以采用该框架的SyndicationFeed 层次有点低层次有点低

不支持已删除条目(甚至存在解析问题)

不兼容 WinRT (Win8 移动应用) 不兼容 WinRT (Win8 移动应用)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 86: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

C# 之中的捆束之中的捆束Bundles in C#

位于 Atom 解析器上面的抽象

B dl f d B dl E t t Bundle = feed, BundleEntry = entry.Bundle result = new Bundle() { Title = "Demo bundle" };Bundle result   new Bundle() { Title    Demo bundle };

result.Entries.Add(new ResourceEntry<Patient>() { L tU d t d D t Ti Off t N C t t P ti t() }){ LastUpdated=DateTimeOffset.Now, Content = new Patient() });

result.Entries.Add(new DeletedEntry() { Id = new Uri("http://..."), When = DateTime.Now });

var bundleXml = FhirSerializer.SerializeBundleToXml(result);

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 87: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

Java之中的捆束之中的捆束Bundles in Javat d f d t d()AtomFeed feed = new AtomFeed();

feed.setTitle("Demo bundle");

AtomEntr pat ne AtomEntr ();AtomEntry pat = new AtomEntry();pat.setUpdated(Calendar.getInstance());pat.setResource(new Patient());feed getEntryList() add(pat);feed.getEntryList().add(pat);

AtomEntry del = new AtomEntry();del setUpdated(Calendar getInstance());del.setUpdated(Calendar.getInstance());del.setDeleted(true);  del.setId("http://nu.nl/fhir");feed.getEntryList().add(del);

ByteArrayOutputStream bos = new ByteArrayOutputStream();AtomComposer comp = new AtomComposer();comp.compose(bos, feed, true);

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

p p ( , , );String xml = bos.toString("UTF8");

Page 88: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

示例:保持同步示例:保持同步

服务器上所有资源的历史 http://server org/fhir/ history http://server.org/fhir/_history

服务器上所有患者资源的历史 htt // /fhi /P ti t/ hi t http://server.org/fhir/Patient/_history

服务器上特定患者资源的历史// / / / / http://server.org/fhir/Patient/1/_history

由所有变更组成的历史:更新和删除 且按 由所有变更组成的历史:更新和删除,且按最新者优先来排序

采用 i 和 t 进行限制

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

采用_since 和_count 进行限制

Page 89: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

最后,还有一种 REST操作 (目前):

搜索功能SEARCH FUNCTIONALITY

最后,还有 种 REST操作 (目前):

SEARCH FUNCTIONALITY

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 90: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

获取“所有的”患者获取 所有的 患者Getting “all” patients

http://server.org/fhir/Patient

始终返回的是一个经过分页的 feed

Use _count 用于表示每页结果的数量

“真实”搜索操作的特例:

http://server.org/fhir/Patient/_search?name=evehttp://server.org/fhir/Patient?name=eve

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 91: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

搜索患者资源搜索患者资源Search (patient)每种资源都有 套“标准的”搜索操作每种资源都有一套“标准的”搜索操作,因此,并不是对每个元素都能够进行搜索!

刚才我们最后刚才我们最后一次搜索使用的是这个参数

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 92: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

多项参数的组合使用多项参数的组合使用

指定多项参数时,将查找的是符合所有参数的那些资源 “AND”的那些资源 AND

每项参数可以列出多个取值 “OR” http://server.org/fhir

/Patient/search?/Patient/search?birthdate=1972-11-30

&language NL FR&language=NL,FR

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 93: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

搜索患者资源搜索患者资源Search (patient)

每项搜索参数都具有一种类型 ‘type’

参数类型

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

参数类型

Page 94: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

好吧,那我到底是找到没?好吧,那我到底是找到没Ok I get it…or not?

http://server.org/fhir/Patient/ 406 条符合http://server.org/fhir/Patient?gender=M 234 条符合p // g/ / g 条符合http://server.org/fhir/Patient?gender=F 167 条符合

401Total: 234 + 167 = 401

http://server org/fhir/Patient/ 406 条符合http://server.org/fhir/Patient/ 406 条符合http://server.org/fhir/Patient?gender=M 234 条符合http://server.org/fhir/Patient?gender=F 167 条符合http://server org/fhir/Patient?gender:missing=true 5 条符合http://server.org/fhir/Patient?gender:missing=true 5 条符合

Total: 234 + 167 + 5 = 406

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 95: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

链式搜索链式搜索Chained searches

患者资源有一个针对姓名“name”的搜索

P ti t h h f “ ” Patient has a search for “name”. 观察资源有一个针对主体对象 “subject” 观察资源 个 对 对象 j

(Patient、Group 或Device的id)的搜索

那么 在搜索患者姓名的同时 又如何找出 那么,在搜索患者姓名的同时,又如何找出该患者的那些观察结果呢?

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 96: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

二合一式查询合 式查询2 queries in 1

作为客户端,您不必分别单独进行操作,一次即可完成次即可完成:

http://server.com/fhir/Observation/_search?subject.name=jim

但请注意:这种方法仅对预先定义的搜索参数但请注意:这种方法仅对预先定义的搜索参数有效。只是不能采用资源的任何属性( property )

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

( property )

Page 97: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

更多的优化更多的优化

如说 我们进行如 搜索 比如说,我们进行如下搜索: http://fhir.com/fhir/Observation?date=2014-01-20p 我们获得: 一个具有 0..* 个观察资源“Observations” 的捆束Bundle

那么,我们通常难道不需要相应的患者信息吗? => 对于每个观察资源的主体对象吗? => 对于每个观察资源的主体对象“subject” ,那就需要进行“N”次查询

捷径 捷径:?_include=Observation.subject

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

j将同时返回 Observations + Patients

Page 98: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 如何支持消息/报文及文档

除了 REST 以外BEYOND REST

FHIR 如何支持消息/报文及文档

BEYOND REST

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 99: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

范式范式

FHIR 支持 4 种互操作性范式

REST 消息REST 消息

服务文档 服务

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

99

Page 100: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

无论范式如何无论范式如何内容都是一样的

接收消息之中的检验结果……

FHIR存储库

FHIR 消息FHIR 文档

检验信息系统

国家级交换中心

…将其包装在出院小结文档之中

交换中心

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

…将其包装在出院小结文档之中

Page 101: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.101

Page 102: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

文档资源文档资源Document resource

单独一个资源Resource,

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

且往往是一张列表资源List

Page 103: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 文档FHIR 文档

Bernard医生出院摘要 医生执业人员资源Practitioner

患者Mary患者资源Patient

出院摘要组合式文档资源Composition

肾结石情况资源Condition

主诉

生命体征列表资源list

脉搏观察资源Observation

血压

主诉章节section

体格检查

条目

出院药物

列表资源 血压观察资源Observation体格检查

章节section

出院药物列表资源list 双氯芬酸

药物处方MedicationPrescription

坦索罗辛

药物章节section 条目

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

坦索罗辛药物处方MedicationPrescription

Page 104: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

文档 – 属于捆束文档 属于捆束Documents – are bundles

组合式文书资源Composition

章节章节

<feed><entry>

<Composition />证实人员证实人员元数据元数据

章节章节 </entry><entry>

<Observation />/ t

观察资源Observation</entry><entry>

<Device /></entry>装置资源Device

处方资源P i i

</entry><entry>

<Prescription /></entry>

患者资源Patient

处方资源Prescription </entry><entry>

<Patient /></entry>

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

患者资源Patient </entry></feed>

Page 105: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

利用标签标记为“文档”利用标签标记为 文档Tag as “Document”

该捆束属于文档资源

Document

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Document

Page 106: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

文档的通讯传输文档的通讯传输

您可以把文档“投递(drop)”到:http://server org/fhir/Mailbox http://server.org/fhir/Mailbox

并不表示存储或拆解,只是完整地派送一份文档

当接收此类文档时 服务器可以实施交易伙 当接收此类文档时,服务器可以实施交易伙伴之间所需要/要求的任何具体功能

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 107: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

文档的通讯传输文档的通讯传输

您可以采用如何方式存储您的文档http://server org/fhir/Document http://server.org/fhir/Document

只是存储,并不表示拆解,文档(及签名)都会保持完整无缺

支持搜索(您可以针对它的消息标头进行搜 支持搜索(您可以针对它的消息标头进行搜索 – 组合式文书资源Composition )

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 108: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

V3 与 FHIRV3 与 FHIR

CDA -> FHIR文档桥

FHIR

FHIR 文档处理器

FHIRFHIR文档

存储库

FHIRREST

医院信息系统 A

注: 文档属于组合式文书资源compositions注: 文档属于组合式文书资源compositions• 不更新语义• 语境?• 完整性?

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

完整性?

Page 109: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

消息标头资源消息标头资源MessageHeader Resource

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 110: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

消息 – 也属于捆束消息 也属于捆束Messages – are bundles

消息资源Message来源地来源地 目的地目的地

<feed><entry>

<MessageHeader />

观察资源

</entry><entry>

<Observation />

事件事件

观察资源 Observation </entry><entry>

<Patient />/ t装置资源 Device </entry>

<entry><Device />

</entry>

患者资源 Patient

</entry></feed>

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 111: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

利用标签标记为“消息”利用标签标记为 消息Tag as “Message”

该捆束属于该捆束属于消息资源Message

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 112: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

发送消息发送消息

同样, REST没有必要,但是……存在着 个明确的REST端点 存在着一个明确的REST端点: http://server.org/fhir/Mailbox

并不表示存储。可能会是个路由(router),并转换成v2等等等等转换成v2等等等等

服务器可以依据相应的事件代码来处理它们,并将响应作为另 条消息来返回(同样也是并将响应作为另一条消息来返回(同样也是捆束bundle )

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 113: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

V2 与 FHIRV2 与 FHIR

V2 -> FHIR桥FHIR

FHIR 消息处理器

FHIRFHIR消息

存储库

FHIRREST

医院信息系统

注 消息属于事件 t注: 消息属于事件eventsREST公开的是某个“存储库”数据模型……

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 114: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

二进制资源端点进制资源端点Binary Endpoint

http://server.org/fhir/Binary/接受任何种类的内容 接受任何种类的内容

原样存储内容,并同时带有HTTP标头所提供原 存 容,并同 头所提供的内容类型信息

其行为正如普通的资源端点(Resource 其行为正如普通的资源端点(Resource endpoints)(但没有搜索)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 115: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

对附件有用对附件有用Useful for Attachments

/Binary/23344

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 116: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 分发形式的内部情况INSIDE THE FHIR DISTRIBUTIONINSIDE THE FHIR DISTRIBUTION

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 117: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 118: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

浏览FHIR站点浏览FHIR站点

REST API数据类型 数据类型

XML 和 JSON 代码/ 术语集

资源列表 资源列表

Stack Overflow 公开可用的测试服务器

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 119: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 分发形式FHIR 分发形式

Implementation->Support->Downloads在实施页面支持栏目的下载项当中提供有在实施页面支持栏目的下载项当中提供有: XSD Schema’s / schematrons

模型 串行 程序 解 Java / C# / Delphi zips (模型、串行化程序、解析器等,包括代码和二进制程序)

全部的 XML + JSON 示例

供离线阅读的技术规范全文( FHIR 随时随地陪伴在您的左右)

注意! .NET 实施项目已迁至GitHub

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

分发方:NuGet (.NET) 和 Maven (Java)

Page 120: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

在 FHIR SVN 中在 FHIR SVN 中

您只需构建 FHIR (/build)全部的讲义幻灯片(/ t ti ) 全部的讲义幻灯片(/presentations)

发布过程的来源 (/build/tools, 我们采用的是发 过程的 源 ( , 我们采 的是Eclipse + Java 1.6)

FHIR既往版本归档 (/archive) FHIR既往版本归档 (/archive)

您可以仅仅下载 /build 然后运行 publish bat 并等着就是啦

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

然后运行 publish.bat 并等着就是啦

Page 121: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR SVNFHIR SVN

“b ild” SVN 树状结构 “f ll” SVN 树状结构 “build” SVN 树状结构, “full” SVN 树状结构 http://gforge.hl7.org/svn/fhir 用户名 ‘anonymous’, 密码空白

注意:必须允许发布程序publisher才能构建C#和D l hi源代码 否则 不会编译!C#和Delphi源代码。否则……不会编译!

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 122: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 的源代码“Source” of FHIR

直接来自位于gforge.hl7.org 的代 存储库

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

HL7 SVN “code” 代码存储库

Page 123: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

发布过程发布过程

.INI示例

发布工具(org hl7 fhir tools jar)

示例

(org.hl7.fhir.tools.jar)

Java, C#,Delphi

网站 示例 资源UML

eCoreDefinitions.xml验证

Schema’s DictXml 资源概貌

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 124: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

生成器编写者Generator writers!

有一个C#生成器所采用的文件,名为:eCoreDefinitions xml 该文件之中有来自各eCoreDefinitions.xml 。该文件之中有来自各种定义的所有详细信息

对于每种资源,存在着若干的概貌Profiles, 对于每种资源,存在着若干的概貌Profiles,基本上描述的是那些“未经约束的”资源

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 125: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

简要介绍一下

概貌与验证PROFILES AND VALIDATION

简要介绍 下

PROFILES AND VALIDATION

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 126: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

概貌的必要性概貌的必要性The need for Profiles

医疗保健领域有许多不同的语境,但资源却只有那么一套只有那么一套

需要能够依据用途和语境来描述相应的约束

考虑到下列用法: 采用结构化方式编纂 采用结构化方式编纂

在存储库之中发布

作为基础 用于验证、编写代码、报告和生成用户界面 作为基础,用于验证、编写代码、报告和生成用户界面

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 127: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

基数的约束基数的约束Constraining cardinality

将基数限制为1..2(比如,最多是贵机构的标识符+(比如,最多是贵机构的标识符全国性标识符)1..2

1..1

将姓名元素name限制为仅仅1个 (而不是 0..*)0..0

禁用任何的电子通讯方式元素telecom

注意:在核心定义之中,有的东西为强制型(必填型),无法在概貌中改为可选型

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 128: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

对值域加以限制对值域加以限制Limit value domains

如果提供deceased, 则必须为dateTime, 而不是boolean

OrganizationNL

对于MaritalStatus,采用全国性的代码

=“true” 采用另一种经过概貌约束的资源(profiled Resource)

固定取值: 只允许“active”

(profiled Resource)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

固定取值 只允许 active 为真的患者Patients

Page 129: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

采用标签来标记资源采用标签来标记资源Tagging a Resource

Patient

MRN 22234

http://hl7.org/fhir/tag/security“我是VIP身份 – 不能透露我的信息”MRN 22234

“Ewout Kramer”30-11-1972Amsterdam

我是 身份 不能透露我的信息

http://hl7.org/fhir/tag“这是测试数据! 请勿使用!”

http://hl7.org/fhir/tag/profilehttp://hl7.org/fhir/tag/profile“我是挪威概貌之中所定义的一个患者资源Patient – 参见http://hl7.no/Profiles/patient-no”

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 130: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

验证 Validation验证 Validation

2.1.12 validation验证交互旨在检查是否可将所附加的内容接受为验证交互旨在检查是否可将所附加的内容接受为对于某个已有资源的更新。该交互是利用如下的HTTP POST操作来完成的HTTP POST操作来完成的:

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 131: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

验证 Validation验证 Validation

当收到一个 XML 资源时1 利用 S h 进行验证 1. 利用 Schema 进行验证

2. 运行 Schematrons 当收到 JSON

1. 解析 JSON解析

2. 串行化为 XML 3 利用 Schema 进行验证 3. 利用 Schema 进行验证

4. 运行 Schematrons目前 有 个适用于J 的验证包

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

目前,有一个适用于Java 的验证包

Page 132: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

(分布式) 验证( )(Distributed) validation

应用程序服务器

存储和验证全国性验证服务器

概貌 X概貌 X

概貌 Y

概貌 Y

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 133: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

操作结局资源操作结局资源Operation Outcome

一旦出现问题…… 就会返回操作结局资源OperationOutcome!OperationOutcome!

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 134: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR 实践

构建FHIR服务器BUILDING A FHIR SERVER

FHIR 实践

BUILDING A FHIR SERVER

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 135: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

一些可能的情况一些可能的情况

v3 应用程序

v2 FHIR

FHIR

代理

PHRFHIR

公共接口

FHIR 数据库

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

135

Page 136: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

存储库模型存储库模型

HIS LIMS PACS XXX系统 网关

FHIR FHIR FHIRFHIRFHIR

厂商中立型存储库

FHIR FHIR FHIRFHIRFHIR

厂商中立型存储库Vendor Neutral Repository

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 137: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

服务器概览服务器概览

HTTP / REST 接口 编码/解码、参数验证、参数验证、语法验证按技术规范之中的

描述实施各项服务操作

FHIR服务

操作

索引程序/搜索 存储

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

137

Page 138: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

从有线格式到存储格式从有线格式到存储格式From wire to store

REST 接口 JSON/XML JSON/XML JSON/XML

FHIR 解析器 FHIR解析器 FHIR解析器

FHIR服务 POCO/POJO POCO/POJO POCO/POJO

存储

O-R 映射 串行化

NoSql

串行化

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

存储DBMS

138

NoSql(Xml/Json) DBMS

Page 139: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

极其简单地介绍一下JSON极其简单地介绍一下JSON

JSON (“JavaScript Object Notation”): 实质是JavaScript 并不是置标/标记/markup语言!JavaScript,并不是置标/标记/markup语言!

{ “Country" : {

“ " “th N th l d "“name" : “the Netherlands",“population" : 16696000,“popDensity” : 447.9

}}}

var report = eval(“({…})”);alert(report.LabReport.status);

JavaScript 客户端解析起来非常容易。

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

p 客户端解析起 非常容易但实际上,采用的却是JSON.parse() ;-)

Page 140: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

Xml 不同于 JSONXml 不同于 JSON

XML<XXX xmlns=“urn:foo”>

JSON{ “B”: { “a” : “c” }<XXX xmlns= urn:foo >

<B a=“c” /><C>One</C>

{ B : { a : c },“C”: [ “One”, “Two” ],“D” : “One”,

<C>Two</C><D>One</D>

/

“div” : {“text-before”:“Not ”,

<div>Not <b>so</b>easy</div>

</XXX>

b:“so”,“tekst-after”:“easy”}

}/ }

• 任何保留命名空间?• 如何标识特征属性attributes?

• 如何区分单个元素与某个元素之中的列表?

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.14

• 数据类型之间的差异如何过渡? • 混合型内容(Mixed content)呢?

Page 141: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR之中的XML和JSONFHIR之中的XML和JSON

code.coding is 0..*

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 142: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

FHIR之中的XML和JSONFHIR之中的XML和JSON

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 143: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

对二者的处理对二者的处理

您需要利用定义的”元”语言来区分列表/特征属性 lists / attributes性:lists / attributes

Java/C# APIs能够轻松地完成相互转换

数字签名(采用JSON?) 在转换时是个问题存储原始格式存储原始格式

JAXB / XmlSerializer / DataContract 会需要大量的定制/额外的 @ t ti / [ tt ib t ]大量的定制/额外的 @annotation / [attributes]。联系我们!

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 144: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

面向文档型存储面向文档型存储Document-oriented store

面向文档型存储可以将若干的资源存储为一份“完整的”文档份 完整的 文档

比如,MongoDb 就可以采用JSON存储文档:post = { author: “mike”,

text: “my blog post...”, tags: [“mongodb”,“intro”] };

db.posts.save( post );p ( p )

db.posts.find( { author: “mike” } );db.posts.find().sort({date: -1}).limit(10);

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

db.posts.find().sort({date: 1}).limit(10);

Page 145: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 146: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

无 (sql) 交易无 ( q ) 交易No (sql) transactions

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 147: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

批处理:需要交易批处理 需要交易Batch: needs transactions

交易transaction 交易

交易交互用于提交所要在服务器上更新、创建或删除的一套资源。该交互允许在单次交易当中更新/创建多个资源。该交互是利用如下的交互允许在单次交易当中更新/创建多个资源。该交互是利用如下的HTTP POST 操作来完成的:

POST [service-url] (?_format=mimeType)

该POST操作所提交的内容是一个资源捆束(resource bundle)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 148: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

资源的存储资源的存储

FHIR POCO 模型

Mongo

患者资源 观察资源二进制资源

Atom 条目(所存储的JSON)

Patient ObservationBinary( )

资源

Amazon S3 元数据

二进制资源Binary

原始格式(JSON或XML)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 149: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

RDBMS: BLOB + 索引RDBMS: BLOB + 索引

Id ResourceId VersionId LastUpdate Contents1 1 1 2012-12-19 <Patient …>

i2 1 2 2012-12-20 <Patient …>

3 2 1 2012-12-20 <Observation …>

Id Param Value System2 Patient.Name “Ewout”2 Patient.DoB “1972-11-30”

现行和历史分别采用不同的表?

3 Obs.Code “234332” SNOMED

Type VersionIdHighyp gPatient 2

Lab 3

只需索引最新版本!

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 150: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

施两个实施项目分别采用单独加以维护的搜索索引吗?的搜索索引吗?

是。其原因就是……

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 151: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

具有可预测性的搜索具有可预测性的搜索Predictable search

每种资源都具有固定的一套搜索参数:

所搜索的所搜索的元素

参数数据类型

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

数据类型

Page 152: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

参数的数据类型参数的数据类型

integer 搜索参数必须是简单整数

string 搜索参数为简单字符串,如姓名的组成部分。搜索不区分大小写和重音。可能配的只是字符串的开头匹配的只是字符串的开头。

date 搜索的是特定日期的精确匹配记录(参数的形式如1956-05-27T12:34:12+04:00或者更短)

token 搜索参数针对的是代码类元素或标识符。可用于搜索文本、显示名称displayname、代码code和代码/系统code/codesystem (对于代码)以及标记(label)、系统(system )和键值(key )(对于标识符)

reference 资源类型和资源标识符所组成的对子并以“/”分隔。在资源引用解析到指定类型和标识符的时候进行匹配。类型和标识符的时候进行匹配。

注意:您需要对查询字符串进行转义!!

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 153: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

部分/组合式匹配Partial/combined match

搜索参数描述表明,匹配肯定并非始终都是精确的,且甚至可以组合使用几个元素的内容:

名称/ 类型 描述

个元素的内容:

address : string 任何种类地址/患者资源组成部分之中的地址

family : string 患者姓氏的一部分

given : string 患者名字的一部分

name : string 患者姓氏或名字的一部分name : string 患者姓氏或名字的一部分

phonetic : string 采用某种语音匹配算法时,姓氏或名字的一部分

telecom : string 患者任何种类电子通讯方式详情之中的取值

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 154: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

准备您自己的数据!准备您自己的数据!

patient/search?name=johan&name=johan&name=grafin&t l 5552004telecom=5552004

“Groom” – 为搜索做准备使…作好准备使…作好准备

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 155: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

马上就结束啦……

当前教程已接近尾声……马上就结束啦……

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 156: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

投票计划投票计划

首个试行版标准(DSTU)已完成 FHIR 如今已经发布为DSTU 今 发布为

将为实施人员提供半稳定性的平台,而同时如果实施经验表明的确需要的话,仍允许为规范版而进行非向后兼容性变更

更多的DSTU版本大概每年都会进行修订 引入新的资源 更多的DSTU版本大概每年都会进行修订,引入新的资源

规范版标准的出台大约要3年左右的时间 规范版标准的出台大约要3年左右的时间 在致力于向后兼容性工作之前,我们还需要*很多很多的*实施经验

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 157: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

下一步您能做什么下一步您能做什么

阅读FHIR技术规范:http://hl7.org/fhir 试着去实施FHIR吧 试着去实施FHIR吧

来(欧洲?)参加Connectathon连通测试活动

[email protected] #FHIR #FHIR 实施人员频道Skype Channel 阿姆斯特丹举办的FHIR开发者活动日(11月24 – 26日) 阿姆斯特丹举办的FHIR开发者活动日(11月24 – 26日) StackOverflow: hl7 fhir tag

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

Page 158: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

国际HL7 FHIR 开发者活动日International HL7 FHIR Developer DaysInternational HL7 FHIR Developer Days

阿姆斯特丹 2014年11月24-26日 教育培训 教育培训

共有14 个培训教程

可供您挑选

Connectathon 与开发者同道会面

参与FHIR测试活动

建立人际网络 随时可以接触/联系到FHIR专家和编制人员

http://fhir furore com/devdayshttp://fhir.furore.com/devdays

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

158

Page 159: 开发人员FHIR教程 FHIRforDevelopersFHIR for Developerswiki.hl7.org.cn/images/4/40/FHIR_for_Developers-1405... · 2016-03-23 · 资源Resources(Resources (回顾!) “资源”

提问环节提问环节

http://hl7.org/fhir

Authored and Presented by Ewout Kramer (2014-05)Translated by Lin Zhang (2014-10-07)

© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

159