FHIR / FHIR/sushi

Consider soft-indexing syntax to append an array item rather than overwriting existing array items

Open
#875 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
188
Forks
64
Avg merge
8d 8h
Merged PRs (30d)
5

Description

Current soft indexing resolves the initial index to zero (0) and increments from there. For example:
```
* ^extension[+].url = "https://fhir.example.com/dp/StructureDefinition/dp-api"
* ^extension[=].valueCode = #external-api
* ^extension[+].url = "https://fhir.example.com/dp/StructureDefinition/dp-api-interaction"
* ^extension[=].valueCode = #READ
```
resolves to
```
* ^extension[0].url = "https://fhir.example.com/dp/StructureDefinition/dp-api"
* ^extension[0].valueCode = #external-api
* ^extension[1].url = "https://fhir.example.com/dp/StructureDefinition/dp-api-interaction"
* ^extension[1].valueCode = #READ
```
In most "assignment" use cases, this is the desired behavior. However, when dealing with metadata elements in StructureDefinitions and ElementDefinitions, the parent metadata element can already contain data that would get overwritten with this syntax rather than appended. For example, FHIR StructureDefinition resources contain extensions and if I want to add extensions in my profile, I want them to be appended to the extension array and not overwrite the existing extensions.

[Zulip conversation](https://chat.fhir.org/#narrow/stream/215610-shorthand/topic/Caret.20Rules.20Overwrite.20Array.20Elements/near/245496372) suggested the idea of introducing a syntax that indicates that an item should be appended to the end of the list (e.g., `^extension[/]` or `^extension[>]`, etc.). So, the above example would become (assuming the parent StructureDefinition.extension array contains 2 extensions):
```
* ^extension[>].url = "https://fhir.example.com/dp/StructureDefinition/dp-api"
* ^extension[=].valueCode = #external-api
* ^extension[+].url = "https://fhir.example.com/dp/StructureDefinition/dp-api-interaction"
* ^extension[=].valueCode = #READ
```
resolves to
```
* ^extension[2].url = "https://fhir.example.com/dp/StructureDefinition/dp-api"
* ^extension[2].valueCode = #external-api
* ^extension[3].url = "https://fhir.example.com/dp/StructureDefinition/dp-api-interaction"
* ^extension[3].valueCode = #READ
```

Note: This behavior should apply to any array-based element and not just extension.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.