Bell Eapen MD, PhD.

Bringing Digital health & Gen AI research to life!

Clinical Query Language – Part 1

Clinical Query Language (CQL) is a high-level query language to represent and generate unambiguous quality measures or clinical decision rules. I am not a CQL expert. These are my notes from a system development perspective. I am trying to make sense of this emerging concept and add my notes here in the hope that others may find this useful.

Clinical Query Language – Part 1
U.S. Navy photo by Chief Warrant Officer 4 Seth Rossman. / Public domain (wikimedia)

Clinical Query Language is designed to be intuitive for clinicians authoring the queries for quality measures and clinical decision support. The decision support rules are mostly alert type rules at the individual and population level that is calculated from a database (not usually diagnostic decision support). You can use any data model with CQL.

Here is an example segment of CQL:

define “InDemographic”:
AgeInYearsAt(start of MeasurementPeriod) >= 16 and AgeInYearsAt(start of MeasurementPeriod) < 24
and “Patient”.”gender” in “Female Administrative Sex”

As Clinical Query Language follows strict semantics, you can autogenerate lexers, parsers and visitors using ANTLR. In simple terms, CQL’s semantics can be represented as a ‘grammar’ that ANTLR can read and generate code to process any CQL in a variety of programming languages, including Java, Javascript, Python, C# and Go. The CQL grammar files are here: https://cql.hl7.org/08-a-cqlsyntax.html. Incidentally, CQL grammar inherits from fhirpath.

If you wish to generate code from these files, there are two things to note:

  • You need to rename CQL.g4 to cql.g4 as the library names are case-sensitive and should correspond to the filename.
  • Put fhirpath.g4 in the same folder as cql.g4, and cql refers to fhirpath grammar.

Clinical Query Language aims to provide a high-level domain-independent language for clinicians that can be translated into low-level database logic. As CQL does not prescribe a data model, an intermediary format linking CQL to the data management logic is required. That is called the Expression Logical Model (ELM) which we will discuss in part 2.

Update: cql-exec-vsac is a VSAC-enabled code service for the JavaScript CQL Execution project. This allows the CQL Execution Engine to execute CQL containing references to Value Sets that are published in the National Library of Medicine’s (NLM) Value Set Authority Center (VSAC). I have added a feature that adds support for any FHIR server other than VSAC to support private terminology servers. Check it out!

Importing ONTODerm Ontology

Map of Colombia with Departments
Map of Colombia with Departments (Photo credit: Wikipedia)

Two engineering students from Colombia are using ONTODerm for a noble cause. They are planning to take dermatology to the poor and the underprivileged. They started a teledermatology project, but discontinued it because of lack of support. Now they are working on an Ontology based diagnostic application using semantic web technologies.

One of the problems they have encountered may be important to be addressed here. They could not import ONTODerm into Sesame. The URL provided in the ONTODerm home page is protege specific. However you can export the latest ONTODerm version in the native format from the project page on knoodl. Just request for a free membership to ONTODerm community.

Please keep me posted if you are using ONTODerm or DermKnowledgeBASE for any such projects and I wish both of them all the very best.

DermKnowledgeBASE – A Dermatology Knowledge Base with semi-automated knowledge discovery.

English: Map Summarizing Rosacea, It was creat...
English: Map Summarizing Rosacea, It was created by the author and Reem Al-Qudah using Clinical dermatology book Dahl, Mark V.; Weller, Richard E.; Hunter, John G.; Savin, John (2008). Clinical Dermatology. Wiley-Blackwell. Reference (Photo credit: Wikipedia)

For the last few weeks I have been working on DermKnowledgeBASE (DKB) that I believe is the first RDF knowledgebase for dermatology. It implements RDFS using RAP library for php. The terminology in dermatology facilitate the diagnostic process because many skin disorders have distinct features that can be represented by appropriate categories of terms. But dermatological terms are different from the traditional medical linguistics. Hence DKB is not rooted on MeSH  or any popular medical ontologies but on ONTODerm, the ontology I started developing for dermatology. I wrote about an offshoot of this project called slise before. DKB makes use of eutil webservices and whatizit from EBI. It is semi automated and can learn most of the relations on its own. But it relies on curators for confirming difficult rules. Its focus is on providing diagnostic support. Hence curators can add further information about the relevance of each feature in a particular disease. Features can be classified as pathognomonic, common, important, rare etc which helps in streamlining diagnostic accuracy. It provides a range of  functions and SOAP web services in addition to a ‘consult’ function to obtain differential diagnosis based on the description of clinical findings. It is still early days, but hopefully it may evolve into a very useful application for dermatology.

Click the banner below to access DermKnowledgeBASE: