{
  "openapi": "3.0.0",
  "paths": {
    "/health": {
      "get": {
        "operationId": "HealthController_health",
        "parameters": [],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "tags": [
          "health"
        ]
      }
    },
    "/pac/v1/internal/health-report/preview": {
      "get": {
        "operationId": "DailyHealthReportController_preview",
        "parameters": [],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "summary": "预览每日健康报告文本(不推企微)",
        "tags": [
          "internal"
        ]
      }
    },
    "/pac/v1/internal/health-report/run": {
      "post": {
        "operationId": "DailyHealthReportController_run",
        "parameters": [],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "summary": "立即生成并推送每日健康报告到企微",
        "tags": [
          "internal"
        ]
      }
    },
    "/pac/v1/patients/{patientId}/persona": {
      "get": {
        "operationId": "PersonaController_getCurrent",
        "parameters": [
          {
            "name": "patientId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PersonaResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "Current (non-superseded) persona for the patient",
        "tags": [
          "persona"
        ]
      }
    },
    "/pac/v1/plans": {
      "get": {
        "description": "Use ?view=pool to fetch the unassigned active pool, ?view=mine for my assigned plans, ?view=all for everything (subject to permission). Without view, staff sees own only.",
        "operationId": "PlanController_list",
        "parameters": [
          {
            "name": "scenario",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "assigned",
                "completed",
                "abandoned",
                "superseded"
              ]
            }
          },
          {
            "name": "targetClinicId",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "targetClinicIds",
            "required": false,
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "assigneeUserId",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "view",
            "required": false,
            "in": "query",
            "description": "\"pool\" = active+unassigned;  \"mine\" = assigned to caller;  \"all\" = no extra filter",
            "schema": {
              "type": "string",
              "enum": [
                "pool",
                "mine",
                "all"
              ]
            }
          },
          {
            "name": "keyword",
            "required": false,
            "in": "query",
            "schema": {
              "minLength": 1,
              "type": "string"
            }
          },
          {
            "name": "personaTags",
            "required": false,
            "in": "query",
            "schema": {
              "minLength": 1,
              "type": "string"
            }
          },
          {
            "name": "phoneVerified",
            "required": false,
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "sort",
            "required": false,
            "in": "query",
            "schema": {
              "default": "priority_desc",
              "type": "string",
              "enum": [
                "priority_desc",
                "priority_asc",
                "created_desc"
              ]
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 9007199254740991,
              "default": 1,
              "type": "integer"
            }
          },
          {
            "name": "pageSize",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ListPlansResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "List plans (recall pool, my queue, or by filters)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/counts": {
      "get": {
        "operationId": "PlanController_counts",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PlanCountsResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "Plan counts for KPI / tab badges (one SQL roundtrip, replaces 5 list calls)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}": {
      "get": {
        "operationId": "PlanController_detail",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PlanDetailResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/assign": {
      "post": {
        "operationId": "PlanController_assign",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignPlanRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PlanActionAckDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/recycle": {
      "post": {
        "operationId": "PlanController_recycle",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecyclePlanRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PlanActionAckDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/executions": {
      "post": {
        "operationId": "PlanController_submitExecution",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitExecutionRequestDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/SubmitExecutionResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "接口 2: write a Plan execution outcome. Strict invariant — execution feedback NEVER promotes to PatientFactEvent.",
        "tags": [
          "plan"
        ]
      },
      "get": {
        "operationId": "PlanController_listExecutions",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ListExecutionsResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "某 plan 的执行历史(给\"通话记录\"面板)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/recompute": {
      "post": {
        "operationId": "PlanController_recompute",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RecomputeAckDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "Force a plan recompute for the patient owning this plan (ops/dev tool)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/recompute/by-patient/{patientId}": {
      "post": {
        "operationId": "PlanController_recomputeByPatient",
        "parameters": [
          {
            "name": "patientId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RecomputeAckDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "Recompute plans for a patient that has no plan yet (ops/dev cold-start tool)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/admin/recall-debug/search": {
      "get": {
        "operationId": "RecallDebugController_search",
        "parameters": [
          {
            "name": "q",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "查患者(姓名/病历号/external_id/手机号)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/recall-debug/transaction/{txId}/raw": {
      "get": {
        "operationId": "RecallDebugController_raw",
        "parameters": [
          {
            "name": "txId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "看 transaction 原始 rawPayload(证据链链底)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/recall-debug/{patientId}": {
      "get": {
        "operationId": "RecallDebugController_explain",
        "parameters": [
          {
            "name": "patientId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "患者召回归因(为什么召 / 为什么没召)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/sync/trigger": {
      "post": {
        "operationId": "SyncController_trigger",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TriggerSyncRequestDto"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/TriggerSyncResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "Force a pull run (ops). Defaults to current host; admin can target any.",
        "tags": [
          "sync"
        ]
      }
    },
    "/pac/v1/sync/patient/{patientId}/refresh": {
      "post": {
        "operationId": "SyncController_refreshPatient",
        "parameters": [
          {
            "name": "patientId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RefreshPatientResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "On-demand single-patient refresh (staff/leader)",
        "tags": [
          "sync"
        ]
      }
    },
    "/pac/v1/push/events": {
      "post": {
        "description": "Headers 必填 X-PAC-Host-Id / X-PAC-Timestamp / X-PAC-Signature。",
        "operationId": "PushController_receive",
        "parameters": [],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "summary": "宿主推送事件 webhook(HMAC 验签)",
        "tags": [
          "push"
        ]
      }
    },
    "/pac/v1/push/rows": {
      "post": {
        "description": "Headers 必填 X-PAC-Host-Id / X-PAC-Timestamp / X-PAC-Signature。Body: { source, rows[] }。 加 ?dryRun=1 走**预检**:跑完整管线(transforms+装配+归一)但不落库、不触发重算,响应带各资源样本 canonical —— 对接自测先预检到 failed=0 且 mappingMisses/suspectFields 为 0,再正式推。",
        "operationId": "PushController_receiveRows",
        "parameters": [
          {
            "name": "dryRun",
            "required": false,
            "in": "query",
            "description": "预检开关:'1' / 'true' / 'yes' = 跑完整管线但不落库、不触发重算,响应带样本 canonical",
            "schema": {}
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "summary": "宿主推送原生表行 webhook(形态 A,HMAC 验签;?dryRun=1 预检不落库)",
        "tags": [
          "push"
        ]
      }
    },
    "/pac/v1/push/logs": {
      "get": {
        "description": "Headers 同 push:X-PAC-Host-Id / X-PAC-Timestamp / X-PAC-Signature。GET 无 body,签名对空串算:hex(HMAC-SHA256(`<timestamp>.`, secret))。返回最近 N 批(默认 50、上限 200):source / status / dryRun / 收行数 / 落库数 / 去重 / 失败 / 报错。",
        "operationId": "PushController_logs",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "返回条数,默认 50、上限 200",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "summary": "查询本宿主推送记录(HMAC 验签,免登录)",
        "tags": [
          "push"
        ]
      }
    },
    "/pac/v1/admin/host/self": {
      "get": {
        "operationId": "HostSelfAdminController_getSelf",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/HostDetailDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "当前宿主配置详情(含 pullConfig / push secret meta / 运行状态)",
        "tags": [
          "admin"
        ]
      },
      "patch": {
        "description": "凭据轮换走 rotate 端点;不能改 name / appId",
        "operationId": "HostSelfAdminController_update",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateHostRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/HostSummaryDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "更新当前宿主配置(pullConfig / actionUrls / active)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/stats": {
      "get": {
        "operationId": "HostSelfAdminController_getStats",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/HostStatsDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "当前宿主运行状态(只刷新指标,不刷新整页用)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/push-logs": {
      "get": {
        "description": "按时间倒序列最近 N 批 push(默认 50,上限 200)。每批含 source / 收行数 / 落库数 / 去重数 / 失败数 / 报错原因;dryRun=true 的是 ?dryRun=1 预检批次。用途:当时的同步响应没留存也能事后查——对接期定位\"哪批错了、错在哪\"。",
        "operationId": "HostSelfAdminController_getPushLogs",
        "parameters": [
          {
            "name": "limit",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PushLogsDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "当前宿主的推送记录(对接自助排查)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/rotate-app-secret": {
      "post": {
        "description": "返回的 plaintext 仅本次显示,请立即保存。",
        "operationId": "HostSelfAdminController_rotateAppSecret",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RotateSecretResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "轮换 appSecret(旧立即失效)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/push-secrets": {
      "post": {
        "description": "返回的 plaintext 仅本次显示,请立即保存。",
        "operationId": "HostSelfAdminController_addPushSecret",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RotatePushSecretResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "添加新 push secret(数组前插,旧 key 进 grace period)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/push-secrets/{suffix}": {
      "delete": {
        "operationId": "HostSelfAdminController_removePushSecret",
        "parameters": [
          {
            "name": "suffix",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RemovePushSecretResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "按 suffix 删除某条 push secret(不能删唯一一条)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/callback-secrets": {
      "post": {
        "description": "返回的 plaintext 仅本次显示,请立即保存。回执地址(callbackUrl)走 PATCH 设置。",
        "operationId": "HostSelfAdminController_addCallbackSecret",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RotateCallbackSecretResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "添加新 callback secret(数组前插,旧 key 进 grace period)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/callback-secrets/{suffix}": {
      "delete": {
        "operationId": "HostSelfAdminController_removeCallbackSecret",
        "parameters": [
          {
            "name": "suffix",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RemovePushSecretResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "按 suffix 删除某条 callback secret(不能删唯一一条)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/cold-import": {
      "post": {
        "description": "zip 内含 manifest.tables 声明的数据文件(CSV/JSON);manifest+assemblers 取自 PAC 代码库不接受上传。校验通过后落后台队列,返回 jobId 供轮询进度。",
        "operationId": "HostSelfAdminController_coldImport",
        "parameters": [],
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ColdImportUploadResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "上传数据压缩包触发整包 cold-import",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/host/self/cold-import/{jobId}": {
      "get": {
        "operationId": "HostSelfAdminController_coldImportStatus",
        "parameters": [
          {
            "name": "jobId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ColdImportStatusDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "查询一次 cold-import 进度(前端轮询,含运行中百分比)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/ai-invocations": {
      "get": {
        "operationId": "AiInvocationsAdminController_list",
        "parameters": [
          {
            "name": "callKey",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "promptVersion",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modelName",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "evalMode",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "linkedPlanId",
            "required": false,
            "in": "query",
            "schema": {
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
              "type": "string"
            }
          },
          {
            "name": "linkedPatientId",
            "required": false,
            "in": "query",
            "schema": {
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 9007199254740991,
              "default": 1,
              "type": "integer"
            }
          },
          {
            "name": "pageSize",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ListAiInvocationsResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "AI 调用列表(分页 + 筛选)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/ai-invocations/stats": {
      "get": {
        "operationId": "AiInvocationsAdminController_stats",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AiInvocationStatsDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "24h 调用总览 + 按 callKey 分组热点",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/ai-invocations/{id}": {
      "get": {
        "operationId": "AiInvocationsAdminController_detail",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AiInvocationDetailDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "AI 调用详情(含 inputSnapshot / promptTemplate / output)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/admin/mapping-miss": {
      "get": {
        "operationId": "MappingMissAdminController_recent",
        "parameters": [
          {
            "name": "limit",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "摄入漂移报告:misses(落 _default 的原值,扩字典)+ suspectFields(整列缺席,疑似宿主改表)。扫最近 N 次 sync run 的 metadata(默认 100,上限 500)",
        "tags": [
          "admin"
        ]
      }
    },
    "/pac/v1/facts": {
      "post": {
        "description": "Accepts a batch of fact events. Idempotency on (hostId, tenantId, externalRef) is the caller responsibility for now. Triggers persona / plan recompute downstream.",
        "operationId": "FactsController_ingest",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IngestFactsRequestDto"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/IngestFactsResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "API Pool 1 — push patient fact events into the timeline",
        "tags": [
          "facts"
        ]
      }
    },
    "/pac/v1/auth/token": {
      "post": {
        "operationId": "AuthController_exchangeToken",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenExchangeRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/TokenExchangeResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Token Exchange — host backend trades appId+appSecret+user for an accessToken + one-time code",
        "tags": [
          "auth"
        ]
      }
    },
    "/pac/v1/auth/exchange-code": {
      "post": {
        "operationId": "AuthController_exchangeCode",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExchangeCodeRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ExchangeCodeResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Exchange a one-time code (from iframe URL) for the accessToken",
        "tags": [
          "auth"
        ]
      }
    },
    "/pac/v1/auth/refresh": {
      "post": {
        "operationId": "AuthController_refresh",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshTokenRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/RefreshTokenResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Refresh the accessToken before expiry",
        "tags": [
          "auth"
        ]
      }
    },
    "/pac/v1/auth/client-diag": {
      "post": {
        "operationId": "AuthController_clientDiag",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientDiagRequestDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": ""
          }
        },
        "summary": "前端 bootstrap 诊断信标 — 把嵌入首开鉴权走的分支(有无 code / store 有无 token / 结局)落一行服务端日志,定位「登录已过期」",
        "tags": [
          "auth"
        ]
      }
    },
    "/pac/v1/auth/mock-login": {
      "post": {
        "description": "env: PAC_ENABLE_MOCK_LOGIN=true 强开 / =false 强关;不设按 NODE_ENV(prod 默认关)。生产真 host SSO 接入后,把 env 设 false 或删该 endpoint。",
        "operationId": "AuthController_mockLogin",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MockLoginRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/MockLoginResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Mock login(开发 / 试部署用,env 门控)— 按 { tenant, role } 预制 user payload 直产 JWT",
        "tags": [
          "auth"
        ]
      }
    },
    "/pac/v1/auth/mock-users": {
      "get": {
        "description": "派生自 data/jvs-dw/users.json(回访表 · 近 12 月在岗)。mock 登录禁用时返空数组。",
        "operationId": "AuthController_mockUsers",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/MockUsersResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "客服花名册(开发 / 试部署用)— 给\"快速登录\"对话框选人",
        "tags": [
          "auth"
        ]
      }
    },
    "/pac/v1/auth/mock-orgs": {
      "get": {
        "operationId": "AuthController_mockOrgs",
        "parameters": [
          {
            "name": "host",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenant",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "summary": "(dev) 真实组织结构(品牌→诊所),给快速登录选数据范围",
        "tags": [
          "auth"
        ]
      }
    },
    "/pac/v1/auth/session": {
      "get": {
        "operationId": "AuthController_session",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/SessionResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "当前会话视图 — 把 JWT.orgScope 展开成 clinicIds/sourceUnits 返给前端(设计 B:JWT 只装通用 orgScope,前端展不开)",
        "tags": [
          "auth"
        ]
      }
    },
    "/pac/v1/patients/{id}/timeline": {
      "get": {
        "operationId": "PatientController_getTimeline",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "msg",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "enum": [
                        0
                      ]
                    },
                    "msg": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PatientTimelineResponseDto_Output"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "Patient fact timeline (most recent first)",
        "tags": [
          "patient"
        ]
      }
    },
    "/pac/v1/patients/{id}/phone-reveal": {
      "get": {
        "operationId": "PatientController_revealPhone",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "Reveal masked phone — 拉患者明文手机号(需 PATIENT_VIEW 权限)",
        "tags": [
          "patient"
        ]
      }
    },
    "/pac/v1/mcp": {
      "post": {
        "operationId": "McpController_handle",
        "parameters": [],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "summary": "PAC MCP server(Streamable HTTP)— 暴露患者只读工具给 agent;Bearer JWT 鉴权",
        "tags": [
          "mcp"
        ]
      }
    },
    "/pac/v1/assistant/transcribe": {
      "post": {
        "operationId": "AssistantController_transcribe",
        "parameters": [],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "语音转文字(听写)— 浏览器录音上传,返回 { text }",
        "tags": [
          "assistant"
        ]
      }
    },
    "/pac/v1/assistant/pet-say": {
      "post": {
        "operationId": "AssistantController_petSay",
        "parameters": [],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "桌宠环境观察发言(SSE,简短一句)",
        "tags": [
          "assistant"
        ]
      }
    },
    "/pac/v1/assistant/chat": {
      "post": {
        "operationId": "AssistantController_chat",
        "parameters": [],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "助手对话(SSE)— 模型自主调 PAC MCP 工具",
        "tags": [
          "assistant"
        ]
      }
    },
    "/pac/v1/internal/wx-aibot/push-urgent": {
      "post": {
        "operationId": "WeixinAibotController_pushUrgent",
        "parameters": [],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "summary": "[DEV] 主动推一条紧急召回提醒到群(需 PAC_WX_AIBOT_DEMO_PUSH=1)",
        "tags": [
          "internal"
        ]
      }
    },
    "/pac/v1/plans/{id}/full": {
      "get": {
        "description": "前端 (app)/plans/[planId] 用本端点;PlanController.detail 走 strict Zod 给外部。",
        "operationId": "PlansAggregateController_getFull",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "Plan 详情聚合(plan+patient+profile+persona+chains+facts)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/recall-summary": {
      "get": {
        "operationId": "PlansAggregateController_getRecallSummary",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "回访历史一句话摘要(有则取、无则当场生成)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/persona-summary": {
      "get": {
        "operationId": "PlansAggregateController_getPersonaSummary",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "画像标签一句话重点(有则取、无则当场生成)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/recall-brief": {
      "get": {
        "operationId": "PlansAggregateController_getRecallBrief",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "本次召回一句话简报(有则取、无则当场生成)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/script{regenerate}": {
      "post": {
        "operationId": "PlansAggregateController_regenerateScript",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "bustCache",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "model",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tier",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "重新生成 plan 话术(测试 / 调试用,输入不变)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/script{stream}": {
      "get": {
        "operationId": "PlansAggregateController_streamScript",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "流式重新生成 plan 话术(SSE)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/script-feedback": {
      "post": {
        "operationId": "PlansAggregateController_submitScriptFeedback",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "对当前话术 thumbs up/down 反馈(\"本段是否好用\")",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/recall-feedback": {
      "post": {
        "operationId": "PlansAggregateController_submitRecallFeedback",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "召回反馈(plan 级)— 对\"这条召回准不准\"打拇指 + 文字(down 弹窗收集)",
        "tags": [
          "plan"
        ]
      }
    },
    "/pac/v1/plans/{id}/summary{stream}": {
      "get": {
        "operationId": "PlansAggregateController_streamSummary",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "accessToken": []
          }
        ],
        "summary": "流式重新生成 plan 摘要(SSE,1 次产 3 段)",
        "tags": [
          "plan"
        ]
      }
    }
  },
  "info": {
    "title": "PAC API",
    "description": "Patient Analysis Center — three-pool framework (facts in, plans out, agents inside).",
    "version": "0.1.0",
    "contact": {}
  },
  "tags": [
    {
      "name": "admin",
      "description": "后台管理:映射缺失、AI 调用、host 自助。"
    },
    {
      "name": "assistant",
      "description": "实时坐席助手 / 会话辅助。"
    },
    {
      "name": "auth",
      "description": "登录换票、会话、数据权限(orgScope)。"
    },
    {
      "name": "facts",
      "description": "患者事实写入(事件账本)与查询。"
    },
    {
      "name": "health",
      "description": "健康检查。"
    },
    {
      "name": "internal",
      "description": "内部任务(日报预览 / 触发等)。"
    },
    {
      "name": "mcp",
      "description": "MCP(Model Context Protocol)工具端点。"
    },
    {
      "name": "patient",
      "description": "患者主档、检索、时间线。"
    },
    {
      "name": "persona",
      "description": "患者画像与特征。"
    },
    {
      "name": "plan",
      "description": "随访计划:生成、分配、回收、统计。"
    },
    {
      "name": "push",
      "description": "触达结果回推 host(HMAC 验签)。"
    },
    {
      "name": "sync",
      "description": "数据摄入与增量同步。"
    }
  ],
  "servers": [
    {
      "url": "http://localhost:3101",
      "description": "PAC API"
    }
  ],
  "components": {
    "securitySchemes": {
      "accessToken": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "type": "http",
        "name": "Authorization",
        "in": "header"
      }
    },
    "schemas": {
      "PersonaResponseDto_Output": {
        "type": "object",
        "properties": {
          "persona": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "hostId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "FK → platforms.id"
              },
              "tenantId": {
                "type": "string"
              },
              "patientId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "version": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "triggeredBy": {
                "type": "string"
              },
              "computedAt": {
                "type": "string"
              },
              "supersededAt": {
                "type": "string",
                "nullable": true
              },
              "eventWatermark": {
                "type": "string",
                "nullable": true
              },
              "features": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "personaId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "key": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "score": {
                      "type": "number",
                      "nullable": true
                    },
                    "evidence": {
                      "type": "object",
                      "properties": {
                        "factIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        },
                        "agentInvocationIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        },
                        "ruleIds": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "promptVersion": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": {}
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "personaId",
                    "key",
                    "description",
                    "evidence",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "id",
              "hostId",
              "tenantId",
              "patientId",
              "version",
              "triggeredBy",
              "computedAt",
              "supersededAt",
              "eventWatermark",
              "features"
            ],
            "additionalProperties": false,
            "nullable": true
          }
        },
        "required": [
          "persona"
        ],
        "additionalProperties": false
      },
      "ListPlansResponseDto_Output": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "hostId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "description": "FK → platforms.id"
                },
                "tenantId": {
                  "type": "string"
                },
                "patientId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "personaId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "nullable": true
                },
                "targetClinicId": {
                  "type": "string",
                  "nullable": true
                },
                "scenario": {
                  "type": "string"
                },
                "version": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "priorityScore": {
                  "type": "number"
                },
                "inclusionReason": {
                  "type": "string"
                },
                "recommendedAt": {
                  "type": "string",
                  "nullable": true
                },
                "recommendedRole": {
                  "type": "string",
                  "nullable": true
                },
                "recommendedChannel": {
                  "type": "string",
                  "nullable": true
                },
                "evidence": {
                  "type": "object",
                  "properties": {
                    "factIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      }
                    },
                    "personaVersion": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "agentInvocationIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      }
                    },
                    "ruleIds": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "additionalProperties": {}
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "active",
                    "assigned",
                    "completed",
                    "abandoned",
                    "superseded"
                  ]
                },
                "recycleAt": {
                  "type": "string",
                  "nullable": true
                },
                "snoozedUntil": {
                  "type": "string",
                  "nullable": true
                },
                "assigneeUserId": {
                  "type": "string",
                  "nullable": true
                },
                "assignedAt": {
                  "type": "string",
                  "nullable": true
                },
                "createdAt": {
                  "type": "string"
                },
                "updatedAt": {
                  "type": "string"
                },
                "supersededAt": {
                  "type": "string",
                  "nullable": true
                },
                "patient": {
                  "type": "object",
                  "properties": {
                    "externalId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string",
                      "nullable": true
                    },
                    "nameMasked": {
                      "type": "string",
                      "nullable": true
                    },
                    "phoneMasked": {
                      "type": "string",
                      "nullable": true
                    },
                    "phoneVerified": {
                      "type": "boolean"
                    },
                    "gender": {
                      "type": "string",
                      "nullable": true
                    },
                    "age": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "nullable": true
                    }
                  },
                  "required": [
                    "externalId",
                    "name",
                    "nameMasked",
                    "phoneMasked",
                    "gender",
                    "age"
                  ],
                  "additionalProperties": false
                },
                "scenarioLabel": {
                  "type": "string"
                },
                "reasons": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "scenario": {
                        "type": "string"
                      },
                      "subKey": {
                        "type": "string",
                        "nullable": true
                      },
                      "signals": {
                        "type": "object",
                        "properties": {
                          "subKey": {
                            "type": "string",
                            "minLength": 1
                          },
                          "triggers": {
                            "minItems": 1,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "code": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "type"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "toothPosition": {
                            "type": "string",
                            "nullable": true
                          },
                          "daysSince": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          "signalOccurredAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                            "nullable": true
                          },
                          "expectedCategories": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": [
                          "subKey",
                          "triggers",
                          "daysSince",
                          "expectedCategories"
                        ],
                        "additionalProperties": false,
                        "nullable": true
                      },
                      "priorityScore": {
                        "type": "number"
                      },
                      "reason": {
                        "type": "string"
                      },
                      "breakdown": {
                        "nullable": true
                      }
                    },
                    "required": [
                      "id",
                      "scenario",
                      "subKey",
                      "signals",
                      "priorityScore",
                      "reason"
                    ],
                    "additionalProperties": false
                  }
                },
                "lastOutcome": {
                  "type": "string",
                  "enum": [
                    "abandoned",
                    "no_answer",
                    "quick_hangup",
                    "scheduled_next",
                    "success_appointed",
                    "rescheduled",
                    "considering",
                    "declined_recent",
                    "needs_doctor",
                    "external_treatment",
                    "refused",
                    "pending_info",
                    "sms_sent",
                    "marked_invalid"
                  ],
                  "nullable": true
                }
              },
              "required": [
                "id",
                "hostId",
                "tenantId",
                "patientId",
                "personaId",
                "targetClinicId",
                "scenario",
                "version",
                "priorityScore",
                "inclusionReason",
                "recommendedAt",
                "recommendedRole",
                "recommendedChannel",
                "evidence",
                "status",
                "recycleAt",
                "snoozedUntil",
                "assigneeUserId",
                "assignedAt",
                "createdAt",
                "updatedAt",
                "supersededAt",
                "patient",
                "scenarioLabel",
                "reasons"
              ],
              "additionalProperties": false
            }
          },
          "total": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "page": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "pageSize": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "pageSize"
        ],
        "additionalProperties": false
      },
      "PlanCountsResponseDto_Output": {
        "type": "object",
        "properties": {
          "mine": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "mineAssigned": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "mineCompleted": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "pool": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "all": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "mine",
          "mineAssigned",
          "mineCompleted",
          "pool",
          "all"
        ],
        "additionalProperties": false
      },
      "PlanDetailResponseDto_Output": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "hostId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "FK → platforms.id"
              },
              "tenantId": {
                "type": "string"
              },
              "patientId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "personaId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "nullable": true
              },
              "targetClinicId": {
                "type": "string",
                "nullable": true
              },
              "scenario": {
                "type": "string"
              },
              "version": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "priorityScore": {
                "type": "number"
              },
              "inclusionReason": {
                "type": "string"
              },
              "recommendedAt": {
                "type": "string",
                "nullable": true
              },
              "recommendedRole": {
                "type": "string",
                "nullable": true
              },
              "recommendedChannel": {
                "type": "string",
                "nullable": true
              },
              "evidence": {
                "type": "object",
                "properties": {
                  "factIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    }
                  },
                  "personaVersion": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "agentInvocationIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    }
                  },
                  "ruleIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "additionalProperties": {}
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "assigned",
                  "completed",
                  "abandoned",
                  "superseded"
                ]
              },
              "recycleAt": {
                "type": "string",
                "nullable": true
              },
              "snoozedUntil": {
                "type": "string",
                "nullable": true
              },
              "assigneeUserId": {
                "type": "string",
                "nullable": true
              },
              "assignedAt": {
                "type": "string",
                "nullable": true
              },
              "createdAt": {
                "type": "string"
              },
              "updatedAt": {
                "type": "string"
              },
              "supersededAt": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "id",
              "hostId",
              "tenantId",
              "patientId",
              "personaId",
              "targetClinicId",
              "scenario",
              "version",
              "priorityScore",
              "inclusionReason",
              "recommendedAt",
              "recommendedRole",
              "recommendedChannel",
              "evidence",
              "status",
              "recycleAt",
              "snoozedUntil",
              "assigneeUserId",
              "assignedAt",
              "createdAt",
              "updatedAt",
              "supersededAt"
            ],
            "additionalProperties": false
          },
          "patient": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "hostId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "FK → platforms.id"
              },
              "tenantId": {
                "type": "string"
              },
              "externalId": {
                "type": "string"
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "gender": {
                "type": "string",
                "nullable": true
              },
              "birthDate": {
                "type": "string",
                "nullable": true
              },
              "preferences": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {},
                "nullable": true
              },
              "doNotContact": {
                "type": "boolean"
              },
              "doNotContactReason": {
                "type": "string",
                "nullable": true
              },
              "doNotContactAt": {
                "type": "string",
                "nullable": true
              },
              "deceased": {
                "type": "boolean"
              },
              "deceasedAt": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "archived",
                  "merged"
                ]
              },
              "mergedIntoId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "nullable": true
              },
              "createdAt": {
                "type": "string"
              },
              "updatedAt": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "hostId",
              "tenantId",
              "externalId",
              "name",
              "phone",
              "gender",
              "birthDate",
              "preferences",
              "doNotContact",
              "doNotContactReason",
              "doNotContactAt",
              "deceased",
              "deceasedAt",
              "status",
              "mergedIntoId",
              "createdAt",
              "updatedAt"
            ],
            "additionalProperties": false
          },
          "persona": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "hostId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "FK → platforms.id"
              },
              "tenantId": {
                "type": "string"
              },
              "patientId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "version": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "triggeredBy": {
                "type": "string"
              },
              "computedAt": {
                "type": "string"
              },
              "supersededAt": {
                "type": "string",
                "nullable": true
              },
              "eventWatermark": {
                "type": "string",
                "nullable": true
              },
              "features": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "personaId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "key": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "score": {
                      "type": "number",
                      "nullable": true
                    },
                    "evidence": {
                      "type": "object",
                      "properties": {
                        "factIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        },
                        "agentInvocationIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        },
                        "ruleIds": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "promptVersion": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": {}
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "personaId",
                    "key",
                    "description",
                    "evidence",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "id",
              "hostId",
              "tenantId",
              "patientId",
              "version",
              "triggeredBy",
              "computedAt",
              "supersededAt",
              "eventWatermark",
              "features"
            ],
            "additionalProperties": false,
            "nullable": true
          },
          "script": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "hostId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "tenantId": {
                "type": "string"
              },
              "planId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "content": {
                "type": "string",
                "maxLength": 8000,
                "nullable": true
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "ready",
                  "failed"
                ]
              },
              "source": {
                "type": "string",
                "enum": [
                  "agent",
                  "template_fallback",
                  "manual"
                ],
                "nullable": true
              },
              "agentInvocationId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "nullable": true
              },
              "createdAt": {
                "type": "string"
              },
              "updatedAt": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "hostId",
              "tenantId",
              "planId",
              "content",
              "status",
              "source",
              "agentInvocationId",
              "createdAt",
              "updatedAt"
            ],
            "additionalProperties": false,
            "description": "plan-level 单条话术(可能在生成中)",
            "nullable": true
          },
          "summaries": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "hostId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "tenantId": {
                  "type": "string"
                },
                "planId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "type": {
                  "type": "string"
                },
                "content": {
                  "type": "string",
                  "maxLength": 8000,
                  "nullable": true
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "ready",
                    "failed"
                  ]
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "agent",
                    "template_fallback",
                    "manual"
                  ],
                  "nullable": true
                },
                "agentInvocationId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "nullable": true
                },
                "createdAt": {
                  "type": "string"
                },
                "updatedAt": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "hostId",
                "tenantId",
                "planId",
                "type",
                "content",
                "status",
                "source",
                "agentInvocationId",
                "createdAt",
                "updatedAt"
              ],
              "additionalProperties": false
            },
            "description": "3 种 type 各一条(部分可能在生成中)"
          },
          "executions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "hostId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "tenantId": {
                  "type": "string"
                },
                "executorClinicId": {
                  "type": "string"
                },
                "planId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "operatorUserId": {
                  "type": "string"
                },
                "channel": {
                  "type": "string"
                },
                "outcome": {
                  "type": "string",
                  "enum": [
                    "abandoned",
                    "no_answer",
                    "quick_hangup",
                    "scheduled_next",
                    "success_appointed",
                    "rescheduled",
                    "considering",
                    "declined_recent",
                    "needs_doctor",
                    "external_treatment",
                    "refused",
                    "pending_info",
                    "sms_sent",
                    "marked_invalid"
                  ]
                },
                "notes": {
                  "type": "string",
                  "nullable": true
                },
                "abandonReasons": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "abandonOther": {
                  "type": "string",
                  "nullable": true
                },
                "scheduledNextAt": {
                  "type": "string",
                  "nullable": true
                },
                "createdAt": {
                  "type": "string",
                  "description": "提交时间 ≈ 通话结束时间"
                }
              },
              "required": [
                "id",
                "hostId",
                "tenantId",
                "executorClinicId",
                "planId",
                "operatorUserId",
                "channel",
                "outcome",
                "notes",
                "abandonReasons",
                "abandonOther",
                "scheduledNextAt",
                "createdAt"
              ],
              "additionalProperties": false
            }
          },
          "evidence": {
            "type": "object",
            "properties": {
              "factIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                }
              },
              "personaVersion": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "agentInvocationIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                }
              },
              "ruleIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "additionalProperties": {}
          }
        },
        "required": [
          "plan",
          "patient",
          "persona",
          "script",
          "summaries",
          "executions",
          "evidence"
        ],
        "additionalProperties": false
      },
      "AssignPlanRequestDto": {
        "type": "object",
        "properties": {
          "assigneeUserId": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "assigneeUserId"
        ]
      },
      "PlanActionAckDto_Output": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "ok"
        ],
        "additionalProperties": false
      },
      "RecyclePlanRequestDto": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string"
          }
        }
      },
      "SubmitExecutionRequestDto": {
        "type": "object",
        "properties": {
          "channel": {
            "type": "string",
            "enum": [
              "phone",
              "wecom",
              "sms",
              "other"
            ]
          },
          "outcome": {
            "type": "string",
            "enum": [
              "abandoned",
              "no_answer",
              "quick_hangup",
              "scheduled_next",
              "success_appointed",
              "rescheduled",
              "considering",
              "declined_recent",
              "needs_doctor",
              "external_treatment",
              "refused",
              "pending_info",
              "sms_sent",
              "marked_invalid"
            ]
          },
          "notes": {
            "type": "string"
          },
          "abandonReasons": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "wrong_number",
                "patient_refused",
                "out_of_service_area",
                "treated_elsewhere",
                "not_interested",
                "do_not_contact_request",
                "other"
              ]
            }
          },
          "abandonOther": {
            "type": "string"
          },
          "scheduledNextAt": {
            "type": "string"
          },
          "closeReason": {
            "type": "string",
            "enum": [
              "no_intent",
              "inaccurate",
              "competitor",
              "price",
              "treated",
              "unreachable",
              "other"
            ]
          }
        },
        "required": [
          "channel",
          "outcome"
        ]
      },
      "SubmitExecutionResponseDto_Output": {
        "type": "object",
        "properties": {
          "planStatus": {
            "type": "string"
          },
          "contactAttempts": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "breakerTripped": {
            "type": "boolean"
          },
          "executionId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          }
        },
        "required": [
          "planStatus",
          "contactAttempts",
          "breakerTripped",
          "executionId"
        ],
        "additionalProperties": false
      },
      "ListExecutionsResponseDto_Output": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "hostId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "tenantId": {
                  "type": "string"
                },
                "executorClinicId": {
                  "type": "string"
                },
                "planId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "operatorUserId": {
                  "type": "string"
                },
                "channel": {
                  "type": "string"
                },
                "outcome": {
                  "type": "string",
                  "enum": [
                    "abandoned",
                    "no_answer",
                    "quick_hangup",
                    "scheduled_next",
                    "success_appointed",
                    "rescheduled",
                    "considering",
                    "declined_recent",
                    "needs_doctor",
                    "external_treatment",
                    "refused",
                    "pending_info",
                    "sms_sent",
                    "marked_invalid"
                  ]
                },
                "notes": {
                  "type": "string",
                  "nullable": true
                },
                "abandonReasons": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "abandonOther": {
                  "type": "string",
                  "nullable": true
                },
                "scheduledNextAt": {
                  "type": "string",
                  "nullable": true
                },
                "createdAt": {
                  "type": "string",
                  "description": "提交时间 ≈ 通话结束时间"
                }
              },
              "required": [
                "id",
                "hostId",
                "tenantId",
                "executorClinicId",
                "planId",
                "operatorUserId",
                "channel",
                "outcome",
                "notes",
                "abandonReasons",
                "abandonOther",
                "scheduledNextAt",
                "createdAt"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "items"
        ],
        "additionalProperties": false
      },
      "RecomputeAckDto_Output": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "plansCreated": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "accepted",
          "plansCreated"
        ],
        "additionalProperties": false
      },
      "TriggerSyncRequestDto": {
        "type": "object",
        "properties": {
          "hostId": {
            "description": "Platform UUID; defaults to caller",
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          }
        }
      },
      "TriggerSyncResponseDto_Output": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "syncLogId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "fetched": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "transactionsWritten": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "factsEmitted": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "accepted",
          "syncLogId",
          "fetched",
          "transactionsWritten",
          "factsEmitted"
        ],
        "additionalProperties": false
      },
      "RefreshPatientResponseDto_Output": {
        "type": "object",
        "properties": {
          "syncLogId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "status": {
            "type": "string"
          },
          "dedupedFromExisting": {
            "type": "boolean"
          },
          "transactionsWritten": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "factsEmitted": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "plansCreated": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "planOutcome": {
            "type": "string",
            "enum": [
              "created",
              "superseded",
              "unchanged",
              "suppressed",
              "closed",
              "none",
              "error"
            ]
          },
          "currentPlanId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "nullable": true
          }
        },
        "required": [
          "syncLogId",
          "status"
        ],
        "additionalProperties": false
      },
      "HostDetailDto_Output": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "appId": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "appSecret": {
            "type": "object",
            "properties": {
              "masked": {
                "type": "string"
              },
              "rotatedAt": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "masked",
              "rotatedAt"
            ],
            "additionalProperties": false
          },
          "pushSecrets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "suffix": {
                  "type": "string",
                  "description": "用作删除时的唯一定位 — 不暴露 hash 本身"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "current",
                    "grace"
                  ]
                }
              },
              "required": [
                "index",
                "suffix",
                "role"
              ],
              "additionalProperties": false
            }
          },
          "callbackSecrets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "suffix": {
                  "type": "string",
                  "description": "用作删除时的唯一定位 — 不暴露 hash 本身"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "current",
                    "grace"
                  ]
                }
              },
              "required": [
                "index",
                "suffix",
                "role"
              ],
              "additionalProperties": false
            }
          },
          "pullConfig": {
            "type": "object",
            "properties": {
              "endpoints": {
                "type": "object",
                "properties": {
                  "patients": {
                    "type": "string",
                    "format": "uri"
                  },
                  "consultations": {
                    "type": "string",
                    "format": "uri"
                  },
                  "appointments": {
                    "type": "string",
                    "format": "uri"
                  },
                  "visit_registrations": {
                    "type": "string",
                    "format": "uri"
                  },
                  "visit_receptions": {
                    "type": "string",
                    "format": "uri"
                  },
                  "clinical_encounters": {
                    "type": "string",
                    "format": "uri"
                  },
                  "emr_documents": {
                    "type": "string",
                    "format": "uri"
                  },
                  "charge_orders": {
                    "type": "string",
                    "format": "uri"
                  },
                  "payments": {
                    "type": "string",
                    "format": "uri"
                  },
                  "refunds": {
                    "type": "string",
                    "format": "uri"
                  },
                  "image_studies": {
                    "type": "string",
                    "format": "uri"
                  },
                  "users": {
                    "type": "string",
                    "format": "uri"
                  }
                },
                "additionalProperties": false
              },
              "credentials": {
                "type": "object",
                "properties": {
                  "loginUrl": {
                    "type": "string",
                    "format": "uri"
                  },
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "apiKey": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              "amountUnit": {
                "type": "string",
                "enum": [
                  "fen",
                  "yuan"
                ]
              },
              "timezone": {
                "type": "string",
                "minLength": 1,
                "description": "IANA 时区,如 Asia/Shanghai"
              },
              "intervalMinutes": {
                "default": 5,
                "type": "integer",
                "minimum": 1,
                "maximum": 1440
              }
            },
            "required": [
              "endpoints",
              "amountUnit",
              "timezone",
              "intervalMinutes"
            ],
            "additionalProperties": false,
            "nullable": true
          },
          "actionUrls": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string",
              "nullable": true
            },
            "description": "Action template URLs for host UI deep-links"
          },
          "callbackUrl": {
            "type": "string",
            "nullable": true
          },
          "stats": {
            "type": "object",
            "properties": {
              "patientCount": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "transactionCount24h": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "transactionCount30d": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "factCount": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "lastPullAt": {
                "type": "string",
                "nullable": true
              },
              "lastPullStatus": {
                "type": "string",
                "nullable": true
              },
              "lastPullCursor": {
                "type": "string",
                "nullable": true
              },
              "lastPushAt": {
                "type": "string",
                "nullable": true
              },
              "lastPushStatus": {
                "type": "string",
                "nullable": true
              },
              "aiInvocations24h": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "aiCostYuan24h": {
                "type": "number"
              },
              "failureRate24h": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "recentEvents": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "pull",
                        "push",
                        "reconcile",
                        "cold_import"
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "startedAt": {
                      "type": "string"
                    },
                    "transactionsWritten": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "errorMessage": {
                      "type": "string",
                      "nullable": true
                    }
                  },
                  "required": [
                    "kind",
                    "status",
                    "startedAt",
                    "transactionsWritten",
                    "errorMessage"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "patientCount",
              "transactionCount24h",
              "transactionCount30d",
              "factCount",
              "lastPullAt",
              "lastPullStatus",
              "lastPullCursor",
              "lastPushAt",
              "lastPushStatus",
              "aiInvocations24h",
              "aiCostYuan24h",
              "failureRate24h",
              "recentEvents"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "name",
          "appId",
          "createdAt",
          "updatedAt",
          "active",
          "appSecret",
          "pushSecrets",
          "callbackSecrets",
          "pullConfig",
          "actionUrls",
          "callbackUrl",
          "stats"
        ],
        "additionalProperties": false
      },
      "HostStatsDto_Output": {
        "type": "object",
        "properties": {
          "patientCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "transactionCount24h": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "transactionCount30d": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "factCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "lastPullAt": {
            "type": "string",
            "nullable": true
          },
          "lastPullStatus": {
            "type": "string",
            "nullable": true
          },
          "lastPullCursor": {
            "type": "string",
            "nullable": true
          },
          "lastPushAt": {
            "type": "string",
            "nullable": true
          },
          "lastPushStatus": {
            "type": "string",
            "nullable": true
          },
          "aiInvocations24h": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "aiCostYuan24h": {
            "type": "number"
          },
          "failureRate24h": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "recentEvents": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "pull",
                    "push",
                    "reconcile",
                    "cold_import"
                  ]
                },
                "status": {
                  "type": "string"
                },
                "startedAt": {
                  "type": "string"
                },
                "transactionsWritten": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "errorMessage": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "kind",
                "status",
                "startedAt",
                "transactionsWritten",
                "errorMessage"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "patientCount",
          "transactionCount24h",
          "transactionCount30d",
          "factCount",
          "lastPullAt",
          "lastPullStatus",
          "lastPullCursor",
          "lastPushAt",
          "lastPushStatus",
          "aiInvocations24h",
          "aiCostYuan24h",
          "failureRate24h",
          "recentEvents"
        ],
        "additionalProperties": false
      },
      "PushLogsDto_Output": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "source": {
                  "type": "string",
                  "description": "推送的源表名"
                },
                "status": {
                  "type": "string",
                  "description": "success / partial / failed"
                },
                "dryRun": {
                  "type": "boolean",
                  "description": "true = 预检批次(未落库)"
                },
                "fetched": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "收到的行数"
                },
                "transactionsWritten": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "实际落库事件数(与 fetched 的差 = 被 PAC 规则过滤)"
                },
                "duplicates": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "幂等命中数(重推安全的证据)"
                },
                "failed": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "errorMessage": {
                  "type": "string",
                  "nullable": true
                },
                "startedAt": {
                  "type": "string"
                },
                "endedAt": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "id",
                "source",
                "status",
                "dryRun",
                "fetched",
                "transactionsWritten",
                "duplicates",
                "failed",
                "errorMessage",
                "startedAt",
                "endedAt"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "items"
        ],
        "additionalProperties": false
      },
      "UpdateHostRequestDto": {
        "type": "object",
        "properties": {
          "pullConfig": {
            "type": "object",
            "properties": {
              "endpoints": {
                "type": "object",
                "properties": {
                  "patients": {
                    "type": "string",
                    "format": "uri"
                  },
                  "consultations": {
                    "type": "string",
                    "format": "uri"
                  },
                  "appointments": {
                    "type": "string",
                    "format": "uri"
                  },
                  "visit_registrations": {
                    "type": "string",
                    "format": "uri"
                  },
                  "visit_receptions": {
                    "type": "string",
                    "format": "uri"
                  },
                  "clinical_encounters": {
                    "type": "string",
                    "format": "uri"
                  },
                  "emr_documents": {
                    "type": "string",
                    "format": "uri"
                  },
                  "charge_orders": {
                    "type": "string",
                    "format": "uri"
                  },
                  "payments": {
                    "type": "string",
                    "format": "uri"
                  },
                  "refunds": {
                    "type": "string",
                    "format": "uri"
                  },
                  "image_studies": {
                    "type": "string",
                    "format": "uri"
                  },
                  "users": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              },
              "credentials": {
                "type": "object",
                "properties": {
                  "loginUrl": {
                    "type": "string",
                    "format": "uri"
                  },
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "apiKey": {
                    "type": "string"
                  }
                }
              },
              "amountUnit": {
                "type": "string",
                "enum": [
                  "fen",
                  "yuan"
                ]
              },
              "timezone": {
                "type": "string",
                "minLength": 1,
                "description": "IANA 时区,如 Asia/Shanghai"
              },
              "intervalMinutes": {
                "default": 5,
                "type": "integer",
                "minimum": 1,
                "maximum": 1440
              }
            },
            "required": [
              "endpoints",
              "amountUnit",
              "timezone"
            ],
            "nullable": true
          },
          "actionUrls": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string",
              "nullable": true
            },
            "description": "Action template URLs for host UI deep-links"
          },
          "active": {
            "type": "boolean"
          },
          "callbackUrl": {
            "type": "string",
            "format": "uri",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "HostSummaryDto_Output": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "appId": {
            "type": "string"
          },
          "pullEnabled": {
            "type": "boolean"
          },
          "pushEnabled": {
            "type": "boolean"
          },
          "pushKeyCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "active": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "appId",
          "pullEnabled",
          "pushEnabled",
          "pushKeyCount",
          "active",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": false
      },
      "RotateSecretResponseDto_Output": {
        "type": "object",
        "properties": {
          "appSecret": {
            "type": "string",
            "description": "New plaintext app secret; save now — cannot be retrieved later"
          }
        },
        "required": [
          "appSecret"
        ],
        "additionalProperties": false
      },
      "RotatePushSecretResponseDto_Output": {
        "type": "object",
        "properties": {
          "pushSecret": {
            "type": "string",
            "description": "New plaintext HMAC secret added to front of array"
          },
          "totalKeys": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Total keys in rotation after this add"
          }
        },
        "required": [
          "pushSecret",
          "totalKeys"
        ],
        "additionalProperties": false
      },
      "RemovePushSecretResponseDto_Output": {
        "type": "object",
        "properties": {
          "totalKeysRemaining": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "totalKeysRemaining"
        ],
        "additionalProperties": false
      },
      "RotateCallbackSecretResponseDto_Output": {
        "type": "object",
        "properties": {
          "callbackSecret": {
            "type": "string",
            "description": "New plaintext callback HMAC secret added to front of array"
          },
          "totalKeys": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Total keys in rotation after this add"
          }
        },
        "required": [
          "callbackSecret",
          "totalKeys"
        ],
        "additionalProperties": false
      },
      "ColdImportUploadResponseDto_Output": {
        "type": "object",
        "properties": {
          "jobId": {
            "type": "string"
          }
        },
        "required": [
          "jobId"
        ],
        "additionalProperties": false
      },
      "ColdImportStatusDto_Output": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string"
          },
          "result": {
            "nullable": true
          },
          "failedReason": {
            "type": "string",
            "nullable": true
          },
          "progress": {
            "type": "object",
            "properties": {
              "done": {
                "type": "number"
              },
              "total": {
                "type": "number"
              }
            },
            "required": [
              "done",
              "total"
            ],
            "additionalProperties": false,
            "nullable": true
          }
        },
        "required": [
          "state",
          "result",
          "failedReason",
          "progress"
        ],
        "additionalProperties": false
      },
      "ListAiInvocationsResponseDto_Output": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "kind": {
                  "type": "string"
                },
                "callKey": {
                  "type": "string"
                },
                "promptVersion": {
                  "type": "string"
                },
                "modelProvider": {
                  "type": "string"
                },
                "modelName": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "cacheHit": {
                  "type": "boolean"
                },
                "evalMode": {
                  "type": "string"
                },
                "workflowRunId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "parentInvocationId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "nullable": true
                },
                "linkedPatientId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "nullable": true
                },
                "linkedPlanId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "nullable": true
                },
                "promptTokens": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "completionTokens": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "totalTokens": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "cachedInputTokens": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "reasoningTokens": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "costYuan": {
                  "type": "number"
                },
                "judgeScore": {
                  "type": "number",
                  "nullable": true
                },
                "errorMessage": {
                  "type": "string",
                  "nullable": true
                },
                "startedAt": {
                  "type": "string"
                },
                "endedAt": {
                  "type": "string",
                  "nullable": true
                },
                "durationMs": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "nullable": true
                }
              },
              "required": [
                "id",
                "kind",
                "callKey",
                "promptVersion",
                "modelProvider",
                "modelName",
                "status",
                "cacheHit",
                "evalMode",
                "workflowRunId",
                "parentInvocationId",
                "linkedPatientId",
                "linkedPlanId",
                "promptTokens",
                "completionTokens",
                "totalTokens",
                "cachedInputTokens",
                "reasoningTokens",
                "costYuan",
                "judgeScore",
                "errorMessage",
                "startedAt",
                "endedAt",
                "durationMs"
              ],
              "additionalProperties": false
            }
          },
          "total": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "page": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "pageSize": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "pageSize"
        ],
        "additionalProperties": false
      },
      "AiInvocationStatsDto_Output": {
        "type": "object",
        "properties": {
          "count24h": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "cost24h": {
            "type": "number"
          },
          "failureRate24h": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "byCallKey": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "callKey": {
                  "type": "string"
                },
                "count": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "costYuan": {
                  "type": "number"
                },
                "avgDurationMs": {
                  "type": "number",
                  "nullable": true
                }
              },
              "required": [
                "callKey",
                "count",
                "costYuan",
                "avgDurationMs"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "count24h",
          "cost24h",
          "failureRate24h",
          "byCallKey"
        ],
        "additionalProperties": false
      },
      "AiInvocationDetailDto_Output": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "kind": {
            "type": "string"
          },
          "callKey": {
            "type": "string"
          },
          "promptVersion": {
            "type": "string"
          },
          "modelProvider": {
            "type": "string"
          },
          "modelName": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "cacheHit": {
            "type": "boolean"
          },
          "evalMode": {
            "type": "string"
          },
          "workflowRunId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "parentInvocationId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "nullable": true
          },
          "linkedPatientId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "nullable": true
          },
          "linkedPlanId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "nullable": true
          },
          "promptTokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "completionTokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "totalTokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "cachedInputTokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "reasoningTokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "costYuan": {
            "type": "number"
          },
          "judgeScore": {
            "type": "number",
            "nullable": true
          },
          "errorMessage": {
            "type": "string",
            "nullable": true
          },
          "startedAt": {
            "type": "string"
          },
          "endedAt": {
            "type": "string",
            "nullable": true
          },
          "durationMs": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "nullable": true
          },
          "inputSnapshot": {},
          "promptTemplate": {
            "type": "string",
            "nullable": true
          },
          "output": {
            "nullable": true
          },
          "outputText": {
            "type": "string",
            "nullable": true
          },
          "judgeRubric": {
            "nullable": true
          }
        },
        "required": [
          "id",
          "kind",
          "callKey",
          "promptVersion",
          "modelProvider",
          "modelName",
          "status",
          "cacheHit",
          "evalMode",
          "workflowRunId",
          "parentInvocationId",
          "linkedPatientId",
          "linkedPlanId",
          "promptTokens",
          "completionTokens",
          "totalTokens",
          "cachedInputTokens",
          "reasoningTokens",
          "costYuan",
          "judgeScore",
          "errorMessage",
          "startedAt",
          "endedAt",
          "durationMs",
          "inputSnapshot",
          "promptTemplate",
          "output",
          "outputText",
          "judgeRubric"
        ],
        "additionalProperties": false
      },
      "IngestFactsRequestDto": {
        "type": "object",
        "properties": {
          "events": {
            "minItems": 1,
            "maxItems": 500,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "sourceEventId": {
                  "type": "string",
                  "minLength": 1,
                  "description": "Host event ID; idempotency key"
                },
                "sourceActorId": {
                  "type": "string"
                },
                "sourceActorRole": {
                  "type": "string"
                },
                "clinicId": {
                  "type": "string",
                  "minLength": 1
                },
                "patientExternalId": {
                  "type": "string"
                },
                "action": {
                  "type": "string",
                  "minLength": 1
                },
                "subjectType": {
                  "type": "string",
                  "minLength": 1
                },
                "subjectId": {
                  "type": "string",
                  "minLength": 1
                },
                "rawPayload": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "occurredAt": {
                  "type": "string",
                  "description": "Host-side occurred time, ISO 8601 with offset"
                }
              },
              "required": [
                "sourceEventId",
                "clinicId",
                "action",
                "subjectType",
                "subjectId",
                "rawPayload",
                "occurredAt"
              ]
            }
          }
        },
        "required": [
          "events"
        ]
      },
      "IngestFactsResponseDto_Output": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "written": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "Newly written transactions (after idempotency dedup)"
          },
          "duplicates": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "source_event_id already existed, skipped"
          },
          "factsEmitted": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "Fact versions emitted by parser"
          },
          "rejected": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "reason": {
                  "type": "string"
                }
              },
              "required": [
                "index",
                "reason"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "accepted",
          "written",
          "duplicates",
          "factsEmitted",
          "rejected",
          "errors"
        ],
        "additionalProperties": false
      },
      "TokenExchangeRequestDto": {
        "type": "object",
        "properties": {
          "appId": {
            "type": "string",
            "minLength": 1,
            "description": "App id assigned to the host platform"
          },
          "appSecret": {
            "type": "string",
            "minLength": 1,
            "description": "App secret paired with appId. Held server-side only."
          },
          "user": {
            "type": "object",
            "properties": {
              "userId": {
                "type": "string",
                "minLength": 1,
                "description": "Host-side user id"
              },
              "tenantId": {
                "type": "string",
                "minLength": 1,
                "description": "Host-side tenant id (the host's own customer / org id)"
              },
              "role": {
                "type": "string",
                "enum": [
                  "staff",
                  "leader",
                  "admin"
                ],
                "description": "PAC role granted to this user. PAC ships three: staff (执行客服) / leader (主管) / admin (后台管理员)"
              },
              "orgScope": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "数据权限(唯一入口):用户可达的 org 节点 id,任意层级 —— 集团 / 区域(可多级)/ 品牌 / 诊所。PAC 按 host org 树 expandOrgScope 展开成内部过滤维(sourceUnits + clinicIds)。空数组 = 不限(集团级 / 超管)。诊所级即传诊所 id 列表;没有品牌概念的 host 同理只传诊所 id。"
              },
              "dictionary": {
                "description": "Optional id→name dictionary for UI display (clinics / users)",
                "type": "object",
                "properties": {
                  "clinics": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "users": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "required": [
              "userId",
              "tenantId",
              "role",
              "orgScope"
            ],
            "additionalProperties": false,
            "description": "User context for the token being signed"
          }
        },
        "required": [
          "appId",
          "appSecret",
          "user"
        ],
        "additionalProperties": false
      },
      "TokenExchangeResponseDto_Output": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string",
            "description": "Bearer JWT for subsequent API calls (default 2h TTL)"
          },
          "refreshToken": {
            "type": "string",
            "description": "Refresh JWT — exchange before access token expires"
          },
          "code": {
            "type": "string",
            "description": "One-time exchange code. Pass to the iframe URL; consumed by /auth/exchange-code (default 60s TTL)."
          },
          "expiresIn": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "Access token lifetime in seconds"
          },
          "codeExpiresIn": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "One-time code lifetime in seconds"
          }
        },
        "required": [
          "accessToken",
          "refreshToken",
          "code",
          "expiresIn",
          "codeExpiresIn"
        ],
        "additionalProperties": false
      },
      "ExchangeCodeRequestDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "code"
        ],
        "additionalProperties": false
      },
      "ExchangeCodeResponseDto_Output": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "refreshToken": {
            "type": "string"
          },
          "expiresIn": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "accessToken",
          "refreshToken",
          "expiresIn"
        ],
        "additionalProperties": false
      },
      "RefreshTokenRequestDto": {
        "type": "object",
        "properties": {
          "refreshToken": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "refreshToken"
        ],
        "additionalProperties": false
      },
      "RefreshTokenResponseDto_Output": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "refreshToken": {
            "type": "string"
          },
          "expiresIn": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "accessToken",
          "refreshToken",
          "expiresIn"
        ],
        "additionalProperties": false
      },
      "ClientDiagRequestDto": {
        "type": "object",
        "properties": {
          "phase": {
            "type": "string",
            "maxLength": 40
          },
          "ev": {
            "type": "string",
            "maxLength": 40
          },
          "hadCode": {
            "type": "boolean"
          },
          "codeTag": {
            "type": "string",
            "maxLength": 16,
            "nullable": true
          },
          "storedAccess": {
            "type": "boolean"
          },
          "storedRefresh": {
            "type": "boolean"
          },
          "storedAccessValid": {
            "type": "boolean"
          },
          "err": {
            "type": "string",
            "maxLength": 120,
            "nullable": true
          },
          "storageWritable": {
            "type": "boolean"
          },
          "isEmbedded": {
            "type": "boolean"
          },
          "hostOrigin": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "isReload": {
            "type": "boolean"
          },
          "ua": {
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "MockLoginRequestDto": {
        "type": "object",
        "properties": {
          "tenant": {
            "type": "string",
            "enum": [
              "ruier",
              "ruitai",
              "friday"
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "staff",
              "leader",
              "admin"
            ]
          },
          "userExternalId": {
            "type": "string"
          },
          "orgLevel": {
            "type": "string",
            "enum": [
              "group"
            ]
          },
          "orgId": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "tenant",
          "role"
        ],
        "additionalProperties": false
      },
      "MockLoginResponseDto_Output": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "refreshToken": {
            "type": "string"
          },
          "expiresIn": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "accessToken",
          "refreshToken",
          "expiresIn"
        ],
        "additionalProperties": false
      },
      "MockUsersResponseDto_Output": {
        "type": "object",
        "properties": {
          "users": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "externalId": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "tenant": {
                  "type": "string",
                  "enum": [
                    "ruier",
                    "ruitai"
                  ]
                },
                "lastActiveAt": {
                  "type": "string"
                },
                "contactCount": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "clinics": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "clinicId": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "clinicId",
                      "name"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "externalId",
                "name",
                "tenant",
                "lastActiveAt",
                "contactCount",
                "clinics"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "users"
        ],
        "additionalProperties": false
      },
      "SessionResponseDto_Output": {
        "type": "object",
        "properties": {
          "sub": {
            "type": "string"
          },
          "hostId": {
            "type": "string"
          },
          "tenantId": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "staff",
              "leader",
              "admin"
            ]
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "orgScope": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "clinicIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sourceUnits": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "dictionary": {
            "type": "object",
            "properties": {
              "clinics": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              },
              "users": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            },
            "additionalProperties": false,
            "description": "Optional id→displayName dictionary (clinics / users), host-provided"
          },
          "actionUrls": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string",
              "nullable": true
            }
          }
        },
        "required": [
          "sub",
          "hostId",
          "tenantId",
          "role",
          "permissions",
          "orgScope",
          "clinicIds",
          "sourceUnits"
        ],
        "additionalProperties": false
      },
      "PatientTimelineResponseDto_Output": {
        "type": "object",
        "properties": {
          "patient": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "externalId": {
                "type": "string"
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "gender": {
                "type": "string",
                "nullable": true
              },
              "birthDate": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "externalId",
              "name",
              "phone",
              "gender",
              "birthDate",
              "status"
            ],
            "additionalProperties": false
          },
          "facts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "subjectId": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "actual",
                    "planned"
                  ]
                },
                "type": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "active",
                    "superseded",
                    "cancelled",
                    "fulfilled",
                    "expired",
                    "invalidated"
                  ]
                },
                "version": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "clinicId": {
                  "type": "string",
                  "nullable": true
                },
                "occurredAt": {
                  "type": "string",
                  "nullable": true
                },
                "plannedFor": {
                  "type": "string",
                  "nullable": true
                },
                "validFrom": {
                  "type": "string",
                  "nullable": true
                },
                "validUntil": {
                  "type": "string",
                  "nullable": true
                },
                "title": {
                  "type": "string",
                  "nullable": true
                },
                "summary": {
                  "type": "string",
                  "nullable": true
                },
                "content": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "transactionIds": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "createdAt": {
                  "type": "string"
                },
                "updatedAt": {
                  "type": "string"
                },
                "supersededAt": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "id",
                "subjectId",
                "kind",
                "type",
                "status",
                "version",
                "clinicId",
                "occurredAt",
                "plannedFor",
                "validFrom",
                "validUntil",
                "title",
                "summary",
                "content",
                "transactionIds",
                "createdAt",
                "updatedAt",
                "supersededAt"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "patient",
          "facts"
        ],
        "additionalProperties": false
      },
      "ApiErrorEnvelope": {
        "type": "object",
        "description": "Wrapped error response. HTTP status is 200 unless the server crashed (5xx).",
        "properties": {
          "code": {
            "type": "integer",
            "description": "Non-zero business code (HTTP-status-style)."
          },
          "msg": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "nullable": true
          },
          "details": {
            "description": "Optional structured detail (e.g. zod issues)."
          }
        },
        "required": [
          "code",
          "msg",
          "data"
        ]
      }
    }
  }
}
