From 390c871d35608ce6af4e3444046b12085c0257e9 Mon Sep 17 00:00:00 2001 From: lik Date: Thu, 27 Aug 2026 22:00:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=A1=A8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=81=A5=E5=BA=B7=E6=A1=A3=E6=A1=88id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/schema/escort_record.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/models/schema/escort_record.js b/models/schema/escort_record.js index 5185be6..cf2860f 100644 --- a/models/schema/escort_record.js +++ b/models/schema/escort_record.js @@ -6,7 +6,7 @@ import mongoose from "mongoose"; * 陪诊记录Schema定义 * * 用于记录和管理陪诊服务全流程数据,包含以下主要分类: - * - 基础信息:userId(订单提交用户) + * - 基础信息:userId(订单提交用户)、healthProfileId(关联健康档案ID) * - 患者信息:patient(姓名、电话、性别、年龄、身份证号) * - 陪诊服务:escort(服务ID、服务名称) * - 就诊信息:hospital(医院省份、名称、地址、科室、医生、病历号) @@ -31,6 +31,18 @@ const EscortRecordSchema = mongoose.Schema( comment: "提交订单用户ID" }, + /** + * 关联健康档案ID(可为空) + * @type {ObjectId} + * @ref health_profile + */ + healthProfileId: { + type: mongoose.Schema.Types.ObjectId, + ref: "health_profile", + default: null, + comment: "关联健康档案ID" + }, + /** * 患者信息 - 就诊患者的基本信息 */ @@ -271,6 +283,11 @@ EscortRecordSchema.statics.deleteRecord = async function (id, cb) { */ EscortRecordSchema.index({ userId: 1, "schedule.date": -1 }); +/** + * 健康档案ID索引 - 稀疏索引,用于快速按健康档案筛选记录 + */ +EscortRecordSchema.index({ healthProfileId: 1 }, { sparse: true }); + /** * 陪诊员ID索引 - 用于快速查询陪诊员的服务记录 */