FHIR Chat · rule() · fhirpath

Stream: fhirpath

Topic: rule()


view this post on Zulip Grahame Grieve (Jul 06 2019 at 21:57):

take this rule, from the snapshot generator tests:

fixture('t43o').snapshot.element.where(id = 'Observation.value[x]:Quantity')).sliceName = 'Quantity'

view this post on Zulip Grahame Grieve (Jul 06 2019 at 21:57):

if there's no elements that meet the where clause, this passes.

view this post on Zulip Grahame Grieve (Jul 06 2019 at 21:57):

so I have to also make a rule:

fixture('t43o').snapshot.element.where(id = 'Observation.value[x]:Quantity')).exists()

view this post on Zulip Grahame Grieve (Jul 06 2019 at 21:58):

but it would be more convenient to do this:

view this post on Zulip Grahame Grieve (Jul 06 2019 at 21:58):

fixture('t43o').snapshot.element.where(id = 'Observation.value[x]:Quantity')).check(size() = 1).sliceName = 'Quantity'

view this post on Zulip Grahame Grieve (Jul 06 2019 at 21:59):

where .check([condition]) works like .trace() - returns the focus if the condition passes, else raises an error.

view this post on Zulip Grahame Grieve (Jul 06 2019 at 22:00):

I don't see that we have a function like that, but it seems like it would be generally useful?

view this post on Zulip Grahame Grieve (Jul 06 2019 at 22:05):

no should be .check(condition, message)


Last updated: Apr 12 2022 at 19:14 UTC