feat(escort): 病历与诉求支持多材料解析为四段摘要

新增独立病历整理 Agent 与异步解析任务,支持 PDF 文本、图片 OCR、
语音 ASR 与文字输入,统一整理为基础健康、检查治疗、用药和问诊诉求。
Agent 只产出草稿,订单本人在编辑页核对确认后才写入当前订单;
原件在任务结束、失败或取消时立即清除。

inquiry 增加三段规范字段,medicalHistory 保留为旧版兼容摘要,
并兼容旧客户端只写 medicalHistory 的更新方式。
This commit is contained in:
lik
2026-11-16 20:44:46 +08:00
parent 77a201c0b3
commit 6d2fc04424
17 changed files with 901 additions and 12 deletions
+15 -1
View File
@@ -185,7 +185,11 @@ const EscortRecordSchema = mongoose.Schema(
* 问诊信息 - 就诊人补充的病历与诉求,与下单备注分开
*/
inquiry: {
medicalHistory: { type: String, default: "", comment: "病历" },
// 四段为规范字段;medicalHistory 由前三段生成,保留给旧版客户端展示。
basicHealth: { type: String, default: "", comment: "基础健康状况与基础疾病" },
treatmentHistory: { type: String, default: "", comment: "检查与治疗病历" },
medications: { type: String, default: "", comment: "用药情况" },
medicalHistory: { type: String, default: "", comment: "病历兼容摘要" },
demand: { type: String, default: "", comment: "诉求" },
},
@@ -471,6 +475,16 @@ EscortRecordSchema.statics.updateRecord = async function (id, update, cb) {
);
};
// 解析草稿确认必须基于创建任务时的订单版本,避免覆盖解析期间的其他修改。
EscortRecordSchema.statics.updateRecordIfUnchanged = async function (id, expectedUpdatedAt, update) {
if (!expectedUpdatedAt) return null;
return await this.findOneAndUpdate(
{ _id: id, deletedAt: null, "meta.updatetime": new Date(expectedUpdatedAt) },
{ $set: { ...update, "meta.updatetime": Date.now() } },
{ new: true, runValidators: true }
);
};
// 状态迁移必须仍以读取时的状态为条件,避免并发请求重复取消或跨过服务阶段。
EscortRecordSchema.statics.updateRecordStatus = async function (id, fromStatus, update) {
return await this.findOneAndUpdate(