FHIR Chat · Possible to make elements mandatory in different use cases? · implementers

Stream: implementers

Topic: Possible to make elements mandatory in different use cases?


view this post on Zulip Rebecka Hansson (Jun 26 2020 at 12:56):

Hi!
I have a question regarding if it is possible to set use case based rules in profiles. I want to use the same profile but for different use cases and want a certain element or attribute to be mandatory/optional.
Here is one example:
Profile on the encounter resorce: First time when posting the encounter we need the start time on the period.start attribute and we need status=in-progress. When updating the encounter with status=finished we want to require an end time. Is it possible to somehow connect the cardinality on the period.end attribute to be 0..1 when status=in-progress and 1..1 when status=finished?
Do anyone have a suggestion on how to solve this? Maybe by applying implicitRules?

view this post on Zulip Jose Costa Teixeira (Jun 26 2020 at 13:30):

Seems like you can add an invariant in your profile

view this post on Zulip Lloyd McKenzie (Jun 26 2020 at 14:09):

Invariant can only make use of data within the instance - it can't make use of environmental context (e.g. whether something is sent as a POST or PUT, or what system a request is coming from). You can express such rules in text in a profile, but there's no way to enforce them computably with a single profile - you'd need multiples. And even then, you'd need extensions in your CapabilityStatement to allow declaring distinct profiles for different usage contexts

view this post on Zulip Jose Costa Teixeira (Jun 26 2020 at 14:18):

period.end attribute to be 0..1 when status=in-progress and 1..1 when status=finished?

this could be done inside the instance, if that is all it is required, right?

view this post on Zulip Jose Costa Teixeira (Jun 26 2020 at 14:19):

With that in mind, this sounds like 2 different types of transactions and thus 2 profiles.

view this post on Zulip Lloyd McKenzie (Jun 26 2020 at 14:26):

Yes, but what needs to be true on create vs. update couldn't be

view this post on Zulip Rebecka Hansson (Jun 29 2020 at 17:30):

Thank you!


Last updated: Apr 12 2022 at 19:14 UTC