官方說明:
Clinical Quality Language (CQL) is a high-level, domain-specific language focused on clinical quality and targeted at measure and decision support artifact authors.
In addition, this specification describes a machine-readable canonical representation called Expression Logical Model (ELM) targeted at implementations and designed to enable sharing of clinical knowledge.
https://build.fhir.org/ig/HL7/cql/
簡單的說,CQL為領域專家撰寫的語言,人可以看得懂;ELM則是機器看得懂的語言,專注在系統開發與整合使用。下圖說明了彼此的關係,透過工具,可以將CQL與ELM互相轉換,應用於分析與需求確認。實際系統開發則是從ELM出發,透過程式語言,將複雜的邏輯轉換為可執行程式。
以Firely這家公司為例,在DevDays 2023就發表了CQL Engine,將ELM轉換成為C#原始碼,透過編譯成DLL後,其他C#程式就可以直接使用原始CQL所定義的運算邏輯。
Evan Machusak & Ann Smith - CQL on Firely: Digital measures for .NET | DevDays 2023 Amsterdam https://www.youtube.com/watch?v=_fEZOxjtyY0&list=PLKuZNI94tzWY1J988TdEGhJ69r4DnTiAN&index=33&t=2241s
CQL的開發流程可區分為以下步驟:
https://github.com/cqframework/cql-translation-service
),將CQL轉換成ELM這樣的流程代表著將來Cinical Quality相關需求就可以由使用者直接撰寫CQL,使用工具產生相關Library,搭配FHIR Server即可快速產生可運作的程式。另外,使用LLM來產生CQL也成為非常有潛力的應用。
開發CQL所需要的環境為Visual Studio Code + CQFramework Clinical Quality Landuage Extension。安裝流程非常簡單(就是一般VS Code安裝plugin的基本步驟,選擇cqframework.cql Extension,按下inslall),相關資料可參考 https://github.com/cqframework/vscode-cql/wiki/User-Guide
安裝完成後,可從git hub執行git clone https://github.com/cqframework/cqf-exercises.git
匯入CQF Exercises。這個專案提供了由簡入繁的CQL程式開發練習。
建立整個開發環境的過程中,有以下幾點需要注意:
ig.ini
和input/cqf-exercise.xml
,可手動加入或是下載另一個版本(issue3-missing-ini-file)簡單的說,每一個cql檔案必須位於input/cql
,每個檔案就是一個library,名稱必須與檔案名稱相同。所需要的測試資料必須放在input/test/<cql-libray>
下(若使用到Patient時,相關資料必須置於input/tests/<cql-library-name>/<patient-id>
),執行CQL後的輸出檔案會放在input/tests/results/<cql-library-name>.txt
。CQL所需要的Terminology則是放在input/vocabulary
。
基本語法在Exercise1 ~ Exercise6都有說明,就不再贅述,實際應用案例以Exercise 10為例:
應用情境:
The USPSTF recommends annual screening for lung cancer with low-dose computed tomography (LDCT) in adults aged 55 to 80 years who have a 30 pack-year smoking history and currently smoke or have quit within the past 15 years. Screening
should be discontinued once a person has not smoked for 15 years or develops a health problem that substantially limits life expectancy or the ability or willingness to have curative lung surgery(USPSTF 建議對55至80歲、有30年吸菸史、目前吸菸或在過去 15 年內戒菸的成年人每年進行一次低劑量電腦斷層掃描(LDCT)肺癌篩檢。一旦一個人15年不吸煙或出現嚴重限制預期壽命或進行治療性肺部手術的能力或意願的健康問題,就應停止篩檢 ~ from google translator)
測試資料與執行結果
在input/tests/Exercise10
共計有三筆測試資料,分別是Heavy-Smoker、Never-Smoker與Former-Smoker。執行結果如下:
程式碼說明如下:
cql-translation-service介紹
CQL程式Walkthrough
Cooking with CQL 69 - Colorectal Cancer Concepts