Stream: shorthand
Topic: populating array with null in shorthand
Kippi Bordowitz (Apr 12 2022 at 09:24):
I am trying to populate an array in an example instance with null for a special use-case.
I have searched up and down the "language reference" site but there isn't a single word on the subject. I also goFSHed a JSON file that has a null where I would like it but the FSH file shows nothing. Is there a way to do this in FSH or is this a special case where I am forced to work directly on the JSON? If so, this is a problem, as SUSHI always deletes the resources folder so this means I would be forced to save the JSON in a separate location, which is problematic at this point.
Mint Thompson (Apr 12 2022 at 13:05):
If you want an element in an array to be null, this can be accomplished by skipping an index when assigning values in the Instance. Note that SUSHI will emit a warning when doing this, since this is not usually correct. If you want the array element itself to be null, however, SUSHI does not currently have a way of doing this.
David Pyke (Apr 12 2022 at 13:10):
I'm not sure of your use case, but FHIR doesn't support nulls. If you don't have a value for an element you would need to omit it (or use an extension with Data Absent Reason).
Gino Canessa (Apr 12 2022 at 15:09):
As a note, in JSON there is a time when null
is present. If you have an array of primitives that have extensions and not every element has both, the indexes have to match and you end up with explicit nulls (edit: note this can be in either direction):
"code": [ "au", "nz" ],
"_code": [
null,
{
"extension" : [ {
"url" : "http://hl7.org/fhir/StructureDefinition/display",
"valueString" : "New Zealand a.k.a Kiwiland"
}]
}
]
Last updated: Apr 12 2022 at 19:14 UTC