{
  "openapi": "3.0.3",
  "info": {
    "title": "ICU Care 傳輸 API（扁平記錄 JSON）",
    "version": "0.1.0",
    "description": "越南兒童醫院 ICU Phase 1 前後端之間的傳輸介面。**不是 FHIR**：傳的是扁平記錄 JSON——一列一筆、沒有巢狀、小寫 `resourceType`、引用用 `xxxId`、代碼走值域表（樣子就像 fhirfox 教材裡「醫院匯出的來源資料」）。FHIR 留給對外交換；每個記錄型別與值域都附 FHIR 對應，日後用 fhirfox 的規則表就能轉。\n\n### 六條格式規則\n1. 一列一筆，全部扁平：欄位只能是純量或純量陣列；一對多拆成另一種記錄用 `xxxId` 回指。\n2. `resourceType` 必有、小寫駝峰。\n3. 引用只用 id（字串，伺服器發）。\n4. 代碼走值域表（`GET /value-sets/{name}`）；標「開放」者允許自訂文字。\n5. 時間一律 ISO 8601 含時區（`2026-08-31T08:00:00+07:00`）；日期 `YYYY-MM-DD`。\n6. 缺值回 `null`，不省略欄位；不補 0。\n\n### 請求與回應送哪些欄位\n每個欄位的 `x-source`：**M** 使用者輸入、**P** 前次帶入（請求要送）；**H** HIS 鏡像、**C** 系統計算（只在回應，請求送了也忽略）。同一個 schema 同時描述請求與回應：請求只需要 M／P 的必填欄。`actorId`／`authorId` 永遠由 token 決定。\n\n### 外殼\n`{ error, status, message, data }`。HTTP 狀態碼與 `status` 一致，業務拒絕用 4xx。清單回 `data: { total, list[] }`；`GET /patients/{id}/bundle` 回 `data: { records[] }`（混合型別陣列）。母記錄可多帶子記錄陣列（鍵名＝子型別複數，例 `labResults`）。\n\n### 共同義務（H12）\n寫入帶 `Idempotency-Key`、`If-Match`；每次寫入落一列 `auditEvent`；所有寫入（草稿除外）要先 `POST /assignments/confirm`。錯誤碼 G1–G18 見 H12 §6.2。\n\n### 來源\n`api/model.mjs` 是唯一來源；本文件、JSON Schema、值域 CSV、欄位表都由它產生。完整規則見 `docs/10_傳輸格式_API_JSON.md`。展示專用、API 不收的原型 action：scenario、retrySave、reset、clockAdvance。",
    "contact": {
      "name": "ICU Phase 1 專案"
    },
    "license": {
      "name": "院內文件，未對外授權"
    }
  },
  "externalDocs": {
    "description": "10｜傳輸格式：扁平記錄 JSON（規則、欄位表、端點表、值域）",
    "url": "../10-transport-json.html"
  },
  "servers": [
    {
      "url": "https://{host}/api/v1/icu",
      "description": "ICU Care 後端",
      "variables": {
        "host": {
          "default": "emr.icu.local"
        }
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "系統"
    },
    {
      "name": "人員與照護名單"
    },
    {
      "name": "病人與就醫"
    },
    {
      "name": "醫囑"
    },
    {
      "name": "執行"
    },
    {
      "name": "量測"
    },
    {
      "name": "檢驗檢查"
    },
    {
      "name": "病歷"
    },
    {
      "name": "目標、溝通、照會"
    },
    {
      "name": "手術與交接"
    },
    {
      "name": "工作與交班"
    },
    {
      "name": "目錄與常用"
    },
    {
      "name": "設定與稽核"
    }
  ],
  "paths": {
    "/capabilities": {
      "get": {
        "tags": [
          "系統"
        ],
        "summary": "伺服器支援的記錄型別、端點與錯誤碼；前端據此決定按鈕要不要出現",
        "description": "伺服器支援的記錄型別、端點與錯誤碼；前端據此決定按鈕要不要出現\n\n角色：全",
        "operationId": "getCapabilities",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；data 為 capabilities",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Capabilities"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/batch": {
      "post": {
        "tags": [
          "系統"
        ],
        "summary": "一個交易寫多筆",
        "description": "一個交易寫多筆（全成功或全退回）\n\n角色：全",
        "operationId": "postBatch",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 batch",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/BatchResponse"
                    }
                  }
                },
                "examples": {
                  "17_batch_transaction": {
                    "summary": "一個交易寫多筆：新增追蹤工作＋簽署醫囑；全成功或全退回",
                    "value": {
                      "error": false,
                      "status": 200,
                      "message": "OK",
                      "data": {
                        "results": [
                          {
                            "status": 201,
                            "record": {
                              "resourceType": "task",
                              "id": "T200",
                              "patientId": "A",
                              "title": "明早複查 Hb",
                              "sourceId": "manual",
                              "ownerId": "D001",
                              "status": "open",
                              "evidence": null,
                              "createdAt": "2026-08-31T12:10:00+07:00"
                            }
                          },
                          {
                            "status": 200,
                            "record": {
                              "resourceType": "order",
                              "id": "M132",
                              "patientId": "A",
                              "encounterId": "ENC-A",
                              "version": 1,
                              "kind": "medication",
                              "category": "medication",
                              "name": "Vinrolac 30 mg（Ketorolac 30 mg/2 mL）",
                              "catalogKey": "medication:43636",
                              "catalogVersion": "20260831-b1",
                              "fromSetId": null,
                              "batchId": "BATCH130",
                              "quantity": 30,
                              "unit": "mg",
                              "dose": "30 mg",
                              "routeKey": "route:996316",
                              "routeText": "Tiêm tĩnh mạch（IV）",
                              "routeMismatch": false,
                              "dosingMode": "prn",
                              "frequency": "PRN（需要時）",
                              "days": null,
                              "rate": null,
                              "concentration": null,
                              "prnIndication": "疼痛評分 ≥ 4",
                              "prnMinInterval": "6 小時",
                              "prnMaxPerDay": 4,
                              "start": "2026-08-31T09:00:00+07:00",
                              "end": null,
                              "orderedAt": "2026-08-31T08:41:00+07:00",
                              "authorId": "D001",
                              "clinicalStatus": "draft",
                              "localStatus": "signed",
                              "hisStatus": "notSent",
                              "signedAt": "2026-08-31T12:10:00+07:00",
                              "signatureExempt": false,
                              "occurrenceId": "M132-V1-D1",
                              "progressNoteId": "DOC101",
                              "consultSourceId": null,
                              "clinicalInfo": null,
                              "stopAt": null,
                              "stopReason": null,
                              "stopById": null,
                              "cancelAt": null,
                              "cancelReason": null,
                              "cancelById": null,
                              "source": null
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "G5 請先確認本班照護名單；請先確認本班照護名單（任一項被 guard 擋下 → 整個交易退回，results 列出每項的 status／message）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchRequest"
              },
              "examples": {
                "17_batch_transaction": {
                  "summary": "一個交易寫多筆：新增追蹤工作＋簽署醫囑；全成功或全退回",
                  "value": {
                    "items": [
                      {
                        "op": "create",
                        "endpoint": "POST /tasks",
                        "record": {
                          "resourceType": "task",
                          "patientId": "A",
                          "title": "明早複查 Hb",
                          "sourceId": "manual",
                          "status": "open"
                        }
                      },
                      {
                        "op": "action",
                        "endpoint": "POST /orders/M132/sign",
                        "record": {
                          "progressNoteId": "DOC101"
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/me": {
      "get": {
        "tags": [
          "人員與照護名單"
        ],
        "summary": "我是誰：人＋類別＋科別＋班別",
        "description": "我是誰：人＋類別＋科別＋班別\n\n角色：全",
        "operationId": "getMe",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；data 為 practitioner",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/practitioner"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/staff": {
      "get": {
        "tags": [
          "人員與照護名單"
        ],
        "summary": "找人員",
        "description": "找人員（指定接班者、照會對象）\n\n角色：全",
        "operationId": "getStaff",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "role",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "department",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "預設 20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 practitioner[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/practitioner"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/staff/{id}": {
      "get": {
        "tags": [
          "人員與照護名單"
        ],
        "summary": "/staff/{id}",
        "description": "角色：全",
        "operationId": "getStaffId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 practitioner",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/practitioner"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "人員與照護名單"
        ],
        "summary": "維護人員姓名／科別／班別",
        "description": "維護人員姓名／科別／班別\n\n原型 action：`personSave`\n\n角色：管",
        "operationId": "putStaffId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 practitioner",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/practitioner"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：管",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "personSave"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/practitioner"
              }
            }
          }
        }
      }
    },
    "/assignments": {
      "get": {
        "tags": [
          "人員與照護名單"
        ],
        "summary": "本班分派給我的照護名單",
        "description": "本班分派給我的照護名單\n\n角色：全",
        "operationId": "getAssignments",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；data 為 rosterConfirmation",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/rosterConfirmation"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/assignments/confirm": {
      "post": {
        "tags": [
          "人員與照護名單"
        ],
        "summary": "確認本班照護名單——所有寫入的前置閘",
        "description": "確認本班照護名單——所有寫入的前置閘\n\n原型 action：`confirmRoster`\n\n角色：全",
        "operationId": "postAssignmentsConfirm",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 rosterConfirmation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/rosterConfirmation"
                    }
                  }
                },
                "examples": {
                  "01_confirm_roster": {
                    "summary": "確認本班照護名單（所有寫入的前置閘）",
                    "value": {
                      "error": false,
                      "status": 200,
                      "message": "OK",
                      "data": {
                        "resourceType": "rosterConfirmation",
                        "id": "RC-D001-20260831",
                        "practitionerId": "D001",
                        "shift": "D1",
                        "patientIds": [
                          "A",
                          "B",
                          "D",
                          "E",
                          "G",
                          "I"
                        ],
                        "at": "2026-08-31T07:04:12+07:00",
                        "source": "示範院方預先分派"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單（未確認前的任何寫入（草稿除外））",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "confirmRoster"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "無 body（空物件）"
              },
              "examples": {
                "01_confirm_roster": {
                  "summary": "確認本班照護名單（所有寫入的前置閘）",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/care-team": {
      "get": {
        "tags": [
          "人員與照護名單"
        ],
        "summary": "該病人的照護關係",
        "description": "該病人的照護關係\n\n角色：全",
        "operationId": "getPatientsIdCareTeam",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 careRelationship[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/careRelationship"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "人員與照護名單"
        ],
        "summary": "新增／停用照護關係；指定新主治會自動結束舊主治",
        "description": "新增／停用照護關係；指定新主治會自動結束舊主治\n\n原型 action：`relationshipSave`\n\n角色：管",
        "operationId": "postPatientsIdCareTeam",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 careRelationship[]",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/careRelationship"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：管",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "relationshipSave"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/careRelationship"
              }
            }
          }
        }
      }
    },
    "/worklist": {
      "get": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "今日工作儀表板清單",
        "description": "今日工作儀表板清單\n\n角色：全",
        "operationId": "getWorklist",
        "parameters": [
          {
            "name": "ward",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "預設 20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 patient[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/patient"
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "02_worklist": {
                    "summary": "今日工作儀表板清單",
                    "value": {
                      "error": false,
                      "status": 200,
                      "message": "OK",
                      "data": {
                        "total": 2,
                        "list": [
                          {
                            "resourceType": "patient",
                            "id": "A",
                            "identifier": "DEMO-A",
                            "visitNo": "O26083000101",
                            "name": "虛構病人 A",
                            "gender": "male",
                            "birthDate": "2019-04-12",
                            "ward": "201",
                            "bed": "201A",
                            "department": "ICU",
                            "admitted": "2026-08-30",
                            "admittedAt": "2026-08-30T14:20:00+07:00",
                            "dischargedAt": null,
                            "attendingId": "D001",
                            "attendingName": "示範主治醫師・陳",
                            "problem": "術後照護（示意）",
                            "flags": [
                              "ALG",
                              "LINE"
                            ],
                            "allergyStatus": "recorded",
                            "allergySummary": "Penicillin 類抗生素（蕁麻疹與血管性水腫）",
                            "surgeryDate": "2026-08-30",
                            "surgeryProcedure": null,
                            "surgeryStart": null,
                            "surgeryEnd": null,
                            "surgerySurgeon": null,
                            "surgeryAnesthesia": null,
                            "surgeryIcuArrival": null,
                            "surgeryNote": null,
                            "encounterId": "ENC-A",
                            "episodeId": "ICU-A",
                            "stayDays": 1,
                            "admittedById": null,
                            "registeredAt": null,
                            "source": "示範資料，非院方主檔"
                          },
                          {
                            "resourceType": "patient",
                            "id": "B",
                            "identifier": "DEMO-B",
                            "visitNo": "O26082800112",
                            "name": "虛構病人 B",
                            "gender": "female",
                            "birthDate": "2021-11-03",
                            "ward": "201",
                            "bed": "201B",
                            "department": "ICU",
                            "admitted": "2026-08-28",
                            "admittedAt": null,
                            "dischargedAt": null,
                            "attendingId": "D001",
                            "attendingName": "示範主治醫師・陳",
                            "problem": "呼吸支持追蹤（示意）",
                            "flags": [
                              "ISO",
                              "VENT"
                            ],
                            "allergyStatus": "unknown",
                            "allergySummary": "來源未記錄，不能視為無過敏",
                            "surgeryDate": null,
                            "surgeryProcedure": null,
                            "surgeryStart": null,
                            "surgeryEnd": null,
                            "surgerySurgeon": null,
                            "surgeryAnesthesia": null,
                            "surgeryIcuArrival": null,
                            "surgeryNote": null,
                            "encounterId": "ENC-B",
                            "episodeId": "ICU-B",
                            "stayDays": 3,
                            "admittedById": null,
                            "registeredAt": null,
                            "source": "示範資料，非院方主檔"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients": {
      "get": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "按病歷號／姓名／床號找病人",
        "description": "按病歷號／姓名／床號找病人（手圈掃碼、病歷查詢）\n\n角色：全",
        "operationId": "getPatients",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "預設 20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 patient[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/patient"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "接診登錄",
        "description": "接診登錄（示範替代；正式由 HIS 推入）\n\n原型 action：`admitPatient`\n\n角色：醫護管",
        "operationId": "postPatients",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 patient",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/patient"
                    }
                  }
                },
                "examples": {
                  "14_admit_patient": {
                    "summary": "示範接診登錄：patient ＋ allergies[] ＋ conditions[]（正式環境由 HIS 推入，此端點只在示範／無 HIS 時用）",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "resourceType": "patient",
                        "id": "P180",
                        "identifier": "DEMO-K",
                        "visitNo": "O26083100180",
                        "name": "虛構病人 K",
                        "gender": "female",
                        "birthDate": "2020-02-14",
                        "ward": "203",
                        "bed": "203E",
                        "department": "ICU",
                        "admitted": "2026-08-31",
                        "admittedAt": "2026-08-31T10:15:00+07:00",
                        "dischargedAt": null,
                        "attendingId": "D001",
                        "attendingName": "示範主治醫師・陳",
                        "nurseId": null,
                        "problem": "急性腎損傷（示意）",
                        "flags": [
                          "RESTRICT"
                        ],
                        "allergyStatus": "recorded",
                        "allergySummary": "Penicillin 類抗生素（蕁麻疹）",
                        "surgeryDate": null,
                        "surgeryProcedure": null,
                        "surgeryStart": null,
                        "surgeryEnd": null,
                        "surgerySurgeon": null,
                        "surgeryAnesthesia": null,
                        "surgeryIcuArrival": null,
                        "surgeryNote": null,
                        "encounterId": "ENC-P180",
                        "episodeId": "ICU-P180",
                        "stayDays": 0,
                        "admittedById": "D001",
                        "registeredAt": "2026-08-31T10:18:00+07:00",
                        "source": "接診登錄（示範），非 HIS 主檔",
                        "allergies": [
                          {
                            "resourceType": "allergy",
                            "id": "ALG181",
                            "patientId": "P180",
                            "substanceKind": "class",
                            "substanceText": "Penicillin 類抗生素",
                            "ingredient": null,
                            "drugClass": "penicillin",
                            "type": "allergy",
                            "category": "medication",
                            "criticality": "high",
                            "clinicalStatus": "active",
                            "verificationStatus": "confirmed",
                            "manifestation": "蕁麻疹",
                            "severity": "moderate",
                            "recordedDate": "2026-08-31",
                            "recorderId": "D001",
                            "source": "接診登錄（示範），非 HIS 過敏主檔"
                          }
                        ],
                        "conditions": [
                          {
                            "resourceType": "condition",
                            "id": "DX182",
                            "patientId": "P180",
                            "encounterId": "ENC-P180",
                            "icdKey": "icd:12971",
                            "icdCode": "E87.6",
                            "icdText": "Hạ kali máu",
                            "icdEnglish": "Hypokalaemia",
                            "category": "encounter-diagnosis",
                            "stage": "admission",
                            "rank": "primary",
                            "clinicalStatus": "active",
                            "verificationStatus": "confirmed",
                            "onset": "2026-08-31",
                            "recordedDate": "2026-08-31",
                            "recorderId": "D001",
                            "active": true,
                            "source": "接診登錄（示範），非 HIS 診斷主檔"
                          }
                        ],
                        "careRelationships": [
                          {
                            "resourceType": "careRelationship",
                            "id": "REL183",
                            "patientId": "P180",
                            "practitionerId": "D001",
                            "role": "attending",
                            "active": true,
                            "startedAt": "2026-08-31T10:18:00+07:00",
                            "endedAt": null,
                            "byId": "D001",
                            "via": "admit"
                          },
                          {
                            "resourceType": "careRelationship",
                            "id": "REL184",
                            "patientId": "P180",
                            "practitionerId": "N001",
                            "role": "nurse",
                            "active": true,
                            "startedAt": "2026-08-31T10:18:00+07:00",
                            "endedAt": null,
                            "byId": "D001",
                            "via": "admit"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長；G9 時間格式不正確或不在有效區間；選擇「有已知過敏」時至少要填一筆過敏原；若是問過但沒有，請選「無已知過敏」（allergyStatus=recorded 但 allergies 為空）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫護管",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）；病歷號已存在：DEMO-K（identifier 重複）；此病床仍有住院病人：203E（床位未出院）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "admitPatient"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/patient"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "allergies": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/allergy"
                        }
                      },
                      "conditions": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/condition"
                        }
                      }
                    }
                  }
                ]
              },
              "examples": {
                "14_admit_patient": {
                  "summary": "示範接診登錄：patient ＋ allergies[] ＋ conditions[]（正式環境由 HIS 推入，此端點只在示範／無 HIS 時用）",
                  "value": {
                    "resourceType": "patient",
                    "identifier": "DEMO-K",
                    "name": "虛構病人 K",
                    "gender": "female",
                    "birthDate": "2020-02-14",
                    "ward": "203",
                    "bed": "203E",
                    "admitted": "2026-08-31",
                    "admittedAt": "2026-08-31T10:15:00+07:00",
                    "problem": "急性腎損傷（示意）",
                    "flags": [
                      "RESTRICT"
                    ],
                    "allergyStatus": "recorded",
                    "surgeryProcedure": null,
                    "surgeryStart": null,
                    "surgeryEnd": null,
                    "surgerySurgeon": null,
                    "surgeryAnesthesia": null,
                    "surgeryIcuArrival": null,
                    "surgeryNote": null,
                    "attendingId": "D001",
                    "nurseId": "N001",
                    "allergies": [
                      {
                        "resourceType": "allergy",
                        "substanceKind": "class",
                        "substanceText": "Penicillin 類抗生素",
                        "ingredient": null,
                        "drugClass": "penicillin",
                        "type": "allergy",
                        "category": "medication",
                        "criticality": "high",
                        "clinicalStatus": "active",
                        "verificationStatus": "confirmed",
                        "manifestation": "蕁麻疹",
                        "severity": "moderate"
                      }
                    ],
                    "conditions": [
                      {
                        "resourceType": "condition",
                        "icdKey": "icd:12971",
                        "category": "encounter-diagnosis",
                        "stage": "admission",
                        "rank": "primary",
                        "clinicalStatus": "active",
                        "verificationStatus": "confirmed",
                        "onset": "2026-08-31"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}": {
      "get": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "/patients/{id}",
        "description": "角色：全",
        "operationId": "getPatientsId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 patient",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/patient"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/bundle": {
      "get": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "一次下載這位病人的全部記錄",
        "description": "一次下載這位病人的全部記錄（混合型別陣列，fhirfox 式）\n\n角色：全",
        "operationId": "getPatientsIdBundle",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "types",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 records[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Records"
                    }
                  }
                },
                "examples": {
                  "16_patient_bundle": {
                    "summary": "一次下載一位病人的全部記錄：混合型別陣列（fhirfox 來源 JSON 的樣子），前端據此水合整份 state",
                    "value": {
                      "error": false,
                      "status": 200,
                      "message": "OK",
                      "data": {
                        "patientId": "A",
                        "generatedAt": "2026-08-31T12:00:00+07:00",
                        "revision": 418,
                        "records": [
                          {
                            "resourceType": "patient",
                            "id": "A",
                            "identifier": "DEMO-A",
                            "visitNo": "O26083000101",
                            "name": "虛構病人 A",
                            "gender": "male",
                            "birthDate": "2019-04-12",
                            "ward": "201",
                            "bed": "201A",
                            "department": "ICU",
                            "admitted": "2026-08-30",
                            "admittedAt": "2026-08-30T14:20:00+07:00",
                            "dischargedAt": null,
                            "attendingId": "D001",
                            "attendingName": "示範主治醫師・陳",
                            "problem": "術後照護（示意）",
                            "flags": [
                              "ALG",
                              "LINE"
                            ],
                            "allergyStatus": "recorded",
                            "allergySummary": "Penicillin 類抗生素（蕁麻疹與血管性水腫）",
                            "surgeryDate": "2026-08-30",
                            "surgeryProcedure": null,
                            "surgeryStart": null,
                            "surgeryEnd": null,
                            "surgerySurgeon": null,
                            "surgeryAnesthesia": null,
                            "surgeryIcuArrival": null,
                            "surgeryNote": null,
                            "encounterId": "ENC-A",
                            "episodeId": "ICU-A",
                            "stayDays": 1,
                            "admittedById": null,
                            "registeredAt": null,
                            "source": "示範資料，非院方主檔"
                          },
                          {
                            "resourceType": "encounter",
                            "id": "ENC-A",
                            "patientId": "A",
                            "episodeId": "ICU-A",
                            "status": "in-progress",
                            "encounterNumber": "O26083000101",
                            "admittedAt": "2026-08-30T14:20:00+07:00",
                            "dischargedAt": null,
                            "department": "ICU",
                            "ward": "201",
                            "bed": "201A",
                            "archiveStatus": "open"
                          },
                          {
                            "resourceType": "practitioner",
                            "id": "D001",
                            "name": "示範主治醫師・陳",
                            "role": "doctor",
                            "department": "心臟外科",
                            "specialty": null,
                            "consultationOnly": false,
                            "shift": "D1",
                            "shiftStart": "07:00",
                            "shiftEnd": "19:00",
                            "active": true
                          },
                          {
                            "resourceType": "practitioner",
                            "id": "N001",
                            "name": "示範護理師・日班",
                            "role": "nurse",
                            "department": "加護病房",
                            "specialty": null,
                            "consultationOnly": false,
                            "shift": "N1",
                            "shiftStart": "07:30",
                            "shiftEnd": "15:30",
                            "active": true
                          },
                          {
                            "resourceType": "careRelationship",
                            "id": "REL-A-1",
                            "patientId": "A",
                            "practitionerId": "D001",
                            "role": "attending",
                            "active": true,
                            "startedAt": "2026-08-30T14:20:00+07:00",
                            "endedAt": null,
                            "byId": null,
                            "via": "seed"
                          },
                          {
                            "resourceType": "careRelationship",
                            "id": "REL-A-2",
                            "patientId": "A",
                            "practitionerId": "N001",
                            "role": "nurse",
                            "active": true,
                            "startedAt": "2026-08-30T14:20:00+07:00",
                            "endedAt": null,
                            "byId": null,
                            "via": "seed"
                          },
                          {
                            "resourceType": "condition",
                            "id": "DX-A",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "icdKey": "icd:3793",
                            "icdCode": "I71.0",
                            "icdText": "Tách thành động mạch chủ [bất kỳ đoạn nào]",
                            "icdEnglish": "Dissection of aorta [any part]",
                            "category": "encounter-diagnosis",
                            "stage": "admission",
                            "rank": "primary",
                            "clinicalStatus": "active",
                            "verificationStatus": "confirmed",
                            "onset": "2026-08-30",
                            "recordedDate": "2026-08-30",
                            "recorderId": "D001",
                            "active": true,
                            "source": "示範資料，非院方診斷主檔"
                          },
                          {
                            "resourceType": "allergy",
                            "id": "ALG-A",
                            "patientId": "A",
                            "substanceKind": "class",
                            "substanceText": "Penicillin 類抗生素",
                            "ingredient": null,
                            "drugClass": "penicillin",
                            "type": "allergy",
                            "category": "medication",
                            "criticality": "high",
                            "clinicalStatus": "active",
                            "verificationStatus": "confirmed",
                            "manifestation": "蕁麻疹與血管性水腫",
                            "severity": "severe",
                            "recordedDate": "2026-08-30",
                            "recorderId": "D001",
                            "source": "示範資料，非院方過敏主檔"
                          },
                          {
                            "resourceType": "order",
                            "id": "M131",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "version": 1,
                            "kind": "medication",
                            "category": "medication",
                            "name": "Ibufar 200（Ibuprofen 200 mg）",
                            "catalogKey": "medication:44978",
                            "catalogVersion": "20260831-b1",
                            "fromSetId": null,
                            "batchId": "BATCH130",
                            "quantity": 200,
                            "unit": "mg",
                            "dose": "200 mg",
                            "routeKey": "route:913",
                            "routeText": "Uống（口服）",
                            "routeMismatch": false,
                            "dosingMode": "scheduled",
                            "frequency": "BID（每日 2 次）",
                            "days": 5,
                            "rate": null,
                            "concentration": null,
                            "prnIndication": null,
                            "prnMinInterval": null,
                            "prnMaxPerDay": null,
                            "start": "2026-08-31T09:00:00+07:00",
                            "end": "2026-09-05T09:00:00+07:00",
                            "orderedAt": "2026-08-31T08:41:00+07:00",
                            "authorId": "D001",
                            "clinicalStatus": "active",
                            "localStatus": "signed",
                            "hisStatus": "accepted",
                            "signedAt": "2026-08-31T08:45:30+07:00",
                            "signatureExempt": false,
                            "occurrenceId": "M131-V1-D1",
                            "progressNoteId": "DOC101",
                            "consultSourceId": null,
                            "clinicalInfo": "術後疼痛控制",
                            "stopAt": null,
                            "stopReason": null,
                            "stopById": null,
                            "cancelAt": null,
                            "cancelReason": null,
                            "cancelById": null,
                            "source": null
                          },
                          {
                            "resourceType": "order",
                            "id": "L133",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "version": 1,
                            "kind": "service",
                            "category": "labimaging",
                            "name": "Tổng phân tích tế bào máu ngoại vi（CBC）",
                            "catalogKey": "service:1020",
                            "catalogVersion": "20260831-b1",
                            "fromSetId": null,
                            "batchId": "BATCH130",
                            "quantity": null,
                            "unit": null,
                            "dose": "1 lần",
                            "routeKey": null,
                            "routeText": "檢驗",
                            "routeMismatch": false,
                            "dosingMode": "once",
                            "frequency": "本次",
                            "days": null,
                            "rate": null,
                            "concentration": null,
                            "prnIndication": null,
                            "prnMinInterval": null,
                            "prnMaxPerDay": null,
                            "start": "2026-08-31T09:00:00+07:00",
                            "end": null,
                            "orderedAt": "2026-08-31T08:41:00+07:00",
                            "authorId": "D001",
                            "clinicalStatus": "active",
                            "localStatus": "signed",
                            "hisStatus": "accepted",
                            "signedAt": "2026-08-31T08:41:00+07:00",
                            "signatureExempt": true,
                            "occurrenceId": "L133-V1-D1",
                            "progressNoteId": "DOC101",
                            "consultSourceId": null,
                            "clinicalInfo": null,
                            "stopAt": null,
                            "stopReason": null,
                            "stopById": null,
                            "cancelAt": null,
                            "cancelReason": null,
                            "cancelById": null,
                            "source": null
                          },
                          {
                            "resourceType": "execution",
                            "id": "E140",
                            "patientId": "A",
                            "orderId": "M131",
                            "orderVersion": 1,
                            "occurrenceId": "M131-V1-D1",
                            "status": "done",
                            "at": "2026-08-31T09:05:00+07:00",
                            "recordedAt": "2026-08-31T09:06:12+07:00",
                            "actorId": "N001",
                            "actualDose": "200 mg",
                            "actualRoute": "Uống（口服）",
                            "reason": null,
                            "checkPatient": true,
                            "checkDrug": true,
                            "checkDose": true,
                            "checkRoute": true,
                            "checkTime": true,
                            "reviewOutcome": null,
                            "reviewNote": null,
                            "reviewById": null,
                            "reviewAt": null
                          },
                          {
                            "resourceType": "observation",
                            "id": "O120",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "code": "HR",
                            "display": "心率",
                            "value": 102,
                            "unit": "/min",
                            "at": "2026-08-31T08:00:00+07:00",
                            "recordedAt": "2026-08-31T08:03:10+07:00",
                            "actorId": "N001",
                            "setId": "OS-120",
                            "entry": "manual",
                            "source": "observation"
                          },
                          {
                            "resourceType": "observation",
                            "id": "O122",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "code": "SBP",
                            "display": "收縮壓",
                            "value": 96,
                            "unit": "mmHg",
                            "at": "2026-08-31T08:00:00+07:00",
                            "recordedAt": "2026-08-31T08:03:10+07:00",
                            "actorId": "N001",
                            "setId": "OS-120",
                            "entry": "manual",
                            "source": "observation / observation_component"
                          },
                          {
                            "resourceType": "observation",
                            "id": "O123",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "code": "DBP",
                            "display": "舒張壓",
                            "value": 58,
                            "unit": "mmHg",
                            "at": "2026-08-31T08:00:00+07:00",
                            "recordedAt": "2026-08-31T08:03:10+07:00",
                            "actorId": "N001",
                            "setId": "OS-120",
                            "entry": "manual",
                            "source": "observation / observation_component"
                          },
                          {
                            "resourceType": "report",
                            "id": "R134",
                            "patientId": "A",
                            "orderId": "L133",
                            "kind": "lab",
                            "examType": null,
                            "status": "returned",
                            "version": 1,
                            "text": "CBC 已回報",
                            "at": "2026-08-31T11:20:00+07:00",
                            "collectedAt": "2026-08-31T09:30:00+07:00",
                            "recordedAt": "2026-08-31T11:20:05+07:00",
                            "catalogKey": "service:1020",
                            "source": "HIS ClinicalResultAvailable",
                            "cancelledAt": null,
                            "cancelledById": null
                          },
                          {
                            "resourceType": "labResult",
                            "id": "R134:WBC",
                            "reportId": "R134",
                            "patientId": "A",
                            "code": "WBC",
                            "name": "白血球",
                            "value": "12.4",
                            "unit": "10^9/L",
                            "reference": "4.0 - 10.0",
                            "interpretation": "H",
                            "classification": "abnormal",
                            "at": "2026-08-31T11:20:00+07:00"
                          },
                          {
                            "resourceType": "reportReview",
                            "id": "RV-301",
                            "reportId": "R134",
                            "patientId": "A",
                            "action": "processed",
                            "reportVersion": 1,
                            "actorId": "D001",
                            "at": "2026-08-31T11:42:00+07:00",
                            "note": "WBC 偏高，配合 CRP 追蹤；暫不調整抗生素"
                          },
                          {
                            "resourceType": "task",
                            "id": "T135",
                            "patientId": "A",
                            "title": "追蹤 L133 待回結果",
                            "sourceId": "L133",
                            "ownerId": "D001",
                            "status": "waiting",
                            "evidence": null,
                            "createdAt": "2026-08-31T08:41:00+07:00"
                          },
                          {
                            "resourceType": "note",
                            "id": "DOC101",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "noteType": "admission",
                            "format": "sections",
                            "kind": "住院病歷紀錄",
                            "text": "CC: 主動脈剝離術後轉入 ICU 監測\n\n…",
                            "S": null,
                            "O": null,
                            "A": null,
                            "P": null,
                            "clinicalAt": "2026-08-30T15:00:00+07:00",
                            "authorId": "D001",
                            "version": 1,
                            "replacesId": null,
                            "reason": null,
                            "status": "signed",
                            "reviewStatus": "pending",
                            "at": "2026-08-30T15:20:00+07:00",
                            "signedAt": "2026-08-30T15:30:00+07:00",
                            "signatureId": "SIG-1",
                            "referenceIds": [
                              "icd:3793"
                            ],
                            "diagnosisKeys": [
                              "icd:3793"
                            ],
                            "addendum": false,
                            "copiedFromId": null,
                            "source": "病歷撰寫工作區"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:CC",
                            "noteId": "DOC101",
                            "code": "CC",
                            "text": "主動脈剝離術後轉入 ICU 監測"
                          },
                          {
                            "resourceType": "signature",
                            "id": "SIG-1",
                            "documentId": "DOC101",
                            "documentType": "note",
                            "version": 1,
                            "actorId": "D001",
                            "at": "2026-08-30T15:30:00+07:00",
                            "method": "展示身分確認（非正式電子簽章）",
                            "image": "brand/signature-demo.svg"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/discharge": {
      "post": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "登記出院",
        "description": "登記出院（需出院病摘已核定）\n\n原型 action：`dischargePatient`\n\n角色：醫",
        "operationId": "postPatientsIdDischarge",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 patient",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/patient"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "dischargePatient"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/archive": {
      "post": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "病歷封存",
        "description": "病歷封存（必要文件全部核定、無暫存）\n\n原型 action：`archiveComplete`\n\n角色：醫",
        "operationId": "postPatientsIdArchive",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 archive",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/archive"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "archiveComplete"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "無 body（空物件）"
              }
            }
          }
        }
      }
    },
    "/encounters/{id}": {
      "get": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "/encounters/{id}",
        "description": "角色：全",
        "operationId": "getEncountersId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 encounter",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/encounter"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/allergies": {
      "get": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "/patients/{id}/allergies",
        "description": "角色：全",
        "operationId": "getPatientsIdAllergies",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 allergy[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/allergy"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/conditions": {
      "get": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "/patients/{id}/conditions",
        "description": "角色：全",
        "operationId": "getPatientsIdConditions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "stage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 condition[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/condition"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "病人與就醫"
        ],
        "summary": "新增診斷",
        "description": "新增診斷（代碼必在 ICD-10 目錄）\n\n原型 action：`diagnosisSave`\n\n角色：醫",
        "operationId": "postPatientsIdConditions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 condition[]",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/condition"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "G10 品項不存在、停用或僅供備查",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "diagnosisSave"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/condition"
                }
              }
            }
          }
        }
      }
    },
    "/orders": {
      "get": {
        "tags": [
          "醫囑"
        ],
        "summary": "跨病人或單一病人的醫囑；全科待簽佇列用 status=draft",
        "description": "跨病人或單一病人的醫囑；全科待簽佇列用 status=draft\n\n角色：全",
        "operationId": "getOrders",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "預設 20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 order[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/order"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "tags": [
          "醫囑"
        ],
        "summary": "含 orderSafety、execution",
        "description": "含 orderSafety、execution\n\n角色：全",
        "operationId": "getOrdersId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 order",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/order"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/order-cart": {
      "get": {
        "tags": [
          "醫囑"
        ],
        "summary": "本次新增清單",
        "description": "本次新增清單（伺服器端草稿）\n\n角色：醫",
        "operationId": "getPatientsIdOrderCart",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 draft",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/draft"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "醫囑"
        ],
        "summary": "整份覆寫待開清單",
        "description": "整份覆寫待開清單\n\n原型 action：`cartAdd／cartAddSet／cartRemove`\n\n角色：醫",
        "operationId": "putPatientsIdOrderCart",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 draft",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/draft"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "G10 品項不存在、停用或僅供備查",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "cartAdd",
          "cartAddSet",
          "cartRemove"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/draft"
              }
            }
          }
        }
      }
    },
    "/patients/{id}/orders:batch": {
      "post": {
        "tags": [
          "醫囑"
        ],
        "summary": "整組確認開立",
        "description": "整組確認開立（購物車 → 醫囑草稿；檢驗檢查直接可執行）\n\n原型 action：`catalogOrder`\n\n角色：醫",
        "operationId": "postPatientsIdOrdersBatch",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 order[]",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/order"
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "04_orders_batch": {
                    "summary": "整組確認開立：一筆排定重複的藥囑＋一筆 PRN 藥囑＋一筆檢驗；用藥安全提示的處理決定一併送",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "total": 3,
                        "list": [
                          {
                            "resourceType": "order",
                            "id": "M131",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "version": 1,
                            "kind": "medication",
                            "category": "medication",
                            "name": "Ibufar 200（Ibuprofen 200 mg）",
                            "catalogKey": "medication:44978",
                            "catalogVersion": "20260831-b1",
                            "fromSetId": null,
                            "batchId": "BATCH130",
                            "quantity": 200,
                            "unit": "mg",
                            "dose": "200 mg",
                            "routeKey": "route:913",
                            "routeText": "Uống（口服）",
                            "routeMismatch": false,
                            "dosingMode": "scheduled",
                            "frequency": "BID（每日 2 次）",
                            "days": 5,
                            "rate": null,
                            "concentration": null,
                            "prnIndication": null,
                            "prnMinInterval": null,
                            "prnMaxPerDay": null,
                            "start": "2026-08-31T09:00:00+07:00",
                            "end": "2026-09-05T09:00:00+07:00",
                            "orderedAt": "2026-08-31T08:41:00+07:00",
                            "authorId": "D001",
                            "clinicalStatus": "draft",
                            "localStatus": "draft",
                            "hisStatus": "notSent",
                            "signedAt": null,
                            "signatureExempt": false,
                            "occurrenceId": "M131-V1-D1",
                            "progressNoteId": "DOC101",
                            "consultSourceId": null,
                            "clinicalInfo": "術後疼痛控制",
                            "stopAt": null,
                            "stopReason": null,
                            "stopById": null,
                            "cancelAt": null,
                            "cancelReason": null,
                            "cancelById": null,
                            "source": null,
                            "orderSafeties": [
                              {
                                "resourceType": "orderSafety",
                                "id": "SAF-1",
                                "orderId": "M131",
                                "pair": "medication:44978|medication:43636",
                                "ruleId": "RX-BLEED-02",
                                "severity": "moderate",
                                "kind": "interaction",
                                "label": "NSAID 併用：出血與腎功能風險",
                                "decision": "handled",
                                "handling": "監測腎功能與出血徵象",
                                "reason": null,
                                "byId": "D001",
                                "at": "2026-08-31T08:41:00+07:00"
                              }
                            ]
                          },
                          {
                            "resourceType": "order",
                            "id": "M132",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "version": 1,
                            "kind": "medication",
                            "category": "medication",
                            "name": "Vinrolac 30 mg（Ketorolac 30 mg/2 mL）",
                            "catalogKey": "medication:43636",
                            "catalogVersion": "20260831-b1",
                            "fromSetId": null,
                            "batchId": "BATCH130",
                            "quantity": 30,
                            "unit": "mg",
                            "dose": "30 mg",
                            "routeKey": "route:996316",
                            "routeText": "Tiêm tĩnh mạch（IV）",
                            "routeMismatch": false,
                            "dosingMode": "prn",
                            "frequency": "PRN（需要時）",
                            "days": null,
                            "rate": null,
                            "concentration": null,
                            "prnIndication": "疼痛評分 ≥ 4",
                            "prnMinInterval": "6 小時",
                            "prnMaxPerDay": 4,
                            "start": "2026-08-31T09:00:00+07:00",
                            "end": null,
                            "orderedAt": "2026-08-31T08:41:00+07:00",
                            "authorId": "D001",
                            "clinicalStatus": "draft",
                            "localStatus": "draft",
                            "hisStatus": "notSent",
                            "signedAt": null,
                            "signatureExempt": false,
                            "occurrenceId": "M132-V1-D1",
                            "progressNoteId": "DOC101",
                            "consultSourceId": null,
                            "clinicalInfo": null,
                            "stopAt": null,
                            "stopReason": null,
                            "stopById": null,
                            "cancelAt": null,
                            "cancelReason": null,
                            "cancelById": null,
                            "source": null
                          },
                          {
                            "resourceType": "order",
                            "id": "L133",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "version": 1,
                            "kind": "service",
                            "category": "labimaging",
                            "name": "Tổng phân tích tế bào máu ngoại vi（CBC）",
                            "catalogKey": "service:1020",
                            "catalogVersion": "20260831-b1",
                            "fromSetId": null,
                            "batchId": "BATCH130",
                            "quantity": null,
                            "unit": null,
                            "dose": "1 lần",
                            "routeKey": null,
                            "routeText": "檢驗",
                            "routeMismatch": false,
                            "dosingMode": "once",
                            "frequency": "本次",
                            "days": null,
                            "rate": null,
                            "concentration": null,
                            "prnIndication": null,
                            "prnMinInterval": null,
                            "prnMaxPerDay": null,
                            "start": "2026-08-31T09:00:00+07:00",
                            "end": null,
                            "orderedAt": "2026-08-31T08:41:00+07:00",
                            "authorId": "D001",
                            "clinicalStatus": "active",
                            "localStatus": "signed",
                            "hisStatus": "accepted",
                            "signedAt": "2026-08-31T08:41:00+07:00",
                            "signatureExempt": true,
                            "occurrenceId": "L133-V1-D1",
                            "progressNoteId": "DOC101",
                            "consultSourceId": null,
                            "clinicalInfo": null,
                            "stopAt": null,
                            "stopReason": null,
                            "stopById": null,
                            "cancelAt": null,
                            "cancelReason": null,
                            "cancelById": null,
                            "source": null
                          }
                        ],
                        "opened": {
                          "reports": [
                            {
                              "resourceType": "report",
                              "id": "R134",
                              "patientId": "A",
                              "orderId": "L133",
                              "kind": "lab",
                              "examType": null,
                              "status": "pending",
                              "version": 1,
                              "text": null,
                              "at": null,
                              "collectedAt": null,
                              "recordedAt": "2026-08-31T08:41:00+07:00",
                              "catalogKey": "service:1020",
                              "source": null,
                              "cancelledAt": null,
                              "cancelledById": null
                            }
                          ],
                          "tasks": [
                            {
                              "resourceType": "task",
                              "id": "T135",
                              "patientId": "A",
                              "title": "追蹤 L133 待回結果",
                              "sourceId": "L133",
                              "ownerId": "D001",
                              "status": "waiting",
                              "evidence": null,
                              "createdAt": "2026-08-31T08:41:00+07:00"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長；G9 時間格式不正確或不在有效區間；請人工選擇有效的給藥途徑（藥囑 routeKey 不是 route 目錄鍵）；「Ketorolac ＋ Ibuprofen」屬於禁忌等級，必須填寫覆寫理由才能建立草稿（severity=high 的提示沒有 decision=override＋reason）；同一項不能同時填療程天數與結束時間；擇一即可（days 與 end 同時有值）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "G10 品項不存在、停用或僅供備查；品項已停用或查不到，請重新選取（catalogKey 不在目錄或 active=false）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "catalogOrder"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/order"
                    }
                  },
                  {
                    "type": "object",
                    "properties": {
                      "orderSafeties": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/orderSafety"
                        }
                      }
                    }
                  }
                ]
              },
              "examples": {
                "04_orders_batch": {
                  "summary": "整組確認開立：一筆排定重複的藥囑＋一筆 PRN 藥囑＋一筆檢驗；用藥安全提示的處理決定一併送",
                  "value": {
                    "list": [
                      {
                        "resourceType": "order",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "catalogKey": "medication:44978",
                        "quantity": 200,
                        "unit": "mg",
                        "routeKey": "route:913",
                        "dosingMode": "scheduled",
                        "frequency": "BID（每日 2 次）",
                        "days": 5,
                        "start": "2026-08-31T09:00:00+07:00",
                        "end": null,
                        "progressNoteId": "DOC101",
                        "consultSourceId": null,
                        "clinicalInfo": "術後疼痛控制",
                        "fromSetId": null
                      },
                      {
                        "resourceType": "order",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "catalogKey": "medication:43636",
                        "quantity": 30,
                        "unit": "mg",
                        "routeKey": "route:996316",
                        "dosingMode": "prn",
                        "prnIndication": "疼痛評分 ≥ 4",
                        "prnMinInterval": "6 小時",
                        "prnMaxPerDay": 4,
                        "start": "2026-08-31T09:00:00+07:00",
                        "end": null,
                        "progressNoteId": "DOC101",
                        "clinicalInfo": null
                      },
                      {
                        "resourceType": "order",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "catalogKey": "service:1020",
                        "dosingMode": "once",
                        "start": "2026-08-31T09:00:00+07:00",
                        "end": null,
                        "progressNoteId": "DOC101"
                      }
                    ],
                    "orderSafeties": [
                      {
                        "resourceType": "orderSafety",
                        "pair": "medication:44978|medication:43636",
                        "decision": "handled",
                        "handling": "監測腎功能與出血徵象",
                        "reason": null
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/orders": {
      "post": {
        "tags": [
          "醫囑"
        ],
        "summary": "單筆手動開立",
        "description": "單筆手動開立（需病程來源）\n\n原型 action：`order`\n\n角色：醫",
        "operationId": "postPatientsIdOrders",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/order"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長；G9 時間格式不正確或不在有效區間",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "order"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/order"
              }
            }
          }
        }
      }
    },
    "/orders/{id}/sign": {
      "post": {
        "tags": [
          "醫囑"
        ],
        "summary": "簽署",
        "description": "簽署（只能簽自己的草稿）\n\n原型 action：`signOrder`\n\n角色：醫",
        "operationId": "postOrdersIdSign",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/order"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "signOrder"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "progressNoteId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/send": {
      "post": {
        "tags": [
          "醫囑"
        ],
        "summary": "送出 HIS",
        "description": "送出 HIS（觸發 L3）\n\n原型 action：`sendOrder`\n\n角色：醫",
        "operationId": "postOrdersIdSend",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/order"
                    }
                  }
                },
                "examples": {
                  "05_order_send": {
                    "summary": "送出已簽署的藥囑到 HIS（觸發 L3 PrescriptionCreated）",
                    "value": {
                      "error": false,
                      "status": 200,
                      "message": "OK",
                      "data": {
                        "resourceType": "order",
                        "id": "M131",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "version": 1,
                        "kind": "medication",
                        "category": "medication",
                        "name": "Ibufar 200（Ibuprofen 200 mg）",
                        "catalogKey": "medication:44978",
                        "catalogVersion": "20260831-b1",
                        "fromSetId": null,
                        "batchId": "BATCH130",
                        "quantity": 200,
                        "unit": "mg",
                        "dose": "200 mg",
                        "routeKey": "route:913",
                        "routeText": "Uống（口服）",
                        "routeMismatch": false,
                        "dosingMode": "scheduled",
                        "frequency": "BID（每日 2 次）",
                        "days": 5,
                        "rate": null,
                        "concentration": null,
                        "prnIndication": null,
                        "prnMinInterval": null,
                        "prnMaxPerDay": null,
                        "start": "2026-08-31T09:00:00+07:00",
                        "end": "2026-09-05T09:00:00+07:00",
                        "orderedAt": "2026-08-31T08:41:00+07:00",
                        "authorId": "D001",
                        "clinicalStatus": "draft",
                        "localStatus": "signed",
                        "hisStatus": "sent",
                        "signedAt": "2026-08-31T08:45:30+07:00",
                        "signatureExempt": false,
                        "occurrenceId": "M131-V1-D1",
                        "progressNoteId": "DOC101",
                        "consultSourceId": null,
                        "clinicalInfo": "術後疼痛控制",
                        "stopAt": null,
                        "stopReason": null,
                        "stopById": null,
                        "cancelAt": null,
                        "cancelReason": null,
                        "cancelById": null,
                        "source": null
                      }
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "G18 HIS 逾時，結果未知；記錄 hisStatus=unknown，不得重送；系統回應未確認；應查明原請求，不重複建立（HIS 逾時：記錄 hisStatus=unknown，前端標示「結果未知・禁止重送」）",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/order"
                    }
                  }
                },
                "examples": {
                  "05_order_send": {
                    "summary": "送出已簽署的藥囑到 HIS（觸發 L3 PrescriptionCreated）",
                    "value": {
                      "error": false,
                      "status": 200,
                      "message": "OK",
                      "data": {
                        "resourceType": "order",
                        "id": "M131",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "version": 1,
                        "kind": "medication",
                        "category": "medication",
                        "name": "Ibufar 200（Ibuprofen 200 mg）",
                        "catalogKey": "medication:44978",
                        "catalogVersion": "20260831-b1",
                        "fromSetId": null,
                        "batchId": "BATCH130",
                        "quantity": 200,
                        "unit": "mg",
                        "dose": "200 mg",
                        "routeKey": "route:913",
                        "routeText": "Uống（口服）",
                        "routeMismatch": false,
                        "dosingMode": "scheduled",
                        "frequency": "BID（每日 2 次）",
                        "days": 5,
                        "rate": null,
                        "concentration": null,
                        "prnIndication": null,
                        "prnMinInterval": null,
                        "prnMaxPerDay": null,
                        "start": "2026-08-31T09:00:00+07:00",
                        "end": "2026-09-05T09:00:00+07:00",
                        "orderedAt": "2026-08-31T08:41:00+07:00",
                        "authorId": "D001",
                        "clinicalStatus": "draft",
                        "localStatus": "signed",
                        "hisStatus": "sent",
                        "signedAt": "2026-08-31T08:45:30+07:00",
                        "signatureExempt": false,
                        "occurrenceId": "M131-V1-D1",
                        "progressNoteId": "DOC101",
                        "consultSourceId": null,
                        "clinicalInfo": "術後疼痛控制",
                        "stopAt": null,
                        "stopReason": null,
                        "stopById": null,
                        "cancelAt": null,
                        "cancelReason": null,
                        "cancelById": null,
                        "source": null
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）；請先簽署（localStatus 仍是 draft）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "sendOrder"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "無 body（空物件）"
              },
              "examples": {
                "05_order_send": {
                  "summary": "送出已簽署的藥囑到 HIS（觸發 L3 PrescriptionCreated）",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/his-response": {
      "post": {
        "tags": [
          "醫囑"
        ],
        "summary": "HIS 回應",
        "description": "HIS 回應（accepted／rejected）；逾時 → unknown\n\n原型 action：`hisResponse`\n\n角色：介接",
        "operationId": "postOrdersIdHisResponse",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/order"
                    }
                  }
                },
                "examples": {
                  "06_order_his_response": {
                    "summary": "HIS 回應（介接入向，由 D1 事件轉接層呼叫，不是前端按鈕）；accepted → 醫囑生效",
                    "value": {
                      "error": false,
                      "status": 200,
                      "message": "OK",
                      "data": {
                        "resourceType": "order",
                        "id": "M131",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "version": 1,
                        "kind": "medication",
                        "category": "medication",
                        "name": "Ibufar 200（Ibuprofen 200 mg）",
                        "catalogKey": "medication:44978",
                        "catalogVersion": "20260831-b1",
                        "fromSetId": null,
                        "batchId": "BATCH130",
                        "quantity": 200,
                        "unit": "mg",
                        "dose": "200 mg",
                        "routeKey": "route:913",
                        "routeText": "Uống（口服）",
                        "routeMismatch": false,
                        "dosingMode": "scheduled",
                        "frequency": "BID（每日 2 次）",
                        "days": 5,
                        "rate": null,
                        "concentration": null,
                        "prnIndication": null,
                        "prnMinInterval": null,
                        "prnMaxPerDay": null,
                        "start": "2026-08-31T09:00:00+07:00",
                        "end": "2026-09-05T09:00:00+07:00",
                        "orderedAt": "2026-08-31T08:41:00+07:00",
                        "authorId": "D001",
                        "clinicalStatus": "active",
                        "localStatus": "signed",
                        "hisStatus": "accepted",
                        "signedAt": "2026-08-31T08:45:30+07:00",
                        "signatureExempt": false,
                        "occurrenceId": "M131-V1-D1",
                        "progressNoteId": "DOC101",
                        "consultSourceId": null,
                        "clinicalInfo": "術後疼痛控制",
                        "stopAt": null,
                        "stopReason": null,
                        "stopById": null,
                        "cancelAt": null,
                        "cancelReason": null,
                        "cancelById": null,
                        "source": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "無效HIS回應（status 不是 accepted／rejected）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：介接",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）；沒有待確認的送出醫囑（hisStatus 不是 sent／unknown）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "hisResponse"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string"
                  }
                }
              },
              "examples": {
                "06_order_his_response": {
                  "summary": "HIS 回應（介接入向，由 D1 事件轉接層呼叫，不是前端按鈕）；accepted → 醫囑生效",
                  "value": {
                    "status": "accepted",
                    "hisReference": "RX-2026-000931"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/stop": {
      "post": {
        "tags": [
          "醫囑"
        ],
        "summary": "停止有效醫囑",
        "description": "停止有效醫囑（不得早於已完成執行）\n\n原型 action：`stopOrder`\n\n角色：醫",
        "operationId": "postOrdersIdStop",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/order"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G9 時間格式不正確或不在有效區間",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "stopOrder"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "stopAt": {
                    "type": "string"
                  },
                  "stopReason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/cancel": {
      "post": {
        "tags": [
          "醫囑"
        ],
        "summary": "取消",
        "description": "取消（有完成執行不能取消；報告已回不能取消）\n\n原型 action：`cancelOrder`\n\n角色：醫",
        "operationId": "postOrdersIdCancel",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/order"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "cancelOrder"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cancelReason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/order-safety/assess": {
      "post": {
        "tags": [
          "醫囑"
        ],
        "summary": "比對待開清單與現行醫囑，回衝突清單與涵蓋率",
        "description": "比對待開清單與現行醫囑，回衝突清單與涵蓋率\n\n角色：醫",
        "operationId": "postOrderSafetyAssess",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 orderSafety[]+coverage",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/orderSafety"
                          }
                        },
                        "coverage": {
                          "$ref": "#/components/schemas/Coverage"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "patientId": {
                    "type": "string"
                  },
                  "catalogKeys": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/executions": {
      "get": {
        "tags": [
          "執行"
        ],
        "summary": "按病人／時間窗查全部劑次",
        "description": "按病人／時間窗查全部劑次（eMAR、交班用）\n\n角色：全",
        "operationId": "getExecutions",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 execution[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/execution"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/executions": {
      "post": {
        "tags": [
          "執行"
        ],
        "summary": "記錄已給藥／延遲／未執行",
        "description": "記錄已給藥／延遲／未執行\n\n原型 action：`execute`\n\n角色：護",
        "operationId": "postOrdersIdExecutions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 execution",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/execution"
                    }
                  }
                },
                "examples": {
                  "07_execution": {
                    "summary": "護理師記錄本次給藥：五對逐項勾選（五個獨立布林）",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "resourceType": "execution",
                        "id": "E140",
                        "patientId": "A",
                        "orderId": "M131",
                        "orderVersion": 1,
                        "occurrenceId": "M131-V1-D1",
                        "status": "done",
                        "at": "2026-08-31T09:05:00+07:00",
                        "recordedAt": "2026-08-31T09:06:12+07:00",
                        "actorId": "N001",
                        "actualDose": "200 mg",
                        "actualRoute": "Uống（口服）",
                        "reason": null,
                        "checkPatient": true,
                        "checkDrug": true,
                        "checkDose": true,
                        "checkRoute": true,
                        "checkTime": true,
                        "reviewOutcome": null,
                        "reviewNote": null,
                        "reviewById": null,
                        "reviewAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G9 時間格式不正確或不在有效區間；G13 需逐項人工確認五對；不能由單次掃碼推定；需逐項人工確認五對；不能由單次掃碼推定（藥囑 done 但五個 check 不全為 true（G13））",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：護；G6 角色限制：此操作僅限醫師／護理師",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）；G11 本劑次已有完成紀錄；不可重複給藥；G14 HIS 尚未接受，不可視為可執行；HIS尚未接受，不可視為可執行（hisStatus ≠ accepted（G14））；本劑次已有完成紀錄；不可重複給藥（同 occurrenceId 已有 done（G11））",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "G12 實際時間不在此醫囑版本有效期間；實際時間不在此醫囑版本有效期間（at < start 或 ≥ end（G12））",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "execute"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/execution"
              },
              "examples": {
                "07_execution": {
                  "summary": "護理師記錄本次給藥：五對逐項勾選（五個獨立布林）",
                  "value": {
                    "resourceType": "execution",
                    "patientId": "A",
                    "orderId": "M131",
                    "status": "done",
                    "at": "2026-08-31T09:05:00+07:00",
                    "actualDose": "200 mg",
                    "actualRoute": "Uống（口服）",
                    "reason": null,
                    "checkPatient": true,
                    "checkDrug": true,
                    "checkDose": true,
                    "checkRoute": true,
                    "checkTime": true
                  }
                }
              }
            }
          }
        }
      }
    },
    "/executions/{id}/review": {
      "post": {
        "tags": [
          "執行"
        ],
        "summary": "核對執行結果",
        "description": "核對執行結果\n\n原型 action：`reviewExecution`\n\n角色：醫",
        "operationId": "postExecutionsIdReview",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 execution",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/execution"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "reviewExecution"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reviewOutcome": {
                    "type": "string"
                  },
                  "reviewNote": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/infusion-checks": {
      "get": {
        "tags": [
          "執行"
        ],
        "summary": "/infusion-checks",
        "description": "角色：全",
        "operationId": "getInfusionChecks",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 infusionCheck[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/infusionCheck"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/infusion-checks": {
      "post": {
        "tags": [
          "執行"
        ],
        "summary": "/orders/{id}/infusion-checks",
        "description": "原型 action：`infusion`\n\n角色：護",
        "operationId": "postOrdersIdInfusionChecks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 infusionCheck",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/infusionCheck"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長；G9 時間格式不正確或不在有效區間",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：護；G6 角色限制：此操作僅限醫師／護理師",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）；G14 HIS 尚未接受，不可視為可執行",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "infusion"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/infusionCheck"
              }
            }
          }
        }
      }
    },
    "/observations": {
      "get": {
        "tags": [
          "量測"
        ],
        "summary": "原始量測；時間窗由前端換算成絕對時間",
        "description": "原始量測；時間窗由前端換算成絕對時間\n\n角色：全",
        "operationId": "getObservations",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "預設 20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 observation[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/observation"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/observations": {
      "post": {
        "tags": [
          "量測"
        ],
        "summary": "一次輸入多個項目",
        "description": "一次輸入多個項目（同時點同交易）；血壓送 SBP＋DBP 兩列\n\n原型 action：`measure／measureSet／measureBP`\n\n角色：護",
        "operationId": "postPatientsIdObservations",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 observation[]",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/observation"
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "03_observations_set": {
                    "summary": "護理師一次輸入四項量測（同時點同交易）；血壓是 SBP＋DBP 兩列共用 setId",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "total": 4,
                        "list": [
                          {
                            "resourceType": "observation",
                            "id": "O120",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "code": "HR",
                            "display": "心率",
                            "value": 102,
                            "unit": "/min",
                            "at": "2026-08-31T08:00:00+07:00",
                            "recordedAt": "2026-08-31T08:03:10+07:00",
                            "actorId": "N001",
                            "setId": "OS-120",
                            "entry": "manual",
                            "source": "observation"
                          },
                          {
                            "resourceType": "observation",
                            "id": "O121",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "code": "TEMP",
                            "display": "體溫",
                            "value": 37.2,
                            "unit": "°C",
                            "at": "2026-08-31T08:00:00+07:00",
                            "recordedAt": "2026-08-31T08:03:10+07:00",
                            "actorId": "N001",
                            "setId": "OS-120",
                            "entry": "manual",
                            "source": "observation"
                          },
                          {
                            "resourceType": "observation",
                            "id": "O122",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "code": "SBP",
                            "display": "收縮壓",
                            "value": 96,
                            "unit": "mmHg",
                            "at": "2026-08-31T08:00:00+07:00",
                            "recordedAt": "2026-08-31T08:03:10+07:00",
                            "actorId": "N001",
                            "setId": "OS-120",
                            "entry": "manual",
                            "source": "observation / observation_component"
                          },
                          {
                            "resourceType": "observation",
                            "id": "O123",
                            "patientId": "A",
                            "encounterId": "ENC-A",
                            "code": "DBP",
                            "display": "舒張壓",
                            "value": 58,
                            "unit": "mmHg",
                            "at": "2026-08-31T08:00:00+07:00",
                            "recordedAt": "2026-08-31T08:03:10+07:00",
                            "actorId": "N001",
                            "setId": "OS-120",
                            "entry": "manual",
                            "source": "observation / observation_component"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長；G9 時間格式不正確或不在有效區間；血壓需同時填寫收縮壓與舒張壓（非負數值）（只送 SBP 沒送 DBP）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：護；G6 角色限制：此操作僅限醫師／護理師；角色限制：此操作僅限護理師（醫師呼叫）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "measure",
          "measureSet",
          "measureBP"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/observation"
                }
              },
              "examples": {
                "03_observations_set": {
                  "summary": "護理師一次輸入四項量測（同時點同交易）；血壓是 SBP＋DBP 兩列共用 setId",
                  "value": {
                    "list": [
                      {
                        "resourceType": "observation",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "code": "HR",
                        "value": 102,
                        "at": "2026-08-31T08:00:00+07:00"
                      },
                      {
                        "resourceType": "observation",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "code": "TEMP",
                        "value": 37.2,
                        "at": "2026-08-31T08:00:00+07:00"
                      },
                      {
                        "resourceType": "observation",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "code": "SBP",
                        "value": 96,
                        "at": "2026-08-31T08:00:00+07:00"
                      },
                      {
                        "resourceType": "observation",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "code": "DBP",
                        "value": 58,
                        "at": "2026-08-31T08:00:00+07:00"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reports": {
      "get": {
        "tags": [
          "檢驗檢查"
        ],
        "summary": "/reports",
        "description": "角色：全",
        "operationId": "getReports",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateBasis",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 report[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/report"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/reports/{id}": {
      "get": {
        "tags": [
          "檢驗檢查"
        ],
        "summary": "含 labResult[]、reportReview[]",
        "description": "含 labResult[]、reportReview[]\n\n角色：全",
        "operationId": "getReportsId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 report",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/report"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/lab-results": {
      "get": {
        "tags": [
          "檢驗檢查"
        ],
        "summary": "逐項數值",
        "description": "逐項數值（矩陣由前端排）\n\n角色：全",
        "operationId": "getLabResults",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateBasis",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "abnormalOnly",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 labResult[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/labResult"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/reports/{id}/reviews": {
      "post": {
        "tags": [
          "檢驗檢查"
        ],
        "summary": "action=seen 任何人；action=processed 限醫師且 note 必填",
        "description": "action=seen 任何人；action=processed 限醫師且 note 必填\n\n原型 action：`readReport／processReport`\n\n角色：全／醫",
        "operationId": "postReportsIdReviews",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 reportReview",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/reportReview"
                    }
                  }
                },
                "examples": {
                  "09_report_review": {
                    "summary": "醫師判讀處理報告（action=processed，note 必填）；記錄的是當時的報告版本",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "resourceType": "reportReview",
                        "id": "RV-301",
                        "reportId": "R134",
                        "patientId": "A",
                        "action": "processed",
                        "reportVersion": 1,
                        "actorId": "D001",
                        "at": "2026-08-31T11:42:00+07:00",
                        "note": "WBC 偏高，配合 CRP 追蹤；暫不調整抗生素"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：全／醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會；角色限制：照會醫師僅可查閱資料與回覆指派照會（非主責醫師送 processed）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）；G17 來源缺漏或報告未回，無法記錄已閱／判讀；來源缺漏或報告未回，不能判讀（report.status ≠ returned（G17））；這個版本你已經記錄過已閱（同人同版本重送 seen）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "readReport",
          "processReport"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/reportReview"
              },
              "examples": {
                "09_report_review": {
                  "summary": "醫師判讀處理報告（action=processed，note 必填）；記錄的是當時的報告版本",
                  "value": {
                    "resourceType": "reportReview",
                    "reportId": "R134",
                    "patientId": "A",
                    "action": "processed",
                    "note": "WBC 偏高，配合 CRP 追蹤；暫不調整抗生素"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reports/{id}/return": {
      "post": {
        "tags": [
          "檢驗檢查"
        ],
        "summary": "HIS 回報結果",
        "description": "HIS 回報結果（D1 事件轉接）\n\n原型 action：`reportReturn`\n\n角色：介接",
        "operationId": "postReportsIdReturn",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/report"
                    }
                  }
                },
                "examples": {
                  "08_report_return": {
                    "summary": "HIS 回報檢驗結果（介接入向）；一列一指標；classification 只依 interpretation 推，不比對參考範圍",
                    "value": {
                      "error": false,
                      "status": 200,
                      "message": "OK",
                      "data": {
                        "resourceType": "report",
                        "id": "R134",
                        "patientId": "A",
                        "orderId": "L133",
                        "kind": "lab",
                        "examType": null,
                        "status": "returned",
                        "version": 1,
                        "text": "CBC 已回報",
                        "at": "2026-08-31T11:20:00+07:00",
                        "collectedAt": "2026-08-31T09:30:00+07:00",
                        "recordedAt": "2026-08-31T11:20:05+07:00",
                        "catalogKey": "service:1020",
                        "source": "HIS ClinicalResultAvailable",
                        "cancelledAt": null,
                        "cancelledById": null,
                        "labResults": [
                          {
                            "resourceType": "labResult",
                            "id": "R134:WBC",
                            "reportId": "R134",
                            "patientId": "A",
                            "code": "WBC",
                            "name": "白血球",
                            "value": "12.4",
                            "unit": "10^9/L",
                            "reference": "4.0 - 10.0",
                            "interpretation": "H",
                            "classification": "abnormal",
                            "at": "2026-08-31T11:20:00+07:00"
                          },
                          {
                            "resourceType": "labResult",
                            "id": "R134:Hb",
                            "reportId": "R134",
                            "patientId": "A",
                            "code": "Hb",
                            "name": "血紅素",
                            "value": "12.1",
                            "unit": "g/dL",
                            "reference": "M: 13.5-17.5, F: 12.0-16.0",
                            "interpretation": "N",
                            "classification": "normal",
                            "at": "2026-08-31T11:20:00+07:00"
                          },
                          {
                            "resourceType": "labResult",
                            "id": "R134:PLT",
                            "reportId": "R134",
                            "patientId": "A",
                            "code": "PLT",
                            "name": "血小板",
                            "value": "210",
                            "unit": "10^9/L",
                            "reference": "150 - 400",
                            "interpretation": null,
                            "classification": "unknown",
                            "at": "2026-08-31T11:20:00+07:00"
                          }
                        ],
                        "reportReviews": []
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：介接",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "reportReturn"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/report"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "labResults": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/labResult"
                        }
                      }
                    }
                  }
                ]
              },
              "examples": {
                "08_report_return": {
                  "summary": "HIS 回報檢驗結果（介接入向）；一列一指標；classification 只依 interpretation 推，不比對參考範圍",
                  "value": {
                    "resourceType": "report",
                    "patientId": "A",
                    "status": "returned",
                    "version": 1,
                    "text": "CBC 已回報",
                    "at": "2026-08-31T11:20:00+07:00",
                    "collectedAt": "2026-08-31T09:30:00+07:00",
                    "labResults": [
                      {
                        "resourceType": "labResult",
                        "patientId": "A",
                        "code": "WBC",
                        "name": "白血球",
                        "value": "12.4",
                        "unit": "10^9/L",
                        "reference": "4.0 - 10.0",
                        "interpretation": "H"
                      },
                      {
                        "resourceType": "labResult",
                        "patientId": "A",
                        "code": "Hb",
                        "name": "血紅素",
                        "value": "12.1",
                        "unit": "g/dL",
                        "reference": "M: 13.5-17.5, F: 12.0-16.0",
                        "interpretation": "N"
                      },
                      {
                        "resourceType": "labResult",
                        "patientId": "A",
                        "code": "PLT",
                        "name": "血小板",
                        "value": "210",
                        "unit": "10^9/L",
                        "reference": "150 - 400",
                        "interpretation": null
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/notes": {
      "get": {
        "tags": [
          "病歷"
        ],
        "summary": "跨病人待簽佇列用 status=draft 或 reviewStatus=pending",
        "description": "跨病人待簽佇列用 status=draft 或 reviewStatus=pending\n\n角色：全",
        "operationId": "getNotes",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "noteType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "reviewStatus",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 note[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/note"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/notes/{id}": {
      "get": {
        "tags": [
          "病歷"
        ],
        "summary": "含 noteSection[]、signature",
        "description": "含 noteSection[]、signature\n\n角色：全",
        "operationId": "getNotesId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 note",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/note"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/notes": {
      "post": {
        "tags": [
          "病歷"
        ],
        "summary": "建立病歷",
        "description": "建立病歷（結構化 noteSection[] 或 SOAP 或全文）；replacesId 有值＝修改既有版本\n\n原型 action：`recordNote／note`\n\n角色：醫／護",
        "operationId": "postPatientsIdNotes",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 note",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/note"
                    }
                  }
                },
                "examples": {
                  "10_note_progress": {
                    "summary": "醫師寫病程 SOAP（format=soap 四欄）並引用今天的量測與醫囑",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "resourceType": "note",
                        "id": "DOC150",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "noteType": "progress",
                        "format": "soap",
                        "kind": "病程記錄",
                        "text": "S：病人表示傷口疼痛 4/10，夜間可入睡。\nO：HR 102、T 37.2、BP 96/58。CBC 待回。\nA：術後第一天，循環穩定，疼痛控制中。\nP：續 Ibuprofen BID；PRN Ketorolac；追蹤 CBC。",
                        "S": "病人表示傷口疼痛 4/10，夜間可入睡。",
                        "O": "HR 102、T 37.2、BP 96/58。CBC 待回。",
                        "A": "術後第一天，循環穩定，疼痛控制中。",
                        "P": "續 Ibuprofen BID；PRN Ketorolac；追蹤 CBC。",
                        "clinicalAt": "2026-08-31T09:30:00+07:00",
                        "authorId": "D001",
                        "version": 1,
                        "replacesId": null,
                        "reason": null,
                        "status": "draft",
                        "reviewStatus": "saved",
                        "at": "2026-08-31T09:34:00+07:00",
                        "signedAt": null,
                        "signatureId": null,
                        "referenceIds": [
                          "O120",
                          "O121",
                          "O122",
                          "O123",
                          "M131",
                          "L133"
                        ],
                        "diagnosisKeys": [],
                        "addendum": false,
                        "copiedFromId": null,
                        "source": "病歷撰寫工作區"
                      }
                    }
                  },
                  "11_note_admission": {
                    "summary": "住院病歷（入院診察）：結構化段落 noteSection[] ＋ diagnosisKeys（第一個為主要診斷）",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "resourceType": "note",
                        "id": "DOC101",
                        "patientId": "A",
                        "encounterId": "ENC-A",
                        "noteType": "admission",
                        "format": "sections",
                        "kind": "住院病歷紀錄",
                        "text": "CC: 主動脈剝離術後轉入 ICU 監測\n\nPI: 08/30 急診胸痛，CT 確診 Stanford A，當日手術。\n\n…",
                        "S": null,
                        "O": null,
                        "A": null,
                        "P": null,
                        "clinicalAt": "2026-08-30T15:00:00+07:00",
                        "authorId": "D001",
                        "version": 1,
                        "replacesId": null,
                        "reason": null,
                        "status": "draft",
                        "reviewStatus": "saved",
                        "at": "2026-08-30T15:20:00+07:00",
                        "signedAt": null,
                        "signatureId": null,
                        "referenceIds": [
                          "icd:3793"
                        ],
                        "diagnosisKeys": [
                          "icd:3793"
                        ],
                        "addendum": false,
                        "copiedFromId": null,
                        "source": "病歷撰寫工作區",
                        "noteSections": [
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:CC",
                            "noteId": "DOC101",
                            "code": "CC",
                            "text": "主動脈剝離術後轉入 ICU 監測"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:PI",
                            "noteId": "DOC101",
                            "code": "PI",
                            "text": "08/30 急診胸痛，CT 確診 Stanford A，當日手術。"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:PH",
                            "noteId": "DOC101",
                            "code": "PH",
                            "text": "無已知慢性病。"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:PHFamily",
                            "noteId": "DOC101",
                            "code": "PHFamily",
                            "text": "父：高血壓。"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:vitalSummary",
                            "noteId": "DOC101",
                            "code": "vitalSummary",
                            "text": "HR 108、BP 110/70、T 37.1、SpO₂ 97%"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:examGeneral",
                            "noteId": "DOC101",
                            "code": "examGeneral",
                            "text": "意識清，傷口乾燥。"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:summary",
                            "noteId": "DOC101",
                            "code": "summary",
                            "text": "術後第 0 天，循環需升壓劑支持。"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:initialAssessment",
                            "noteId": "DOC101",
                            "code": "initialAssessment",
                            "text": "術後照護，監測出血與腎功能。"
                          },
                          {
                            "resourceType": "noteSection",
                            "id": "DOC101:treatmentPlan",
                            "noteId": "DOC101",
                            "code": "treatmentPlan",
                            "text": "維持 MAP > 65，每 4 小時追蹤 Hb。"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長；G9 時間格式不正確或不在有效區間；請填寫 S 主觀資料（SOAP 任一段為空）；請至少選取一個 ICD-10 診斷碼；主要診斷為第一個（diagnosisKeys 為空）；請填寫入院理由（缺必填段落 CC（其餘必填段落見 docs/10 §5））",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫／護；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會；僅限照護醫師（沒有有效照護關係）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "G10 品項不存在、停用或僅供備查；請選擇有效 ICD-10 診斷碼：icd:999999（diagnosisKeys 有不在目錄的鍵）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "recordNote",
          "note"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/note"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "noteSections": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/noteSection"
                        }
                      }
                    }
                  }
                ]
              },
              "examples": {
                "10_note_progress": {
                  "summary": "醫師寫病程 SOAP（format=soap 四欄）並引用今天的量測與醫囑",
                  "value": {
                    "resourceType": "note",
                    "patientId": "A",
                    "encounterId": "ENC-A",
                    "noteType": "progress",
                    "format": "soap",
                    "clinicalAt": "2026-08-31T09:30:00+07:00",
                    "S": "病人表示傷口疼痛 4/10，夜間可入睡。",
                    "O": "HR 102、T 37.2、BP 96/58。CBC 待回。",
                    "A": "術後第一天，循環穩定，疼痛控制中。",
                    "P": "續 Ibuprofen BID；PRN Ketorolac；追蹤 CBC。",
                    "referenceIds": [
                      "O120",
                      "O121",
                      "O122",
                      "O123",
                      "M131",
                      "L133"
                    ],
                    "replacesId": null
                  }
                },
                "11_note_admission": {
                  "summary": "住院病歷（入院診察）：結構化段落 noteSection[] ＋ diagnosisKeys（第一個為主要診斷）",
                  "value": {
                    "resourceType": "note",
                    "patientId": "A",
                    "encounterId": "ENC-A",
                    "noteType": "admission",
                    "format": "sections",
                    "clinicalAt": "2026-08-30T15:00:00+07:00",
                    "diagnosisKeys": [
                      "icd:3793"
                    ],
                    "noteSections": [
                      {
                        "resourceType": "noteSection",
                        "code": "CC",
                        "text": "主動脈剝離術後轉入 ICU 監測"
                      },
                      {
                        "resourceType": "noteSection",
                        "code": "PI",
                        "text": "08/30 急診胸痛，CT 確診 Stanford A，當日手術。"
                      },
                      {
                        "resourceType": "noteSection",
                        "code": "PH",
                        "text": "無已知慢性病。"
                      },
                      {
                        "resourceType": "noteSection",
                        "code": "PHFamily",
                        "text": "父：高血壓。"
                      },
                      {
                        "resourceType": "noteSection",
                        "code": "vitalSummary",
                        "text": "HR 108、BP 110/70、T 37.1、SpO₂ 97%"
                      },
                      {
                        "resourceType": "noteSection",
                        "code": "examGeneral",
                        "text": "意識清，傷口乾燥。"
                      },
                      {
                        "resourceType": "noteSection",
                        "code": "summary",
                        "text": "術後第 0 天，循環需升壓劑支持。"
                      },
                      {
                        "resourceType": "noteSection",
                        "code": "initialAssessment",
                        "text": "術後照護，監測出血與腎功能。"
                      },
                      {
                        "resourceType": "noteSection",
                        "code": "treatmentPlan",
                        "text": "維持 MAP > 65，每 4 小時追蹤 Hb。"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/notes/{id}/sign": {
      "post": {
        "tags": [
          "病歷"
        ],
        "summary": "簽名定版",
        "description": "簽名定版（只能簽自己的未簽草稿）\n\n原型 action：`signNote`\n\n角色：作者",
        "operationId": "postNotesIdSign",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 note",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/note"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：作者",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "signNote"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "無 body（空物件）"
              }
            }
          }
        }
      }
    },
    "/notes/{id}/review": {
      "post": {
        "tags": [
          "病歷"
        ],
        "summary": "確認完成",
        "description": "確認完成（本院無代簽代核）\n\n原型 action：`reviewNote`\n\n角色：作者",
        "operationId": "postNotesIdReview",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 note",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/note"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：作者",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "reviewNote"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "無 body（空物件）"
              }
            }
          }
        }
      }
    },
    "/notes/{id}/amend": {
      "post": {
        "tags": [
          "病歷"
        ],
        "summary": "留痕更正：建新版本",
        "description": "留痕更正：建新版本\n\n原型 action：`amendNote`\n\n角色：作者",
        "operationId": "postNotesIdAmend",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 note",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/note"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：作者",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "amendNote"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/note"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "noteSections": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/noteSection"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/patients/{id}/notes/previous-progress": {
      "get": {
        "tags": [
          "病歷"
        ],
        "summary": "前一日已簽病程供複製",
        "description": "前一日已簽病程供複製\n\n原型 action：`copyPreviousProgress`\n\n角色：醫",
        "operationId": "getPatientsIdNotesPreviousProgress",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 note",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/note"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "copyPreviousProgress"
        ]
      }
    },
    "/drafts": {
      "get": {
        "tags": [
          "病歷"
        ],
        "summary": "/drafts",
        "description": "角色：全",
        "operationId": "getDrafts",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 draft[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/draft"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/drafts/{kind}": {
      "put": {
        "tags": [
          "病歷"
        ],
        "summary": "存草稿",
        "description": "存草稿（不需先確認名單）\n\n原型 action：`saveDraft`\n\n角色：全",
        "operationId": "putDraftsKind",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "草稿種類（值域 draft-kind）"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 draft",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/draft"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "saveDraft"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/draft"
              }
            }
          }
        }
      }
    },
    "/patients/{id}/goals": {
      "get": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "/patients/{id}/goals",
        "description": "角色：全",
        "operationId": "getPatientsIdGoals",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 goal[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/goal"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "/patients/{id}/goals",
        "description": "原型 action：`goal`\n\n角色：醫",
        "operationId": "postPatientsIdGoals",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 goal",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/goal"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "G10 品項不存在、停用或僅供備查",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "goal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/goal"
              }
            }
          }
        }
      }
    },
    "/patients/{id}/care-focuses": {
      "get": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "唯讀歷史",
        "description": "唯讀歷史\n\n角色：全",
        "operationId": "getPatientsIdCareFocuses",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 careFocus[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/careFocus"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "/patients/{id}/care-focuses",
        "description": "原型 action：`careFocus`\n\n角色：醫",
        "operationId": "postPatientsIdCareFocuses",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 careFocus",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/careFocus"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "careFocus"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/careFocus"
              }
            }
          }
        }
      }
    },
    "/communications": {
      "get": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "/communications",
        "description": "角色：全",
        "operationId": "getCommunications",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 communication[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/communication"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/communications": {
      "post": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "/patients/{id}/communications",
        "description": "原型 action：`communication`\n\n角色：醫護",
        "operationId": "postPatientsIdCommunications",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 communication",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/communication"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫護",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "communication"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/communication"
              }
            }
          }
        }
      }
    },
    "/consultations": {
      "get": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "/consultations",
        "description": "角色：全",
        "operationId": "getConsultations",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "assignee",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 consultation[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/consultation"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/consultations": {
      "post": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "/patients/{id}/consultations",
        "description": "原型 action：`consultRequest`\n\n角色：醫",
        "operationId": "postPatientsIdConsultations",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 consultation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/consultation"
                    }
                  }
                },
                "examples": {
                  "15_consultation": {
                    "summary": "主治發出照會（指定照會醫師）",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "resourceType": "consultation",
                        "id": "CONS190",
                        "patientId": "A",
                        "specialty": "心臟內科",
                        "urgency": "urgent",
                        "assigneeId": "C001",
                        "subject": "術後心律",
                        "question": "術後第一天間歇性心房顫動，請評估抗凝與節律控制。",
                        "requesterId": "D001",
                        "requestedAt": "2026-08-31T10:40:00+07:00",
                        "status": "requested",
                        "recommendation": null,
                        "responderId": null,
                        "respondedAt": null,
                        "adoptionDecision": null,
                        "adoptionNote": null,
                        "adoptionById": null,
                        "adoptionAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "G8 欄位必填／過長",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫；G7 角色限制：僅限主責醫師；照會醫師僅可回覆指派照會；此照會不是指派給目前登入者（非 assigneeId 回覆）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "請指定有效的照會醫師（assigneeId 不是 consultationOnly 的醫師）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "consultRequest"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/consultation"
              },
              "examples": {
                "15_consultation": {
                  "summary": "主治發出照會（指定照會醫師）",
                  "value": {
                    "resourceType": "consultation",
                    "patientId": "A",
                    "urgency": "urgent",
                    "assigneeId": "C001",
                    "subject": "術後心律",
                    "question": "術後第一天間歇性心房顫動，請評估抗凝與節律控制。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/consultations/{id}/response": {
      "post": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "只有被指派者能回覆",
        "description": "只有被指派者能回覆\n\n原型 action：`consultRespond`\n\n角色：照",
        "operationId": "postConsultationsIdResponse",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 consultation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/consultation"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：照",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "consultRespond"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recommendation": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/consultations/{id}/adoption": {
      "post": {
        "tags": [
          "目標、溝通、照會"
        ],
        "summary": "主治採納／不採納／追蹤",
        "description": "主治採納／不採納／追蹤\n\n原型 action：`consultAdopt`\n\n角色：醫",
        "operationId": "postConsultationsIdAdoption",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 consultation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/consultation"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "consultAdopt"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "adoptionDecision": {
                    "type": "string"
                  },
                  "adoptionNote": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/surgeries": {
      "get": {
        "tags": [
          "手術與交接"
        ],
        "summary": "/surgeries",
        "description": "角色：全",
        "operationId": "getSurgeries",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 surgery[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/surgery"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/patients/{id}/surgeries": {
      "post": {
        "tags": [
          "手術與交接"
        ],
        "summary": "/patients/{id}/surgeries",
        "description": "原型 action：`surgerySave`\n\n角色：手術醫師",
        "operationId": "postPatientsIdSurgeries",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 surgery",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/surgery"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：手術醫師",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "surgerySave"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/surgery"
              }
            }
          }
        }
      }
    },
    "/surgeries/{id}/send": {
      "post": {
        "tags": [
          "手術與交接"
        ],
        "summary": "/surgeries/{id}/send",
        "description": "原型 action：`surgerySend`\n\n角色：手術醫師",
        "operationId": "postSurgeriesIdSend",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 surgery",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/surgery"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：手術醫師",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "surgerySend"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "無 body（空物件）"
              }
            }
          }
        }
      }
    },
    "/surgeries/{id}/receive": {
      "post": {
        "tags": [
          "手術與交接"
        ],
        "summary": "/surgeries/{id}/receive",
        "description": "原型 action：`surgeryReceive`\n\n角色：醫",
        "operationId": "postSurgeriesIdReceive",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 surgery",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/surgery"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "surgeryReceive"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "無 body（空物件）"
              }
            }
          }
        }
      }
    },
    "/tasks": {
      "get": {
        "tags": [
          "工作與交班"
        ],
        "summary": "/tasks",
        "description": "角色：全",
        "operationId": "getTasks",
        "parameters": [
          {
            "name": "owner",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 task[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/task"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "工作與交班"
        ],
        "summary": "/tasks",
        "description": "原型 action：`task`\n\n角色：全",
        "operationId": "postTasks",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 task",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/task"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "task"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/task"
              }
            }
          }
        }
      }
    },
    "/tasks/{id}": {
      "patch": {
        "tags": [
          "工作與交班"
        ],
        "summary": "更新狀態／完成證據",
        "description": "更新狀態／完成證據\n\n原型 action：`taskStatus`\n\n角色：負責者",
        "operationId": "patchTasksId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 task",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/task"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：負責者",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "taskStatus"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string"
                  },
                  "evidence": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/handovers": {
      "get": {
        "tags": [
          "工作與交班"
        ],
        "summary": "上一班交給我／我交出的",
        "description": "上一班交給我／我交出的\n\n角色：全",
        "operationId": "getHandovers",
        "parameters": [
          {
            "name": "receiver",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "author",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pending",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 handover[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/handover"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "工作與交班"
        ],
        "summary": "交出一位病人",
        "description": "交出一位病人（或更正前一版）\n\n原型 action：`handover／handoverPublish`\n\n角色：醫護",
        "operationId": "postHandovers",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 handover",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/handover"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫護",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "handover",
          "handoverPublish"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/handover"
              }
            }
          }
        }
      }
    },
    "/handovers:batch": {
      "post": {
        "tags": [
          "工作與交班"
        ],
        "summary": "整批交班",
        "description": "整批交班（每位病人一筆，沒有接班者整批擋下）\n\n原型 action：`handoverPublishBatch`\n\n角色：醫護",
        "operationId": "postHandoversBatch",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 handover[]",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/handover"
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "12_handover_batch": {
                    "summary": "醫師整批交班（ISBAR）：每位病人一筆；I 未填由伺服器帶入病人識別",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "total": 2,
                        "list": [
                          {
                            "resourceType": "handover",
                            "id": "H160",
                            "patientId": "A",
                            "role": "doctor",
                            "shift": "D1",
                            "authorId": "D001",
                            "receiverId": "D003",
                            "version": 1,
                            "replacesId": null,
                            "reason": null,
                            "batchId": "HB159",
                            "format": "ISBAR",
                            "I": "201A · 虛構病人 A · DEMO-A · 術後照護（示意）",
                            "S": "夜間血壓偏低已調升升壓劑，晨間回穩。",
                            "B": "主動脈剝離術後第一天，動脈導管與中心靜脈導管在位。",
                            "A": "循環穩定但仍需密切監測。",
                            "R": "續監測血壓與尿量，今日評估拔除動脈導管。",
                            "summary": "I：201A · 虛構病人 A · DEMO-A · 術後照護（示意）\nS：夜間血壓偏低已調升升壓劑，晨間回穩。\nB：主動脈剝離術後第一天，動脈導管與中心靜脈導管在位。\nA：循環穩定但仍需密切監測。\nR：續監測血壓與尿量，今日評估拔除動脈導管。",
                            "attendingTransferred": false,
                            "at": "2026-08-31T18:35:00+07:00",
                            "clinicalAt": "2026-08-31T18:30:00+07:00",
                            "taskIds": [
                              "T135"
                            ]
                          },
                          {
                            "resourceType": "handover",
                            "id": "H161",
                            "patientId": "B",
                            "role": "doctor",
                            "shift": "D1",
                            "authorId": "D001",
                            "receiverId": "D003",
                            "version": 1,
                            "replacesId": null,
                            "reason": null,
                            "batchId": "HB159",
                            "format": "ISBAR",
                            "I": "201B · 虛構病人 B · DEMO-B · 呼吸支持追蹤（示意）",
                            "S": "夜間呼吸器設定未調整，血氧維持。",
                            "B": "急性呼吸衰竭插管第三天，隔離中。",
                            "A": "氧合改善，可評估減降支持。",
                            "R": "今日安排脫離呼吸器評估。",
                            "summary": "I：201B · 虛構病人 B · DEMO-B · 呼吸支持追蹤（示意）\nS：夜間呼吸器設定未調整，血氧維持。\nB：急性呼吸衰竭插管第三天，隔離中。\nA：氧合改善，可評估減降支持。\nR：今日安排脫離呼吸器評估。",
                            "attendingTransferred": false,
                            "at": "2026-08-31T18:35:00+07:00",
                            "clinicalAt": "2026-08-31T18:30:00+07:00",
                            "taskIds": []
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "尚未指定接班者：201A 虛構病人 A；請勾選這幾位指定接班者後暫存，或設定「整批交給誰」。（任一病人沒有 receiverId（整批擋下））",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：醫護；病人 A：請指定同角色的接班者（receiverId 不是同角色、是本人、或是照會醫師／管理者）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "handoverPublishBatch"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/handover"
                }
              },
              "examples": {
                "12_handover_batch": {
                  "summary": "醫師整批交班（ISBAR）：每位病人一筆；I 未填由伺服器帶入病人識別",
                  "value": {
                    "list": [
                      {
                        "resourceType": "handover",
                        "patientId": "A",
                        "receiverId": "D003",
                        "S": "夜間血壓偏低已調升升壓劑，晨間回穩。",
                        "B": "主動脈剝離術後第一天，動脈導管與中心靜脈導管在位。",
                        "A": "循環穩定但仍需密切監測。",
                        "R": "續監測血壓與尿量，今日評估拔除動脈導管。",
                        "attendingTransferred": false,
                        "clinicalAt": "2026-08-31T18:30:00+07:00",
                        "replacesId": null,
                        "reason": null
                      },
                      {
                        "resourceType": "handover",
                        "patientId": "B",
                        "receiverId": "D003",
                        "S": "夜間呼吸器設定未調整，血氧維持。",
                        "B": "急性呼吸衰竭插管第三天，隔離中。",
                        "A": "氧合改善，可評估減降支持。",
                        "R": "今日安排脫離呼吸器評估。",
                        "attendingTransferred": false,
                        "clinicalAt": "2026-08-31T18:30:00+07:00",
                        "replacesId": null,
                        "reason": null
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/handovers/{id}/receipts": {
      "post": {
        "tags": [
          "工作與交班"
        ],
        "summary": "/handovers/{id}/receipts",
        "description": "原型 action：`receive`\n\n角色：接班者",
        "operationId": "postHandoversIdReceipts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "記錄代理鍵（字串）；不得用 HIS 代碼"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "201": {
            "description": "成功；data 為 handoverReceipt",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/handoverReceipt"
                    }
                  }
                },
                "examples": {
                  "13_handover_receipt": {
                    "summary": "下一班醫師接收交班；未結工作自動轉手（回應附 taskEvents）",
                    "value": {
                      "error": false,
                      "status": 201,
                      "message": "OK",
                      "data": {
                        "resourceType": "handoverReceipt",
                        "id": "RCPT-170",
                        "handoverId": "H160",
                        "handoverVersion": 1,
                        "actorId": "D003",
                        "at": "2026-08-31T19:06:40+07:00",
                        "clinicalAt": "2026-08-31T19:05:00+07:00",
                        "taskEvents": [
                          {
                            "resourceType": "taskEvent",
                            "id": "TE-171",
                            "taskId": "T135",
                            "fromStatus": null,
                            "toStatus": null,
                            "fromOwnerId": "D001",
                            "toOwnerId": "D003",
                            "handoverId": "H160",
                            "actorId": "D003",
                            "at": "2026-08-31T19:06:40+07:00"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：接班者；交班接收者或角色不符（呼叫者不是 receiverId）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）；此版本已更正，請接收最新版本（handover 已被新版本 replaces）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "receive"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/handoverReceipt"
              },
              "examples": {
                "13_handover_receipt": {
                  "summary": "下一班醫師接收交班；未結工作自動轉手（回應附 taskEvents）",
                  "value": {
                    "resourceType": "handoverReceipt",
                    "handoverId": "H160",
                    "clinicalAt": "2026-08-31T19:05:00+07:00"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/catalog/items": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "去聲調比對；預設 20 筆",
        "description": "去聲調比對；預設 20 筆\n\n角色：全",
        "operationId": "getCatalogItems",
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "預設 20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 catalogItem[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/catalogItem"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/catalog/items/{key}": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "/catalog/items/{key}",
        "description": "角色：全",
        "operationId": "getCatalogItemsKey",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "目錄鍵，例 medication:41652"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 catalogItem",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/catalogItem"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/catalog/icd10": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "/catalog/icd10",
        "description": "角色：全",
        "operationId": "getCatalogIcd10",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "預設 20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 catalogItem[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/catalogItem"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/catalog/routes": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "/catalog/routes",
        "description": "角色：全",
        "operationId": "getCatalogRoutes",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；data 為 catalogItem[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/catalogItem"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/catalog/frequencies": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "/catalog/frequencies",
        "description": "角色：全",
        "operationId": "getCatalogFrequencies",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；data 為 value-set",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ValueSet"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/catalog/taxonomy": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "/catalog/taxonomy",
        "description": "角色：全",
        "operationId": "getCatalogTaxonomy",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；data 為 orderCategory[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/orderCategory"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/value-sets/{name}": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "任一值域表",
        "description": "任一值域表（api/value-sets/*.csv 的 JSON 版）\n\n角色：全",
        "operationId": "getValueSetsName",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "值域名稱（api/value-sets/_index.csv）"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 value-set",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ValueSet"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/favorites": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "/favorites",
        "description": "角色：全",
        "operationId": "getFavorites",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 favorite[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/favorite"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/favorites/{key}": {
      "put": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "加入／移除",
        "description": "加入／移除（body {scope, on}）\n\n原型 action：`toggleFavorite`\n\n角色：全",
        "operationId": "putFavoritesKey",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "目錄鍵，例 medication:41652"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 favorite[]",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/favorite"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "病人、醫囑、報告不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "toggleFavorite"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "無 body（空物件）"
              }
            }
          }
        }
      }
    },
    "/order-sets": {
      "get": {
        "tags": [
          "目錄與常用"
        ],
        "summary": "/order-sets",
        "description": "角色：全",
        "operationId": "getOrderSets",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；data 為 order-set[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/OrderSet"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/settings": {
      "get": {
        "tags": [
          "設定與稽核"
        ],
        "summary": "/settings",
        "description": "角色：全",
        "operationId": "getSettings",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；data 為 settings+orderCategory[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/settings"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "orderCategories": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/orderCategory"
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "設定與稽核"
        ],
        "summary": "/settings",
        "description": "原型 action：`settingsSave`\n\n角色：管",
        "operationId": "putSettings",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "同鍵重送回第一次的結果，不建第二筆"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "樂觀鎖：讀取回應的 ETag（revision）；不符回 409"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 settings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/settings"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "角色限制：管",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "請先確認本班照護名單；樂觀鎖：其他分頁已有較新版本（If-Match 不符）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "x-prototype-action": [
          "settingsSave"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/settings"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "orderCategories": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/orderCategory"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/audit-events": {
      "get": {
        "tags": [
          "設定與稽核"
        ],
        "summary": "/audit-events",
        "description": "角色：依權限",
        "operationId": "getAuditEvents",
        "parameters": [
          {
            "name": "patient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "actor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "action",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 含時區；時間窗由前端換算成絕對時間"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 auditEvent[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "total",
                        "list"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/auditEvent"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/provenance": {
      "get": {
        "tags": [
          "設定與稽核"
        ],
        "summary": "誰簽的、何時判讀、名單誰確認——reportReview／signature／rosterConfirmation 的統一查詢",
        "description": "誰簽的、何時判讀、名單誰確認——reportReview／signature／rosterConfirmation 的統一查詢\n\n角色：全",
        "operationId": "getProvenance",
        "parameters": [
          {
            "name": "target",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；data 為 records[]",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "revision，寫入時放 If-Match"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "status": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Records"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "未知操作者／token 無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "H12 §4：使用者登入與 RBAC 由後端自建；token 決定 actorId、角色與班別。"
      }
    },
    "schemas": {
      "patient": {
        "title": "病人（patient）",
        "description": "病人識別與行政資料。病歷號、姓名、出生日期、性別一律 H 或 P，永不 M；接診登錄（admitPatient）是示範替代，正式由 HIS 推入。\n\nFHIR 對應：Patient（＋Encounter 摘要）\n\n原型 state：`patients[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "patient"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "病人代理鍵；原型為 A–J 或 P101…",
            "x-source": "C"
          },
          "identifier": {
            "type": "string",
            "description": "病歷號（TDL.0004）",
            "x-source": "H"
          },
          "visitNo": {
            "type": "string",
            "description": "就醫序號（R-035 未拍板，預設隱藏；不得放進 URL）",
            "x-source": "H",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "姓名（TDL.0005），維持來源語言",
            "x-source": "H"
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female",
              "other",
              "unknown"
            ],
            "description": "值域 gender",
            "x-source": "H",
            "nullable": true
          },
          "birthDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "x-source": "H",
            "nullable": true
          },
          "ward": {
            "type": "string",
            "description": "病房",
            "x-source": "H"
          },
          "bed": {
            "type": "string",
            "description": "病床號",
            "x-source": "H"
          },
          "department": {
            "type": "string",
            "description": "科別（Phase 1 固定 ICU）",
            "x-source": "H",
            "nullable": true
          },
          "admitted": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "入院日",
            "x-source": "H"
          },
          "admittedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "入院時間（有才給）",
            "x-source": "H",
            "nullable": true
          },
          "dischargedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "出院登記時間（dischargePatient）",
            "x-source": "C",
            "nullable": true
          },
          "attendingId": {
            "type": "string",
            "description": "回應：由 careRelationship(role=attending, active) 推得；只有 POST /patients 的請求收它（指定主治）；→ practitioner.id",
            "x-source": "M",
            "nullable": true
          },
          "attendingName": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "nurseId": {
            "type": "string",
            "description": "只在 POST /patients 的請求收（接診時指定主要護理師）；之後一律走 careRelationship，回應回 null；→ practitioner.id",
            "x-source": "M",
            "nullable": true
          },
          "problem": {
            "type": "string",
            "description": "入院診斷／主要問題（自由文字）",
            "x-source": "M",
            "nullable": true
          },
          "flags": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "ALG",
                "ISO",
                "DNR",
                "FALL",
                "LINE",
                "VENT",
                "RESTRICT"
              ]
            },
            "description": "特殊註記；空陣列＝無；值域 flag-code",
            "x-source": "H",
            "nullable": true
          },
          "allergyStatus": {
            "type": "string",
            "enum": [
              "unknown",
              "none-known",
              "recorded"
            ],
            "description": "值域 allergy-status",
            "x-source": "M"
          },
          "allergySummary": {
            "type": "string",
            "description": "病人列的單行過敏摘要，三種狀態文字不同",
            "x-source": "C",
            "nullable": true
          },
          "surgeryDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "無資料回 null，前端顯示「尚未取得」；不得省略欄位",
            "x-source": "H",
            "nullable": true
          },
          "surgeryProcedure": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "surgeryStart": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M",
            "nullable": true
          },
          "surgeryEnd": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M",
            "nullable": true
          },
          "surgerySurgeon": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "surgeryAnesthesia": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "surgeryIcuArrival": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M",
            "nullable": true
          },
          "surgeryNote": {
            "type": "string",
            "maxLength": 2000,
            "x-source": "M",
            "nullable": true
          },
          "encounterId": {
            "type": "string",
            "description": "→ encounter.id",
            "x-source": "C"
          },
          "episodeId": {
            "type": "string",
            "description": "ICU 照護段",
            "x-source": "C",
            "nullable": true
          },
          "stayDays": {
            "type": "number",
            "description": "由 admitted 與今日算，不入庫",
            "x-source": "C",
            "nullable": true
          },
          "admittedById": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "registeredAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "source": {
            "type": "string",
            "description": "來源標註，例「接診登錄（示範），非 HIS 主檔」",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "identifier",
          "name",
          "ward",
          "bed",
          "admitted",
          "allergyStatus",
          "encounterId"
        ],
        "additionalProperties": false
      },
      "encounter": {
        "title": "就醫事件（encounter）",
        "description": "L2 HIS 唯讀鏡像。Phase 1 一位病人一次 ICU 住院＝一個 encounter。\n\nFHIR 對應：Encounter\n\n原型 state：`patients[].encounter／episode／archives`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "encounter"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "例 ENC-A",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "episodeId": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "in-progress",
              "finished"
            ],
            "description": "值域 encounter-status",
            "x-source": "C"
          },
          "encounterNumber": {
            "type": "string",
            "description": "HIS 就醫序號；只回傳不進 URL",
            "x-source": "H",
            "nullable": true
          },
          "admittedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "H",
            "nullable": true
          },
          "dischargedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "department": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "ward": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "bed": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "archiveStatus": {
            "type": "string",
            "enum": [
              "open",
              "grace",
              "sealed"
            ],
            "description": "值域 archive-status",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "status"
        ],
        "additionalProperties": false
      },
      "allergy": {
        "title": "過敏（allergy）",
        "description": "欄位取 FHIR R4 AllergyIntolerance 必要子集，值域用 FHIR 原始代碼；顯示層才翻中文。\n\nFHIR 對應：AllergyIntolerance\n\n原型 state：`patients[].allergies[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "allergy"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "substanceKind": {
            "type": "string",
            "enum": [
              "medication",
              "ingredient",
              "class"
            ],
            "description": "值域 substance-kind",
            "x-source": "M"
          },
          "substanceText": {
            "type": "string",
            "description": "過敏原顯示文字（code.text）",
            "x-source": "M"
          },
          "ingredient": {
            "type": "string",
            "description": "substanceKind=ingredient 時",
            "x-source": "M",
            "nullable": true
          },
          "drugClass": {
            "type": "string",
            "description": "substanceKind=class 時，須在藥理類別表",
            "x-source": "M",
            "nullable": true
          },
          "type": {
            "type": "string",
            "enum": [
              "allergy",
              "intolerance"
            ],
            "description": "值域 allergy-type",
            "x-source": "M",
            "nullable": true
          },
          "category": {
            "type": "string",
            "enum": [
              "medication",
              "food",
              "environment",
              "biologic"
            ],
            "description": "值域 allergy-category",
            "x-source": "M",
            "nullable": true
          },
          "criticality": {
            "type": "string",
            "enum": [
              "low",
              "high",
              "unable-to-assess"
            ],
            "description": "值域 allergy-criticality",
            "x-source": "M",
            "nullable": true
          },
          "clinicalStatus": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "resolved"
            ],
            "description": "值域 allergy-clinical",
            "x-source": "M"
          },
          "verificationStatus": {
            "type": "string",
            "enum": [
              "unconfirmed",
              "confirmed",
              "refuted",
              "entered-in-error"
            ],
            "description": "值域 allergy-verification",
            "x-source": "M",
            "nullable": true
          },
          "manifestation": {
            "type": "string",
            "description": "反應型態；沒有反應型態就無法判斷嚴重度",
            "x-source": "M"
          },
          "severity": {
            "type": "string",
            "enum": [
              "mild",
              "moderate",
              "severe"
            ],
            "description": "值域 reaction-severity",
            "x-source": "M",
            "nullable": true
          },
          "recordedDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "x-source": "C",
            "nullable": true
          },
          "recorderId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "source": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "substanceKind",
          "substanceText",
          "clinicalStatus",
          "manifestation"
        ],
        "additionalProperties": false
      },
      "condition": {
        "title": "診斷（condition）",
        "description": "代碼必在 ICD-10 目錄；換代碼＝另建一筆，不改既有。\n\nFHIR 對應：Condition\n\n原型 state：`patients[].conditions[]／diagnoses[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "condition"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "encounterId": {
            "type": "string",
            "description": "→ encounter.id",
            "x-source": "M",
            "nullable": true
          },
          "icdKey": {
            "type": "string",
            "description": "目錄鍵，例 icd:3793",
            "x-source": "M"
          },
          "icdCode": {
            "type": "string",
            "description": "例 I71.0",
            "x-source": "C",
            "nullable": true
          },
          "icdText": {
            "type": "string",
            "description": "越南文名稱",
            "x-source": "C",
            "nullable": true
          },
          "icdEnglish": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "category": {
            "type": "string",
            "enum": [
              "encounter-diagnosis",
              "problem-list-item"
            ],
            "description": "值域 condition-category",
            "x-source": "M"
          },
          "stage": {
            "type": "string",
            "enum": [
              "admission",
              "icu",
              "discharge"
            ],
            "description": "值域 condition-stage",
            "x-source": "M",
            "nullable": true
          },
          "rank": {
            "type": "string",
            "enum": [
              "primary",
              "secondary"
            ],
            "description": "值域 condition-rank",
            "x-source": "M",
            "nullable": true
          },
          "clinicalStatus": {
            "type": "string",
            "enum": [
              "active",
              "recurrence",
              "relapse",
              "inactive",
              "remission",
              "resolved"
            ],
            "description": "值域 condition-clinical",
            "x-source": "M"
          },
          "verificationStatus": {
            "type": "string",
            "enum": [
              "unconfirmed",
              "provisional",
              "differential",
              "confirmed",
              "refuted",
              "entered-in-error"
            ],
            "description": "值域 condition-verification",
            "x-source": "M"
          },
          "onset": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "x-source": "M",
            "nullable": true
          },
          "recordedDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "x-source": "C",
            "nullable": true
          },
          "recorderId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "x-source": "C",
            "nullable": true
          },
          "source": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "icdKey",
          "category",
          "clinicalStatus",
          "verificationStatus"
        ],
        "additionalProperties": false
      },
      "practitioner": {
        "title": "人員（practitioner）",
        "description": "帳號、類別、科別、班別。正式認證與 RBAC 由後端。\n\nFHIR 對應：Practitioner＋PractitionerRole\n\n原型 state：`people{}`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "practitioner"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "帳號代理鍵，例 D001",
            "x-source": "C"
          },
          "name": {
            "type": "string",
            "x-source": "H"
          },
          "role": {
            "type": "string",
            "enum": [
              "doctor",
              "nurse",
              "admin"
            ],
            "description": "值域 practitioner-role",
            "x-source": "H"
          },
          "department": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "specialty": {
            "type": "string",
            "description": "照會醫師的專科",
            "x-source": "H",
            "nullable": true
          },
          "consultationOnly": {
            "type": "boolean",
            "description": "true＝只看得到被指派照會的病人",
            "x-source": "H",
            "nullable": true
          },
          "shift": {
            "type": "string",
            "description": "班別代碼，例 D1／N1",
            "x-source": "H",
            "nullable": true
          },
          "shiftStart": {
            "type": "string",
            "pattern": "^\\d{2}:\\d{2}(\\+1)?$",
            "description": "HH:mm",
            "x-source": "M",
            "nullable": true
          },
          "shiftEnd": {
            "type": "string",
            "pattern": "^\\d{2}:\\d{2}(\\+1)?$",
            "description": "HH:mm，跨日加 +1",
            "x-source": "M",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "x-source": "H",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "name",
          "role"
        ],
        "additionalProperties": false
      },
      "careRelationship": {
        "title": "照護關係（careRelationship）",
        "description": "同人可有多個關係；每病人同一時間只有一個有效主治。\n\nFHIR 對應：CareTeam.participant\n\n原型 state：`relationships[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "careRelationship"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "practitionerId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "M"
          },
          "role": {
            "type": "string",
            "enum": [
              "attending",
              "care",
              "consult",
              "nurse",
              "surgeon"
            ],
            "description": "值域 care-role",
            "x-source": "M"
          },
          "active": {
            "type": "boolean",
            "x-source": "C"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "endedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "byId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "via": {
            "type": "string",
            "enum": [
              "seed",
              "admit",
              "handover",
              "consult",
              "settings"
            ],
            "description": "值域 relationship-via",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "practitionerId",
          "role",
          "active"
        ],
        "additionalProperties": false
      },
      "rosterConfirmation": {
        "title": "照護名單確認（rosterConfirmation）",
        "description": "所有寫入的前置閘；未確認前除草稿外回 409。\n\nFHIR 對應：Provenance(roster-confirm)\n\n原型 state：`confirmed{}`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "rosterConfirmation"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "practitionerId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C"
          },
          "shift": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "patientIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "source": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "practitionerId",
          "patientIds"
        ],
        "additionalProperties": false
      },
      "catalogItem": {
        "title": "目錄品項（catalogItem）",
        "description": "B 目錄快照，唯讀。醫囑建立時再快照一次存進 order（catalogKey＋catalogVersion）。\n\nFHIR 對應：ValueSet／Medication\n\n原型 state：`ICUCatalog.entries[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "catalogItem"
            ],
            "type": "string"
          },
          "key": {
            "type": "string",
            "description": "`kind:id`，例 medication:41652",
            "x-source": "H"
          },
          "kind": {
            "type": "string",
            "enum": [
              "service",
              "medication",
              "supply",
              "diet",
              "icd",
              "route",
              "unit"
            ],
            "description": "值域 catalog-kind",
            "x-source": "H"
          },
          "code": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "name": {
            "type": "string",
            "x-source": "H"
          },
          "zh": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "english": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "ingredient": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "atc": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "strength": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "unit": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "routeCode": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "routeId": {
            "type": "string",
            "description": "目錄預設途徑",
            "x-source": "H",
            "nullable": true
          },
          "group": {
            "type": "string",
            "description": "服務群組（越南文）",
            "x-source": "H",
            "nullable": true
          },
          "inputCode": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "reportCode": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "isLab": {
            "type": "boolean",
            "x-source": "H",
            "nullable": true
          },
          "category": {
            "type": "string",
            "enum": [
              "medication",
              "labimaging",
              "procedure",
              "surgery",
              "supply",
              "diet",
              "other"
            ],
            "description": "七分類（首個相符者勝）；值域 order-category",
            "x-source": "C",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "x-source": "H"
          },
          "source": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "catalogVersion": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "sourceSHA256": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "key",
          "kind",
          "name",
          "active"
        ],
        "additionalProperties": false
      },
      "favorite": {
        "title": "常用品項（favorite）",
        "description": "個人常用上限 60；只收目錄既有品項。\n\nFHIR 對應：List.entry\n\n原型 state：`favorites{}`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "favorite"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "scope": {
            "type": "string",
            "enum": [
              "doctor",
              "department"
            ],
            "description": "值域 favorite-scope",
            "x-source": "M"
          },
          "ownerId": {
            "type": "string",
            "description": "scope=doctor 為本人；department 為科別代碼；→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "catalogKey": {
            "type": "string",
            "x-source": "M"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "scope",
          "catalogKey"
        ],
        "additionalProperties": false
      },
      "order": {
        "title": "醫囑（order）",
        "description": "開立、簽署、送出、HIS 回應、實際執行是五個分開的狀態。檢驗檢查免簽署，開立即可執行並自動開出 report(pending)＋task。\n\nFHIR 對應：MedicationRequest／ServiceRequest\n\n原型 state：`orders[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "order"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "M…藥囑／L…檢驗檢查／C…照護",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "encounterId": {
            "type": "string",
            "description": "就醫事件；必須與 patientId 相符，否則 422；→ encounter.id",
            "x-source": "M"
          },
          "version": {
            "type": "number",
            "x-source": "C"
          },
          "kind": {
            "type": "string",
            "enum": [
              "medication",
              "service",
              "care"
            ],
            "description": "值域 order-kind",
            "x-source": "C"
          },
          "category": {
            "type": "string",
            "enum": [
              "medication",
              "labimaging",
              "procedure",
              "surgery",
              "supply",
              "diet",
              "other"
            ],
            "description": "值域 order-category",
            "x-source": "C",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "品項名稱快照",
            "x-source": "C"
          },
          "catalogKey": {
            "type": "string",
            "description": "目錄鍵；送出時重新快照，停用或查不到回 422",
            "x-source": "M",
            "nullable": true
          },
          "catalogVersion": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "fromSetId": {
            "type": "string",
            "description": "套組來源",
            "x-source": "M",
            "nullable": true
          },
          "batchId": {
            "type": "string",
            "description": "同一次確認開立的批次",
            "x-source": "C",
            "nullable": true
          },
          "quantity": {
            "type": "number",
            "description": "藥囑必填 > 0",
            "x-source": "M",
            "nullable": true
          },
          "unit": {
            "type": "string",
            "description": "藥囑必填",
            "x-source": "M",
            "nullable": true
          },
          "dose": {
            "type": "string",
            "description": "顯示用「數量 單位」",
            "x-source": "C",
            "nullable": true
          },
          "routeKey": {
            "type": "string",
            "description": "藥囑必填，必須對回 route 目錄鍵；自由文字回 400",
            "x-source": "M",
            "nullable": true
          },
          "routeText": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "routeMismatch": {
            "type": "boolean",
            "description": "與目錄預設途徑不一致，不阻擋但留存",
            "x-source": "C",
            "nullable": true
          },
          "dosingMode": {
            "type": "string",
            "enum": [
              "once",
              "scheduled",
              "prn",
              "infusion"
            ],
            "description": "藥囑；服務一律 once；值域 dosing-mode",
            "x-source": "M",
            "nullable": true
          },
          "frequency": {
            "type": "string",
            "description": "scheduled 必填；其餘由 mode 決定；值域 frequency",
            "x-source": "M",
            "nullable": true
          },
          "days": {
            "type": "number",
            "description": "療程天數 1–365；與 end 擇一",
            "x-source": "M",
            "nullable": true
          },
          "rate": {
            "type": "string",
            "description": "infusion 必填",
            "x-source": "M",
            "nullable": true
          },
          "concentration": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "prnIndication": {
            "type": "string",
            "description": "prn 必填",
            "x-source": "M",
            "nullable": true
          },
          "prnMinInterval": {
            "type": "string",
            "description": "prn 必填",
            "x-source": "M",
            "nullable": true
          },
          "prnMaxPerDay": {
            "type": "number",
            "description": "prn 必填 > 0",
            "x-source": "M",
            "nullable": true
          },
          "start": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "生效時間",
            "x-source": "M"
          },
          "end": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "留空＝持續到停用",
            "x-source": "M",
            "nullable": true
          },
          "orderedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "authorId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C"
          },
          "clinicalStatus": {
            "type": "string",
            "enum": [
              "draft",
              "active",
              "stopped",
              "cancelled"
            ],
            "description": "值域 order-clinical-status",
            "x-source": "C"
          },
          "localStatus": {
            "type": "string",
            "enum": [
              "draft",
              "signed"
            ],
            "description": "值域 order-local-status",
            "x-source": "C"
          },
          "hisStatus": {
            "type": "string",
            "enum": [
              "notSent",
              "sent",
              "accepted",
              "rejected",
              "unknown"
            ],
            "description": "值域 his-status",
            "x-source": "C"
          },
          "signedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "signatureExempt": {
            "type": "boolean",
            "description": "檢驗檢查免簽署",
            "x-source": "C",
            "nullable": true
          },
          "occurrenceId": {
            "type": "string",
            "description": "劑次識別 `<id>-V<version>-D1`",
            "x-source": "C",
            "nullable": true
          },
          "progressNoteId": {
            "type": "string",
            "description": "病程來源（同病人、本人所寫）；→ note.id",
            "x-source": "M",
            "nullable": true
          },
          "consultSourceId": {
            "type": "string",
            "description": "須為同病人已採納的建議；→ consultation.id",
            "x-source": "M",
            "nullable": true
          },
          "clinicalInfo": {
            "type": "string",
            "maxLength": 5000,
            "x-source": "M",
            "nullable": true
          },
          "stopAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M",
            "nullable": true
          },
          "stopReason": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "stopById": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "cancelAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "cancelReason": {
            "type": "string",
            "description": "hisStatus=accepted 時必填",
            "x-source": "M",
            "nullable": true
          },
          "cancelById": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "source": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "encounterId",
          "version",
          "kind",
          "name",
          "start",
          "authorId",
          "clinicalStatus",
          "localStatus",
          "hisStatus"
        ],
        "additionalProperties": false
      },
      "orderSafety": {
        "title": "用藥安全提示處理（orderSafety）",
        "description": "寫入端重算；畫面漏掉不等於檢核通過。只有 high 且牽涉本次新增才擋。\n\nFHIR 對應：DetectedIssue\n\n原型 state：`orders[].safety[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "orderSafety"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "orderId": {
            "type": "string",
            "description": "→ order.id",
            "x-source": "C"
          },
          "pair": {
            "type": "string",
            "description": "配對鍵",
            "x-source": "C"
          },
          "ruleId": {
            "type": "string",
            "description": "例 RX-BLEED-01",
            "x-source": "C",
            "nullable": true
          },
          "severity": {
            "type": "string",
            "enum": [
              "high",
              "moderate"
            ],
            "description": "值域 safety-severity",
            "x-source": "C",
            "nullable": true
          },
          "kind": {
            "type": "string",
            "enum": [
              "duplicate",
              "interaction"
            ],
            "description": "值域 safety-kind",
            "x-source": "C",
            "nullable": true
          },
          "label": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "decision": {
            "type": "string",
            "enum": [
              "shown",
              "handled",
              "override"
            ],
            "description": "值域 safety-decision",
            "x-source": "M"
          },
          "handling": {
            "type": "string",
            "description": "decision=handled 的處理方式；「其他」時 reason 必填",
            "x-source": "M",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "decision=override 必填",
            "x-source": "M",
            "nullable": true
          },
          "byId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "orderId",
          "pair",
          "decision"
        ],
        "additionalProperties": false
      },
      "execution": {
        "title": "執行紀錄（eMAR）（execution）",
        "description": "同一 occurrenceId 不得有第二筆 done；五對是五個獨立布林，單一 scanned 一律 400。\n\nFHIR 對應：MedicationAdministration／Procedure\n\n原型 state：`executions[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "execution"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "orderId": {
            "type": "string",
            "description": "→ order.id",
            "x-source": "M"
          },
          "orderVersion": {
            "type": "number",
            "x-source": "C",
            "nullable": true
          },
          "occurrenceId": {
            "type": "string",
            "x-source": "C"
          },
          "status": {
            "type": "string",
            "enum": [
              "done",
              "held",
              "notDone"
            ],
            "description": "值域 execution-status",
            "x-source": "M"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "實際時間；須在醫囑版本有效期間內",
            "x-source": "M"
          },
          "recordedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "actualDose": {
            "type": "string",
            "description": "與醫囑不同時 reason 必填",
            "x-source": "M",
            "nullable": true
          },
          "actualRoute": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "status≠done 或有差異時必填",
            "x-source": "M",
            "nullable": true
          },
          "checkPatient": {
            "type": "boolean",
            "description": "五對：病人",
            "x-source": "M",
            "nullable": true
          },
          "checkDrug": {
            "type": "boolean",
            "description": "五對：藥物",
            "x-source": "M",
            "nullable": true
          },
          "checkDose": {
            "type": "boolean",
            "description": "五對：劑量",
            "x-source": "M",
            "nullable": true
          },
          "checkRoute": {
            "type": "boolean",
            "description": "五對：途徑",
            "x-source": "M",
            "nullable": true
          },
          "checkTime": {
            "type": "boolean",
            "description": "五對：時間",
            "x-source": "M",
            "nullable": true
          },
          "reviewOutcome": {
            "type": "string",
            "enum": [
              "reviewed",
              "difference"
            ],
            "description": "值域 review-outcome",
            "x-source": "M",
            "nullable": true
          },
          "reviewNote": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "reviewById": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "reviewAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "orderId",
          "occurrenceId",
          "status",
          "at",
          "actorId"
        ],
        "additionalProperties": false
      },
      "infusionCheck": {
        "title": "輸注速率核對（infusionCheck）",
        "description": "FHIR 對應：Observation(infusion-rate)\n\n原型 state：`infusionChecks[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "infusionCheck"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "orderId": {
            "type": "string",
            "description": "→ order.id",
            "x-source": "M"
          },
          "orderVersion": {
            "type": "number",
            "x-source": "C",
            "nullable": true
          },
          "rate": {
            "type": "number",
            "x-source": "M"
          },
          "unit": {
            "type": "string",
            "x-source": "M"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M"
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "reason": {
            "type": "string",
            "description": "觀察與差異說明",
            "x-source": "M"
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "orderId",
          "rate",
          "unit",
          "at",
          "actorId",
          "reason"
        ],
        "additionalProperties": false
      },
      "observation": {
        "title": "量測（observation）",
        "description": "一列一個數值。血壓是收縮壓、舒張壓兩列，用同一個 setId 綁在一起（原型是一筆兩個 component，轉接層展開）。缺值不補 0。\n\nFHIR 對應：Observation(vital-signs)\n\n原型 state：`observations[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "observation"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "encounterId": {
            "type": "string",
            "description": "→ encounter.id",
            "x-source": "M",
            "nullable": true
          },
          "code": {
            "type": "string",
            "enum": [
              "HR",
              "TEMP",
              "RR",
              "SPO2",
              "SBP",
              "DBP",
              "WT",
              "IN",
              "OUT"
            ],
            "description": "值域 observation-code",
            "x-source": "M"
          },
          "display": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "value": {
            "type": "number",
            "description": "非負數",
            "x-source": "M"
          },
          "unit": {
            "type": "string",
            "description": "由 code 決定",
            "x-source": "C",
            "nullable": true
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "量測時點",
            "x-source": "M"
          },
          "recordedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "setId": {
            "type": "string",
            "description": "同一次輸入的多個項目共用",
            "x-source": "C",
            "nullable": true
          },
          "entry": {
            "type": "string",
            "enum": [
              "manual",
              "device",
              "import"
            ],
            "description": "值域 observation-entry",
            "x-source": "C",
            "nullable": true
          },
          "source": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "code",
          "value",
          "at",
          "actorId"
        ],
        "additionalProperties": false
      },
      "report": {
        "title": "檢驗檢查報告（report）",
        "description": "L2 HIS 唯讀鏡像；報告自帶識別碼，不沿用醫囑編號。待回顯示「待回」不顯示 0。\n\nFHIR 對應：DiagnosticReport\n\n原型 state：`reports[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "report"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "orderId": {
            "type": "string",
            "description": "→ order.id",
            "x-source": "C",
            "nullable": true
          },
          "kind": {
            "type": "string",
            "enum": [
              "lab",
              "imaging",
              "exam"
            ],
            "description": "值域 report-kind",
            "x-source": "H"
          },
          "examType": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "returned",
              "cancelled"
            ],
            "description": "值域 report-status",
            "x-source": "H"
          },
          "version": {
            "type": "number",
            "x-source": "H"
          },
          "text": {
            "type": "string",
            "description": "文字報告／結論",
            "x-source": "H",
            "nullable": true
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "報告時間",
            "x-source": "H",
            "nullable": true
          },
          "collectedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "採檢時間",
            "x-source": "H",
            "nullable": true
          },
          "recordedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "catalogKey": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "source": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "cancelledAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "cancelledById": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "kind",
          "status",
          "version"
        ],
        "additionalProperties": false
      },
      "labResult": {
        "title": "檢驗數值（labResult）",
        "description": "參考範圍隨每列走只做顯示；classification 只依 interpretation，不由數值推。\n\nFHIR 對應：Observation(laboratory)\n\n原型 state：`reports[].components[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "labResult"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "reportId": {
            "type": "string",
            "description": "→ report.id",
            "x-source": "H"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "code": {
            "type": "string",
            "description": "指標短碼，例 WBC",
            "x-source": "H"
          },
          "name": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "value": {
            "type": "string",
            "description": "待回為 null；文字型結果亦放這裡",
            "x-source": "H",
            "nullable": true
          },
          "unit": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "x-source": "H",
            "nullable": true
          },
          "interpretation": {
            "type": "string",
            "enum": [
              "N",
              "H",
              "L",
              "HH",
              "LL",
              "A",
              "AA",
              "POS",
              "NEG",
              "DET",
              "ND"
            ],
            "description": "值域 interpretation",
            "x-source": "H",
            "nullable": true
          },
          "classification": {
            "type": "string",
            "enum": [
              "pending",
              "abnormal",
              "normal",
              "unknown",
              "unavailable"
            ],
            "description": "值域 result-classification",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "H",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "reportId",
          "patientId",
          "code",
          "classification"
        ],
        "additionalProperties": false
      },
      "reportReview": {
        "title": "報告已閱／判讀（reportReview）",
        "description": "記錄的是「當時的報告版本」；來源缺漏或報告未回一律 409。\n\nFHIR 對應：Provenance(clinical-review)\n\n原型 state：`reports[].seen[]／processed[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "reportReview"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "reportId": {
            "type": "string",
            "description": "→ report.id",
            "x-source": "M"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "action": {
            "type": "string",
            "enum": [
              "seen",
              "processed"
            ],
            "description": "值域 review-action",
            "x-source": "M"
          },
          "reportVersion": {
            "type": "number",
            "x-source": "C"
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "note": {
            "type": "string",
            "description": "processed 必填",
            "x-source": "M",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "reportId",
          "patientId",
          "action",
          "reportVersion",
          "actorId"
        ],
        "additionalProperties": false
      },
      "task": {
        "title": "工作（task）",
        "description": "結案要證據；來源報告要已判讀才能結案。\n\nFHIR 對應：Task\n\n原型 state：`tasks[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "task"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "title": {
            "type": "string",
            "x-source": "M"
          },
          "sourceId": {
            "type": "string",
            "description": "來源醫囑／報告 id，或 manual",
            "x-source": "M",
            "nullable": true
          },
          "ownerId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "accepted",
              "waiting",
              "done"
            ],
            "description": "值域 task-status",
            "x-source": "M"
          },
          "evidence": {
            "type": "string",
            "description": "done 必填",
            "x-source": "M",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "title",
          "ownerId",
          "status"
        ],
        "additionalProperties": false
      },
      "taskEvent": {
        "title": "工作歷程（taskEvent）",
        "description": "FHIR 對應：Provenance\n\n原型 state：`tasks[].history[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "taskEvent"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "taskId": {
            "type": "string",
            "description": "→ task.id",
            "x-source": "C"
          },
          "fromStatus": {
            "type": "string",
            "enum": [
              "open",
              "accepted",
              "waiting",
              "done"
            ],
            "description": "值域 task-status",
            "x-source": "C",
            "nullable": true
          },
          "toStatus": {
            "type": "string",
            "enum": [
              "open",
              "accepted",
              "waiting",
              "done"
            ],
            "description": "值域 task-status",
            "x-source": "C",
            "nullable": true
          },
          "fromOwnerId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "toOwnerId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "handoverId": {
            "type": "string",
            "description": "→ handover.id",
            "x-source": "C",
            "nullable": true
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "taskId",
          "actorId"
        ],
        "additionalProperties": false
      },
      "note": {
        "title": "病歷（note）",
        "description": "草稿可改、簽後不可改；更正＝建新版本 replacesId 指向舊版。結構化段落在 noteSection。\n\nFHIR 對應：Composition\n\n原型 state：`notes[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "note"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "DOC…",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "encounterId": {
            "type": "string",
            "description": "就醫事件；必須與 patientId 相符，否則 422；→ encounter.id",
            "x-source": "M"
          },
          "noteType": {
            "type": "string",
            "enum": [
              "admission",
              "progress",
              "discharge",
              "nursing",
              "free"
            ],
            "description": "值域 note-type",
            "x-source": "M"
          },
          "format": {
            "type": "string",
            "enum": [
              "soap",
              "text",
              "sections"
            ],
            "description": "值域 note-format",
            "x-source": "M"
          },
          "kind": {
            "type": "string",
            "description": "顯示用中文類別",
            "x-source": "C",
            "nullable": true
          },
          "text": {
            "type": "string",
            "description": "format=text 必填；其餘由段落組成（C）",
            "x-source": "M",
            "nullable": true
          },
          "S": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "O": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "A": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "P": {
            "type": "string",
            "description": "SOAP 四段，format=soap 必填",
            "x-source": "M",
            "nullable": true
          },
          "clinicalAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "臨床時間（事件發生）",
            "x-source": "M"
          },
          "authorId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C"
          },
          "version": {
            "type": "number",
            "x-source": "C"
          },
          "replacesId": {
            "type": "string",
            "description": "更正／修改自哪一版；→ note.id",
            "x-source": "M",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "已簽署版本的更正原因必填",
            "x-source": "M",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "signed"
            ],
            "description": "值域 note-status",
            "x-source": "C"
          },
          "reviewStatus": {
            "type": "string",
            "enum": [
              "saved",
              "pending",
              "completed"
            ],
            "description": "值域 review-status",
            "x-source": "C",
            "nullable": true
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "description": "存檔時間",
            "x-source": "C",
            "nullable": true
          },
          "signedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "signatureId": {
            "type": "string",
            "description": "→ signature.id",
            "x-source": "C",
            "nullable": true
          },
          "referenceIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "引用的量測／醫囑／診斷鍵（引用不複製）",
            "x-source": "M",
            "nullable": true
          },
          "diagnosisKeys": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "admission 至少一個 ICD 目錄鍵，第一個為主要",
            "x-source": "M",
            "nullable": true
          },
          "addendum": {
            "type": "boolean",
            "description": "封存後追加更正",
            "x-source": "C",
            "nullable": true
          },
          "copiedFromId": {
            "type": "string",
            "description": "複製前一日病程；→ note.id",
            "x-source": "C",
            "nullable": true
          },
          "source": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "encounterId",
          "noteType",
          "format",
          "clinicalAt",
          "authorId",
          "version",
          "status"
        ],
        "additionalProperties": false
      },
      "noteSection": {
        "title": "病歷段落（noteSection）",
        "description": "住院病歷／出院病摘的結構化欄位，一列一段。必填段落依 noteType，見 docs/10 §5。\n\nFHIR 對應：Composition.section\n\n原型 state：`notes[].sections{}`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "noteSection"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "noteId": {
            "type": "string",
            "description": "→ note.id",
            "x-source": "C"
          },
          "code": {
            "type": "string",
            "enum": [
              "CC",
              "illnessDay",
              "PI",
              "PH",
              "PHFamily",
              "vitalSummary",
              "examGeneral",
              "examCirculatory",
              "examRespiratory",
              "examDigestive",
              "examRenal",
              "examNeuro",
              "examMusculoskeletal",
              "examOther",
              "plannedTests",
              "summary",
              "initialAssessment",
              "differential",
              "prognosis",
              "treatmentPlan",
              "S",
              "O",
              "A",
              "P",
              "admissionDate",
              "admissionDiagnosis",
              "dischargeDate",
              "dischargeDiagnosis",
              "course",
              "labsSummary",
              "treatmentMethod",
              "proceduresSummary",
              "ordersSummary",
              "dischargeCondition",
              "followup",
              "referral",
              "dischargeReadiness",
              "dischargeBarriers",
              "dischargeFollowup",
              "educationAudience",
              "educationContent",
              "educationTeachBack"
            ],
            "description": "值域 note-section",
            "x-source": "M"
          },
          "text": {
            "type": "string",
            "maxLength": 5000,
            "x-source": "M"
          }
        },
        "required": [
          "resourceType",
          "id",
          "noteId",
          "code",
          "text"
        ],
        "additionalProperties": false
      },
      "signature": {
        "title": "簽章紀錄（signature）",
        "description": "展示身分確認，非正式電子簽章。\n\nFHIR 對應：Provenance.signature\n\n原型 state：`signatureRecords[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "signature"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "SIG…",
            "x-source": "C"
          },
          "documentId": {
            "type": "string",
            "x-source": "C"
          },
          "documentType": {
            "type": "string",
            "enum": [
              "note",
              "archive"
            ],
            "description": "值域 document-type",
            "x-source": "C"
          },
          "version": {
            "type": "number",
            "x-source": "C",
            "nullable": true
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "method": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "image": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "documentId",
          "documentType",
          "actorId"
        ],
        "additionalProperties": false
      },
      "goal": {
        "title": "本日問題與目標（goal）",
        "description": "FHIR 對應：Goal\n\n原型 state：`goals[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "goal"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "problem": {
            "type": "string",
            "x-source": "M"
          },
          "assessment": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "goal": {
            "type": "string",
            "x-source": "M"
          },
          "icdKey": {
            "type": "string",
            "description": "須為 active 的 icd 目錄鍵",
            "x-source": "M",
            "nullable": true
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "problem",
          "goal",
          "actorId"
        ],
        "additionalProperties": false
      },
      "careFocus": {
        "title": "醫師照顧重點（唯讀歷史）（careFocus）",
        "description": "FHIR 對應：Goal\n\n原型 state：`careFocuses[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "careFocus"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "text": {
            "type": "string",
            "x-source": "M"
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "text",
          "actorId"
        ],
        "additionalProperties": false
      },
      "communication": {
        "title": "必要溝通（communication）",
        "description": "照會醫師不能寫必要溝通。\n\nFHIR 對應：Communication(essential)\n\n原型 state：`communications[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "communication"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "kind": {
            "type": "string",
            "description": "值域 communication-kind",
            "x-source": "M"
          },
          "recipient": {
            "type": "string",
            "x-source": "M"
          },
          "text": {
            "type": "string",
            "x-source": "M"
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "kind",
          "recipient",
          "text",
          "actorId"
        ],
        "additionalProperties": false
      },
      "consultation": {
        "title": "照會（consultation）",
        "description": "回覆必指向照會單；只有被指派者能回覆；主治採納後才能當醫囑來源。\n\nFHIR 對應：ServiceRequest(consult)＋Communication(consult-reply)\n\n原型 state：`consultations[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "consultation"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "CONS…",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "specialty": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "urgency": {
            "type": "string",
            "enum": [
              "routine",
              "urgent"
            ],
            "description": "值域 consult-urgency",
            "x-source": "M"
          },
          "assigneeId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "M"
          },
          "subject": {
            "type": "string",
            "maxLength": 80,
            "x-source": "M",
            "nullable": true
          },
          "question": {
            "type": "string",
            "x-source": "M"
          },
          "requesterId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C"
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "requested",
              "completed"
            ],
            "description": "值域 consult-status",
            "x-source": "C"
          },
          "recommendation": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "responderId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "respondedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "adoptionDecision": {
            "type": "string",
            "enum": [
              "adopt",
              "decline",
              "follow"
            ],
            "description": "值域 adoption-decision",
            "x-source": "M",
            "nullable": true
          },
          "adoptionNote": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "adoptionById": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "adoptionAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "urgency",
          "assigneeId",
          "question",
          "requesterId",
          "status"
        ],
        "additionalProperties": false
      },
      "surgery": {
        "title": "手術紀錄（surgery）",
        "description": "手術醫師登打；交出後 ICU 主治／照護醫師接收。ICU 端唯讀。\n\nFHIR 對應：Procedure\n\n原型 state：`surgeries[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "surgery"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "OR…",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "procedure": {
            "type": "string",
            "x-source": "M"
          },
          "preDiagnosis": {
            "type": "string",
            "x-source": "M"
          },
          "postDiagnosis": {
            "type": "string",
            "x-source": "M"
          },
          "team": {
            "type": "string",
            "x-source": "M"
          },
          "events": {
            "type": "string",
            "x-source": "M"
          },
          "airway": {
            "type": "string",
            "x-source": "M"
          },
          "fluids": {
            "type": "string",
            "x-source": "M"
          },
          "lines": {
            "type": "string",
            "x-source": "M"
          },
          "pending": {
            "type": "string",
            "x-source": "M"
          },
          "recommendations": {
            "type": "string",
            "x-source": "M"
          },
          "start": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M"
          },
          "end": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M"
          },
          "authorId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C"
          },
          "version": {
            "type": "number",
            "x-source": "C",
            "nullable": true
          },
          "replacesId": {
            "type": "string",
            "description": "→ surgery.id",
            "x-source": "M",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "saved",
              "sent",
              "received"
            ],
            "description": "值域 surgery-status",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "sentAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "receiverId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "receivedById": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "procedure",
          "preDiagnosis",
          "postDiagnosis",
          "team",
          "events",
          "airway",
          "fluids",
          "lines",
          "pending",
          "recommendations",
          "start",
          "end",
          "authorId",
          "status"
        ],
        "additionalProperties": false
      },
      "handover": {
        "title": "交班（handover）",
        "description": "醫師 ISBAR、護理 SBAR；接收後才算完成，未接收前病人仍算在交出者身上。\n\nFHIR 對應：Composition(handover)\n\n原型 state：`handovers[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "handover"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "H…",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "role": {
            "type": "string",
            "enum": [
              "doctor",
              "nurse",
              "admin"
            ],
            "description": "值域 practitioner-role",
            "x-source": "C",
            "nullable": true
          },
          "shift": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "authorId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C"
          },
          "receiverId": {
            "type": "string",
            "description": "同角色、非本人；→ practitioner.id",
            "x-source": "M"
          },
          "version": {
            "type": "number",
            "x-source": "C",
            "nullable": true
          },
          "replacesId": {
            "type": "string",
            "description": "→ handover.id",
            "x-source": "M",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "更正時必填",
            "x-source": "M",
            "nullable": true
          },
          "batchId": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "format": {
            "type": "string",
            "enum": [
              "ISBAR",
              "SBAR"
            ],
            "description": "值域 handover-format",
            "x-source": "C"
          },
          "I": {
            "type": "string",
            "description": "身分確認；未填由病人識別資料帶入",
            "x-source": "P",
            "nullable": true
          },
          "S": {
            "type": "string",
            "x-source": "M"
          },
          "B": {
            "type": "string",
            "x-source": "M"
          },
          "A": {
            "type": "string",
            "x-source": "M"
          },
          "R": {
            "type": "string",
            "x-source": "M"
          },
          "summary": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "attendingTransferred": {
            "type": "boolean",
            "description": "主治是否一併轉移",
            "x-source": "M",
            "nullable": true
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "clinicalAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M",
            "nullable": true
          },
          "taskIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "交出時的未結工作快照",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "authorId",
          "receiverId",
          "format",
          "S",
          "B",
          "A",
          "R"
        ],
        "additionalProperties": false
      },
      "handoverReceipt": {
        "title": "交班接收（handoverReceipt）",
        "description": "FHIR 對應：Provenance(receive)\n\n原型 state：`receipts[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "handoverReceipt"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "handoverId": {
            "type": "string",
            "description": "→ handover.id",
            "x-source": "M"
          },
          "handoverVersion": {
            "type": "number",
            "x-source": "C",
            "nullable": true
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "clinicalAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "M",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "handoverId",
          "actorId"
        ],
        "additionalProperties": false
      },
      "archive": {
        "title": "病歷封存（archive）",
        "description": "出院登記 → 必要文件全部核定 → 封存（過渡期 0 或 24 小時）。\n\nFHIR 對應：—\n\n原型 state：`archives{}`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "archive"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "病人代理鍵（原型 `p`）；→ patient.id",
            "x-source": "M"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "grace",
              "sealed"
            ],
            "description": "值域 archive-status",
            "x-source": "C"
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "dueAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "sealedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          },
          "documentIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "x-source": "C",
            "nullable": true
          },
          "signatureId": {
            "type": "string",
            "description": "→ signature.id",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "patientId",
          "status",
          "actorId"
        ],
        "additionalProperties": false
      },
      "auditEvent": {
        "title": "稽核事件（auditEvent）",
        "description": "append-only；每一次寫入一列，八欄一個不能少。\n\nFHIR 對應：AuditEvent\n\n原型 state：`audit[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "auditEvent"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "revision": {
            "type": "number",
            "x-source": "C",
            "nullable": true
          },
          "action": {
            "type": "string",
            "description": "原型 action 名",
            "x-source": "C"
          },
          "actorId": {
            "type": "string",
            "description": "伺服器由 token 決定，不收前端值；→ practitioner.id",
            "x-source": "C"
          },
          "actorRole": {
            "type": "string",
            "enum": [
              "doctor",
              "nurse",
              "admin"
            ],
            "description": "當時的作業角色；值域 practitioner-role",
            "x-source": "C",
            "nullable": true
          },
          "patientId": {
            "type": "string",
            "description": "→ patient.id",
            "x-source": "C",
            "nullable": true
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C"
          },
          "target": {
            "type": "string",
            "description": "物件.欄位",
            "x-source": "C",
            "nullable": true
          },
          "oldValue": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "newValue": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          },
          "sourceScreen": {
            "type": "string",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "action",
          "actorId",
          "at"
        ],
        "additionalProperties": false
      },
      "draft": {
        "title": "草稿（draft）",
        "description": "伺服器端暫存格，換裝置看得到；內容不驗證。\n\nFHIR 對應：—\n\n原型 state：`drafts{}`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "draft"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "ownerId": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C"
          },
          "patientId": {
            "type": "string",
            "description": "→ patient.id",
            "x-source": "M",
            "nullable": true
          },
          "kind": {
            "type": "string",
            "enum": [
              "cart",
              "orderDetails",
              "note",
              "recordWriter:admission",
              "recordWriter:progress",
              "recordWriter:discharge",
              "surgery",
              "handover"
            ],
            "description": "值域 draft-kind",
            "x-source": "M"
          },
          "dataJson": {
            "type": "string",
            "description": "表單內容的 JSON 字串",
            "x-source": "M"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id",
          "ownerId",
          "kind",
          "dataJson"
        ],
        "additionalProperties": false
      },
      "settings": {
        "title": "維護設定（settings）",
        "description": "FHIR 對應：—\n\n原型 state：`settings`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "settings"
            ],
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "伺服器發的記錄代理鍵（字串）",
            "x-source": "C"
          },
          "version": {
            "type": "number",
            "x-source": "C",
            "nullable": true
          },
          "graceHours": {
            "type": "number",
            "description": "0 或 24",
            "x-source": "M",
            "nullable": true
          },
          "categoryOrder": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "medication",
                "labimaging",
                "procedure",
                "surgery",
                "supply",
                "diet",
                "other"
              ]
            },
            "description": "七類全含不重複；值域 order-category",
            "x-source": "M",
            "nullable": true
          },
          "templateAdmission": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "templateProgress": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "templateDischarge": {
            "type": "string",
            "x-source": "M",
            "nullable": true
          },
          "changedById": {
            "type": "string",
            "description": "→ practitioner.id",
            "x-source": "C",
            "nullable": true
          },
          "changedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})$",
            "x-source": "C",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "id"
        ],
        "additionalProperties": false
      },
      "orderCategory": {
        "title": "醫囑分類顯示名（orderCategory）",
        "description": "FHIR 對應：—\n\n原型 state：`settings.categories[]`\n\n取得（x-source）：M 輸入／P 帶入／H HIS 鏡像／C 系統計算；H／C 只在回應，請求送了也忽略。",
        "type": "object",
        "properties": {
          "resourceType": {
            "enum": [
              "orderCategory"
            ],
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "medication",
              "labimaging",
              "procedure",
              "surgery",
              "supply",
              "diet",
              "other"
            ],
            "description": "值域 order-category",
            "x-source": "M"
          },
          "label": {
            "type": "string",
            "x-source": "M"
          },
          "sortOrder": {
            "type": "number",
            "x-source": "M",
            "nullable": true
          }
        },
        "required": [
          "resourceType",
          "code",
          "label"
        ],
        "additionalProperties": false
      },
      "ErrorEnvelope": {
        "type": "object",
        "required": [
          "error",
          "status",
          "message"
        ],
        "description": "HTTP 狀態碼與 status 一致；message 是原型 must(...) 的訊息文字，前端直接顯示。",
        "properties": {
          "error": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "status": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "validationErrors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Records": {
        "type": "object",
        "description": "fhirfox 式混合陣列：一個陣列裝多種 resourceType，每筆獨立、扁平、順序無意義。",
        "required": [
          "records"
        ],
        "properties": {
          "patientId": {
            "type": "string",
            "nullable": true
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "revision": {
            "type": "integer",
            "description": "即 ETag"
          },
          "records": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/patient"
                },
                {
                  "$ref": "#/components/schemas/encounter"
                },
                {
                  "$ref": "#/components/schemas/allergy"
                },
                {
                  "$ref": "#/components/schemas/condition"
                },
                {
                  "$ref": "#/components/schemas/practitioner"
                },
                {
                  "$ref": "#/components/schemas/careRelationship"
                },
                {
                  "$ref": "#/components/schemas/rosterConfirmation"
                },
                {
                  "$ref": "#/components/schemas/catalogItem"
                },
                {
                  "$ref": "#/components/schemas/favorite"
                },
                {
                  "$ref": "#/components/schemas/order"
                },
                {
                  "$ref": "#/components/schemas/orderSafety"
                },
                {
                  "$ref": "#/components/schemas/execution"
                },
                {
                  "$ref": "#/components/schemas/infusionCheck"
                },
                {
                  "$ref": "#/components/schemas/observation"
                },
                {
                  "$ref": "#/components/schemas/report"
                },
                {
                  "$ref": "#/components/schemas/labResult"
                },
                {
                  "$ref": "#/components/schemas/reportReview"
                },
                {
                  "$ref": "#/components/schemas/task"
                },
                {
                  "$ref": "#/components/schemas/taskEvent"
                },
                {
                  "$ref": "#/components/schemas/note"
                },
                {
                  "$ref": "#/components/schemas/noteSection"
                },
                {
                  "$ref": "#/components/schemas/signature"
                },
                {
                  "$ref": "#/components/schemas/goal"
                },
                {
                  "$ref": "#/components/schemas/careFocus"
                },
                {
                  "$ref": "#/components/schemas/communication"
                },
                {
                  "$ref": "#/components/schemas/consultation"
                },
                {
                  "$ref": "#/components/schemas/surgery"
                },
                {
                  "$ref": "#/components/schemas/handover"
                },
                {
                  "$ref": "#/components/schemas/handoverReceipt"
                },
                {
                  "$ref": "#/components/schemas/archive"
                },
                {
                  "$ref": "#/components/schemas/auditEvent"
                },
                {
                  "$ref": "#/components/schemas/draft"
                },
                {
                  "$ref": "#/components/schemas/settings"
                },
                {
                  "$ref": "#/components/schemas/orderCategory"
                }
              ],
              "discriminator": {
                "propertyName": "resourceType"
              }
            }
          }
        }
      },
      "Capabilities": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "basePath": {
            "type": "string"
          },
          "resourceTypes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "patient",
                "encounter",
                "allergy",
                "condition",
                "practitioner",
                "careRelationship",
                "rosterConfirmation",
                "catalogItem",
                "favorite",
                "order",
                "orderSafety",
                "execution",
                "infusionCheck",
                "observation",
                "report",
                "labResult",
                "reportReview",
                "task",
                "taskEvent",
                "note",
                "noteSection",
                "signature",
                "goal",
                "careFocus",
                "communication",
                "consultation",
                "surgery",
                "handover",
                "handoverReceipt",
                "archive",
                "auditEvent",
                "draft",
                "settings",
                "orderCategory"
              ]
            }
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                },
                "roles": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "errorCodes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "BatchRequest": {
        "type": "object",
        "required": [
          "items"
        ],
        "description": "一個交易寫多筆，全成功或全退回。",
        "properties": {
          "items": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": [
                "op",
                "endpoint"
              ],
              "properties": {
                "op": {
                  "type": "string",
                  "enum": [
                    "create",
                    "update",
                    "action"
                  ]
                },
                "endpoint": {
                  "type": "string",
                  "description": "例 `POST /tasks`、`POST /orders/M1/sign`"
                },
                "record": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "BatchResponse": {
        "type": "object",
        "required": [
          "results"
        ],
        "properties": {
          "results": {
            "type": "array",
            "description": "與 items 等長",
            "items": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer"
                },
                "record": {
                  "type": "object",
                  "additionalProperties": true
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ValueSet": {
        "type": "object",
        "required": [
          "name",
          "values"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "labelZh": {
            "type": "string"
          },
          "fhir": {
            "type": "string"
          },
          "open": {
            "type": "boolean",
            "description": "true＝允許表外自訂文字"
          },
          "values": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "code"
              ],
              "properties": {
                "code": {
                  "type": "string"
                },
                "labelZh": {
                  "type": "string"
                },
                "fhirCode": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "OrderSet": {
        "type": "object",
        "required": [
          "id",
          "name",
          "catalogKeys"
        ],
        "description": "套組（UI 標籤，未經院方核准）",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "groupId": {
            "type": "string",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "nullable": true
          },
          "catalogKeys": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Coverage": {
        "type": "object",
        "description": "用藥安全比對涵蓋率：無 ATC 的藥品無法比對。沒有提示不等於已確認安全。",
        "required": [
          "total",
          "checked",
          "missing"
        ],
        "properties": {
          "total": {
            "type": "integer"
          },
          "checked": {
            "type": "integer"
          },
          "missing": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "x-value-sets": {
    "gender": {
      "labelZh": "性別",
      "fhir": "http://hl7.org/fhir/administrative-gender",
      "open": false,
      "values": [
        {
          "code": "male",
          "labelZh": "男",
          "fhirCode": "male"
        },
        {
          "code": "female",
          "labelZh": "女",
          "fhirCode": "female"
        },
        {
          "code": "other",
          "labelZh": "其他",
          "fhirCode": "other"
        },
        {
          "code": "unknown",
          "labelZh": "未知",
          "fhirCode": "unknown"
        }
      ]
    },
    "flag-code": {
      "labelZh": "特殊註記",
      "fhir": "Flag.code（院內碼）",
      "open": false,
      "values": [
        {
          "code": "ALG",
          "labelZh": "過敏",
          "fhirCode": null
        },
        {
          "code": "ISO",
          "labelZh": "接觸隔離",
          "fhirCode": null
        },
        {
          "code": "DNR",
          "labelZh": "DNR",
          "fhirCode": null
        },
        {
          "code": "FALL",
          "labelZh": "跌倒高風險",
          "fhirCode": null
        },
        {
          "code": "LINE",
          "labelZh": "中心導管",
          "fhirCode": null
        },
        {
          "code": "VENT",
          "labelZh": "呼吸器",
          "fhirCode": null
        },
        {
          "code": "RESTRICT",
          "labelZh": "限水",
          "fhirCode": null
        }
      ]
    },
    "allergy-status": {
      "labelZh": "過敏登錄狀態",
      "fhir": "—（Patient 層摘要）",
      "open": false,
      "values": [
        {
          "code": "unknown",
          "labelZh": "來源未記錄，不能視為無過敏",
          "fhirCode": null
        },
        {
          "code": "none-known",
          "labelZh": "登錄為無已知過敏",
          "fhirCode": null
        },
        {
          "code": "recorded",
          "labelZh": "有已知過敏，見 allergy 記錄",
          "fhirCode": null
        }
      ]
    },
    "allergy-clinical": {
      "labelZh": "過敏臨床狀態",
      "fhir": "allergyintolerance-clinical",
      "open": false,
      "values": [
        {
          "code": "active",
          "labelZh": "有效",
          "fhirCode": null
        },
        {
          "code": "inactive",
          "labelZh": "非有效",
          "fhirCode": null
        },
        {
          "code": "resolved",
          "labelZh": "已解除",
          "fhirCode": null
        }
      ]
    },
    "allergy-verification": {
      "labelZh": "過敏驗證狀態",
      "fhir": "allergyintolerance-verification",
      "open": false,
      "values": [
        {
          "code": "unconfirmed",
          "labelZh": "未確認",
          "fhirCode": null
        },
        {
          "code": "confirmed",
          "labelZh": "已確認",
          "fhirCode": null
        },
        {
          "code": "refuted",
          "labelZh": "已排除",
          "fhirCode": null
        },
        {
          "code": "entered-in-error",
          "labelZh": "誤建",
          "fhirCode": null
        }
      ]
    },
    "allergy-type": {
      "labelZh": "過敏類型",
      "fhir": "allergy-intolerance-type",
      "open": false,
      "values": [
        {
          "code": "allergy",
          "labelZh": "過敏",
          "fhirCode": null
        },
        {
          "code": "intolerance",
          "labelZh": "不耐受",
          "fhirCode": null
        }
      ]
    },
    "allergy-category": {
      "labelZh": "過敏原類別",
      "fhir": "allergy-intolerance-category",
      "open": false,
      "values": [
        {
          "code": "medication",
          "labelZh": "藥物",
          "fhirCode": null
        },
        {
          "code": "food",
          "labelZh": "食物",
          "fhirCode": null
        },
        {
          "code": "environment",
          "labelZh": "環境",
          "fhirCode": null
        },
        {
          "code": "biologic",
          "labelZh": "生物製劑",
          "fhirCode": null
        }
      ]
    },
    "allergy-criticality": {
      "labelZh": "過敏危急度",
      "fhir": "allergy-intolerance-criticality",
      "open": false,
      "values": [
        {
          "code": "low",
          "labelZh": "低",
          "fhirCode": null
        },
        {
          "code": "high",
          "labelZh": "高",
          "fhirCode": null
        },
        {
          "code": "unable-to-assess",
          "labelZh": "無法評估",
          "fhirCode": null
        }
      ]
    },
    "reaction-severity": {
      "labelZh": "反應嚴重度",
      "fhir": "reaction-event-severity",
      "open": false,
      "values": [
        {
          "code": "mild",
          "labelZh": "輕",
          "fhirCode": null
        },
        {
          "code": "moderate",
          "labelZh": "中",
          "fhirCode": null
        },
        {
          "code": "severe",
          "labelZh": "重",
          "fhirCode": null
        }
      ]
    },
    "substance-kind": {
      "labelZh": "過敏原種類",
      "fhir": "—",
      "open": false,
      "values": [
        {
          "code": "medication",
          "labelZh": "藥品品項",
          "fhirCode": null
        },
        {
          "code": "ingredient",
          "labelZh": "成分",
          "fhirCode": null
        },
        {
          "code": "class",
          "labelZh": "藥理類別",
          "fhirCode": null
        }
      ]
    },
    "condition-category": {
      "labelZh": "診斷類別",
      "fhir": "condition-category",
      "open": false,
      "values": [
        {
          "code": "encounter-diagnosis",
          "labelZh": "本次就醫診斷",
          "fhirCode": null
        },
        {
          "code": "problem-list-item",
          "labelZh": "問題清單",
          "fhirCode": null
        }
      ]
    },
    "condition-clinical": {
      "labelZh": "診斷臨床狀態",
      "fhir": "condition-clinical",
      "open": false,
      "values": [
        {
          "code": "active",
          "labelZh": "有效",
          "fhirCode": null
        },
        {
          "code": "recurrence",
          "labelZh": "復發",
          "fhirCode": null
        },
        {
          "code": "relapse",
          "labelZh": "再發",
          "fhirCode": null
        },
        {
          "code": "inactive",
          "labelZh": "非有效",
          "fhirCode": null
        },
        {
          "code": "remission",
          "labelZh": "緩解",
          "fhirCode": null
        },
        {
          "code": "resolved",
          "labelZh": "已解除",
          "fhirCode": null
        }
      ]
    },
    "condition-verification": {
      "labelZh": "診斷驗證狀態",
      "fhir": "condition-ver-status",
      "open": false,
      "values": [
        {
          "code": "unconfirmed",
          "labelZh": "未確認",
          "fhirCode": null
        },
        {
          "code": "provisional",
          "labelZh": "暫定",
          "fhirCode": null
        },
        {
          "code": "differential",
          "labelZh": "鑑別",
          "fhirCode": null
        },
        {
          "code": "confirmed",
          "labelZh": "確立",
          "fhirCode": null
        },
        {
          "code": "refuted",
          "labelZh": "排除",
          "fhirCode": null
        },
        {
          "code": "entered-in-error",
          "labelZh": "誤建",
          "fhirCode": null
        }
      ]
    },
    "condition-stage": {
      "labelZh": "診斷階段",
      "fhir": "—（院內）",
      "open": false,
      "values": [
        {
          "code": "admission",
          "labelZh": "入院",
          "fhirCode": null
        },
        {
          "code": "icu",
          "labelZh": "ICU 期間",
          "fhirCode": null
        },
        {
          "code": "discharge",
          "labelZh": "出院",
          "fhirCode": null
        }
      ]
    },
    "condition-rank": {
      "labelZh": "主次診斷",
      "fhir": "Encounter.diagnosis.rank",
      "open": false,
      "values": [
        {
          "code": "primary",
          "labelZh": "主要",
          "fhirCode": null
        },
        {
          "code": "secondary",
          "labelZh": "次要",
          "fhirCode": null
        }
      ]
    },
    "practitioner-role": {
      "labelZh": "人員類別",
      "fhir": "PractitionerRole.code",
      "open": false,
      "values": [
        {
          "code": "doctor",
          "labelZh": "醫師",
          "fhirCode": null
        },
        {
          "code": "nurse",
          "labelZh": "護理師",
          "fhirCode": null
        },
        {
          "code": "admin",
          "labelZh": "管理者",
          "fhirCode": null
        }
      ]
    },
    "care-role": {
      "labelZh": "照護關係身分",
      "fhir": "CareTeam.participant.role",
      "open": false,
      "values": [
        {
          "code": "attending",
          "labelZh": "主治醫師",
          "fhirCode": null
        },
        {
          "code": "care",
          "labelZh": "科內照護",
          "fhirCode": null
        },
        {
          "code": "consult",
          "labelZh": "跨科會診",
          "fhirCode": null
        },
        {
          "code": "nurse",
          "labelZh": "護理照護",
          "fhirCode": null
        },
        {
          "code": "surgeon",
          "labelZh": "手術醫師",
          "fhirCode": null
        }
      ]
    },
    "relationship-via": {
      "labelZh": "照護關係來源",
      "fhir": "—",
      "open": false,
      "values": [
        {
          "code": "seed",
          "labelZh": "院方預先分派",
          "fhirCode": null
        },
        {
          "code": "admit",
          "labelZh": "接診登錄",
          "fhirCode": null
        },
        {
          "code": "handover",
          "labelZh": "交班承接",
          "fhirCode": null
        },
        {
          "code": "consult",
          "labelZh": "照會指派",
          "fhirCode": null
        },
        {
          "code": "settings",
          "labelZh": "維護設定",
          "fhirCode": null
        }
      ]
    },
    "catalog-kind": {
      "labelZh": "目錄品項種類",
      "fhir": "—（B 目錄）",
      "open": false,
      "values": [
        {
          "code": "service",
          "labelZh": "醫療服務",
          "fhirCode": null
        },
        {
          "code": "medication",
          "labelZh": "藥品",
          "fhirCode": null
        },
        {
          "code": "supply",
          "labelZh": "衛材",
          "fhirCode": null
        },
        {
          "code": "diet",
          "labelZh": "飲食",
          "fhirCode": null
        },
        {
          "code": "icd",
          "labelZh": "ICD-10",
          "fhirCode": null
        },
        {
          "code": "route",
          "labelZh": "給藥途徑",
          "fhirCode": null
        },
        {
          "code": "unit",
          "labelZh": "計量單位",
          "fhirCode": null
        }
      ]
    },
    "order-kind": {
      "labelZh": "醫囑種類",
      "fhir": "MedicationRequest／ServiceRequest",
      "open": false,
      "values": [
        {
          "code": "medication",
          "labelZh": "藥囑 → MedicationRequest",
          "fhirCode": null
        },
        {
          "code": "service",
          "labelZh": "服務（檢驗檢查／處置） → ServiceRequest",
          "fhirCode": null
        },
        {
          "code": "care",
          "labelZh": "照護 → ServiceRequest",
          "fhirCode": null
        }
      ]
    },
    "order-category": {
      "labelZh": "醫囑七分類",
      "fhir": "ServiceRequest.category（院內）",
      "open": false,
      "values": [
        {
          "code": "medication",
          "labelZh": "藥囑",
          "fhirCode": null
        },
        {
          "code": "labimaging",
          "labelZh": "檢驗檢查",
          "fhirCode": null
        },
        {
          "code": "procedure",
          "labelZh": "處置",
          "fhirCode": null
        },
        {
          "code": "surgery",
          "labelZh": "手術麻醉",
          "fhirCode": null
        },
        {
          "code": "supply",
          "labelZh": "衛材",
          "fhirCode": null
        },
        {
          "code": "diet",
          "labelZh": "飲食",
          "fhirCode": null
        },
        {
          "code": "other",
          "labelZh": "其他",
          "fhirCode": null
        }
      ]
    },
    "dosing-mode": {
      "labelZh": "給藥模式",
      "fhir": "Dosage.timing／asNeeded／rate",
      "open": false,
      "values": [
        {
          "code": "once",
          "labelZh": "單次／STAT",
          "fhirCode": null
        },
        {
          "code": "scheduled",
          "labelZh": "排定重複",
          "fhirCode": null
        },
        {
          "code": "prn",
          "labelZh": "需要時 PRN",
          "fhirCode": null
        },
        {
          "code": "infusion",
          "labelZh": "連續輸注",
          "fhirCode": null
        }
      ]
    },
    "frequency": {
      "labelZh": "執行頻率（排定重複用；自訂文字亦可）",
      "fhir": "Dosage.timing.code",
      "open": true,
      "values": [
        {
          "code": "STAT（立即）",
          "labelZh": "立即與單次",
          "fhirCode": null
        },
        {
          "code": "本次",
          "labelZh": "立即與單次",
          "fhirCode": null
        },
        {
          "code": "術前一次",
          "labelZh": "立即與單次",
          "fhirCode": null
        },
        {
          "code": "睡前一次（HS）",
          "labelZh": "立即與單次",
          "fhirCode": null
        },
        {
          "code": "QD（每日 1 次）",
          "labelZh": "每日固定",
          "fhirCode": null
        },
        {
          "code": "BID（每日 2 次）",
          "labelZh": "每日固定",
          "fhirCode": null
        },
        {
          "code": "TID（每日 3 次）",
          "labelZh": "每日固定",
          "fhirCode": null
        },
        {
          "code": "QID（每日 4 次）",
          "labelZh": "每日固定",
          "fhirCode": null
        },
        {
          "code": "Q2H（每 2 小時）",
          "labelZh": "固定間隔",
          "fhirCode": null
        },
        {
          "code": "Q4H（每 4 小時）",
          "labelZh": "固定間隔",
          "fhirCode": null
        },
        {
          "code": "Q6H（每 6 小時）",
          "labelZh": "固定間隔",
          "fhirCode": null
        },
        {
          "code": "Q8H（每 8 小時）",
          "labelZh": "固定間隔",
          "fhirCode": null
        },
        {
          "code": "Q12H（每 12 小時）",
          "labelZh": "固定間隔",
          "fhirCode": null
        },
        {
          "code": "QOD（隔日一次）",
          "labelZh": "間隔天數",
          "fhirCode": null
        },
        {
          "code": "每週三次",
          "labelZh": "間隔天數",
          "fhirCode": null
        },
        {
          "code": "QW（每週一次）",
          "labelZh": "間隔天數",
          "fhirCode": null
        },
        {
          "code": "PRN（需要時）",
          "labelZh": "需要時",
          "fhirCode": null
        },
        {
          "code": "連續輸注",
          "labelZh": "持續",
          "fhirCode": null
        },
        {
          "code": "持續監測",
          "labelZh": "持續",
          "fhirCode": null
        }
      ]
    },
    "order-clinical-status": {
      "labelZh": "醫囑臨床狀態",
      "fhir": "MedicationRequest.status",
      "open": false,
      "values": [
        {
          "code": "draft",
          "labelZh": "草稿",
          "fhirCode": "draft"
        },
        {
          "code": "active",
          "labelZh": "有效",
          "fhirCode": "active"
        },
        {
          "code": "stopped",
          "labelZh": "已停止",
          "fhirCode": "stopped"
        },
        {
          "code": "cancelled",
          "labelZh": "已取消",
          "fhirCode": "cancelled"
        }
      ]
    },
    "order-local-status": {
      "labelZh": "醫囑本地簽署狀態",
      "fhir": "—（Provenance）",
      "open": false,
      "values": [
        {
          "code": "draft",
          "labelZh": "未簽署",
          "fhirCode": null
        },
        {
          "code": "signed",
          "labelZh": "已簽署",
          "fhirCode": null
        }
      ]
    },
    "his-status": {
      "labelZh": "HIS 送出狀態",
      "fhir": "—（L3 回寫）",
      "open": false,
      "values": [
        {
          "code": "notSent",
          "labelZh": "未送出",
          "fhirCode": null
        },
        {
          "code": "sent",
          "labelZh": "已送出待回應",
          "fhirCode": null
        },
        {
          "code": "accepted",
          "labelZh": "HIS 已接受",
          "fhirCode": null
        },
        {
          "code": "rejected",
          "labelZh": "HIS 拒絕",
          "fhirCode": null
        },
        {
          "code": "unknown",
          "labelZh": "逾時結果未知・禁止重送",
          "fhirCode": null
        }
      ]
    },
    "safety-severity": {
      "labelZh": "用藥安全嚴重度",
      "fhir": "DetectedIssue.severity",
      "open": false,
      "values": [
        {
          "code": "high",
          "labelZh": "高（禁忌，須覆寫理由）",
          "fhirCode": null
        },
        {
          "code": "moderate",
          "labelZh": "中（須選處理方式）",
          "fhirCode": null
        }
      ]
    },
    "safety-kind": {
      "labelZh": "用藥安全提示種類",
      "fhir": "DetectedIssue.code",
      "open": false,
      "values": [
        {
          "code": "duplicate",
          "labelZh": "重複用藥",
          "fhirCode": null
        },
        {
          "code": "interaction",
          "labelZh": "交互作用",
          "fhirCode": null
        }
      ]
    },
    "safety-decision": {
      "labelZh": "提示處理結果",
      "fhir": "DetectedIssue.mitigation",
      "open": false,
      "values": [
        {
          "code": "shown",
          "labelZh": "已顯示",
          "fhirCode": null
        },
        {
          "code": "handled",
          "labelZh": "已選處理方式",
          "fhirCode": null
        },
        {
          "code": "override",
          "labelZh": "覆寫（禁忌）",
          "fhirCode": null
        }
      ]
    },
    "execution-status": {
      "labelZh": "執行狀態",
      "fhir": "MedicationAdministration.status",
      "open": false,
      "values": [
        {
          "code": "done",
          "labelZh": "已執行",
          "fhirCode": "completed"
        },
        {
          "code": "held",
          "labelZh": "延遲／暫停",
          "fhirCode": "on-hold"
        },
        {
          "code": "notDone",
          "labelZh": "未執行",
          "fhirCode": "not-done"
        }
      ]
    },
    "review-outcome": {
      "labelZh": "執行核對結論",
      "fhir": "—（Provenance）",
      "open": false,
      "values": [
        {
          "code": "reviewed",
          "labelZh": "已核對無差異",
          "fhirCode": null
        },
        {
          "code": "difference",
          "labelZh": "有差異",
          "fhirCode": null
        }
      ]
    },
    "observation-code": {
      "labelZh": "量測項目",
      "fhir": "LOINC",
      "open": false,
      "values": [
        {
          "code": "HR",
          "labelZh": "心率 /min",
          "fhirCode": "8867-4"
        },
        {
          "code": "TEMP",
          "labelZh": "體溫 °C",
          "fhirCode": "8310-5"
        },
        {
          "code": "RR",
          "labelZh": "呼吸頻率 /min",
          "fhirCode": "9279-1"
        },
        {
          "code": "SPO2",
          "labelZh": "SpO₂ %",
          "fhirCode": "59408-5"
        },
        {
          "code": "SBP",
          "labelZh": "收縮壓 mmHg",
          "fhirCode": "8480-6"
        },
        {
          "code": "DBP",
          "labelZh": "舒張壓 mmHg",
          "fhirCode": "8462-4"
        },
        {
          "code": "WT",
          "labelZh": "體重 kg",
          "fhirCode": "29463-7"
        },
        {
          "code": "IN",
          "labelZh": "入量 mL",
          "fhirCode": "—"
        },
        {
          "code": "OUT",
          "labelZh": "出量 mL",
          "fhirCode": "—"
        }
      ]
    },
    "observation-entry": {
      "labelZh": "量測來源方式",
      "fhir": "—",
      "open": false,
      "values": [
        {
          "code": "manual",
          "labelZh": "手動輸入",
          "fhirCode": null
        },
        {
          "code": "device",
          "labelZh": "儀器讀取",
          "fhirCode": null
        },
        {
          "code": "import",
          "labelZh": "HIS／展示匯入",
          "fhirCode": null
        }
      ]
    },
    "report-kind": {
      "labelZh": "報告種類",
      "fhir": "DiagnosticReport.category",
      "open": false,
      "values": [
        {
          "code": "lab",
          "labelZh": "檢驗",
          "fhirCode": "LAB"
        },
        {
          "code": "imaging",
          "labelZh": "影像",
          "fhirCode": "RAD"
        },
        {
          "code": "exam",
          "labelZh": "檢查／其他",
          "fhirCode": "OTH"
        }
      ]
    },
    "report-status": {
      "labelZh": "報告狀態",
      "fhir": "DiagnosticReport.status",
      "open": false,
      "values": [
        {
          "code": "pending",
          "labelZh": "待回",
          "fhirCode": "registered"
        },
        {
          "code": "returned",
          "labelZh": "已回",
          "fhirCode": "final"
        },
        {
          "code": "cancelled",
          "labelZh": "已取消",
          "fhirCode": "cancelled"
        }
      ]
    },
    "interpretation": {
      "labelZh": "檢驗判讀旗標（來源給，不計算）",
      "fhir": "v3-ObservationInterpretation",
      "open": false,
      "values": [
        {
          "code": "N",
          "labelZh": "正常",
          "fhirCode": null
        },
        {
          "code": "H",
          "labelZh": "偏高",
          "fhirCode": null
        },
        {
          "code": "L",
          "labelZh": "偏低",
          "fhirCode": null
        },
        {
          "code": "HH",
          "labelZh": "極高",
          "fhirCode": null
        },
        {
          "code": "LL",
          "labelZh": "極低",
          "fhirCode": null
        },
        {
          "code": "A",
          "labelZh": "異常",
          "fhirCode": null
        },
        {
          "code": "AA",
          "labelZh": "極異常",
          "fhirCode": null
        },
        {
          "code": "POS",
          "labelZh": "陽性",
          "fhirCode": null
        },
        {
          "code": "NEG",
          "labelZh": "陰性",
          "fhirCode": null
        },
        {
          "code": "DET",
          "labelZh": "檢出",
          "fhirCode": null
        },
        {
          "code": "ND",
          "labelZh": "未檢出",
          "fhirCode": null
        }
      ]
    },
    "result-classification": {
      "labelZh": "結果分類（伺服器只依 interpretation 推）",
      "fhir": "—",
      "open": false,
      "values": [
        {
          "code": "pending",
          "labelZh": "待回",
          "fhirCode": null
        },
        {
          "code": "abnormal",
          "labelZh": "異常",
          "fhirCode": null
        },
        {
          "code": "normal",
          "labelZh": "正常",
          "fhirCode": null
        },
        {
          "code": "unknown",
          "labelZh": "無旗標",
          "fhirCode": null
        },
        {
          "code": "unavailable",
          "labelZh": "尚未取得關聯結果",
          "fhirCode": null
        }
      ]
    },
    "review-action": {
      "labelZh": "報告閱讀／處理動作",
      "fhir": "Provenance.activity",
      "open": false,
      "values": [
        {
          "code": "seen",
          "labelZh": "已閱",
          "fhirCode": null
        },
        {
          "code": "processed",
          "labelZh": "已判讀處理",
          "fhirCode": null
        }
      ]
    },
    "task-status": {
      "labelZh": "工作狀態",
      "fhir": "Task.status",
      "open": false,
      "values": [
        {
          "code": "open",
          "labelZh": "待處理",
          "fhirCode": "requested"
        },
        {
          "code": "accepted",
          "labelZh": "已接受",
          "fhirCode": "accepted"
        },
        {
          "code": "waiting",
          "labelZh": "等待中",
          "fhirCode": "on-hold"
        },
        {
          "code": "done",
          "labelZh": "已完成",
          "fhirCode": "completed"
        }
      ]
    },
    "note-type": {
      "labelZh": "病歷類型",
      "fhir": "Composition.type",
      "open": false,
      "values": [
        {
          "code": "admission",
          "labelZh": "住院病歷（入院診察）",
          "fhirCode": null
        },
        {
          "code": "progress",
          "labelZh": "病程記錄 SOAP",
          "fhirCode": null
        },
        {
          "code": "discharge",
          "labelZh": "出院病歷摘要",
          "fhirCode": null
        },
        {
          "code": "nursing",
          "labelZh": "護理紀錄",
          "fhirCode": null
        },
        {
          "code": "free",
          "labelZh": "自由文字病程",
          "fhirCode": null
        }
      ]
    },
    "note-format": {
      "labelZh": "病歷格式",
      "fhir": "—",
      "open": false,
      "values": [
        {
          "code": "soap",
          "labelZh": "SOAP 四段",
          "fhirCode": null
        },
        {
          "code": "text",
          "labelZh": "全文",
          "fhirCode": null
        },
        {
          "code": "sections",
          "labelZh": "結構化段落（見 noteSection）",
          "fhirCode": null
        }
      ]
    },
    "note-status": {
      "labelZh": "病歷簽署狀態",
      "fhir": "Composition.status",
      "open": false,
      "values": [
        {
          "code": "draft",
          "labelZh": "草稿",
          "fhirCode": "preliminary"
        },
        {
          "code": "signed",
          "labelZh": "已簽名",
          "fhirCode": "final"
        }
      ]
    },
    "review-status": {
      "labelZh": "病歷確認狀態",
      "fhir": "—（Provenance）",
      "open": false,
      "values": [
        {
          "code": "saved",
          "labelZh": "已存檔・待確認",
          "fhirCode": null
        },
        {
          "code": "pending",
          "labelZh": "已簽名・待確認",
          "fhirCode": null
        },
        {
          "code": "completed",
          "labelZh": "已確認",
          "fhirCode": null
        }
      ]
    },
    "note-section": {
      "labelZh": "病歷段落代碼",
      "fhir": "Composition.section.code",
      "open": false,
      "values": [
        {
          "code": "CC",
          "labelZh": "入院理由",
          "fhirCode": null
        },
        {
          "code": "illnessDay",
          "labelZh": "於發病第幾天入院",
          "fhirCode": null
        },
        {
          "code": "PI",
          "labelZh": "病程經過",
          "fhirCode": null
        },
        {
          "code": "PH",
          "labelZh": "過去病史（本人）",
          "fhirCode": null
        },
        {
          "code": "PHFamily",
          "labelZh": "過去病史（家族）",
          "fhirCode": null
        },
        {
          "code": "vitalSummary",
          "labelZh": "入院生命徵象",
          "fhirCode": null
        },
        {
          "code": "examGeneral",
          "labelZh": "身體診察（全身）",
          "fhirCode": null
        },
        {
          "code": "examCirculatory",
          "labelZh": "循環系統",
          "fhirCode": null
        },
        {
          "code": "examRespiratory",
          "labelZh": "呼吸系統",
          "fhirCode": null
        },
        {
          "code": "examDigestive",
          "labelZh": "消化系統",
          "fhirCode": null
        },
        {
          "code": "examRenal",
          "labelZh": "腎臟泌尿生殖",
          "fhirCode": null
        },
        {
          "code": "examNeuro",
          "labelZh": "神經系統",
          "fhirCode": null
        },
        {
          "code": "examMusculoskeletal",
          "labelZh": "肌肉骨骼關節",
          "fhirCode": null
        },
        {
          "code": "examOther",
          "labelZh": "五官口腔營養皮膚及其它",
          "fhirCode": null
        },
        {
          "code": "plannedTests",
          "labelZh": "待做檢驗檢查",
          "fhirCode": null
        },
        {
          "code": "summary",
          "labelZh": "病歷摘要",
          "fhirCode": null
        },
        {
          "code": "initialAssessment",
          "labelZh": "初步評估",
          "fhirCode": null
        },
        {
          "code": "differential",
          "labelZh": "鑑別診斷",
          "fhirCode": null
        },
        {
          "code": "prognosis",
          "labelZh": "預後",
          "fhirCode": null
        },
        {
          "code": "treatmentPlan",
          "labelZh": "治療方向",
          "fhirCode": null
        },
        {
          "code": "S",
          "labelZh": "S 主觀資料",
          "fhirCode": null
        },
        {
          "code": "O",
          "labelZh": "O 客觀資料",
          "fhirCode": null
        },
        {
          "code": "A",
          "labelZh": "A 評估",
          "fhirCode": null
        },
        {
          "code": "P",
          "labelZh": "P 計畫",
          "fhirCode": null
        },
        {
          "code": "admissionDate",
          "labelZh": "入院日期",
          "fhirCode": null
        },
        {
          "code": "admissionDiagnosis",
          "labelZh": "入院診斷",
          "fhirCode": null
        },
        {
          "code": "dischargeDate",
          "labelZh": "出院日期",
          "fhirCode": null
        },
        {
          "code": "dischargeDiagnosis",
          "labelZh": "出院診斷",
          "fhirCode": null
        },
        {
          "code": "course",
          "labelZh": "病理過程與臨床演變",
          "fhirCode": null
        },
        {
          "code": "labsSummary",
          "labelZh": "具診斷價值之檢驗檢查摘要",
          "fhirCode": null
        },
        {
          "code": "treatmentMethod",
          "labelZh": "治療方法",
          "fhirCode": null
        },
        {
          "code": "proceduresSummary",
          "labelZh": "重要手術與處置",
          "fhirCode": null
        },
        {
          "code": "ordersSummary",
          "labelZh": "已執行醫囑",
          "fhirCode": null
        },
        {
          "code": "dischargeCondition",
          "labelZh": "出院時病況",
          "fhirCode": null
        },
        {
          "code": "followup",
          "labelZh": "後續治療方向與醫囑",
          "fhirCode": null
        },
        {
          "code": "referral",
          "labelZh": "轉診建議",
          "fhirCode": null
        },
        {
          "code": "dischargeReadiness",
          "labelZh": "出院準備現況",
          "fhirCode": null
        },
        {
          "code": "dischargeBarriers",
          "labelZh": "出院障礙",
          "fhirCode": null
        },
        {
          "code": "dischargeFollowup",
          "labelZh": "追蹤與轉銜準備",
          "fhirCode": null
        },
        {
          "code": "educationAudience",
          "labelZh": "衛教對象",
          "fhirCode": null
        },
        {
          "code": "educationContent",
          "labelZh": "衛教內容",
          "fhirCode": null
        },
        {
          "code": "educationTeachBack",
          "labelZh": "理解確認",
          "fhirCode": null
        }
      ]
    },
    "document-type": {
      "labelZh": "簽章對象",
      "fhir": "Provenance.target",
      "open": false,
      "values": [
        {
          "code": "note",
          "labelZh": "病歷",
          "fhirCode": null
        },
        {
          "code": "archive",
          "labelZh": "病歷封存",
          "fhirCode": null
        }
      ]
    },
    "communication-kind": {
      "labelZh": "必要溝通種類",
      "fhir": "Communication.category",
      "open": true,
      "values": [
        {
          "code": "家屬溝通",
          "labelZh": "家屬溝通",
          "fhirCode": null
        },
        {
          "code": "跨科溝通",
          "labelZh": "跨科溝通",
          "fhirCode": null
        },
        {
          "code": "其他",
          "labelZh": "其他",
          "fhirCode": null
        }
      ]
    },
    "consult-urgency": {
      "labelZh": "照會急迫度",
      "fhir": "ServiceRequest.priority",
      "open": false,
      "values": [
        {
          "code": "routine",
          "labelZh": "常規",
          "fhirCode": "routine"
        },
        {
          "code": "urgent",
          "labelZh": "緊急",
          "fhirCode": "urgent"
        }
      ]
    },
    "consult-status": {
      "labelZh": "照會狀態",
      "fhir": "ServiceRequest.status",
      "open": false,
      "values": [
        {
          "code": "requested",
          "labelZh": "已發出待回覆",
          "fhirCode": "active"
        },
        {
          "code": "completed",
          "labelZh": "已回覆",
          "fhirCode": "completed"
        }
      ]
    },
    "adoption-decision": {
      "labelZh": "照會建議採納",
      "fhir": "—",
      "open": false,
      "values": [
        {
          "code": "adopt",
          "labelZh": "採納",
          "fhirCode": null
        },
        {
          "code": "decline",
          "labelZh": "不採納",
          "fhirCode": null
        },
        {
          "code": "follow",
          "labelZh": "持續追蹤",
          "fhirCode": null
        }
      ]
    },
    "surgery-status": {
      "labelZh": "手術紀錄狀態",
      "fhir": "Procedure.status",
      "open": false,
      "values": [
        {
          "code": "saved",
          "labelZh": "已登打",
          "fhirCode": null
        },
        {
          "code": "sent",
          "labelZh": "已交出 ICU",
          "fhirCode": null
        },
        {
          "code": "received",
          "labelZh": "ICU 已接收",
          "fhirCode": null
        }
      ]
    },
    "handover-format": {
      "labelZh": "交班格式",
      "fhir": "Composition.type",
      "open": false,
      "values": [
        {
          "code": "ISBAR",
          "labelZh": "醫師 ISBAR",
          "fhirCode": null
        },
        {
          "code": "SBAR",
          "labelZh": "護理 SBAR",
          "fhirCode": null
        }
      ]
    },
    "archive-status": {
      "labelZh": "病歷封存狀態",
      "fhir": "—",
      "open": false,
      "values": [
        {
          "code": "open",
          "labelZh": "未封存",
          "fhirCode": null
        },
        {
          "code": "grace",
          "labelZh": "過渡期",
          "fhirCode": null
        },
        {
          "code": "sealed",
          "labelZh": "已封存",
          "fhirCode": null
        }
      ]
    },
    "favorite-scope": {
      "labelZh": "常用清單範圍",
      "fhir": "List.code",
      "open": false,
      "values": [
        {
          "code": "doctor",
          "labelZh": "個人常用",
          "fhirCode": null
        },
        {
          "code": "department",
          "labelZh": "科常用",
          "fhirCode": null
        }
      ]
    },
    "encounter-status": {
      "labelZh": "就醫狀態",
      "fhir": "Encounter.status",
      "open": false,
      "values": [
        {
          "code": "in-progress",
          "labelZh": "住院中",
          "fhirCode": "in-progress"
        },
        {
          "code": "finished",
          "labelZh": "已出院",
          "fhirCode": "finished"
        }
      ]
    },
    "draft-kind": {
      "labelZh": "草稿種類",
      "fhir": "—",
      "open": false,
      "values": [
        {
          "code": "cart",
          "labelZh": "待開清單",
          "fhirCode": null
        },
        {
          "code": "orderDetails",
          "labelZh": "開立明細",
          "fhirCode": null
        },
        {
          "code": "note",
          "labelZh": "自由病程",
          "fhirCode": null
        },
        {
          "code": "recordWriter:admission",
          "labelZh": "住院病歷撰寫",
          "fhirCode": null
        },
        {
          "code": "recordWriter:progress",
          "labelZh": "病程撰寫",
          "fhirCode": null
        },
        {
          "code": "recordWriter:discharge",
          "labelZh": "出院病摘撰寫",
          "fhirCode": null
        },
        {
          "code": "surgery",
          "labelZh": "手術紀錄",
          "fhirCode": null
        },
        {
          "code": "handover",
          "labelZh": "交班",
          "fhirCode": null
        }
      ]
    },
    "batch-op": {
      "labelZh": "交易項目動作",
      "fhir": "Bundle.entry.request.method",
      "open": false,
      "values": [
        {
          "code": "create",
          "labelZh": "新增",
          "fhirCode": null
        },
        {
          "code": "update",
          "labelZh": "更新",
          "fhirCode": null
        },
        {
          "code": "action",
          "labelZh": "狀態動作（簽署／送出／接收…）",
          "fhirCode": null
        }
      ]
    }
  }
}
