From 98fd595218957d8abed364a57336e459daa63fcf Mon Sep 17 00:00:00 2001 From: lik Date: Fri, 13 Nov 2026 15:48:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(escort):=20=E4=B8=8B=E5=8D=95=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E7=A1=AE=E8=AE=A4=E5=85=8D=E8=B4=A3=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E5=B9=B6=E7=95=99=E5=AD=98=E7=89=88=E6=9C=AC=E5=BF=AB=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 GET /health/disclaimer 与精简版免责协议正文(对齐 GB/T 47801);非管理员下单须勾选且协议版本与服务端一致,服务端盖章写入 accepted/version/acceptedAt;agreement 不在更新白名单内,保证凭据不可篡改。 --- handler/escort_record.js | 23 +++++++++- handler/resource.js | 11 ++++- models/schema/escort_record.js | 8 ++++ resource/agreement.js | 75 ++++++++++++++++++++++++++++++++ routes/index.js | 1 + test/attendant_selection.test.js | 27 +++++++++++- 6 files changed, 141 insertions(+), 4 deletions(-) diff --git a/handler/escort_record.js b/handler/escort_record.js index d748e68..f6a579e 100644 --- a/handler/escort_record.js +++ b/handler/escort_record.js @@ -1,6 +1,7 @@ import mongoose from "mongoose"; import { DBModel } from "../models/index.js"; import services from "../resource/services.js"; +import { disclaimer } from "../resource/agreement.js"; import ResponseUtil from "../utils/responseUtil.js"; import logger from "../utils/logger.js"; import { isAdmin as isAdminUser, resolveEscortAdminRole } from "../utils/permissions.js"; @@ -16,7 +17,9 @@ class HandlerEscortRecord { constructor() { } - // 白名单:只允许写入 schema 定义的顶层字段(兼容 'patient.name' 等点号路径) + // 白名单:只允许写入 schema 定义的顶层字段(兼容 'patient.name' 等点号路径)。 + // agreement(免责协议确认快照)有意排除:仅下单时由服务端盖章写入版本与时间, + // 所有角色(含管理员)都不可通过通用更新接口修改,保证凭据不可篡改。 static RECORD_FIELDS = [ "userId", "healthProfileId", "patient", "escort", "attendant", "hospital", "schedule", "payment", "notes", "inquiry", "status", @@ -942,6 +945,24 @@ class HandlerEscortRecord { }; payload.schedule = scheduleResult.schedule; payload.shippingAddress = addressResult.shippingAddress; + // 《全程陪诊服务免责协议》确认快照由服务端盖章写入(版本与时间不信任客户端): + // 非管理员必为本人下单(档案归属校验已保证),必须已勾选且版本与服务端当前一致, + // 避免「读旧版正文、盖新版版本号」;管理员代客下单不强制。 + if (!isAdmin) { + if (body.agreement?.accepted !== true) { + return ResponseUtil.badRequest(ctx, "请先阅读并同意《全程陪诊服务免责协议》"); + } + if (body.agreement?.version !== disclaimer.version) { + return ResponseUtil.badRequest(ctx, "服务协议已更新,请重新阅读并确认后再提交"); + } + } + if (body.agreement?.accepted === true) { + payload.agreement = { + accepted: true, + version: disclaimer.version, + acceptedAt: new Date(), + }; + } if (idempotencyKey) payload.idempotencyKey = idempotencyKey; // 支付渠道:用户端只可选微信支付 / 线下支付;管理员代下单可按 method 推导 diff --git a/handler/resource.js b/handler/resource.js index ec7d41e..aa795e3 100644 --- a/handler/resource.js +++ b/handler/resource.js @@ -1,6 +1,6 @@ import ResponseUtil from "../utils/responseUtil.js"; import services from "../resource/services.js"; -import agreement from "../resource/agreement.js"; +import agreement, { disclaimer } from "../resource/agreement.js"; import hospitalInfo from "../resource/hospital_info.js"; import aiquick_questions from "../resource/aiquick_questions.js"; import { hospitalRanking, departmentRankings } from "../resource/fudan_hospital_ranking.js"; @@ -27,6 +27,15 @@ class HandlerResource { } } + // 获取全程陪诊服务免责协议(下单前必须阅读并勾选确认) + async getDisclaimer(ctx) { + try { + return ResponseUtil.success(ctx, { disclaimer }, "查询成功"); + } catch (err) { + return ResponseUtil.internalError(ctx, err); + } + } + // 获取医院信息 async getHospitalInfo(ctx) { try { diff --git a/models/schema/escort_record.js b/models/schema/escort_record.js index 56097c0..365551d 100644 --- a/models/schema/escort_record.js +++ b/models/schema/escort_record.js @@ -79,6 +79,14 @@ const EscortRecordSchema = mongoose.Schema( address: { type: String, default: "", comment: "完整收货地址" }, }, + // 下单时用户对《全程陪诊服务免责协议》的确认快照,作为电子服务合同凭据留存。 + // 管理员 / 陪诊师端代客下单可不带该字段,历史订单默认未确认。 + agreement: { + accepted: { type: Boolean, default: false, comment: "是否已阅读并同意免责协议" }, + version: { type: String, default: "", comment: "用户确认的协议版本" }, + acceptedAt: { type: Date, default: null, comment: "用户确认时间" }, + }, + /** * 陪诊员信息 - 为患者提供服务的陪诊员 */ diff --git a/resource/agreement.js b/resource/agreement.js index f184e9b..1aa56bd 100644 --- a/resource/agreement.js +++ b/resource/agreement.js @@ -91,4 +91,79 @@ const agreement = { ] }; +// 《全程陪诊服务免责协议》:下单前用户必须阅读并勾选确认。 +// 正文为线下《全程陪诊服务免责协议书》的精简版,保留 GB/T 47801—2026 要求的服务边界、 +// 风险告知、电子合同确认等关键条款。 +export const disclaimer = { + title: "全程陪诊服务免责协议", + subtitle: "请在下单前完整阅读,勾选同意后即可提交预约", + // 版本号随正文修订递增,订单会留存用户确认的版本,便于追溯 + version: "2026-11-13", + sections: [ + { + number: 1, + title: "服务范围", + type: "list", + items: [ + "陪诊服务仅限医院内的陪同引导与事务协助:挂号引导、科室引路、协助缴费取单、陪同常规检查、记录转达医嘱等。", + "平台及陪诊人员不提供诊断、用药指导、医疗护理等任何诊疗服务,不参与医疗操作,不代签任何医疗文书。", + "本协议仅对本次订单的服务对象、日期与时段有效。" + ] + }, + { + number: 2, + title: "风险告知", + type: "list", + items: [ + "就医过程存在病情变化、晕厥跌倒、药物过敏等固有医疗风险,属于医疗机构诊疗范畴。", + "陪诊人员不具备医疗救治能力,仅提供陪同协助与安全提醒,无法完全避免突发意外;遇特殊情况将第一时间联系医护及紧急联系人。", + "孕妇、高龄、术后等高危人群请在家属知情同意后预约,并如实告知身体状况。" + ] + }, + { + number: 3, + title: "您的义务", + type: "list", + items: [ + "保证服务对象意识清醒、具备完全民事行为能力(或已由监护人同意),如实告知病史、过敏史等健康信息;因隐瞒引发后果自行承担。", + "遵从医护安排与陪诊安全提醒,不擅自脱离陪同;贵重物品自行保管,平台不承担财物丢失责任。", + "改期或取消按《陪诊服务协议》约定时限办理,逾期按公示规则扣除违约金。" + ] + }, + { + number: 4, + title: "免责条款", + type: "list", + items: [ + "平台已尽职履行陪同、提醒与应急协助义务的,因下列情形导致的损害或纠纷,平台不承担赔偿责任:", + "医院诊疗行为、麻醉、用药、检查、手术引发的医疗风险及纠纷;", + "服务对象自身疾病发作、隐瞒病史,或不服从安全提醒、擅自行动引发的意外;", + "医院设施问题、不可抗力,以及超出约定服务范围的问题。" + ] + }, + { + number: 5, + title: "隐私保护", + type: "list", + items: [ + "平台仅在服务必需范围内收集使用个人信息;陪诊人员对知悉的病情、病历严格保密,不向无关第三方提供。" + ] + }, + { + number: 6, + title: "生效与争议解决", + type: "list", + items: [ + "勾选并提交订单即表示已阅读、理解并同意全部条款;本协议与《陪诊服务协议》共同构成电子服务合同,与纸质签字具有同等法律效力,但不替代医院的医疗知情同意文书。", + "本协议适用《中华人民共和国民法典》,争议协商不成的,可向平台所在地人民法院提起诉讼。" + ] + } + ], + footer: [ + "依据《中华人民共和国民法典》及 GB/T 47801—2026 制定", + "更新日期:2026年11月13日", + "© 2026 北京奕华盛科技" + ] +}; + export default agreement; diff --git a/routes/index.js b/routes/index.js index cb99d3c..c02e549 100644 --- a/routes/index.js +++ b/routes/index.js @@ -181,6 +181,7 @@ function registerRoutes(app) { router.get("/service", handlerResource.getServices.bind(handlerResource)); router.get("/agreement", handlerResource.getAgreement.bind(handlerResource)); + router.get("/disclaimer", handlerResource.getDisclaimer.bind(handlerResource)); router.get("/hospital-info", handlerResource.getHospitalInfo.bind(handlerResource)); router.get("/hospital-ranking", handlerResource.getHospitalRanking.bind(handlerResource)); router.get("/department-rankings", handlerResource.getDepartmentRankings.bind(handlerResource)); diff --git a/test/attendant_selection.test.js b/test/attendant_selection.test.js index c9c78fa..18d7210 100644 --- a/test/attendant_selection.test.js +++ b/test/attendant_selection.test.js @@ -3,6 +3,7 @@ import assert from "node:assert/strict"; import { DBModel } from "../models/index.js"; import { HandlerEscortRecord } from "../handler/escort_record.js"; +import { disclaimer } from "../resource/agreement.js"; const USER_ID = "64b000000000000000000101"; const PROFILE_ID = "64b000000000000000000102"; @@ -45,6 +46,8 @@ function buildBody(attendant) { hospital: { province: "北京市", name: "北京协和医院" }, schedule: { date: futureDate(3), startTime: "08:00" }, payment: { payChannel: "offline" }, + // 非管理员下单必须确认免责协议,且版本需与服务端当前版本一致 + agreement: { accepted: true, version: disclaimer.version }, ...(attendant ? { attendant } : {}), }; } @@ -83,7 +86,7 @@ function employeeFindOneStub(employee, overrides = {}) { }; } -async function runCreate({ attendant, employee = buildEmployee(), user } = {}) { +async function runCreate({ attendant, employee = buildEmployee(), user, bodyOverrides } = {}) { const calls = { payload: null, bumped: null }; const recordStub = { findByIdempotencyKey: async () => null, @@ -99,7 +102,7 @@ async function runCreate({ attendant, employee = buildEmployee(), user } = {}) { }, }); - const ctx = createCtx(buildBody(attendant), user); + const ctx = createCtx({ ...buildBody(attendant), ...(bodyOverrides || {}) }, user); await withModel("HealthProfile", { findProfileById: async () => buildProfile() }, () => withModel("EscortRecord", recordStub, () => withModel("Employee", employeeStub, () => new HandlerEscortRecord().createRecord(ctx)) @@ -187,3 +190,23 @@ test("陪诊师 ID 不合法返回 400", async () => { assert.equal(ctx.body.code, 400); assert.equal(calls.payload, null); }); + +test("用户下单未确认免责协议返回 400 且不创建订单", async () => { + const { ctx, calls } = await runCreate({ + bodyOverrides: { agreement: undefined }, + }); + + assert.equal(ctx.body.code, 400); + assert.match(ctx.body.msg, /免责协议/); + assert.equal(calls.payload, null); +}); + +test("用户下单协议版本过期返回 400 且不创建订单", async () => { + const { ctx, calls } = await runCreate({ + bodyOverrides: { agreement: { accepted: true, version: "2000-01-01" } }, + }); + + assert.equal(ctx.body.code, 400); + assert.match(ctx.body.msg, /已更新/); + assert.equal(calls.payload, null); +});