FHIR Chat · Slice on code type discrminator with existence of value · implementers

Stream: implementers

Topic: Slice on code type discrminator with existence of value


view this post on Zulip Laureen Loison (Dec 03 2019 at 15:27):

Hello, I try to create a Slice on CommunicationRequest resource on status field and I would like to say : "status = active only if communication request have at least one recipient" do you know how to do that with a slice or constraint ?
Thanks

view this post on Zulip Lloyd McKenzie (Dec 03 2019 at 17:45):

That should be a constraint, not a slice. Slice is for repeating elements within a resource, not for the resource as a whole.

view this post on Zulip Laureen Loison (Dec 03 2019 at 17:56):

Great, thanks, I try with this constraint add in Forge but no errors comes ...
Here it's my try :
{
"key": "cmr-1",
"severity": "error",
"human": "if status = active we must have a recipient,",
"expression": "status != 'active' | recipient.exists()"
}
Do you thing it's a correct expression ? Should I need to add a xpath ?
Thanks

view this post on Zulip Lloyd McKenzie (Dec 03 2019 at 18:22):

It should be status != 'active' or recipient.exists()

view this post on Zulip Laureen Loison (Dec 04 2019 at 11:23):

It should be status != 'active' or recipient.exists()

I try but he didn't work. I have no error on my validation, have you got an other idea ?

view this post on Zulip Lloyd McKenzie (Dec 04 2019 at 13:06):

The invariant is being declared on "CommunicationRequest" root element, correct? How are you trying to validate?

view this post on Zulip Laureen Loison (Dec 04 2019 at 14:24):

Oh sorry I think the constraint should be declared on "CommunicationRequest.status" field, I try and it's work perfectly, thank you

view this post on Zulip Lloyd McKenzie (Dec 04 2019 at 14:52):

Constraints always have to appear on an ancestor (typically the nearest ancestor) that contains all elements referenced by the constraint. Paths are expressed with respect to the element the constraint appears on.


Last updated: Apr 12 2022 at 19:14 UTC