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: docs/v2-to-fhir-spec/add-mapping-fhir-operation.md
+123-6Lines changed: 123 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
1
# ConceptMap Mapping Operations
2
2
3
-
This page defines two operations for managing individual mappings within large [ConceptMap](https://hl7.org/fhir/conceptmap.html) resources: `$add-mapping` and `$remove-mapping`.
3
+
This page defines three operations for managing individual mappings within large [ConceptMap](https://hl7.org/fhir/conceptmap.html) resources: `$add-mapping`, `$update-mapping`, and `$remove-mapping`.
4
4
5
5
## Background
6
6
7
7
The existing [$add](https://fhir.hl7.org/fhir/resource-operation-add.html) and [$remove](https://fhir.hl7.org/fhir/resource-operation-remove.html) operations (see [Operations for Large Resources](https://www.hl7.org/fhir/operations-for-large-resources.html)) return the modified resource and use structural matching on array entries. ConceptMap resources may contain thousands of mappings and require matching on a domain-specific composite key, so these operations return an OperationOutcome instead.
8
8
9
-
For both operations, only `group` elements in the input are processed; all other elements are ignored.
9
+
For all three operations, only `group` elements in the input are processed; all other elements are ignored.
10
10
11
11
## Matching Algorithm
12
12
13
-
Both operations use the same matching algorithm. Two mappings match when they have identical values for `group.source`, `group.target`, `element.code`, and `element.target.code`.
13
+
All three operations use the same matching algorithm. Two mappings match when they have identical values for `group.source`, `group.target`, `element.code`, and `element.target.code`.
14
14
15
15
For `noMap` entries (no `element.target`), matching uses `group.source`, `group.target`, and `element.code` only.
16
16
17
-
Only these fields are compared; other element properties such as `display` or `relationship` are not considered. To update an existing mapping, remove it first and add the replacement.
17
+
Only these fields are compared; other element properties such as `display` or `relationship` are not considered. To update an existing mapping's non-key properties, use `$update-mapping`.
The server SHALL add each input mapping that does not already exist. Existing mappings (same match key) are skipped; the server SHOULD report skipped entries in the OperationOutcome. If no `group` exists for the given `source` and `target`, one is created.
26
26
27
27
It is an error to add a mapping with `target` for a source code that already has `noMap=true`, or to add `noMap=true` for a code that already has target mappings.
28
-
29
28
It is also an error if the ConceptMap contains more than one group with the same `source` and `target` as an input mapping, since the target group is ambiguous.
30
-
31
29
In either case the server SHALL return an OperationOutcome with `severity=error` and `code=business-rule`.
32
30
33
31
Clients MAY supply an `If-Match` header; servers SHALL reject the request if the ETag does not match. See [Managing Resource Contention](https://hl7.org/fhir/http.html#concurrency).
The `$update-mapping` operation ensures mappings in a ConceptMap match the input, updating existing entries and adding new ones.
145
+
146
+
URL: [base]/ConceptMap/[id]/$update-mapping
147
+
148
+
The server SHALL replace each matching mapping with the input values; properties absent from the input are removed from the existing entry. If no matching mapping exists, the server SHALL add it. If no `group` exists for the given `source` and `target`, one is created.
149
+
The server SHOULD report the number of mappings updated and added in the OperationOutcome.
150
+
151
+
Like `$add-mapping`, it is an error to add a mapping with `target` for a source code that already has `noMap=true`, or to add `noMap=true` for a code that already has target mappings.
152
+
It is also an error if the ConceptMap contains more than one group with the same `source` and `target` as an input mapping, since the target group is ambiguous.
153
+
In either case the server SHALL return an OperationOutcome with `severity=error` and `code=business-rule`.
154
+
155
+
Clients MAY supply an `If-Match` header; servers SHALL reject the request if the ETag does not match. See [Managing Resource Contention](https://hl7.org/fhir/http.html#concurrency).
156
+
157
+
**In Parameters**
158
+
159
+
| Name | Cardinality | Type | Documentation |
160
+
|------|-------------|------|---------------|
161
+
| mappings | 1..1 | ConceptMap | Only `group` elements are processed |
162
+
163
+
**Out Parameters**
164
+
165
+
| Name | Cardinality | Type | Documentation |
166
+
|------|-------------|------|---------------|
167
+
| return | 1..1 | OperationOutcome | Outcome of the operation |
168
+
169
+
### Example
170
+
171
+
Request: update the relationship of an existing GLUC → 2345-7 mapping and add a new BUN → 3094-0 mapping in one call.
172
+
173
+
```http
174
+
POST /ConceptMap/lab-codes-to-loinc/$update-mapping HTTP/1.1
175
+
Content-Type: application/fhir+json
176
+
177
+
{
178
+
"resourceType": "ConceptMap",
179
+
"group": [{
180
+
"source": "http://example.org/local-codes",
181
+
"target": "http://loinc.org",
182
+
"element": [
183
+
{
184
+
"code": "GLUC",
185
+
"display": "Glucose",
186
+
"target": [{
187
+
"code": "2345-7",
188
+
"display": "Glucose [Mass/volume] in Serum or Plasma",
189
+
"relationship": "source-is-narrower-than-target"
190
+
}]
191
+
},
192
+
{
193
+
"code": "BUN",
194
+
"display": "Blood Urea Nitrogen",
195
+
"target": [{
196
+
"code": "3094-0",
197
+
"display": "Urea nitrogen [Mass/volume] in Serum or Plasma",
0 commit comments