Aidbox
Search…
⌃K

Update

PUT [base]/[type]/[id]
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

PUT [base]/[type]?[search parameters]
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
POST /fhir/Patient
​
id: pt-1
name: [{family: 'Wrong'}]
create-patient-request
​
POST /Patient
​
id: pt-1
name: [{family: 'Wrong'}]
Status: 201
name:
- family: Wrong
id: 'pt-1'
resourceType: Patient
meta:
lastUpdated: '2019-04-04T09:15:25.210Z'
versionId: '471'
extension:
- url: 'ex:createdAt'
valueInstant: '2019-04-04T09:15:25.210Z'
Status: 201
name:
- family: Wrong
id: 'pt-1'
resourceType: Patient
meta:
lastUpdated: '2019-04-04T09:15:25.210Z'
createdAt: '2019-04-04T09:15:25.210Z'
versionId: '471'
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
PUT /fhir/Patient/pt-id
If-Match: 30
​
name: [{family: ['Smith']}]
versioned-update-request
​
PUT /Patient/pt-id
If-Match: 30
​
name: [{family: ['Smith']}]
If someone has already edited the same patient, his version id was changed, and we got OperationOutcome.
Response (FHIR)
Response (Aidbox)
conflict-response
status: 409
​
resourceType: OperationOutcome
id: 'conflict'
text:
status: generated
div: Version Id mismatch
issue:
- severity: fatal
code: conflict
diagnostics: Version Id mismatch
conflict-response
​
status: 409
​
resourceType: OperationOutcome
id: 'conflict'
text:
status: generated
div: Version Id mismatch
issue:
- severity: fatal
code: conflict
diagnostics: Version Id mismatch
​
​

Conditional Update

PUT [base]/[type]?[search parameters]
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)
PUT /fhir/Patient?name=Tom
​
name: [{given: ["Tom"]}]
gender: male
PUT /Patient?name=Tom
​
name: [{given: ["Tom"]}]
gender: male
Status: 200
name:
- given: [Tom]
gender: male
id: tom-id
resourceType: Patient
meta:
lastUpdated: '2018-11-29T14:10:31.885Z'
versionId: '42'
tag:
- {system: 'https://aidbox.app', code: updated}
​

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)
PUT /fhir/Patient?name=Julie
​
id: julie-id
name: [{given: ["Julie"]}]
gender: female
PUT /Patient?name=Julie
​
id: julie-id
name: [{given: ["Julie"]}]
gender: female
Status: 201
name:
- given: Julie
gender: female
id: julie-id
resourceType: Patient
meta:
lastUpdated: '2018-11-29T14:13:03.416Z'
versionId: '43'
extension:
- url: 'ex:createdAt'
valueInstant: '2018-11-29T14:13:03.416Z'
Status: 201
name:
- given:
- Julie
gender: female
id: 'julie-id'
resourceType: Patient
meta:
lastUpdated: '2018-11-29T14:13:03.416Z'
createdAt: '2018-11-29T14:13:03.416Z'
versionId: '43'
If a patient with the name Julie already exists, update interaction will be performed and id will be ignored.

Update

PUT [base]/[type]/[id]
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)
PUT /fhir/Patient/17b69d79-3d9b-45f8-af79-75f958502763
​
name: [{given: ["Bob"]}]
PUT /Patient/17b69d79-3d9b-45f8-af79-75f958502763
​
name: [{given: ["Bob"]}]
Status: 200
name:
- given:
- Bob
id: 17b69d79-3d9b-45f8-af79-75f958502763
resourceType: Patient
meta:
lastUpdated: '2018-11-29T13:58:03.875Z'
versionId: '38'
extension:
- url: 'ex:createdAt'
valueInstant: '2018-11-29T13:58:03.875Z'
Status: 200
name:
- given: Bob
id: 17b69d79-3d9b-45f8-af79-75f958502763
resourceType: Patient
meta:
lastUpdated: '2018-11-29T13:58:03.875Z'
createdAt: '2018-11-29T13:58:03.875Z'

201 Created

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

​

Last modified 1yr ago