Stream: implementers
Topic: How to make a constraint if one component exist?
Ashwin Djorai (Dec 07 2021 at 10:10):
I have 3 component slices in my Observation resource. I want to add a constraint in my profile. This is my constraint name:
If one of the component codes is present, all SHALL be present.
I have created an expression in the following way:
( component.code.coding.where(system='urn:oid:2.16.840.1.113883.2.4.3.11.60.40.4.0').where(code='4.6.5').empty() and component.code.coding.where(system='urn:oid:2.16.840.1.113883.2.4.3.11.60.40.4.0').where(code='4.6.4').empty() and component.code.coding.where(system='urn:oid:2.16.840.1.113883.2.4.3.11.60.40.4.0').where(code='4.6.3').empty() ) or ( component.code.coding.where(system='urn:oid:2.16.840.1.113883.2.4.3.11.60.40.4.0').where(code='4.6.5').exists() and component.code.coding.where(system='urn:oid:2.16.840.1.113883.2.4.3.11.60.40.4.0').where(code='4.6.4').exists() and component.code.coding.where(system='urn:oid:2.16.840.1.113883.2.4.3.11.60.40.4.0').where(code='4.6.3').exists() )
This works for my use case, but is there a better way to create this expression?
Lloyd McKenzie (Dec 07 2021 at 14:18):
I think you could do
component.code.coding.where(system='...').where(code='4.6.5' or code='4.6.4' or code='4.6.3').empty() or component.code.coding.where(system='...').where(code='4.6.5' or code='4.6.4' or code='4.6.3').code().distinct().count()=3
Ashwin Djorai (Dec 08 2021 at 10:17):
Thank you @Lloyd McKenzie I will test this and let know you the results
Last updated: Apr 12 2022 at 19:14 UTC