chore(schema): organization 移除医院相关定义并留档数据清理脚本

医院数据统一走 hospital 集合后,organization 移除 hospital 枚举、
level 与就医信息字段(overview/photos/departments/doctors/guides)。
新增一次性清理脚本(删医院记录、删 2026-11 前订单)与只读体检脚本
(索引同步、孤儿引用、脏数据检查)。
This commit is contained in:
lik
2026-11-06 17:49:03 +08:00
parent 9ab2a39d08
commit f13af01a95
5 changed files with 295 additions and 34 deletions
+8 -34
View File
@@ -5,14 +5,15 @@ import { pinyin } from "pinyin-pro";
/**
* Organization Schema
* 组织/机构基础信息,支持医院、诊所、体检中心等多种机构类型;
* 组织/机构基础信息,支持诊所、体检中心等机构类型;
* 医院基础信息统一在 hospital 集合(schema/hospital.js),此处不再维护。
* 分院/院区用 parentId 指向总院,先只做一层,更多层级按需再加
*/
const OrganizationSchema = mongoose.Schema(
{
// 基础信息
name: { type: String, required: true, index: true, comment: "机构全称;分院/院区需带总院名,如 北京协和医院西单院区" },
shortName: { type: String, default: "", comment: "机构简称/别名,如 协和西院" },
name: { type: String, required: true, index: true, comment: "机构全称;分院/分点需带主机构名,如 美年大健康西单分院" },
shortName: { type: String, default: "", comment: "机构简称/别名,如 美年西单店" },
pinyin: { type: String, default: "", index: true, comment: "机构名称全拼(小写无分隔,用于搜索)" },
pinyinFL: { type: String, default: "", index: true, comment: "机构名称拼音首字母(用于搜索)" },
code: { type: String, unique: true, sparse: true, comment: "机构编码(不填时字段缺省,避免与 unique sparse 索引冲突)" },
@@ -29,18 +30,12 @@ const OrganizationSchema = mongoose.Schema(
// 机构类型
type: {
type: String,
enum: ["hospital", "clinic", "checkup_center", "other"],
default: "hospital",
comment: "机构类型:医院、诊所、体检中心、其他",
enum: ["clinic", "checkup_center", "other"],
default: "clinic",
comment: "机构类型:诊所、体检中心、其他(医院在 hospital 集合)",
},
// 等级/性质
level: {
type: String,
enum: ["三级甲等", "三级乙等", "二级甲等", "二级乙等", "一级", "未定级", ""],
default: "",
comment: "医院等级",
},
// 性质
nature: {
type: String,
enum: ["public", "private", "joint", "other", ""],
@@ -77,27 +72,6 @@ const OrganizationSchema = mongoose.Schema(
description: { type: String, default: "", comment: "机构简介" },
remark: { type: String, default: "", comment: "备注" },
// 就医信息:agent-first,字段已平铺,先保留够用的部分,后续按需增加
overview: { type: String, default: "", comment: "医院级信息全文(门诊/挂号/缴费/医保/交通)" },
photos: [{
url: { type: String, default: "", comment: "图片链接" },
caption: { type: String, default: "", comment: "说明(医院照片/导引照片 + 描述)" },
}],
departments: [{
name: { type: String, comment: "科室名称(锚点)" },
detail: { type: String, default: "", comment: "科室信息全文(位置/电话/类型/就诊提示)" },
photo: { type: String, default: "", comment: "科室位置导引照片链接" },
}],
doctors: [{
name: { type: String, comment: "医生姓名(锚点)" },
department: { type: String, comment: "所属科室(锚点)" },
detail: { type: String, default: "", comment: "医生信息全文(职称/擅长/号别/坐班停诊)" },
photo: { type: String, default: "", comment: "医生照片链接" },
}],
guides: { type: mongoose.Schema.Types.Mixed, comment: "场景指南(键为场景名,值为文本)" },
infoUpdatedAt: { type: Date, comment: "就医信息最近更新时间" },
infoUpdatedBy: { type: String, default: "", comment: "就医信息最近更新人" },
// 元数据
meta: {
createtime: { type: Date, default: Date.now, comment: "创建时间" },