feat(escort): 病历与诉求支持多材料解析为四段摘要
新增独立病历整理 Agent 与异步解析任务,支持 PDF 文本、图片 OCR、 语音 ASR 与文字输入,统一整理为基础健康、检查治疗、用药和问诊诉求。 Agent 只产出草稿,订单本人在编辑页核对确认后才写入当前订单; 原件在任务结束、失败或取消时立即清除。 inquiry 增加三段规范字段,medicalHistory 保留为旧版兼容摘要, 并兼容旧客户端只写 medicalHistory 的更新方式。
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const InquiryParseJobSchema = mongoose.Schema(
|
||||
{
|
||||
recordId: { type: mongoose.Schema.Types.ObjectId, ref: "escort_record", required: true, index: true },
|
||||
userId: { type: mongoose.Schema.Types.ObjectId, ref: "user", required: true, index: true },
|
||||
status: {
|
||||
type: String,
|
||||
enum: ["queued", "processing", "waiting_confirmation", "failed", "confirmed", "cancelled"],
|
||||
default: "queued",
|
||||
index: true,
|
||||
},
|
||||
// 原始 base64 仅在解析期间保留;任务完成、失败或取消时立即 $unset。
|
||||
inputs: { type: Object, select: false, default: null },
|
||||
active: { type: Boolean, default: true },
|
||||
baseUpdatedAt: { type: Date, default: null },
|
||||
draft: {
|
||||
basicHealth: { type: String, default: "" },
|
||||
treatmentHistory: { type: String, default: "" },
|
||||
medications: { type: String, default: "" },
|
||||
demand: { type: String, default: "" },
|
||||
},
|
||||
uncertainties: { type: [String], default: [] },
|
||||
errorMessage: { type: String, default: "" },
|
||||
expiresAt: { type: Date, required: true },
|
||||
createdAt: { type: Date, default: Date.now },
|
||||
updatedAt: { type: Date, default: Date.now },
|
||||
},
|
||||
{ minimize: false, strict: true, collection: "inquiry_parse_job", timestamps: false }
|
||||
);
|
||||
|
||||
InquiryParseJobSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
||||
InquiryParseJobSchema.index({ recordId: 1, userId: 1, createdAt: -1 });
|
||||
InquiryParseJobSchema.index(
|
||||
{ recordId: 1, userId: 1 },
|
||||
{ unique: true, partialFilterExpression: { active: true }, name: "one_active_inquiry_job" }
|
||||
);
|
||||
|
||||
InquiryParseJobSchema.pre("updateOne", function (next) {
|
||||
this.set({ updatedAt: new Date() });
|
||||
next();
|
||||
});
|
||||
InquiryParseJobSchema.pre("findOneAndUpdate", function (next) {
|
||||
this.set({ updatedAt: new Date() });
|
||||
next();
|
||||
});
|
||||
|
||||
export { InquiryParseJobSchema };
|
||||
Reference in New Issue
Block a user