Consider adding .references() fluent functions as proposed in Cooking with CQL Session 82:
define fluent function references(reference FHIR.Reference, resource FHIR.Resource):
resource.id = Last(Split(reference.reference, '/'))
define fluent function references(references List<FHIR.Reference>, resource FHIR.Resource):
exists (references R where R.references(resource))
https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/blob/master/Source/Cooking%20With%20CQL/82/TestHIVAssay.md#fhir-references