[MedicationRequest: medication in "Antidiabetic Medications"]
where status = 'active'
查詢 (Query)
完整語法
[Encounter: "Inpatient"] E
with [Condition: "Diabetes"] D
such that D.onset during E.period
where E.status = 'finished'
return Tuple {
encounterId: E.id,
diagnosis: D.code.text
}
sort by encounterId
子句順序
順序
子句
說明
1
with/without
關聯條件
2
where
篩選條件
3
return
回傳欄位
4
sort
排序
定義表達式 (Define)
define "PatientHasDiabetes":
exists([Condition: "Diabetes"] D
where D.clinicalStatus ~ "Active")
define "CurrentMedications":
[MedicationRequest] M
where M.status = 'active'
函數 (Function)
define function "GetDrugName"(med MedicationRequest):
if med.medication is CodeableConcept then
(med.medication as CodeableConcept).text
else
null
define function "CalculateAge"(birthDate Date):
years between birthDate and Today()
library ThTxGNNDrugRepurposing version '1.0.0'
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.1'
context Patient
// 取得目前有效的用藥
define "ActiveMedications":
[MedicationRequest] M
where M.status = 'active'
and M.intent = 'order'
// 取得藥物名稱清單
define "MedicationNames":
"ActiveMedications" M
return FHIRHelpers.ToConcept(M.medication as CodeableConcept).display
定義:DDI 檢查邏輯
// 檢查是否有 Warfarin + NSAID 併用
define "WarfarinPlusNSAID":
exists([MedicationRequest: "Warfarin"] W
where W.status = 'active')
and exists([MedicationRequest: "NSAIDs"] N
where N.status = 'active')
// DDI 警示訊息
define "DDIAlertMessage":
if "WarfarinPlusNSAID" then
'WARNING: Concurrent use of Warfarin and NSAIDs increases bleeding risk.'
else
null
定義:老藥新用候選篩選
// 參數:ThTxGNN 預測分數門檻
parameter PredictionScoreThreshold Decimal default 0.9
// 定義:高信心度候選
define "HighConfidenceCandidates":
"DrugRepurposingPredictions" P
where P.score >= PredictionScoreThreshold
and P.evidenceLevel in {'L1', 'L2', 'L3'}