Using Constraint Expressions in Firely SDK #1736
-
I am creating resources using ISourceNode and converting them to POCO. I would like to evaluate the constraint on each node and remove them before POCO. For example, a ContactPoint datattype has this constraint: I want to evaluate this expression on the SourceNode that represents the contact point and get the output so that i can remove that node before creating the POCO class. (I encounter this problem where sometimes the system is not available , but the value is available when i try to map an external data to FHIR and will end up in validation failures.) Is there a way to achieve that using the Firely APIs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
The fhirpath evaluator you would need to evalutate the constraints needs an ITypedElement, which requires more processing than just using ISourceNode, but can be used as input to parsing it to a POCO. So, you'd call |
Beta Was this translation helpful? Give feedback.
The fhirpath evaluator you would need to evalutate the constraints needs an ITypedElement, which requires more processing than just using ISourceNode, but can be used as input to parsing it to a POCO.
So, you'd call
.ToTypedElement()
on the source node, and then run the extension method.Select()
(Hl7.Fhir.FhirPath, namespace Hl7.Fhir.FhirPath) on it, passing it the fhirpath of the constraint. Those methods have a small cache, so calling it multiple times with the same expression will get the compiled fhirpath statement from a cache to speed up processing.