From 139013ae4c447b47179e292a08b9328861a87914 Mon Sep 17 00:00:00 2001 From: lik Date: Wed, 7 Oct 2026 11:52:30 +0800 Subject: [PATCH] tmp --- handler/escort_record.js | 4 ++++ models/schema/escort_record.js | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/handler/escort_record.js b/handler/escort_record.js index 452b304..1b99f16 100644 --- a/handler/escort_record.js +++ b/handler/escort_record.js @@ -105,6 +105,10 @@ class HandlerEscortRecord { if (!record.userId) { return ResponseUtil.badRequest(ctx, "缺少患者信息"); } + // 订单必须关联就诊人:patient 是下单当刻的快照,healthProfileId 才是关联 + if (!record.healthProfileId) { + return ResponseUtil.badRequest(ctx, "缺少就诊人档案ID"); + } const newRecord = await DBModel.EscortRecord.createRecord(HandlerEscortRecord.pickFields(record)); return ResponseUtil.success(ctx, { record: newRecord }, "创建成功"); diff --git a/models/schema/escort_record.js b/models/schema/escort_record.js index 12e50d1..0519b3e 100644 --- a/models/schema/escort_record.js +++ b/models/schema/escort_record.js @@ -7,7 +7,7 @@ import mongoose from "mongoose"; * * 用于记录和管理陪诊服务全流程数据,包含以下主要分类: * - 基础信息:userId(订单提交用户)、healthProfileId(关联健康档案ID) - * - 患者信息:patient(姓名、电话、性别、出生年月、身份证号) + * - 患者信息:patient(名单字段快照:姓名、电话、性别、出生年月) * - 陪诊服务:escort(服务ID、服务名称) * - 就诊信息:hospital(医院省份、名称、地址、科室、医生、病历号) * - 时间安排:schedule(预约时间、开始时间、结束时间、时长) @@ -32,7 +32,7 @@ const EscortRecordSchema = mongoose.Schema( }, /** - * 关联健康档案ID(可为空) + * 关联健康档案ID(下单必填:订单必须关联就诊人) * @type {ObjectId} * @ref health_profile */ @@ -44,16 +44,16 @@ const EscortRecordSchema = mongoose.Schema( }, /** - * 患者信息 - 就诊患者的基本信息 + * 患者信息 - 下单当刻从健康档案拷贝的「名单字段」快照(仅姓名/电话/性别/出生年月)。 + * 档案可随时编辑或删除,历史订单至少需要认出"是谁、怎么联系",故名单快照与 healthProfileId 并存: + * 展示时以档案最新数据为准,档案缺失时回落到这份快照。 + * 体征(身高/体重)与证件号不进快照——它们只有详情页兜底在用,详情页本来就实时拉档案 */ patient: { name: { type: String, default: "", comment: "患者姓名" }, mobile: { type: String, default: "", index: true, comment: "患者联系电话" }, sex: { type: String, enum: ["male", "female"], comment: "患者性别" }, birth: { type: String, default: "", comment: "患者出生年月(YYYY-MM-DD)" }, - weight: { type: Number, default: 0, comment: "患者体重(kg)" }, - height: { type: Number, default: 0, comment: "患者身高(cm)" }, - idnumber: { type: String, default: "", comment: "患者身份证号" }, }, /**