Changes API
Simple API to react on resource changes
By GET /<resource-type>/$changes without the version parameter you will get latest version, which can be used to poll for changes by GET /<resource-type>/$changes?version=<version>

Endpoints

GET /<resourceType>/$changes returns the latest version for the resourceType GET /<resourceType>/<id>/$changes returns latest version of a specific resource Returned version value can be used with the version query-string parameter

Query-string parameters

version=<version> returns changes since the specified version version=<lower-version>,<upper-version> returns changes after the lower-version (exclusive) up to theupper-version (inclusive) fhir=<boolean> if set to true converts changes.*.resource to the FHIR format (note, since Changes API is not /fhir/ endpoint, the rest of the body isn't FHIR compliant)
With parameters which start with dot you can filter resources by equality, e.g. .name.0.family=<string>
omit-resources=<boolean> if set to true omits resources leaving only id & resourceType fields
_count & _page work as described here _total & _countMethod work as described here​

Notes

Polling request is cheap! If you want to watch rare changes (minutes-hours), this API is very resource efficient (no subscriptions, no queues) and provides you lots of control. If nothing has been changed, you will get a response with status 304, otherwise a list of changes and a new version to poll next time.

Examples

1
---
2
GET /Patient/$changes
3
Accept: text/yaml
4
​
5
# status 200
6
version: 1
7
​
8
---
9
GET /Patient/$changes?version=1
10
Accept: text/yaml
11
​
12
# status 304 (Not Modified)
13
​
14
---
15
POST /Patient
16
Accept: text/yaml
17
Content-Type: text/yaml
18
​
19
id: pt-1
20
name:
21
- family: Smith
22
given: [John]
23
​
24
---
25
POST /Patient
26
Accept: text/yaml
27
Content-Type: text/yaml
28
​
29
id: pt-2
30
name:
31
- family: Wood
32
given: [Amanda]
33
​
34
---
35
GET /Patient/$changes?version=1
36
Accept: text/yaml
37
​
38
# status 200
39
version: 3
40
changes:
41
- event: created
42
resource:
43
id: pt-1
44
name:
45
- family: Smith
46
given: [John]
47
- event: created
48
resource:
49
id: pt-2
50
name:
51
- family: Wood
52
given: [Amanda]
53
​
54
---
55
GET /Patient/$changes?version=1&.name.0.family=Wood
56
Accept: text/yaml
57
​
58
# status 200
59
version: 3
60
changes:
61
- event: created
62
resource:
63
id: pt-2
64
name:
65
- family: Wood
66
given: [Amanda]
67
68
---
69
GET /Patient/$changes?version=1,2
70
Accept: text/yaml
71
​
72
# status 200
73
version: 2
74
changes:
75
- event: created
76
resource:
77
id: pt-1
78
name:
79
- family: Smith
80
given: [John]
81
---
82
GET /Patient/pt-1/$changes
83
Accept: text/yaml
84
​
85
# status 200
86
version: 2
87
---
88
GET /Patient/pt-1/$changes?version=1
89
Accept: text/yaml
90
​
91
# status 200
92
version: 2
93
changes:
94
- event: created
95
resource:
96
id: pt-1
97
name:
98
- family: Smith
99
given: [John]
100
---
101
GET /Patient/$changes?version=1&omit-resources=true
102
Accept: text/yaml
103
​
104
# status 200
105
version: 3
106
changes:
107
- event: created
108
resource: {id: pt-1, resourceType: Patient}
109
- event: created
110
resource: {id: pt-2, resourceType: Patient}
Copied!
Last modified 2mo ago