Skip to content

Commit 7828a23

Browse files
committed
Add $update-mapping operation
1 parent d8b1735 commit 7828a23

1 file changed

Lines changed: 123 additions & 6 deletions

File tree

docs/v2-to-fhir-spec/add-mapping-fhir-operation.md

Lines changed: 123 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# ConceptMap Mapping Operations
22

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`.
44

55
## Background
66

77
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.
88

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.
1010

1111
## Matching Algorithm
1212

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`.
1414

1515
For `noMap` entries (no `element.target`), matching uses `group.source`, `group.target`, and `element.code` only.
1616

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`.
1818

1919
## $add-mapping Operation
2020

@@ -25,9 +25,7 @@ URL: [base]/ConceptMap/[id]/$add-mapping
2525
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.
2626

2727
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-
2928
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-
3129
In either case the server SHALL return an OperationOutcome with `severity=error` and `code=business-rule`.
3230

3331
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).
@@ -141,6 +139,125 @@ Content-Type: application/fhir+json
141139
}
142140
```
143141

142+
## $update-mapping Operation
143+
144+
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",
198+
"relationship": "equivalent"
199+
}]
200+
}
201+
]
202+
}]
203+
}
204+
```
205+
206+
Response: one mapping updated, one added.
207+
208+
```http
209+
HTTP/1.1 200 OK
210+
Content-Type: application/fhir+json
211+
212+
{
213+
"resourceType": "OperationOutcome",
214+
"issue": [{
215+
"severity": "information",
216+
"code": "informational",
217+
"diagnostics": "1 mapping updated, 1 mapping added"
218+
}]
219+
}
220+
```
221+
222+
### Formal Definition
223+
224+
```json
225+
{
226+
"resourceType": "OperationDefinition",
227+
"id": "ConceptMap-update-mapping",
228+
"url": "http://hl7.org/fhir/OperationDefinition/ConceptMap-update-mapping",
229+
"version": "6.0.0",
230+
"name": "UpdateMapping",
231+
"title": "Update or add mappings in a ConceptMap",
232+
"status": "draft",
233+
"kind": "operation",
234+
"affectsState": true,
235+
"code": "update-mapping",
236+
"resource": ["ConceptMap"],
237+
"system": false,
238+
"type": false,
239+
"instance": true,
240+
"parameter": [
241+
{
242+
"name": "mappings",
243+
"use": "in",
244+
"min": 1,
245+
"max": "1",
246+
"documentation": "ConceptMap containing mappings to update or add. Only group elements are processed.",
247+
"type": "ConceptMap"
248+
},
249+
{
250+
"name": "return",
251+
"use": "out",
252+
"min": 1,
253+
"max": "1",
254+
"documentation": "Outcome of the operation",
255+
"type": "OperationOutcome"
256+
}
257+
]
258+
}
259+
```
260+
144261
## $remove-mapping Operation
145262

146263
The `$remove-mapping` operation removes mappings from a ConceptMap.

0 commit comments

Comments
 (0)