FHIR🔥 API Extensions
$diff operation
The $diff operation can be used to determine the difference between two versions of a resource or any two resources of the same type.
The difference return by the operation is in FHIR Patch format.
This implementation is derived from the $diff operation implemented in the HAPI Server (see Diff Operation).
Diff on a Resource instance
Optional Parameters
fromVersion=[version] – see below for detailsincludeMeta=(true|false) – defaults tofalseand determines whether the Resources'metaelements are included in the difference or not.
Diff with default version
GET /[type]/[id]/$diff
Determines the changes from version n-1 to version n, where n is the latest version of the Resource.
GET /[type]/[id]/$diff?fromVersion=[version]
Determines the changes from version version to version n, where n is the latest version of the Resource.
Diff with specific version
GET /[type]/[id]/_history/[version]/$diff
Determines the changes from version n to version version, where n is the latest version of the Resource that is not equal to version.
That is, if version is the latest version, then n = version-1, otherwise n = the latest version.
GET /[type]/[id]/_history/[version]/$diff?fromVersion=[fromVersion]
Determines the changes from version fromVersion to version version.
Diff any two Resource instances of the same type
Required Parameters
from=[id]to=[id]
The ids may be versioned or not. That is of either form:
- [
type]/[id] - [
type]/[id]/_history/[version]
Optional Parameters
includeMeta=(true|false) – defaults tofalseand determines whether the Resources'metaelements are included in the difference or not.
GET /$diff?from=[type]/[id1]&to=[type]/[id2]
GET /$diff?from=[type]/[id1]&to=[type]/[id2]/_history/1
Result
The output is in FHIRPatch format.
This is a Parameters Resource where each Parameter represents one of several FHIRPatch operations.
Currently these include:
addinsertdeletereplace
Example result
{
"resourceType": "Parameters",
"parameter": [{
"name": "operation",
"part": [{
"name": "type",
"valueCode": "replace"
}, {
"name": "path",
"valueString": "CodeSystem.concept[6].display"
}, {
"name": "previousValue",
"valueString": "nonsmoker"
}, {
"name": "value",
"valueString": "non-smoker"
}]
}]
}

Ontoserver