iT邦幫忙

2026 iThome 鐵人賽

DAY 28
0

摘要
Day 28 把 Day 27 的 SMART/OAuth sandbox token flow evidence 往之後所需的 live read/search evidence 推進:report 現在不只顯示 sandbox /metadata CapabilityStatement readiness 和 request-scoped token boundary evidence,也會顯示 synthetic/non-PHI workflow evidence 與 policy-only 的 sandbox live read/search execution evidence rows。

這和「能不能交換」有什麼關係?

Day 27 可以回答:

這個 sandbox preflight 有沒有可檢查的 token boundary evidence?

但需要先回答更接近 exchange execution 的問題:

如果要做 allowlisted sandbox read/search evidence,前置條件和拒絕條件是否已經可稽核?

如果一個 quality gate 只知道 token endpoint 是否安全,卻沒有固定 live resource interaction policy,那下一步很容易直接變成不受控的 live executor。Day 28 的重點就是把 live read/search 拆成 policy evidence:

  • 不是 production exchange platform。
  • 不是完整 SMART/OAuth client。
  • 不是 live resource read/search executor。
  • 不是 Bundle submitter。
  • 不是 persistent audit log。
  • 而是先讓 report 能證明:synthetic/non-PHI workflow、resource/operation allowlist、CapabilityStatement declaration、OAuth evidence dependency、response retention policy 都已存在。

例如同一份 Bundle 進來時,Day 28 的判斷會是:

情境 結果
validation 尚未執行 live read/search execution evidence NOT_EVALUATED
使用者未確認 synthetic/non-PHI read/search policy rows NOT_EVALUATED,resource endpoint 不呼叫
Bundle 含 Patient identifier / name / telecom / address / birthDate non-PHI preflight FAILED,resource endpoint 不呼叫
sandbox base URL 未 allowlist read/search policy rows blocked,resource endpoint 不呼叫
sandbox auth mode 是 none read/search policy rows blocked,resource endpoint 不呼叫
CapabilityStatement 未宣告 interaction 對應 resource/operation policy blocked,resource endpoint 不呼叫
OAuth token evidence 啟用但未通過 read/search policy rows blocked,resource endpoint 不呼叫
所有前置條件通過 read / search-type policy allowed,但 Day 28 仍不呼叫 endpoint
create / update / delete / Bundle submit 永遠 policy blocked

這讓 report 可以明確說明:

Sandbox live read/search policy readiness 已能 request-scoped 產生。
但目前只展示 policy boundary evidence,不執行 live Patient / Observation / DiagnosticReport read/search。

今天的實作範圍

Day 28 的 request / report flow 變成:

使用者上傳、貼上 Bundle,或選擇 built-in synthetic sandbox lab fixture
   │
   ├─ 執行原本 JSON / FHIR / TW Core / contract rules
   │
   ├─ terminology server evidence
   │     ├─ ValueSet/$expand
   │     └─ ValueSet/$validate-code
   │
   ├─ live FHIR metadata evidence
   │     └─ GET {FHIR_BASE_URL}/metadata
   │
   ├─ sandbox readiness evidence
   │     ├─ non-PHI workflow evidence
   │     │     ├─ workflow id
   │     │     ├─ fixture source
   │     │     ├─ user confirmation
   │     │     ├─ direct Patient identifier scan result
   │     │     ├─ sensitive findings
   │     │     └─ live-check eligibility reason
   │     ├─ sandbox auth boundary
   │     ├─ CapabilityStatement interaction declarations
   │     ├─ SMART/OAuth sandbox token evidence
   │     └─ sandbox live read/search execution evidence
   │           ├─ resource type
   │           ├─ operation
   │           ├─ policy allowed
   │           ├─ endpoint called = false
   │           ├─ HTTP status = N/A
   │           ├─ response retention policy
   │           └─ evidence statement
   │
   ├─ PHI masking / privacy evidence
   │     ├─ masking policy version
   │     ├─ masked field categories
   │     ├─ masking check result
   │     ├─ raw Bundle policy
   │     └─ retention policy = request-scoped only / no persistent history
   │
   └─ AuditEvent / Provenance resource preview
         ├─ input SHA-256
         ├─ selected contract id/version
         ├─ gate outcome
         ├─ rule count
         ├─ terminology status
         ├─ metadata status
         ├─ sandbox status
         ├─ PHI masking status
         └─ generation policy = generated request-scoped only; not persisted; not submitted

最後 Quality Test Report 的 evidence layer 變成:

Quality Gate blocking result
   ├─ FHIR / TW Core / contract local rules
   ├─ Terminology server evidence
   ├─ Live FHIR metadata evidence
   ├─ Sandbox readiness evidence
   │    ├─ Non-PHI workflow evidence
   │    ├─ CapabilityStatement interaction declarations
   │    ├─ SMART/OAuth token flow evidence
   │    └─ Live read/search execution policy evidence
   ├─ PHI masking / privacy evidence
   └─ AuditEvent / Provenance resource preview evidence
        ├─ AuditEvent JSON preview
        ├─ Provenance JSON preview
        └─ generation policy

Non-PHI workflow evidence 做什麼?

Day 28 新增的是 synthetic/non-PHI workflow evidence,不是 production de-identification。

它會記錄:

  • workflow id。
  • fixture source。
  • user confirmation status。
  • direct identifier scan result。
  • live-check eligibility reason。
  • sensitive finding list。
  • non-PHI evidence statement。

目前支援的 fixture source 包含:

  • user_uploaded_bundle
  • builtin_sandbox_lab_fixture

UI 新增:

Use built-in synthetic sandbox lab fixture

但這個選項不會自動通過 live sandbox guard。使用者仍然必須勾選:

Confirm this Bundle is synthetic/non-PHI test data

https://ithelp.ithome.com.tw/upload/images/20260829/20177913efrdFrPGqc.png

這個 layer 的定位是:

report-visible synthetic/non-PHI workflow evidence
不是 production PHI de-identification / pseudonymization engine

https://ithelp.ithome.com.tw/upload/images/20260829/20177913AlIxZtGW1u.png

Live read/search policy evidence 做什麼?

Day 28 新增的是 policy-only execution evidence rows,不是 live execution。

它會記錄:

  • execution status。
  • resource type。
  • operation。
  • policy allowed。
  • endpoint called。
  • HTTP status placeholder。
  • response retention policy。
  • evidence statement。

Day 28 支援的 future execution target 只包含:

  • Patient read
  • Patient search-type
  • Observation read
  • Observation search-type
  • DiagnosticReport read
  • DiagnosticReport search-type

Day 28 明確 blocked 的 operation 包含:

  • Patient create
  • Patient update
  • Patient delete
  • Observation create
  • Observation update
  • Observation delete
  • DiagnosticReport create
  • DiagnosticReport update
  • DiagnosticReport delete
  • Bundle submit

今天所有 execution rows 都維持:

status = NOT_EVALUATED
endpointCalled = false
httpStatus = N/A

https://ithelp.ithome.com.tw/upload/images/20260829/20177913lEhE5LCeqQ.png

之後才能實作 live resource execution client、read/search URL builder、response masking policy enforcement、operator intent confirmation、或 server response evidence extraction。

Response retention 的邊界?

Day 28 不顯示、不保存、不提交 raw server response。

report 使用:

  • resource type。
  • operation。
  • policy allowed / blocked。
  • endpoint called flag。
  • HTTP status placeholder。
  • response retention policy。
  • evidence statement。

它不輸出:

  • raw Patient response。
  • raw Observation response。
  • raw DiagnosticReport response。
  • raw search Bundle response。
  • raw access token。
  • client secret。
  • PHI。
  • validation history。

Response retention policy 明確顯示:

request-scoped only; raw server response is not displayed, persisted, or submitted

這表示目前版本仍然不會把 uploaded Bundle、token value、client secret、terminology response、FHIR metadata response、sandbox response、AuditEventProvenance 或 PHI 寫進資料庫,也不會送出 Bundle。

今天新增 / 調整的主要類別

  • SandboxLiveInteractionExecutionEvidence

NonPhiPreflightResult 新增:

  • workflowId
  • fixtureSource
  • directIdentifierScanResult
  • liveCheckEligibilityReason

NonPhiPreflightService 調整:

  • 支援傳入 workflow id 與 fixture source。
  • 保留原本 user confirmation guard。
  • 繼續掃描 Patient direct identifier fields。
  • built-in synthetic fixture 沒有 user confirmation 時仍然 NOT_EVALUATED

SandboxFhirPreflightResult 新增:

  • liveInteractionExecutionEvidence

SandboxFhirPreflightService 調整:

  • 從 sandbox allowlist、auth mode、non-PHI result、CapabilityStatement interaction declaration、OAuth token evidence 產生 policy-only execution rows。
  • read / search-type 只有在前置條件通過且 CapabilityStatement 宣告時才標示 policy allowed。
  • create / update / delete / Bundle submit 永遠 blocked。
  • Day 28 不呼叫 resource endpoint;所有 rows 的 endpointCalled 都是 false

ParseController 調整:

  • 新增 useSyntheticFixture request parameter。
  • 啟用時使用內建 synthetic sandbox lab Bundle 作為 input。
  • 將 fixture workflow id / source 傳入 non-PHI preflight。

index.html 調整:

  • Form 新增 Use built-in synthetic sandbox lab fixture
  • Layer summary 新增 Sandbox live read/search policy evidence
  • Sandbox readiness evidence 詳細區新增 workflow id、fixture source、direct identifier scan、live-check eligibility。
  • 新增 Sandbox live read/search execution evidence table。

Endpoint safety 設定

Day 28 沒有新增 endpoint 設定。

既有 sandbox endpoint 設定仍然控制 /metadata 和 OAuth token evidence:

qualitygate.fhir.sandbox.allowed-base-urls=
qualitygate.fhir.sandbox.allow-private-network=false
qualitygate.fhir.sandbox.auth-mode=none
qualitygate.fhir.sandbox.allowed-oauth-token-urls=
qualitygate.fhir.sandbox.oauth-token-url=
qualitygate.fhir.sandbox.oauth-token-request-enabled=false
qualitygate.fhir.sandbox.oauth-client-auth-mode=none
qualitygate.fhir.sandbox.oauth-client-id=
qualitygate.fhir.sandbox.oauth-client-secret=
qualitygate.fhir.sandbox.oauth-scopes=

Day 28 的預設狀態是:

Sandbox live read/search execution evidence = NOT_EVALUATED
HTTP Patient / Observation / DiagnosticReport endpoint = not called
HTTP search endpoint = not called
HTTP Bundle submit endpoint = not called

若要讓 Day 28 的 read/search policy rows 顯示 future execution policy allowed,至少需要:

  • sandbox base URL allowlist。
  • sandbox auth mode 不是 none
  • 使用者確認 synthetic / non-PHI test data。
  • direct Patient identifier scan 通過。
  • CapabilityStatement 宣告對應 resource interaction。
  • 如果 OAuth token request enabled,OAuth token evidence 必須通過。

測試重點

今天新增 / 更新測試確認:

  • built-in synthetic fixture 加上 user confirmation 時,non-PHI preflight PASSED
  • built-in synthetic fixture 沒有 user confirmation 時,non-PHI preflight NOT_EVALUATED
  • user-uploaded Bundle 預設 workflow source 是 user_uploaded_bundle
  • Patient nameidentifier.valuetelecomaddressbirthDate 仍然會 block live checks。
  • sandbox base URL 未 allowlist 時,所有 execution rows 都 policy blocked,HTTP client 不被呼叫。
  • sandbox auth mode 是 none 時,所有 execution rows 都 policy blocked,HTTP client 不被呼叫。
  • non-PHI preflight 未通過時,所有 execution rows 都 policy blocked,HTTP client 不被呼叫。
  • CapabilityStatement 宣告 read / search-type 時,對應 future policy row 可以 policy allowed,但 endpointCalled=false
  • CapabilityStatement 未宣告 interaction 時,對應 future policy row policy blocked。
  • create / update / delete / Bundle submit 永遠 policy blocked。
  • 既有 sandbox /metadata preflight 仍然只呼叫 /metadata,不呼叫 Patient / Observation / DiagnosticReport endpoint。

目前測試結果:

Tests run: 114, Failures: 0, Errors: 0, Skipped: 0

https://ithelp.ithome.com.tw/upload/images/20260829/20177913xdOVLuD0Xq.png

Day 28 完成後的邊界

完成後,專案的定位變成:

pre-exchange quality gate
   ├─ FHIR / TW Core validation
   ├─ partner contract rules
   ├─ contract lifecycle / compatibility
   ├─ unit normalization evidence
   ├─ terminology server evidence
   ├─ metadata preflight
   ├─ sandbox readiness evidence
   │    ├─ non-PHI workflow evidence
   │    ├─ CapabilityStatement interaction declarations
   │    ├─ SMART/OAuth token flow evidence
   │    └─ live read/search policy readiness evidence
   ├─ formal PHI masking / privacy evidence
   └─ request-scoped AuditEvent / Provenance preview

但它不是:

  • production exchange platform。
  • full SMART/OAuth client。
  • SMART launch app。
  • authorization-code redirect UI。
  • refresh token manager。
  • live resource read/search executor。
  • Bundle submitter。
  • persistent audit log。
  • external FHIR AuditEvent / Provenance writer。
  • database-backed validation history。
  • PHI repository。
  • production de-identification / pseudonymization engine。
  • retention deletion workflow。

下一步

預計從 Day 28 的 policy-only live read/search evidence 往下做:

  • allowlisted live Patient / Observation / DiagnosticReport read evidence。
  • allowlisted live Patient / Observation / DiagnosticReport search-type evidence。
  • request-scoped response summary / status evidence。
  • raw server response masking / non-retention evidence。
  • 保持 create、update、delete、Bundle submit blocked。
  • 保持不做 production SMART launch、refresh token management、database-backed history、persistent audit log。

Repository:twcore-data-quality-gate


上一篇
Day27 - SMART/OAuth Sandbox Token Flow Evidence
系列文
醫療資料通過標準驗證,就真的能交換嗎?——30 天打造 TW Core 資料品質閘門28
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言