You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adaptors/fhir-4.md
+31-21Lines changed: 31 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,8 @@ written to the new resource
65
65
66
66
## Bundles
67
67
68
-
The FHIR-4 adaptor provides support for bundles.
68
+
The FHIR-4 adaptor provides support for creating, updating and uploading
69
+
bundles.
69
70
70
71
You can create resources and add them to a bundle:
71
72
@@ -76,25 +77,13 @@ addToBundle($.resource);
76
77
Where `$.resource` is a FHIR resource, or an array of resources, on the state
77
78
object.
78
79
79
-
This will add the resources to a bundle resource, under the `entry` key, on
80
-
state under a key called `bundle`. To save the bundle under a different key,
81
-
pass a string as the second argument:
80
+
`addToBundle` actually does two things:
82
81
83
-
```js
84
-
addToBundle($.resource, 'patients-bundle');
85
-
```
82
+
- First it creates a bundle object on state, setting some defaults
83
+
- Secondly it wraps your resource into an entry object, and add it to the
84
+
bundle.
86
85
87
-
Each item in the bundle will be given a `request` object with the `PUT` method
88
-
and a URL. For example:
89
-
90
-
```js
91
-
addToBundle({
92
-
id:'x',
93
-
resourceType:'Patient',
94
-
});
95
-
```
96
-
97
-
Will create a state object like this:
86
+
The code `addToBundle($.resource)` will give you a state object like this:
98
87
99
88
```json
100
89
{
@@ -103,6 +92,7 @@ Will create a state object like this:
103
92
"entry": [
104
93
{
105
94
"resource": {
95
+
// This object is the resource you passed in
106
96
"id": "x",
107
97
"resourceType": "Patient"
108
98
},
@@ -116,8 +106,24 @@ Will create a state object like this:
116
106
}
117
107
```
118
108
109
+
To save the bundle under a different key, pass a string key name as the second
110
+
argument:
111
+
112
+
```js
113
+
addToBundle($.resource, 'patients-bundle');
114
+
```
115
+
116
+
You can customize the bundle by calling the `createBundle()` function yourself.
117
+
This can be useful for setting the bundle type or other keys.
118
+
119
+
```
120
+
createBundle({ name: 'upload', type: 'batch' })
121
+
```
122
+
119
123
To send the Bundle to the FHIR server defined in `state.configuration.baseURL`,
120
-
call `uploadBundle()`.
124
+
call `uploadBundle()`. This operation will sort the bundle according to the
125
+
dependencies of its contents: so resources that reference other resources will
126
+
appear later in the bundle.
121
127
122
128
You can pass the name of a key on state to upload a specific bundle:
123
129
@@ -722,6 +728,10 @@ b.patient({
722
728
723
729
### I've noticed a problem with this Adaptor, or something is out of date, what can I do?
724
730
725
-
Thanks for asking! We are a fully Open Source Digital Public Good, and we welcome contributions from our community. Check out our [Adaptors Wiki](https://github.com/OpenFn/adaptors/blob/main/wiki/index.md) for more information on how you can update Adaptors!
731
+
Thanks for asking! We are a fully Open Source Digital Public Good, and we
732
+
welcome contributions from our community. Check out our
733
+
[Adaptors Wiki](https://github.com/OpenFn/adaptors/blob/main/wiki/index.md) for
734
+
more information on how you can update Adaptors!
726
735
727
-
Or, you can always reach out to the Community through our [Community Forum here](https://community.openfn.org/).
736
+
Or, you can always reach out to the Community through our
737
+
[Community Forum here](https://community.openfn.org/).
0 commit comments