FHIR Chat · Can't assign a simple quantity to valueQuantity · shorthand

Stream: shorthand

Topic: Can't assign a simple quantity to valueQuantity


view this post on Zulip David Pyke (Feb 10 2022 at 18:21):

I'm trying to assign the following:

view this post on Zulip David Pyke (Feb 10 2022 at 18:23):

  * valueQuantity = 0.8

But I get the error
Cannot assign number value: 0.8. Value does not match element type: Quantity

view this post on Zulip David Pyke (Feb 10 2022 at 18:23):

I don't have a unit as it's the result of a ratio

view this post on Zulip David Pyke (Feb 10 2022 at 18:34):

I've worked around it by simply putting it directly into valueQuantity.value but that seems wrong. Could not having a unit be a warning and not an error?

view this post on Zulip Chris Moesel (Feb 10 2022 at 18:55):

I think we could consider it, but the FSH spec defines a quantity literal (the shortcut syntax) as having both a value and unit -- so it would likely be a change to the spec (not just SUSHI). The spec also shows that to set the value only, you should reference the .value element of the property. See Assignments with Quantity Data Type.

That said, I thought that in cases like you're describing, UCUM unit 1 should be used. The doc on Ratio even seems to imply use of Quantity w/ unit 1 (although it is admittedly a little confusing, so I'm not 100% sure).

view this post on Zulip David Pyke (Feb 10 2022 at 19:05):

I guess that makes sense. Quantity datatype doesn't mandate a unit but I can work with a unit of 1

view this post on Zulip John Moehrke (Feb 10 2022 at 20:06):

I don't mind the normal sushi to require a unit. You can just assign to .value without a unit.

view this post on Zulip Gino Canessa (Feb 10 2022 at 21:25):

Note that there are valid UCUM for things like /{Entity} (per arbitrary entity), e.g., /1 is a valid unit.
(edit: which gives context for 0.8 and prevents people from assuming it is a % - conversely you could change it and use %.. I think either way helps reduce misinterpretation)


Last updated: Apr 12 2022 at 19:14 UTC