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
+206-7Lines changed: 206 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,30 @@
1
1
# ConceptMap Mapping Operations
2
2
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`.
3
+
This page defines four operations for managing individual mappings within large [ConceptMap](https://hl7.org/fhir/conceptmap.html) resources: `$add-mapping`, `$update-mapping`, `$remove-mapping`, and `$replace-element`.
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 all three operations, only `group` elements in the input are processed; all other elements are ignored.
9
+
For all four operations, only `group` elements in the input are processed; all other elements are ignored.
10
10
11
11
## Matching Algorithm
12
12
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`.
13
+
`$add-mapping`, `$update-mapping`, and `$remove-mapping`use target-level matching. 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
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`.
18
18
19
+
`$replace-element` uses element-level matching: two elements match when they have identical values for `group.source`, `group.target`, and `element.code`. All targets and `noMap` state for the matched element are replaced atomically.
20
+
19
21
## $add-mapping Operation
20
22
21
23
The `$add-mapping` operation merges mappings into a ConceptMap, skipping any that already exist.
22
24
23
25
URL: [base]/ConceptMap/[id]/$add-mapping
24
26
25
-
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.
27
+
The server SHALL add each input mapping that does not already exist. If an input mapping already exists (same match key), the server ignores it by default (`if-exists=ignore`) and SHOULD report skipped entries in the OperationOutcome; set `if-exists=fail` to return an error instead. If no `group` exists for the given `source` and `target`, one is created.
26
28
27
29
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
30
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.
@@ -35,6 +37,7 @@ Clients MAY supply an `If-Match` header; servers SHALL reject the request if the
35
37
| Name | Cardinality | Type | Documentation |
36
38
|------|-------------|------|---------------|
37
39
| mappings | 1..1 | ConceptMap | Only `group` elements are processed |
40
+
| if-exists | 0..1 | code | Behaviour when an input mapping already exists: `ignore` (default) — skip with SHOULD-report; `fail` — return an error |
"documentation": "ConceptMap containing mappings to add. Only group elements are processed.",
128
171
"type": "ConceptMap"
129
172
},
173
+
{
174
+
"name": "if-exists",
175
+
"use": "in",
176
+
"min": 0,
177
+
"max": "1",
178
+
"documentation": "Behaviour when an input mapping already exists: 'ignore' (default) — skip with SHOULD-report; 'fail' — return an error.",
179
+
"type": "code"
180
+
},
130
181
{
131
182
"name": "return",
132
183
"use": "out",
@@ -149,7 +200,7 @@ The server SHALL replace each matching mapping with the input values; properties
149
200
The server SHOULD report the number of mappings updated and added in the OperationOutcome.
150
201
151
202
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.
203
+
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
204
In either case the server SHALL return an OperationOutcome with `severity=error` and `code=business-rule`.
154
205
155
206
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).
@@ -264,7 +315,7 @@ The `$remove-mapping` operation removes mappings from a ConceptMap.
264
315
265
316
URL: [base]/ConceptMap/[id]/$remove-mapping
266
317
267
-
The server SHALL remove all mappings that match the input entries, across all groups in the ConceptMap. If no matching mapping exists for an input entry, the server SHALL ignore it.
318
+
The server SHALL remove all mappings that match the input entries. If no matching mapping exists for an input entry, the server SHALL ignore it. If an input entry matches entries across more than one group, the server SHALL return an error by default (`on-multiple-match=fail`); set `on-multiple-match=remove-all` to remove from all matching groups.
268
319
269
320
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).
270
321
@@ -273,6 +324,7 @@ Clients MAY supply an `If-Match` header; servers SHALL reject the request if the
273
324
| Name | Cardinality | Type | Documentation |
274
325
|------|-------------|------|---------------|
275
326
| mappings | 1..1 | ConceptMap | Only `group` elements are processed |
327
+
| on-multiple-match | 0..1 | code | Behaviour when an input entry matches entries across more than one group: `fail` (default) — return an error; `remove-all` — remove from all matching groups |
"documentation": "ConceptMap containing mappings to remove. Only group elements are processed.",
347
436
"type": "ConceptMap"
348
437
},
438
+
{
439
+
"name": "on-multiple-match",
440
+
"use": "in",
441
+
"min": 0,
442
+
"max": "1",
443
+
"documentation": "Behaviour when an input entry matches entries across more than one group: 'fail' (default) — return an error; 'remove-all' — remove from all matching groups.",
444
+
"type": "code"
445
+
},
446
+
{
447
+
"name": "return",
448
+
"use": "out",
449
+
"min": 1,
450
+
"max": "1",
451
+
"documentation": "Outcome of the operation",
452
+
"type": "OperationOutcome"
453
+
}
454
+
]
455
+
}
456
+
```
457
+
458
+
## $replace-element Operation
459
+
460
+
The `$replace-element` operation atomically replaces entire elements (all targets and `noMap` state) in a ConceptMap.
461
+
462
+
URL: [base]/ConceptMap/[id]/$replace-element
463
+
464
+
The server SHALL match each input element by `(group.source, group.target, element.code)` and replace the entire element with the input values. If no matching element exists, the server SHALL add it. If no `group` exists for the given `source` and `target`, one is created. The server SHOULD report the number of elements replaced and added in the OperationOutcome.
465
+
466
+
Unlike `$add-mapping` and `$update-mapping`, no `noMap` conflict check is performed — the input element replaces whatever was previously there, enabling atomic transitions between mapped and `noMap` states.
467
+
468
+
It is an error if the ConceptMap contains more than one group with the same `source` and `target` as an input element, since the target group is ambiguous. The server SHALL return an OperationOutcome with `severity=error` and `code=business-rule`.
469
+
470
+
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).
471
+
472
+
**In Parameters**
473
+
474
+
| Name | Cardinality | Type | Documentation |
475
+
|------|-------------|------|---------------|
476
+
| elements | 1..1 | ConceptMap | Only `group` elements are processed |
477
+
478
+
**Out Parameters**
479
+
480
+
| Name | Cardinality | Type | Documentation |
481
+
|------|-------------|------|---------------|
482
+
| return | 1..1 | OperationOutcome | Outcome of the operation |
483
+
484
+
### Example
485
+
486
+
Request: atomically transition GLUC from a target mapping to `noMap`.
487
+
488
+
```http
489
+
POST /ConceptMap/lab-codes-to-loinc/$replace-element HTTP/1.1
Multiple groups with the same `source` and `target` within a single ConceptMap are permitted but discouraged. When different mapping subsets require different `unmapped` handling, they SHOULD be modeled as separate ConceptMap resources — subsets are a concept map-level concern.
562
+
Multiple groups with the same `source` and `target` within a single ConceptMap are permitted but discouraged. When different mapping subsets require different `unmapped` handling, they SHOULD be modeled as separate ConceptMap resources — subsets are a concept map-level concern.
0 commit comments