Skip to content

Commit e144b17

Browse files
Svyatoslav Krivosheevgitbook-bot
authored andcommitted
GITBOOK-3672: No subject
1 parent 2adb862 commit e144b17

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

aidbox-configuration/init-bundle.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
description: Apply the FHIR Bundle to Aidbox before startup.
32
coverY: 0
43
layout:
54
cover:

api-1/transaction.md

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,35 @@ description: Do multiple operations in one call
66

77
### Introduction
88

9-
Transaction interaction allows performing several interactions using one http request. There are two types of transaction interaction (type is specified by field `type`): batch and transaction. The first one just executes requests one by one, the second one does the same, but roll backs all changes if any request fails.
9+
Transaction interaction allows for several interactions using one HTTP request. There are two types of transaction interaction (type is specified by field `type`): batch and transaction. The first one executes requests one by one, and the second one does the same but rolls back all changes if any request fails.
1010

1111
```
1212
POST [base]
1313
```
1414

15-
The body of such request contains one resource of type Bundle, which contains field entry with an array of interactions, for example: \\
15+
The body of such a request contains one resource of type Bundle, which contains field entry with an array of interactions, for example:
1616

1717
```yaml
18-
POST /
19-
Accept: text/yaml
18+
POST /fhir
19+
Accept: text/yaml
2020
Content-Type: text/yaml
2121

2222
type: transaction
2323
entry:
24-
- resource:
25-
id: admin
26-
email: "[email protected]" # Change this value
27-
password: "password" # Change this value
24+
- resource: {}
2825
request:
29-
method: POST
30-
url: "/User"
31-
26+
method: PUT
27+
url: "/Practitioner/pr1"
28+
- request:
29+
method: GET
30+
url: "/Patient"
3231
- resource:
33-
id: SPA
34-
redirect_uri: http://localhost:4200
32+
id: admin123
33+
34+
password: "password"
3535
request:
3636
method: POST
37-
url: "/Client"
38-
39-
- resource:
40-
engine: json-schema
41-
schema:
42-
type: object
43-
required:
44-
- user
45-
request:
46-
method: POST
47-
url: "/AccessPolicy"
37+
url: "/User"
4838
```
4939
5040
Each element of the entry array contains a resource field (body of the request) and a request field (request line in terms of the HTTP request).
@@ -62,14 +52,14 @@ request:
6252
6353
### Processing rules and Conditional refs
6454
65-
Transaction interaction is processed in the order provided in a bundle, each interaction is executed one by one. It differs from the FHIR transaction [processing rules](https://www.hl7.org/fhir/http.html#trules).
55+
Transaction interactions are processed in the order provided in a bundle; each interaction is executed one by one. This differs from the FHIR transaction [processing rules](https://www.hl7.org/fhir/http.html#trules).
6656
6757
For `type: batch` references to resources inside a bundle won't be resolved.
6858

69-
For `type: transaction` before processing interactions, all references in a resource will attempt to resolve. In this example ProcedureRequest will refer to a newly created patient:
59+
For `type: transaction` before processing interactions, all references in a resource will attempt to resolve. In this example, ProcedureRequest will refer to a newly created patient:
7060

7161
```yaml
72-
POST /
62+
POST /fhir
7363
Accept: text/yaml
7464
Content-Type: text/yaml
7565
@@ -86,55 +76,64 @@ entry:
8676
resourceType: Encounter
8777
status: proposal
8878
subject:
89-
reference: urn:uuid:<uuid-here>
79+
uri: urn:uuid:<uuid-here>
9080
request:
9181
method: POST
9282
url: "/Encounter"
9383
```
9484

95-
You can provide a full Url with value like `"urn:<uuid-here>"` and reference to the resource created by such interaction using ref: `{reference: "urn:<uuid-here>"}`. Those references are temporary and will be translated to valid Aidbox references when interaction entry is processed by a server.
85+
You can provide a full URL with values like `"urn:<uuid-here>"` and reference to the resource created by such interaction using ref: `{uri: "urn:<uuid-here>"}`. Those references are temporary and will be translated to valid Aidbox references when interaction entry is processed by a server.
9686

9787
{% hint style="danger" %}
9888
You SHALL NOT refer resource, which is created later using conditional operations!
9989
{% endhint %}
10090

10191
### Multiple resources with the same id
10292

103-
If you have multiple entries with the same resource id, aidbox will execute them one by one and thus you are able to create a resource with a history in within a single transaction:
93+
If you have multiple entries with the same resource id, Aidbox will execute them one by one and thus you can create a resource with a history within a single transaction:
10494

10595
```yaml
106-
POST /
96+
POST /fhir
10797
Accept: text/yaml
10898
Content-Type: text/yaml
10999
110100
resourceType: Bundle
111101
type: transaction
112102
entry:
113-
- request: {method: PUT, url: 'Patient/pt-1'}
103+
- request: {method: PUT, url: '/Patient/pt-1'}
114104
resource: {birthDate: '2021-01-01'}
115-
- request: {method: PUT, url: 'Patient/pt-1'}
105+
- request: {method: PUT, url: '/Patient/pt-1'}
116106
resource: {birthDate: '2021-01-02'}
117-
- request: {method: PUT, url: 'Patient/pt-1'}
107+
- request: {method: PUT, url: '/Patient/pt-1'}
118108
resource: {birthDate: '2021-01-03'}
119109
```
120110

121111
{% tabs %}
122112
{% tab title="Request" %}
123113
```yaml
124-
GET /Patient/pt-1
114+
GET /fhir/Patient/pt-1
125115
Accept: text/yaml
126116
```
127117
{% endtab %}
128118

129119
{% tab title="Response" %}
130120
```yaml
131-
{birthDate: '2021-01-03', id: pt-1, resourceType: Patient}
121+
id: >-
122+
pt-1
123+
birthDate: '2021-01-03'
124+
resourceType: Patient
125+
meta:
126+
lastUpdated: '2024-11-07T08:18:18.696976Z'
127+
versionId: '73'
128+
extension:
129+
- url: https://fhir.aidbox.app/fhir/StructureDefinition/created-at
130+
valueInstant: '2024-11-07T08:18:18.696976Z'
132131
```
133132
{% endtab %}
134133
{% endtabs %}
135134

136135
```yaml
137-
GET /Patient/pt-1/_history
136+
GET /fhir/Patient/pt-1/_history
138137
Accept: text/yaml
139138
Content-Type: text/yaml
140139
@@ -153,10 +152,10 @@ By default Aidbox uses `SERIALIZABLE` transaction isolation level. This may lead
153152

154153
See more about [transaction isolation in Postgres documentation](https://www.postgresql.org/docs/current/transaction-iso.html).
155154

156-
The best way to handle rejected transactions is to retry them. If it is not possible, you can set maximum isolation level with HTTP header or [environment variable](../reference/configuration/environment-variables/optional-environment-variables.md#box\_features\_fhir\_transaction\_max\_\_isolation\_level). If both HTTP header and environment variable are provided, header will be used.
155+
The best way to handle rejected transactions is to retry them. If it is not possible, you can set the maximum isolation level with the HTTP header or [environment variable](../reference/configuration/environment-variables/optional-environment-variables.md#box\_features\_fhir\_transaction\_max\_\_isolation\_level). If both the HTTP header and environment variable are provided, the header will be used.
157156

158157
{% hint style="danger" %}
159-
Using isolation level lower than serializable may lead to data serialization anomalies.
158+
Using an isolation level lower than serializable may lead to data serialization anomalies.
160159
{% endhint %}
161160

162161
Example:

0 commit comments

Comments
 (0)