wanghaisheng / fhir-cn

FHIR中文版 the Chinese translation of FHIR
https://github.com/FHIR-CN/fhir-spec-ZhCN
72 stars 23 forks source link

The new DSTU2 Operations framework #46

Closed wanghaisheng closed 9 years ago

wanghaisheng commented 9 years ago

http://thefhirplace.com/2015/04/29/the-new-dstu2-operations-framework/ http://hl7-fhir.github.io/operations.html http://hl7-fhir.github.io/parameters.html

wanghaisheng commented 9 years ago

Each operation has a name 但给的例子名称都是$开头的,但是没有那里明确的说明

wanghaisheng commented 9 years ago

在OperationDefinition的字段里有一个OperationDefinition.kind 有2个取值 operation | query 但如何确定该rpc使用的是HTTP的PUT/GET/POST呢?

if it’s “operation” it’s a POST, if it’s “query” it’s a FHIR search operation.

operation部分的解释

2.2.0.5.1 Operation Request In the general case, an operation is invoked by performing an HTTP POST to the operation end-point. The format of the submitted content is the special Parameters format - a list of named parameters (the "in" parameters). For an example, see the value set expansion request example.

Note that the same arrangement as the RESTful interface applies in regard to content types.

If there are no parameters with complex types (including resources) to the operation, and the operation is idempotent (see HTTP specification definition of idempotent), the operation may be invoked by performing an HTTP GET operation where all the parameters are appended to the URL in the search portion of the URL (e.g. after the "?"). Servers SHALL support this method of invocation.

search部分的解释

In the simplest case, a search is executed by performing a GET operation in the RESTful framework: GET [base]/[resourcetype]?name=value&... For this RESTful search (see definition in RESTful API), the parameters are a series of name=[value] pairs encoded in the URL or as an application/x-www-form-urlencoded submission for a POST. The server returns the results in the HTTP response as a bundle which includes the resources that are the results of the search. The server can also include additional resources in the result set, such as OperationOutcome resources. Clients should ignore resources that don't have the expected type. A HTTP status code of 403 signifies that the server refused to perform the search, while some other 4xx or 5xx code signifies that some error occurred.

对Content-Type=application/x-www-form-urlencoded使用的解释 http://www.cnblogs.com/liangjie/archive/2011/05/25/2057399.html https://www.imququ.com/post/four-ways-to-post-data-in-http.html

The OperationDefinition resource provides a formal computable definition of an operation or a named query 也就是说一个OperationDefinition要么是定义一个operation 要么是定义一个特定名称的查询

wanghaisheng commented 9 years ago

对于operation而言,正常情况下,都是使用POST方法,提交的是Parameters对象,Parameters对象把定义的各种in参数整合起来,例外情况下(各种in参数均是基本数据类型),服务器可以选择支持GET方法,将in参数以?参数名=参数值形式拼接在URL的operation名称后面 对于operation的Content-Type也使用如下

XML: application/xml+fhir JSON: application/json+fhir

wanghaisheng commented 9 years ago

对于特定名称的查询而言,鉴于它还是个查询,查询机制里是这么说的,一般都是GET方法,参数跟在URL中,例如?name=value的形式,但是特殊情况也可以使用POST方法,Content-Type设为application/x-www-form-urlencoded ,这时候body的内容应该是

在 Content-Type=application/x-www-form-urlencoded 消息中: ...... name=ryan+ou&email=ryan@rhythmtechnology.com ...... (不同的field会用"&"符号连接;空格被替换成"+";field和value间用"="联系,等等)

为什么不能使用Parameters来封装所有search中的查询参数,这样就不会使用Content-Type=application/x-www-form-urlencoded 了