Update
1
PUT [base]/[type]/[id]
Copied!
Aidbox doesn't have an atomic update yet. It also allows omitting id in the resource body.
Response code
Text
Description
200
OK
Resource successfully updated
201
Created
Resource successfully created
422
Unprocessable Entity
The proposed resource violated applicable FHIR profiles or server business rules

Conditional Update

1
PUT [base]/[type]?[search parameters]
Copied!
In contrast to FHIR, Aidbox conditional update allows creating a resource with a specific id. In case of one match, conditional update ignores the id coming in the request body. That means that resource id can't be changed by any update operation.
  • No matches: The server performs a create interaction (Aidbox version of create)
  • One Match: The server performs the update against the matching resource
  • Multiple matches: The server returns a 412 Precondition Failed error indicating the client's criteria were not selective enough

Versioned Update

While you update, there is a risk of overriding the latest changes done by another operation. To escape this situation, you can use a versioned update by sending with update If-Match header with versionId of resource you want to update. If the server has the same version of resources, the update will be successful. If versions do not match, you will get OperationOutcome with conflict code.

Example

Let say we created a patient:
Request (FHIR)
Request (Aidbox)
Response (FHIR)
Response (Aidbox)
create-patient-request
1
POST /fhir/Patient
2
​
3
id: pt-1
4
name: [{family: 'Wrong'}]
Copied!
1
create-patient-request
2
​
3
POST /Patient
4
​
5
id: pt-1
6
name: [{family: 'Wrong'}]
Copied!
Status: 201
1
name:
2
- family: Wrong
3
id: 'pt-1'
4
resourceType: Patient
5
meta:
6
lastUpdated: '2019-04-04T09:15:25.210Z'
7
versionId: '471'
8
extension:
9
- url: 'ex:createdAt'
10
valueInstant: '2019-04-04T09:15:25.210Z'
Copied!
Status: 201
1
name:
2
- family: Wrong
3
id: 'pt-1'
4
resourceType: Patient
5
meta:
6
lastUpdated: '2019-04-04T09:15:25.210Z'
7
createdAt: '2019-04-04T09:15:25.210Z'
8
versionId: '471'
Copied!
To fix the family for this patient without the risk of overriding someone else's changes, we can use a versioned update request:
Request (FHIR)
Request (Aidbox)
versioned-update-request
1
PUT /fhir/Patient/pt-id
2
If-Match: 30
3
​
4
name: [{family: ['Smith']}]
Copied!
1
versioned-update-request
2
​
3
PUT /Patient/pt-id
4
If-Match: 30
5
​
6
name: [{family: ['Smith']}]
Copied!
If someone has already edited the same patient, his version id was changed, and we got OperationOutcome.
Response (FHIR)
Response (Aidbox)
conflict-response
1
status: 409
2
​
3
resourceType: OperationOutcome
4
id: 'conflict'
5
text:
6
status: generated
7
div: Version Id mismatch
8
issue:
9
- severity: fatal
10
code: conflict
11
diagnostics: Version Id mismatch
Copied!
1
conflict-response
2
​
3
status: 409
4
​
5
resourceType: OperationOutcome
6
id: 'conflict'
7
text:
8
status: generated
9
div: Version Id mismatch
10
issue:
11
- severity: fatal
12
code: conflict
13
diagnostics: Version Id mismatch
14
​
15
​
Copied!

Conditional Update

1
PUT [base]/[type]?[search parameters]
Copied!
This is a more complex way to update a resource, but it gives more power. You can update a resource without knowing the id , but it requires the knowledge of Search. Different response codes will be returned (based on the number of search results):
  • No matches: The server performs a create interaction
  • One Match: The server performs the update against the matching resource
  • Multiple matches: The server returns a 412 Precondition Failed error indicating the client's criteria were not selective enough

200 OK

Update the patient by name.
Request (FHIR)
Request (Aidbox)
Response (FHIR)
Response (Aidbox)
1
PUT /fhir/Patient?name=Tom
2
​
3
name: [{given: ["Tom"]}]
4
gender: male
Copied!
1
PUT /Patient?name=Tom
2
​
3
name: [{given: ["Tom"]}]
4
gender: male
Copied!
Status: 200
1
name:
2
- given: [Tom]
3
gender: male
4
id: tom-id
5
resourceType: Patient
6
meta:
7
lastUpdated: '2018-11-29T14:10:31.885Z'
8
versionId: '42'
9
tag:
10
- {system: 'https://aidbox.app', code: updated}
Copied!
​

201 Created

Create a patient with the name Julie and specified id if no other patients with the same name exist:
Request (FHIR)
Request (Aidbox)
Response (FHIR)
Response (Aidbox)
1
PUT /fhir/Patient?name=Julie
2
​
3
id: julie-id
4
name: [{given: ["Julie"]}]
5
gender: female
Copied!
1
PUT /Patient?name=Julie
2
​
3
id: julie-id
4
name: [{given: ["Julie"]}]
5
gender: female
Copied!
Status: 201
1
name:
2
- given: Julie
3
gender: female
4
id: julie-id
5
resourceType: Patient
6
meta:
7
lastUpdated: '2018-11-29T14:13:03.416Z'
8
versionId: '43'
9
extension:
10
- url: 'ex:createdAt'
11
valueInstant: '2018-11-29T14:13:03.416Z'
Copied!
Status: 201
1
name:
2
- given:
3
- Julie
4
gender: female
5
id: 'julie-id'
6
resourceType: Patient
7
meta:
8
lastUpdated: '2018-11-29T14:13:03.416Z'
9
createdAt: '2018-11-29T14:13:03.416Z'
10
versionId: '43'
Copied!
If a patient with the name Julie already exists, update interaction will be performed and id will be ignored.

Update

1
PUT [base]/[type]/[id]
Copied!
This interaction allows modifying an existing resource (creating a new version of it). After performing this interaction, the resource will be replaced with a new version of the resource provided in the body of the request. id of a resource can't be changed (at least cause of versioning) and id in the body of the resource is ignored in update interaction (in order to make a conditional update possible without knowing the logical id of the resource). If a resource with id (provided in the url) doesn't exist, a new resource will be created. Following codes can be returned by the server:
Response code
Text
Description
200
OK
Resource successfully updated
201
Created
Resource successfully created
422
Unprocessable Entity
The proposed resource violated applicable FHIR profiles or server business rules

200 OK

Update a patient by a given id:
Request (FHIR)
Request (Aidbox)
Response (FHIR)
Response (Aidbox)
1
PUT /fhir/Patient/17b69d79-3d9b-45f8-af79-75f958502763
2
​
3
name: [{given: ["Bob"]}]
Copied!
1
PUT /Patient/17b69d79-3d9b-45f8-af79-75f958502763
2
​
3
name: [{given: ["Bob"]}]
Copied!
Status: 200
1
name:
2
- given:
3
- Bob
4
id: 17b69d79-3d9b-45f8-af79-75f958502763
5
resourceType: Patient
6
meta:
7
lastUpdated: '2018-11-29T13:58:03.875Z'
8
versionId: '38'
9
extension:
10
- url: 'ex:createdAt'
11
valueInstant: '2018-11-29T13:58:03.875Z'
Copied!
Status: 200
1
name:
2
- given: Bob
3
id: 17b69d79-3d9b-45f8-af79-75f958502763
4
resourceType: Patient
5
meta:
6
lastUpdated: '2018-11-29T13:58:03.875Z'
7
createdAt: '2018-11-29T13:58:03.875Z'
Copied!

201 Created

Create a patient with a specified id:
Request (FHIR)
Request (Aidbox)
Response (FHIR)
Response (Aidbox)
1
PUT /fhir/Patient/tom-id
2
​
3
name: [{given: ["Tom"]}]
Copied!
1
PUT /Patient/tom-id
2
​
3
name: [{given: ["Tom"]}]
Copied!
Status: 201
1
name:
2
- given:
3
- Tom
4
id: 'tom-id'
5
resourceType: Patient
6
meta:
7
lastUpdated: '2018-11-29T14:01:09.336Z'
8
versionId: '40'
9
extension:
10
- url: 'ex:createdAt'
11
valueInstant: '2018-11-29T14:01:09.336Z'
Copied!
Status: 201
1
name:
2
- given:
3
- Tom
4
id: 'tom-id'
5
resourceType: Patient
6
meta:
7
lastUpdated: '2018-11-29T14:01:09.336Z'
8
createdAt: '2018-11-29T14:01:09.336Z'
9
versionId: '40'
Copied!

​

Last modified 1yr ago