-
Notifications
You must be signed in to change notification settings - Fork 489
/
VersionedUpdateExample.http
231 lines (211 loc) · 6.99 KB
/
VersionedUpdateExample.http
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# Before running this, update the versioning policy in appsettings.json to:
#
#"Versioning": {
# "Default": "versioned-update",
# "ResourceTypeOverrides":null
# }
@hostname = localhost:44348
###
# Get the capability statement.
# Note that the "versioning" property of every resource type is set to
# "versioned-update"
GET https://{{hostname}}/metadata
Authorization: Bearer {{bearer.response.body.access_token}}
### Get the bearer token, if authentication is enabled
# @name bearer
POST https://{{hostname}}/connect/token
content-type: application/x-www-form-urlencoded
grant_type=client_credentials
&client_id=globalAdminServicePrincipal
&client_secret=globalAdminServicePrincipal
&scope=fhir-api
###
# Create a patient resource that we will update.
# This will create version 1 of a patient resource.
# @name patient
POST https://{{hostname}}/Patient
Content-Type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}
{
"resourceType": "Patient",
"id": "patient-to-update",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: newborn</p><p><b>gender</b>: male</p><p><b>birthDate</b>: 05/09/2017</p></div>"
},
"gender": "male",
"birthDate": "2017-09-05"
}
###
# Attempt to update the patient without specifying the if-match header.
# This should result in an error.
PUT https://{{hostname}}/Patient/{{patient.response.body.id}}
Content-Type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}
{
"resourceType": "Patient",
"id": "{{patient.response.body.id}}",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: newborn</p><p><b>gender</b>: male</p><p><b>birthDate</b>: 05/09/2017</p></div>"
},
"gender": "male",
"birthDate": "2017-09-05",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "2017-05-09T17:11:00+01:00"
}
]
}
}
###
# Attempt to update the patient with an invalid if-match header.
# This should result in an error.
PUT https://{{hostname}}/Patient/{{patient.response.body.id}}
Content-Type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}
If-Match: "1"
{
"resourceType": "Patient",
"id": "{{patient.response.body.id}}",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: newborn</p><p><b>gender</b>: male</p><p><b>birthDate</b>: 05/09/2017</p></div>"
},
"gender": "male",
"birthDate": "2017-09-05",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "2017-05-09T17:11:00+01:00"
}
]
}
}
###
# Update the patient, now setting the if-match header to version 1.
# This should successfully create version 2 of the resource.
PUT https://{{hostname}}/Patient/{{patient.response.body.id}}
Content-Type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}
If-Match: W/"1"
{
"resourceType": "Patient",
"id": "{{patient.response.body.id}}",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: newborn</p><p><b>gender</b>: male</p><p><b>birthDate</b>: 05/09/2017</p></div>"
},
"gender": "male",
"birthDate": "2017-09-05",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "2017-05-09T17:11:00+01:00"
}
]
}
}
###
# Attempt to update the patient, but do not set the if-match header to the most
# recent version. This should return an error.
PUT https://{{hostname}}/Patient/{{patient.response.body.id}}
Content-Type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}
If-Match: W/"1"
{
"resourceType": "Patient",
"id": "{{patient.response.body.id}}",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: newborn</p><p><b>gender</b>: male</p><p><b>birthDate</b>: 05/09/2017</p></div>"
},
"gender": "male",
"birthDate": "2017-09-05",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "2017-05-09T17:11:00+01:00"
}
]
}
}
###
# Re-attempt, now setting the if-match header to version 2.
# This should successfully create version 3.
PUT https://{{hostname}}/Patient/{{patient.response.body.id}}
Content-Type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}
If-Match: W/"2"
{
"resourceType": "Patient",
"id": "{{patient.response.body.id}}",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: newborn</p><p><b>gender</b>: male</p><p><b>birthDate</b>: 05/09/2017</p></div>"
},
"gender": "male",
"birthDate": "2017-09-05",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "2017-05-09T17:11:00+01:00"
}
]
}
}
###
# Create a new resource using PUT.
# This should not require an if-match header to be specified.
PUT https://{{hostname}}/Patient/put-create-patient-1
Content-Type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}
{
"resourceType": "Patient",
"id": "put-create-patient-1",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: newborn</p><p><b>gender</b>: male</p><p><b>birthDate</b>: 05/09/2017</p></div>"
},
"gender": "male",
"birthDate": "2017-09-05",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "2017-05-09T17:11:00+01:00"
}
]
}
}
###
# Create a new resource using PUT, but specify an if-match header.
# This should return an error, since no earlier versions of the resource exist.
PUT https://{{hostname}}/Patient/put-create-patient-2
Content-Type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}
If-Match: W/"2"
{
"resourceType": "Patient",
"id": "put-create-patient-2",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: newborn</p><p><b>gender</b>: male</p><p><b>birthDate</b>: 05/09/2017</p></div>"
},
"gender": "male",
"birthDate": "2017-09-05",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "2017-05-09T17:11:00+01:00"
}
]
}
}