Skip to content

Commit 581ec00

Browse files
authored
Merge pull request #194625 from mikaelweave/main
Updated FHIR REST docs to include PATCH operation.
2 parents 0ec8e94 + cfa35d2 commit 581ec00

File tree

6 files changed

+113
-53
lines changed

6 files changed

+113
-53
lines changed

articles/healthcare-apis/azure-api-for-fhir/fhir-features-supported.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: healthcare-apis
77
ms.subservice: fhir
88
ms.topic: reference
99
ms.date: 03/21/2022
10-
ms.author: cavoeg
10+
ms.author: mikaelw
1111
---
1212

1313
# Features
@@ -31,8 +31,8 @@ Below is a summary of the supported RESTful capabilities. For more information o
3131
| update | Yes | Yes | |
3232
| update with optimistic locking | Yes | Yes |
3333
| update (conditional) | Yes | Yes |
34-
| patch | Yes | Yes | Support for [JSON Patch](https://www.hl7.org/fhir/http.html#patch) only. We've included a workaround to use JSON Patch in a bundle in [this PR](https://github.com/microsoft/fhir-server/pull/2143).|
35-
| patch (conditional) | Yes | Yes | Support for [JSON Patch](https://www.hl7.org/fhir/http.html#patch) only. We've included a workaround to use JSON Patch in a bundle in [this PR](https://github.com/microsoft/fhir-server/pull/2143).
34+
| patch | Yes | Yes | Support for [JSON Patch and FHIRPath Patch](../../healthcare-apis/fhir/fhir-rest-api-capabilities.md#patch-and-conditional-patch) only.
35+
| patch (conditional) | Yes | Yes | Support for [JSON Patch and FHIRPath Patch](../../healthcare-apis/fhir/fhir-rest-api-capabilities.md#patch-and-conditional-patch) only. |
3636
| history | Yes | Yes |
3737
| create | Yes | Yes | Support both POST/PUT |
3838
| create (conditional) | Yes | Yes | Issue [#1382](https://github.com/microsoft/fhir-server/issues/1382) |

articles/healthcare-apis/azure-api-for-fhir/fhir-rest-api-capabilities.md

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: healthcare-apis
66
ms.subservice: fhir
77
ms.topic: conceptual
88
ms.date: 02/15/2022
9-
ms.author: cavoeg
9+
ms.author: mikaelw
1010
---
1111

1212
# FHIR REST API capabilities for Azure API for FHIR
@@ -68,64 +68,94 @@ After you've found the record you want to restore, use the `PUT` operation to re
6868
6969
## Patch and Conditional Patch
7070

71-
Patch is a valuable RESTful operation when you need to update only a portion of the FHIR resource. Using Patch allows you to specify the element(s) that you want to update in the resource without having to update the entire record. FHIR defines three types of ways to Patch resources in FHIR: JSON Patch, XML Patch, and FHIR Path Patch. Azure API for FHIR supports JSON Patch and Conditional JSON Patch (which allows you to Patch a resource based on a search criteria instead of an ID). To walk through some examples of using JSON Patch, refer to the sample [REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/FhirPatchRequests.http).
71+
Patch is a valuable RESTful operation when you need to update only a portion of the FHIR resource. Using patch allows you to specify the element(s) that you want to update in the resource without having to update the entire record. FHIR defines three ways to Patch resources: JSON Patch, XML Patch, and FHIRPath Patch. The FHIR Service support both JSON Patch and FHIRPath Patch along with Conditional JSON Patch and Conditional FHIRPath Patch (which allows you to Patch a resource based on a search criteria instead of a resource ID). To walk through some examples, refer to the sample [FHIRPath Patch REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/FhirPatchRequests.http) and the [JSON Patch REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/JsonPatchRequests.http) for each approach. For additional details, read the [HL7 documentation for patch operations with FHIR](https://www.hl7.org/fhir/http.html#patch).
7272

7373
> [!NOTE]
7474
> When using `PATCH` against STU3, and if you are requesting a History bundle, the patched resource's `Bundle.entry.request.method` is mapped to `PUT`. This is because STU3 doesn't contain a definition for the `PATCH` verb in the [HTTPVerb value set](http://hl7.org/fhir/STU3/valueset-http-verb.html).
7575
76-
### Testing Patch
76+
### Patch with FHIRPath Patch
7777

78-
Within Patch, there's a test operation that allows you to validate that a condition is true before doing the patch. For example, if you wanted to set a patient deceased, only if they weren't already marked as deceased, you could use the example below:
78+
This method of patch is the most powerful as it leverages [FHIRPath](https://hl7.org/fhirpath/) for selecting which element to target. One common scenario is using FHIRPath Patch to update an element in a list without knowing the order of the list. For example, if you want to delete a patient’s home telecom information without knowing the index, you can use the example below.
7979

80-
PATCH `http://{FHIR-SERVICE-NAME}/Patient/{PatientID}`
80+
PATCH `http://{FHIR-SERVICE-HOST-NAME}/Patient/{PatientID}`<br/>
81+
Content-type: `application/fhir+json`
82+
83+
```
84+
{
85+
"resourceType": "Parameters",
86+
"parameter": [
87+
{
88+
"name": "operation",
89+
"part": [
90+
{
91+
"name": "type",
92+
"valueCode": "delete"
93+
},
94+
{
95+
"name": "path",
96+
"valueString": "Patient.telecom.where(use = 'home')"
97+
}
98+
]
99+
}
100+
]
101+
}
102+
```
103+
104+
Any FHIRPath Patch operations must have the `application/fhir+json` Content-Type header set. FHIRPatch Patch supports add, insert, delete, remove, and move operations. FHIRPatch Patch operations also can be easily integrated into Bundles. For more examples, look at the sample [FHIRPath Patch REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/FhirPatchRequests.http).
105+
106+
### Patch with JSON Patch
107+
108+
JSON Patch in the FHIR Service conforms to the well-used [specification defined by the Internet Engineering Task Force](https://datatracker.ietf.org/doc/html/rfc6902). The payload format does not use FHIR resources and instead uses a JSON document leveraging JSON-Pointers for element selection. JSON Patch is more compact and has a test operation that allows you to validate that a condition is true before doing the patch. For example, if you want to set a patient as deceased only if they're not already marked as deceased, you can use the example below.
109+
110+
PATCH `http://{FHIR-SERVICE-HOST-NAME}/Patient/{PatientID}`<br/>
81111
Content-type: `application/json-patch+json`
82112

83113
```
84114
[
85115
{
86-
“op”: “test,
87-
path”: “/deceasedBoolean,
88-
value: false
116+
"op": "test",
117+
"path": "/deceasedBoolean",
118+
"value": false
89119
},
90120
{
91-
“op”: “replace
92-
path”: “/deceasedBoolean,
93-
value: true
121+
"op": "replace",
122+
"path": "/deceasedBoolean",
123+
"value": true
94124
}
95125
]
96-
97126
```
98127

99-
### Patch in Bundles
128+
Any JSON Patch operations must have the `application/json-patch+json` Content-Type header set. JSON Patch supports add, remove, replace, copy, move, and test operations. For more examples, look at the sample [JSON Patch REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/JsonPatchRequests.http).
129+
130+
#### JSON Patch in Bundles
100131

101-
By default, JSON Patch isn't supported in Bundle resources. This is because a Bundle only supports with FHIR resources and JSON Patch isn't a FHIR resource. To work around this, we'll treat Binary resources with a content-type of `"application/json-patch+json"`as base64 encoding of JSON string when a Bundle is executed. For information about this workaround, log in to [Zulip](https://chat.fhir.org/#narrow/stream/179166-implementers/topic/Transaction.20with.20PATCH.20request).
132+
By default, JSON Patch isn't supported in Bundle resources. This is because a Bundle only supports with FHIR resources and the JSON Patch payload isn't a FHIR resource. To work around this, we'll use Binary resources with a Content-Type of `"application/json-patch+json"` and the base64 encoding of the JSON payload inside of a Bundle. For information about this workaround, view this topic on the [FHIR Chat Zulip](https://chat.fhir.org/#narrow/stream/179166-implementers/topic/Transaction.20with.20PATCH.20request).
102133

103134
In the example below, we want to change the gender on the patient to female. We've taken the JSON patch `[{"op":"replace","path":"/gender","value":"female"}]` and encoded it to base64.
104135

105-
POST `https://{FHIR-SERVICE-NAME}/`
106-
content-type: `application/json`
136+
POST `https://{FHIR-SERVICE-HOST-NAME}/`<br/>
137+
Content-Type: `application/json`
107138

108139
```
109140
{
110-
resourceType”: “Bundle
111-
“id”: “bundle-batch,
112-
type”: “batch
113-
entry: [
141+
"resourceType": "Bundle",
142+
"id": "bundle-batch",
143+
"type": "batch",
144+
"entry": [
114145
{
115-
fullUrl”: “Patient/{PatientID},
116-
resource: {
117-
resourceType”: “Binary,
118-
contentType”: “application/json-patch+json,
119-
data: "W3sib3AiOiJyZXBsYWNlIiwicGF0aCI6Ii9nZW5kZXIiLCJ2YWx1ZSI6ImZlbWFsZSJ9XQ=="
146+
"fullUrl": "Patient/{PatientID}",
147+
"resource": {
148+
"resourceType": "Binary",
149+
"contentType": "application/json-patch+json",
150+
"data": "W3sib3AiOiJyZXBsYWNlIiwicGF0aCI6Ii9nZW5kZXIiLCJ2YWx1ZSI6ImZlbWFsZSJ9XQ=="
120151
},
121-
request: {
122-
method”: “PATCH,
123-
url”: “Patient/{PatientID}
152+
"request": {
153+
"method": "PATCH",
154+
"url": "Patient/{PatientID}"
124155
}
125156
}
126157
]
127158
}
128-
129159
```
130160

131161
## Next steps

articles/healthcare-apis/azure-api-for-fhir/release-notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.subservice: fhir
88
ms.topic: reference
99
ms.date: 03/21/2022
1010
ms.custom: references_regions
11-
ms.author: cavoeg
11+
ms.author: mikaelw
1212
---
1313

1414
# Release notes: Azure API for FHIR
@@ -88,7 +88,7 @@ Azure API for FHIR provides a fully managed deployment of the Microsoft FHIR Ser
8888
|Conditional patch |[#2163](https://github.com/microsoft/fhir-server/pull/2163) |
8989
|Added conditional patch audit event. |[#2213](https://github.com/microsoft/fhir-server/pull/2213) |
9090

91-
|Allow JSON patch in bundles | [JSON patch in bundles](././../azure-api-for-fhir/fhir-rest-api-capabilities.md#patch-in-bundles)|
91+
|Allow JSON patch in bundles | [JSON patch in bundles](././../azure-api-for-fhir/fhir-rest-api-capabilities.md#json-patch-in-bundles)|
9292
| :----------------------------------- | ------: |
9393
|Allows for search history bundles with Patch requests. |[#2156](https://github.com/microsoft/fhir-server/pull/2156) |
9494
|Enabled JSON patch in bundles using Binary resources. |[#2143](https://github.com/microsoft/fhir-server/pull/2143) |

articles/healthcare-apis/fhir/fhir-features-supported.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: healthcare-apis
77
ms.subservice: fhir
88
ms.topic: reference
99
ms.date: 03/01/2022
10-
ms.author: cavoeg
10+
ms.author: mikaelw
1111
---
1212

1313
# Supported FHIR Features
@@ -31,8 +31,8 @@ Below is a summary of the supported RESTful capabilities. For more information o
3131
| update | Yes | Yes | |
3232
| update with optimistic locking | Yes | Yes |
3333
| update (conditional) | Yes | Yes |
34-
| patch | Yes | Yes | Support for [JSON Patch](../../healthcare-apis/fhir/fhir-rest-api-capabilities.md#patch-and-conditional-patch) only. |
35-
| patch (conditional) | Yes | Yes |
34+
| patch | Yes | Yes | Support for [JSON Patch and FHIRPath Patch](../../healthcare-apis/fhir/fhir-rest-api-capabilities.md#patch-and-conditional-patch) only. |
35+
| patch (conditional) | Yes | Yes | Support for [JSON Patch and FHIRPath Patch](../../healthcare-apis/fhir/fhir-rest-api-capabilities.md#patch-and-conditional-patch) only. |
3636
| history | Yes | Yes |
3737
| create | Yes | Yes | Support both POST/PUT |
3838
| create (conditional) | Yes | Yes | Issue [#1382](https://github.com/microsoft/fhir-server/issues/1382) |

articles/healthcare-apis/fhir/fhir-rest-api-capabilities.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
2-
title: FHIR Rest API capabilities for Azure Health Data Services FHIR service
2+
title: FHIR REST API capabilities for Azure Health Data Services FHIR service
33
description: This article describes the RESTful interactions and capabilities for Azure Health Data Services FHIR service.
44
author: stevewohl
55
ms.service: healthcare-apis
66
ms.subservice: fhir
77
ms.topic: conceptual
88
ms.date: 03/09/2022
9-
ms.author: cavoeg
9+
ms.author: mikaelw
1010
---
1111

12-
# FHIR Rest API capabilities for Azure Health Data Services FHIR service
12+
# FHIR REST API capabilities for Azure Health Data Services FHIR service
1313

1414
In this article, we'll cover some of the nuances of the RESTful interactions of Azure Health Data Services FHIR service (hereby called FHIR service).
1515

@@ -67,16 +67,46 @@ After you've found the record you want to restore, use the `PUT` operation to re
6767
6868
## Patch and Conditional Patch
6969

70-
Patch is a valuable RESTful operation when you need to update only a portion of the FHIR resource. Using Patch allows you to specify the element(s) that you want to update in the resource without having to update the entire record. FHIR defines three types of ways to Patch resources in FHIR: JSON Patch, XML Patch, and FHIR Path Patch. The FHIR service support JSON Patch and Conditional JSON Patch (which allows you to Patch a resource based on a search criteria instead of an ID). To walk through some examples of using JSON Patch, refer to the sample [REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/FhirPatchRequests.http).
70+
Patch is a valuable RESTful operation when you need to update only a portion of the FHIR resource. Using patch allows you to specify the element(s) that you want to update in the resource without having to update the entire record. FHIR defines three ways to patch resources: JSON Patch, XML Patch, and FHIRPath Patch. The FHIR Service support both JSON Patch and FHIRPath Patch along with Conditional JSON Patch and Conditional FHIRPath Patch (which allows you to patch a resource based on a search criteria instead of a resource ID). To walk through some examples, refer to the sample [FHIRPath Patch REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/FhirPatchRequests.http) and the [JSON Patch REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/JsonPatchRequests.http) for each approach. For additional details, read the [HL7 documentation for patch operations with FHIR](https://www.hl7.org/fhir/http.html#patch).
7171

7272
> [!NOTE]
7373
> When using `PATCH` against STU3, and if you are requesting a History bundle, the patched resource's `Bundle.entry.request.method` is mapped to `PUT`. This is because STU3 doesn't contain a definition for the `PATCH` verb in the [HTTPVerb value set](http://hl7.org/fhir/STU3/valueset-http-verb.html).
7474
75-
### Testing Patch
75+
### Patch with FHIRPath Patch
7676

77-
Within Patch, there's a test operation that allows you to validate that a condition is true before doing the patch. For example, if you want to set a patient as deceased (only if they're not already marked as deceased) you can use the example below:
77+
This method of patch is the most powerful as it leverages [FHIRPath](https://hl7.org/fhirpath/) for selecting which element to target. One common scenario is using FHIRPath Patch to update an element in a list without knowing the order of the list. For example, if you want to delete a patient’s home telecom information without knowing the index, you can use the example below.
7878

79-
PATCH `http://{FHIR-SERVICE-NAME}/Patient/{PatientID}`
79+
PATCH `http://{FHIR-SERVICE-HOST-NAME}/Patient/{PatientID}`<br/>
80+
Content-type: `application/fhir+json`
81+
82+
```
83+
{
84+
"resourceType": "Parameters",
85+
"parameter": [
86+
{
87+
"name": "operation",
88+
"part": [
89+
{
90+
"name": "type",
91+
"valueCode": "delete"
92+
},
93+
{
94+
"name": "path",
95+
"valueString": "Patient.telecom.where(use = 'home')"
96+
}
97+
]
98+
}
99+
]
100+
}
101+
```
102+
103+
Any FHIRPath Patch operations must have the `application/fhir+json` Content-Type header set. FHIRPatch Patch supports add, insert, delete, remove, and move operations. FHIRPatch Patch operations also can be easily integrated into Bundles. For more examples, look at the sample [FHIRPath Patch REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/FhirPatchRequests.http).
104+
105+
### Patch with JSON Patch
106+
107+
JSON Patch in the FHIR Service conforms to the well-used [specification defined by the Internet Engineering Task Force](https://datatracker.ietf.org/doc/html/rfc6902). The payload format does not use FHIR resources and instead uses a JSON document leveraging JSON-Pointers for element selection. JSON Patch is more compact and has a test operation that allows you to validate that a condition is true before doing the patch. For example, if you want to set a patient as deceased only if they're not already marked as deceased, you can use the example below.
108+
109+
PATCH `http://{FHIR-SERVICE-HOST-NAME}/Patient/{PatientID}`<br/>
80110
Content-type: `application/json-patch+json`
81111

82112
```
@@ -92,17 +122,18 @@ Content-type: `application/json-patch+json`
92122
"value": true
93123
}
94124
]
95-
96125
```
97126

98-
### Patch in Bundles
127+
Any JSON Patch operations must have the `application/json-patch+json` Content-Type header set. JSON Patch supports add, remove, replace, copy, move, and test operations. For more examples, look at the sample [JSON Patch REST file](https://github.com/microsoft/fhir-server/blob/main/docs/rest/JsonPatchRequests.http).
128+
129+
#### JSON Patch in Bundles
99130

100-
By default, JSON Patch isn't supported in Bundle resources. This is because a Bundle only supports with FHIR resources and JSON Patch isn't a FHIR resource. To work around this, we'll treat Binary resources with a content-type of `"application/json-patch+json"`as base64 encoding of JSON string when a Bundle is executed. For information about this workaround, log in to [Zulip](https://chat.fhir.org/#narrow/stream/179166-implementers/topic/Transaction.20with.20PATCH.20request).
131+
By default, JSON Patch isn't supported in Bundle resources. This is because a Bundle only supports with FHIR resources and the JSON Patch payload isn't a FHIR resource. To work around this, we'll use Binary resources with a Content-Type of `"application/json-patch+json"` and the base64 encoding of the JSON payload inside of a Bundle. For information about this workaround, view this topic on the [FHIR Chat Zulip](https://chat.fhir.org/#narrow/stream/179166-implementers/topic/Transaction.20with.20PATCH.20request).
101132

102133
In the example below, we want to change the gender on the patient to female. We've taken the JSON patch `[{"op":"replace","path":"/gender","value":"female"}]` and encoded it to base64.
103134

104-
POST `https://{FHIR-SERVICE-NAME}/`
105-
content-type: `application/json`
135+
POST `https://{FHIR-SERVICE-HOST-NAME}/`<br/>
136+
Content-Type: `application/json`
106137

107138
```
108139
{
@@ -124,7 +155,6 @@ content-type: `application/json`
124155
}
125156
]
126157
}
127-
128158
```
129159

130160
## Next steps

articles/healthcare-apis/release-notes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
title: Azure Health Data Services monthly releases
33
description: This article provides details about the Azure Health Data Services monthly features and enhancements.
44
services: healthcare-apis
5-
author: caitlinv39
5+
author: mikaelweave
66
ms.service: healthcare-apis
77
ms.subservice: fhir
88
ms.topic: reference
99
ms.date: 03/21/2022
10-
ms.author: cavoeg
10+
ms.author: mikaelw
1111
---
1212

1313
# Release notes: Azure Health Data Services
@@ -142,7 +142,7 @@ Azure Health Data Services is a set of managed API services based on open standa
142142
|Conditional patch | [#2163](https://github.com/microsoft/fhir-server/pull/2163) |
143143
|Added conditional patch audit event. | [#2213](https://github.com/microsoft/fhir-server/pull/2213) |
144144

145-
|Allow JSON patch in bundles | [JSON patch in bundles](./././azure-api-for-fhir/fhir-rest-api-capabilities.md#patch-in-bundles)|
145+
|Allow JSON patch in bundles | [JSON patch in bundles](./././azure-api-for-fhir/fhir-rest-api-capabilities.md#json-patch-in-bundles)|
146146
| :------------------- | -------------------------------:|
147147
|Allows for search history bundles with Patch requests. |[#2156](https://github.com/microsoft/fhir-server/pull/2156) |
148148
|Enabled JSON patch in bundles using Binary resources. |[#2143](https://github.com/microsoft/fhir-server/pull/2143) |

0 commit comments

Comments
 (0)