Create
FHIR format
Aidbox format
1
POST [base]/fhir/[type]
Copied!
1
POST [base]/[type]
Copied!
FHIR API ignores id in POST requests, but Aidbox API respects id inside the request body and creates a resource with a specific id. This decision was made because we didn't find any reasons to ignore it and to make Aidbox API be closer to the SQL INSERT query. As a result, a new response code 409 Conflict appeared.
Response code
Text
Description
201
Created
Resource successfully created
400
Bad Request
Resource could not be parsed or fail basic FHIR validation rules
409
Conflict
Resource with such id already exists
422
Unprocessable
The proposed resource violated applicable FHIR profiles or server business rules

Conditional create

FHIR format
Aidbox format
1
POST [base]/fhir/[type]?[search parameters]
Copied!
1
POST [base]/[type]?[search parameters]
Copied!
Instead of using the If-None-Exist header, Aidbox uses query parameters as in ordinary read operation. This is done to make all conditional operations to look the same (use search query parameters).
  • No matches: The server performs a create interaction (Aidbox version of create)
  • One Match: The server returns the found resource and 200 OK
  • Multiple matches: The server returns a 412 Precondition Failed error indicating the client's criteria were not selective enough

create

FHIR format
Aidbox format
1
POST [base]/fhir/[type]
Copied!
1
POST [base]/[type]
Copied!
This is one of the most basic interactions which gives an ability to create resources. It uses the POST HTTP method accepting a resource type via path parameters and the resource as a body of the request. A response to this interaction may be one of the following:
Response code
Text
Description
201
Created
Resource successfully created
400
Bad Request
Resource could not be parsed or fail basic FHIR validation rules
409
Conflict
Resource with such id already exists
422
Unprocessable
The proposed resource violated applicable FHIR profiles or server business rules
A successful response (2xx) also contains a created resource as a body and additional headers Location, ETag, Last-Modified which contain the full path to a resource (base url, resource type and id of a newly created resource), additionally information about version (vid) and modification time of that resource.
1
Location: [base]/[type]/[id]/_history/[vid]
2
ETag: [vid]
3
Last-Modified: [modification-datetime]
Copied!
An unsuccessful response (4xx) contains OperationOutcome resource which describes issues the server faced during the creation of this resource.

201 Created

Request (FHIR format)
Request (Aidbox format)
Response (FHIR format)
Response (Aidbox format)
1
POST /fhir/Patient
2
3
name: [{given: ["Bob"]}]
Copied!
1
POST /Patient
2
3
name: [{given: ["Bob"]}]
Copied!
Status: 201
1
name:
2
- given:
3
- Bob
4
id: '17b69d79-3d9b-45f8-af79-75f958502763'
5
resourceType: Patient
6
meta:
7
lastUpdated: '2018-11-29T10:44:10.588Z'
8
versionId: '13'
9
extension:
10
- url: 'ex:createdAt'
11
valueInstant: '2018-11-29T10:44:10.588Z'
Copied!
Status: 201
1
name:
2
- given: [Bob]
3
id: 17b69d79-3d9b-45f8-af79-75f958502763
4
resourceType: Patient
5
meta:
6
lastUpdated: '2018-11-29T10:44:10.588Z'
7
createdAt: '2018-11-29T10:44:10.588Z'
8
versionId: '13'
Copied!

422 Unprocessable entity

Request (FHIR format)
Request (Aidbox format)
Response (FHIR format)
Response (Aidbox format)
1
POST /fhir/Patient
2
3
name: "Bob"
Copied!
1
POST /Patient
2
3
name: "Bob"
Copied!
Status: 422
1
resourceType: OperationOutcome
2
text:
3
status: generated
4
div: Invalid resource
5
issue:
6
- severity: fatal
7
code: invalid
8
expression:
9
- Patient.name
10
diagnostics: expected array
Copied!
1
resourceType: OperationOutcome
2
text:
3
status: generated
4
div: Invalid resource
5
issue:
6
- severity: fatal
7
code: invalid
8
expression:
9
- Patient.name
10
diagnostics: expected array
Copied!
Aidbox REST API doesn't ignoreid and treats it as all other attributes in contrast to FHIR API. Read more about differences here.

Conditional Create

FHIR format
Aidbox format
1
POST [base]/fhir/[type]?[search parameters]
Copied!
1
POST [base]/[type]?[search parameters]
Copied!
A more complex way to create a resource (it requires the knowledge of search) but it gives some additional flexibility. If you provide search parameters, create becomes conditional create and works in the following way (depending on the number of search results):
  • No matches: The server performs a create interaction
  • One Match: The server returns the found resource and 200 OK
  • Multiple matches: The server returns a 412 Precondition Failed error indicating the client's criteria were not selective enough

200 OK

Create a patient if there is no patient with the name Bob.
Request (FHIR format)
Request (Aidbox format)
Response (FHIR format)
Response (Aidbox format)
1
POST /fhir/Patient?name=Bob
2
3
name: [{given: ["Bob"]}]
4
gender: male
Copied!
1
POST /Patient?name=Bob
2
3
name: [{given: ["Bob"]}]
4
gender: male
Copied!
Status: 200
1
name:
2
- given: [Bob]
3
gender: male
4
id: 17b69d79-3d9b-45f8-af79-75f958502763
5
resourceType: Patient
6
meta:
7
lastUpdated: '2018-11-29T10:44:10.588Z'
8
versionId: '13'
9
extension:
10
- url: 'ex:createdAt'
11
valueInstant: '2018-11-29T10:44:10.588Z'
Copied!
Status: 200
1
name:
2
- given: Bob
3
gender: male
4
id: 17b69d79-3d9b-45f8-af79-75f958502763
5
resourceType: Patient
6
meta:
7
lastUpdated: '2018-11-29T10:44:10.588Z'
8
createdAt: '2018-11-29T10:44:10.588Z'
9
versionId: '13'
Copied!
A patient was not created, an existing patient was returned.
Last modified 1yr ago