From fac7b877289d5c3d8d72a0e3eb4302d821808f67 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Fri, 9 Oct 2026 12:31:13 +0800 Subject: [PATCH] feat(db): add biz_sample_storage_cert_qc for storage-cert QC payload. Co-authored-by: Cursor --- backend/app/models/models.py | 31 ++++++++++++++++++- .../2026-10-09-sample-storage-cert-qc.sql | 24 ++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 docs/sql/migrations/2026-10-09-sample-storage-cert-qc.sql diff --git a/backend/app/models/models.py b/backend/app/models/models.py index 3d2a20e6..912ada1d 100644 --- a/backend/app/models/models.py +++ b/backend/app/models/models.py @@ -334,6 +334,10 @@ class BizCustomer(Base): sex = Column(CHAR(1), nullable=True, default="2", comment="性别(0男1女2未知)") id_card_no = Column(String(32), nullable=True, comment="身份证号") age = Column(Integer, nullable=True, comment="年龄") + birth_ym = Column(CHAR(6), nullable=True, comment="出生年月YYYYMM") + ethnic = Column(String(32), nullable=True, comment="民族") + email = Column(String(128), nullable=True, comment="邮箱") + address = Column(String(512), nullable=True, comment="家庭住址") phone_no = Column(String(32), nullable=True, comment="联系电话") customer_tags = Column(String(512), nullable=True, comment="客户标签,逗号分隔") tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号") @@ -1496,7 +1500,8 @@ class BizProtocolCollectionInfo(Base): region_id = Column(String(64), nullable=True, comment="区域ID") hospital_id = Column(String(64), nullable=True, comment="医院ID") medical_staff = Column(String(200), nullable=True, comment="医护人员") - sales_user_id = Column(String(64), nullable=True, comment="销售人员用户ID") + sales_user_id = Column(String(64), nullable=True, comment="市场专员用户ID") + region_manager_user_id = Column(String(64), nullable=True, comment="地区经理用户ID") sample_collect_time = Column(DateTime, nullable=True, comment="样本采集时间") maternal_blood_collect_time = Column(DateTime, nullable=True, comment="母血采集时间") tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号") @@ -1577,6 +1582,7 @@ class BizSampleFreight(Base): __tablename__ = "biz_sample_freight" id = Column(String(64), primary_key=True, comment="主键ID") + freight_no = Column(String(32), nullable=False, default="", comment="运费批次号 YF+YYYYMMDD+序号") transport_mode = Column(String(100), nullable=False, default="", comment="运输方式字典值") freight_amount = Column(Numeric(18, 2), nullable=False, default=0, comment="运费(元)") tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号") @@ -1659,6 +1665,29 @@ class BizProtocolStorageCert(Base): del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记") +class BizSampleStorageCertQc(Base): + """样本储存证质检信息 biz_sample_storage_cert_qc""" + + __tablename__ = "biz_sample_storage_cert_qc" + + id = Column(String(64), primary_key=True, comment="主键ID") + sample_code = Column(String(32), nullable=False, comment="样本编码") + collection_protocol_id = Column(String(64), nullable=True, comment="采集协议单ID冗余") + qc_work_order_id = Column(String(64), nullable=True, comment="最近填写来源工单ID") + sample_type_key = Column(String(32), nullable=False, comment="perinatal_hsc|uc_msc") + payload = Column(Text, nullable=False, comment="业务字段 JSON") + filled_flag = Column(CHAR(1), nullable=False, default="0", comment="是否已保存过 0否1是") + tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号") + order_num = Column(Integer, nullable=True, comment="排序号") + remark = Column(String(512), nullable=True, comment="备注") + create_by = Column(String(64), nullable=True, comment="创建人id") + create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID") + create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间") + update_by = Column(String(64), nullable=True, comment="更新人id") + update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间") + del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记") + + class BizSampleReceptionCheckItem(Base): """样本接收检查项配置 biz_sample_reception_check_item""" diff --git a/docs/sql/migrations/2026-10-09-sample-storage-cert-qc.sql b/docs/sql/migrations/2026-10-09-sample-storage-cert-qc.sql new file mode 100644 index 00000000..c884f3aa --- /dev/null +++ b/docs/sql/migrations/2026-10-09-sample-storage-cert-qc.sql @@ -0,0 +1,24 @@ +-- 样本级储存证质检信息(2026-10-09) +-- 对齐 docs/superpowers/specs/2026-10-09-storage-cert-qc-info-design.md + +CREATE TABLE IF NOT EXISTS biz_sample_storage_cert_qc ( + id VARCHAR(64) NOT NULL COMMENT '主键ID', + sample_code VARCHAR(32) NOT NULL COMMENT '样本编码', + collection_protocol_id VARCHAR(64) DEFAULT NULL COMMENT '采集协议单ID冗余', + qc_work_order_id VARCHAR(64) DEFAULT NULL COMMENT '最近填写来源工单ID', + sample_type_key VARCHAR(32) NOT NULL COMMENT 'perinatal_hsc|uc_msc', + payload TEXT NOT NULL COMMENT '业务字段 JSON', + filled_flag CHAR(1) NOT NULL DEFAULT '0' COMMENT '是否已保存过 0否1是', + tenant_no VARCHAR(64) NOT NULL DEFAULT 'zkxw' COMMENT '租户编号', + order_num INT DEFAULT NULL COMMENT '排序号', + remark VARCHAR(512) DEFAULT NULL COMMENT '备注', + create_by VARCHAR(64) DEFAULT NULL COMMENT '创建人id', + create_dept_id VARCHAR(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID', + create_time DATETIME NOT NULL COMMENT '创建时间', + update_by VARCHAR(64) DEFAULT NULL COMMENT '更新人id', + update_time DATETIME NOT NULL COMMENT '更新时间', + del_flag SMALLINT NOT NULL DEFAULT 0 COMMENT '删除标记', + PRIMARY KEY (id), + UNIQUE KEY uk_storage_cert_qc_tenant_sample (tenant_no, sample_code), + KEY idx_storage_cert_qc_protocol (tenant_no, collection_protocol_id, del_flag) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='样本储存证质检信息';