FHIR Chat · include file path · cql

Stream: cql

Topic: include file path


view this post on Zulip Eric Whitley (Mar 25 2020 at 17:22):

Is there a way to specify an the path of an included library?

EX: I have several different measures in subdirectories and have a common library MySharedStuff

  • /Measure1/Measure1.cql
  • /Measure2/Measure2.cql
  • /Shared/MySharedStuff.cql

What I want to do is have those individual measures be able to include the MySharedStuff library .

The examples I've seen for includes seem to assume that all of the files are in the same directory as there's no reference to a path.

Do I need to copy all shared files into each measure subdirectory or is there a way to refer to the library's path?

EX: include "../Shared/MyShredStuff" version '1' called MySharedStuff

Any direction very much appreciated

view this post on Zulip Chris Moesel (Mar 25 2020 at 19:58):

Hi @Eric Whitley -- the CQL spec only allows for libraries to be included by their name and identifier. It assumes that these are unique and that the implementing system has a mechanism for resolving them. How they get resolved is considered an implementation detail not covered by the spec. The spec itself doesn't say much about this, but there is a little blurb in the Physical Representation section of the doc:

The implementation environment must provide a mechanism for library references to be resolved based on their names and versions.

view this post on Zulip Chris Moesel (Mar 25 2020 at 20:00):

The reference implementation CQL-to-ELM translator, however, does have a specific approach to library resolution -- and if I recall, that approach requires all libraries to (a) have a a file name matching the library name, and (b) be in the same folder. @Bryn Rhodes can confirm or deny that one, however, as he's the primary maintainer of that code.

view this post on Zulip Eric Whitley (Mar 25 2020 at 20:19):

@Chris Moesel I really appreciate you taking the time to answer my question. That makes sense. I was trying to wrap my head around how that would be handled based on the docs. As I think about that now it actually makes way more sense. I was coming at it from the perspective of "script A is here and script B is here" and the resolution is in the script, but it seems like it's more like "library A is used" and then whatever tooling you're using is responsible for resolving where that version of the code is stored. Thanks again - I appreciate you explaining that.

view this post on Zulip Bryn Rhodes (Mar 25 2020 at 20:48):

@Eric Whitley , yes Chris is right, the translator has a default implementation that assumes current directory, but it defines a LibrarySourceProvider interface that environments are expected to provide an implementation for. In the Atom plugin, we're just using the default resolver, so we typically organize around a single CQL directory. For example, in the connectathon repository: https://github.com/DBCG/connectathon/tree/master/fhir3/input/pagecontent/cql

view this post on Zulip Bryn Rhodes (Mar 25 2020 at 20:48):

Within an environment like a FHIR server plugin, we have a resolver that actually references the Library resources available in the server to resolve libraries, and that happens by the canonical URL of the library (which is constructed from the name of the library).

view this post on Zulip Eric Whitley (Mar 25 2020 at 21:04):

Thank you @Chris Moesel and @Bryn Rhodes . This is incredibly helpful. I really appreciate your responses on this. Helps me better understand how to approach thinking about this.

view this post on Zulip Mohammad Afaq Khan (Apr 22 2020 at 14:56):

Is filtering in CQL hash based or loop based? In terms of the Patient Context.

view this post on Zulip Bryn Rhodes (Apr 22 2020 at 18:10):

The CQL specification itself doesn't prescribe how filtering is implemented, that's up to the implementation and depends on a lot of different factors. In the Java-based engine, the patient context filtering is passed to the data access layer, either using the subject parameter of a FhIR URL, or the equivalent subject parameter in the JPA layer of a HAPI FHIR server if it's running in process.

view this post on Zulip Mohammad Afaq Khan (Apr 22 2020 at 19:58):

Thank you @Bryn Rhodes !

view this post on Zulip Chris Moesel (Apr 22 2020 at 21:14):

In the CoffeeScript/JavaScript cql-execution project, filtering is loop-based. For example, [Condition: "Diabetes"] C where C.status.value = 'active' will loop through all Conditions in the passed in bundle, checking for conditions whose code is in the "Diabetes" VS and whose status is active. It's not a very efficient approach, but it does allow CQL to be executed without a database backend.

view this post on Zulip Mohammad Afaq Khan (Apr 23 2020 at 00:04):

O ok, I was curious because someone I work with was concerned about Big O. Thanks @Chris Moesel !

view this post on Zulip Mohammad Afaq Khan (Apr 23 2020 at 20:08):

CHEF BRYN lol put us on a diet jk. #Chef’sGotTheFHIR


Last updated: Apr 12 2022 at 19:14 UTC