臺灣健保預檢規則實作指引
0.0.1 - CI Build

臺灣健保預檢規則實作指引, published by Example Publisher. This guide is not an authorized publication; it is the continuous build for version 0.0.1 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/TWNHIFHIR/cql/ and changes regularly. See the Directory of published versions

Library: 規則共通模組-BCReusable

Official URL: https://nhicore.nhi.gov.tw/cql/Library/BCReusable Version: 1.0.0
Draft as of 2026-03-11 Computable Name: BCReusable

此 Library 為乳癌藥事前審查共通使用規則模組。

Metadata
Title 規則共通模組-BCReusable
Version 1.0.0
Status Draft
Description

此 Library 為乳癌藥事前審查共通使用規則模組。

Type logic-library from http://terminology.hl7.org/CodeSystem/library-type
Parameters
Parameter None
Library Content
CQL Content
library BCReusable version '1.0.0'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1' called FHIRHelpers

include BCCodeConcept version '1.0.0' called CodeConcept

//乳癌疾病代碼:ICD-10-CM = C50
define "ICD-10使用C50":
  exists (
    [Claim] C
      where exists (
        C.diagnosis D
          where D.sequence = 1
            and exists ( 
              D.diagnosis.coding Cdg
                where (
                  Cdg in CodeConcept.ICD10CM2023
                  or Cdg in CodeConcept.ICD10CM2014
                )
                and Substring(Cdg.code, 0, 3) in CodeConcept.ICDBC
            )
      )
  )

//乳癌疾病之腫瘤代碼:ICD-10-CM = C77、C78、C79
define "ICD-10使用C77、C78、C79":
  exists (
    [Claim] C
      where exists (
        C.diagnosis D
          where D.sequence = 1
            and exists ( 
              D.diagnosis.coding Cdg
                where (
                  Cdg in CodeConcept.ICD10CM2023
                  or Cdg in CodeConcept.ICD10CM2014
                )
              and Substring(Cdg.code, 0, 3) in CodeConcept.ICDBCandTumor
          )
      )
  )


//乳癌疾病之腫瘤代碼:ICD-10-CM = C77、C78、C79但排除C79.3
define "ICD-10使用C77、C78、C79但排除C79.3":
  exists (
    [Claim] C
    where exists (
      C.diagnosis D
      where exists ( 
        D.diagnosis.coding Cdg
        where (
          Cdg in CodeConcept.ICD10CM2023
          or Cdg in CodeConcept.ICD10CM2014
        )
        and (
          (Substring(Cdg.code, 0, 3) in { 'C77', 'C78' })
          or (Substring(Cdg.code, 0, 3) = 'C79' and Cdg.code != 'C79.3')
        )
      )
    )
  )


//續用判斷
define "續用註記為1":
  exists (
    [Claim] C
      where exists (
        C.item I
          where exists (
            I.modifier M
                where exists (
                  M.coding Cdg
                         where Cdg in CodeConcept.NHIContinuationStatus
                         and Cdg.code in CodeConcept."續用註記為1"
                  )
          )
      )
  )


//續用判斷
define "續用註記為2":
  exists (
    [Claim] C
      where exists (
        C.item I
          where exists (
            I.modifier M
                where exists (
                  M.coding Cdg
                         where Cdg in CodeConcept.NHIContinuationStatus
                         and Cdg.code in CodeConcept."續用註記為2"
                  )
          )
      )
  )

//用藥線別不為1
define "用藥線別≠1":
  exists (
    [Claim] C
      where exists (
        C.item I
          where exists (
            I.modifier M
              where exists (
                M.coding Cdg
                  where Cdg in CodeConcept.NHILOT
                    and Cdg.code != '1'
              )
          )
      )
  )



// 醫令類別=1 (orderType = '1')
define "醫令類別為1":
 exists (
    [Claim] C
      where exists (
        C.item I
          where exists (
            I.productOrService.coding PSC
              where PSC in CodeConcept.NHIOrderType
              and PSC.code in CodeConcept."醫令類別"
          )
      )
  )

// 檢查 MedicationRequest 是否有有效的時間資訊
define function "HasValidTiming"(MR MedicationRequest):
  MR.dosageInstruction is not null
  and Count(MR.dosageInstruction) > 0
  and MR.dosageInstruction[0].timing is not null
  and MR.dosageInstruction[0].timing.repeat is not null
  and MR.dosageInstruction[0].timing.repeat.bounds is Period
  and (MR.dosageInstruction[0].timing.repeat.bounds as Period).start is not null
  and (MR.dosageInstruction[0].timing.repeat.bounds as Period).end is not null

// 取得 MedicationRequest 的起始時間
define function "GetStartTime"(MR MedicationRequest):
  start of (MR.dosageInstruction[0].timing.repeat.bounds as Period)

// 取得 MedicationRequest 的結束時間  
define function "GetEndTime"(MR MedicationRequest):
  end of (MR.dosageInstruction[0].timing.repeat.bounds as Period)

// 檢查 Plan 的時間範圍是否在 Order 的時間範圍內
define function "PlanTimeWithinOrderTime"(MRPlan MedicationRequest, MROrder MedicationRequest):
  "HasValidTiming"(MRPlan) 
  and "HasValidTiming"(MROrder)
  and "GetStartTime"(MRPlan) >= "GetStartTime"(MROrder)
  and "GetStartTime"(MRPlan) <= "GetEndTime"(MROrder)
  and "GetEndTime"(MRPlan) >= "GetStartTime"(MROrder)
  and "GetEndTime"(MRPlan) <= "GetEndTime"(MROrder)

// 檢查兩個藥物的時間範圍是否重疊
define function "MedicationTimesOverlap"(MR1 MedicationRequest, MR2 MedicationRequest):
  "HasValidTiming"(MR1) and "HasValidTiming"(MR2)
  and "GetStartTime"(MR1) <= "GetEndTime"(MR2)
  and "GetEndTime"(MR1) >= "GetStartTime"(MR2)
ELM XML Content
Encoded data 
ELM JSON Content
Encoded data 
Generated using version 0.5.3-cibuild of the sample-content-ig Liquid templates