Skip to content

Commit

Permalink
#10: Added references fluent function to facilitate reference comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
brynrhodes committed May 5, 2024
1 parent 42bf990 commit de430ff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions input/cql/FHIRCommon.cql
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,22 @@ else
else
Interval[start of condition.onset.toInterval(), abatementDate]

/*
@description: Returns true if the given reference is to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference FHIR.Reference, resource FHIR.Resource):
resource.id = Last(Split(reference.reference, '/'))

/*
@description: Returns true if any of the given references are to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(references List<FHIR.Reference>, resource FHIR.Resource):
exists (references R where R.references(resource))

/*
@description: Returns any extensions defined on the given resource with the specified url.
@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access
Expand Down

0 comments on commit de430ff

Please sign in to comment.