feat(c1): elder + elder_status_log 数据模型
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
239dec912c
commit
b83c59611c
80
prisma/migrations/20261014084652_c1_elder/migration.sql
Normal file
80
prisma/migrations/20261014084652_c1_elder/migration.sql
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `ltc_elder` (
|
||||||
|
`id` VARCHAR(36) NOT NULL,
|
||||||
|
`tenant_code` VARCHAR(64) NOT NULL,
|
||||||
|
`loc_code` VARCHAR(12) NOT NULL,
|
||||||
|
`prev_loc_code` VARCHAR(12) NULL,
|
||||||
|
`transfer_confirm_at` DATETIME(3) NULL,
|
||||||
|
`name` VARCHAR(30) NOT NULL,
|
||||||
|
`gender` CHAR(1) NOT NULL,
|
||||||
|
`birth_date` DATE NOT NULL,
|
||||||
|
`id_card_no` VARCHAR(255) NOT NULL,
|
||||||
|
`phone` VARCHAR(15) NULL,
|
||||||
|
`address` VARCHAR(200) NOT NULL,
|
||||||
|
`guardian_name` VARCHAR(30) NULL,
|
||||||
|
`guardian_phone` VARCHAR(15) NULL,
|
||||||
|
`insur_no` VARCHAR(30) NOT NULL,
|
||||||
|
`insur_type` VARCHAR(10) NOT NULL,
|
||||||
|
`insur_years` INTEGER NULL,
|
||||||
|
`insur_verify_status` VARCHAR(20) NULL,
|
||||||
|
`insur_verify_date` DATE NULL,
|
||||||
|
`assess_level` VARCHAR(20) NULL,
|
||||||
|
`care_level` VARCHAR(20) NULL,
|
||||||
|
`assess_date` DATE NULL,
|
||||||
|
`assess_org` VARCHAR(100) NULL,
|
||||||
|
`assess_evidence_file` VARCHAR(255) NULL,
|
||||||
|
`benefit_start` DATE NULL,
|
||||||
|
`benefit_end` DATE NULL,
|
||||||
|
`treat_status` VARCHAR(20) NOT NULL DEFAULT 'pending_file',
|
||||||
|
`status_source` VARCHAR(10) NOT NULL DEFAULT 'manual',
|
||||||
|
`status_change_date` DATE NULL,
|
||||||
|
`hosp_start` DATE NULL,
|
||||||
|
`hosp_end` DATE NULL,
|
||||||
|
`photo_tier_override` JSON NULL,
|
||||||
|
`need_assess` JSON NULL,
|
||||||
|
`note` TEXT NULL,
|
||||||
|
`biz_line` VARCHAR(20) NOT NULL DEFAULT 'ltci',
|
||||||
|
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`created_by` VARCHAR(36) NULL,
|
||||||
|
`updated_at` DATETIME(3) NOT NULL,
|
||||||
|
`deleted_at` DATETIME(3) NULL,
|
||||||
|
|
||||||
|
INDEX `ltc_elder_tenant_code_name_idx`(`tenant_code`, `name`),
|
||||||
|
UNIQUE INDEX `ltc_elder_tenant_code_id_card_no_key`(`tenant_code`, `id_card_no`),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `ltc_elder_status_log` (
|
||||||
|
`id` VARCHAR(36) NOT NULL,
|
||||||
|
`elder_id` VARCHAR(36) NOT NULL,
|
||||||
|
`tenant_code` VARCHAR(64) NOT NULL,
|
||||||
|
`from_status` VARCHAR(20) NOT NULL,
|
||||||
|
`to_status` VARCHAR(20) NOT NULL,
|
||||||
|
`change_reason` VARCHAR(200) NOT NULL,
|
||||||
|
`source` VARCHAR(10) NOT NULL DEFAULT 'manual',
|
||||||
|
`operator_id` VARCHAR(36) NOT NULL,
|
||||||
|
`evidence_file` VARCHAR(255) NULL,
|
||||||
|
`changed_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
|
||||||
|
INDEX `ltc_elder_status_log_elder_id_idx`(`elder_id`),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||||
|
|
||||||
|
-- RenameIndex
|
||||||
|
ALTER TABLE `ltc_staff` RENAME INDEX `sys_staff_tenant_code_name_idx` TO `ltc_staff_tenant_code_name_idx`;
|
||||||
|
|
||||||
|
-- RenameIndex
|
||||||
|
ALTER TABLE `ltc_staff` RENAME INDEX `sys_staff_user_id_key` TO `ltc_staff_user_id_key`;
|
||||||
|
|
||||||
|
-- RenameIndex
|
||||||
|
ALTER TABLE `svc_local` RENAME INDEX `sys_svc_local_loc_code_idx` TO `svc_local_loc_code_idx`;
|
||||||
|
|
||||||
|
-- RenameIndex
|
||||||
|
ALTER TABLE `svc_mapping` RENAME INDEX `sys_svc_mapping_loc_id_idx` TO `svc_mapping_loc_id_idx`;
|
||||||
|
|
||||||
|
-- RenameIndex
|
||||||
|
ALTER TABLE `svc_national` RENAME INDEX `sys_svc_national_nat_code_key` TO `svc_national_nat_code_key`;
|
||||||
|
|
||||||
|
-- RenameIndex
|
||||||
|
ALTER TABLE `svc_org` RENAME INDEX `sys_svc_org_tenant_code_src_type_idx` TO `svc_org_tenant_code_src_type_idx`;
|
||||||
@ -425,3 +425,66 @@ model LocConfig {
|
|||||||
|
|
||||||
@@map("loc_config")
|
@@map("loc_config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 老人档案
|
||||||
|
model Elder {
|
||||||
|
id String @id @default(uuid(7)) @db.VarChar(36)
|
||||||
|
tenantCode String @map("tenant_code") @db.VarChar(64)
|
||||||
|
locCode String @map("loc_code") @db.VarChar(12)
|
||||||
|
prevLocCode String? @map("prev_loc_code") @db.VarChar(12)
|
||||||
|
transferConfirmAt DateTime? @map("transfer_confirm_at")
|
||||||
|
name String @db.VarChar(30)
|
||||||
|
gender String @db.Char(1)
|
||||||
|
birthDate DateTime @map("birth_date") @db.Date
|
||||||
|
idCardNo String @map("id_card_no") @db.VarChar(255)
|
||||||
|
phone String? @db.VarChar(15)
|
||||||
|
address String @db.VarChar(200)
|
||||||
|
guardianName String? @map("guardian_name") @db.VarChar(30)
|
||||||
|
guardianPhone String? @map("guardian_phone") @db.VarChar(15)
|
||||||
|
insurNo String @map("insur_no") @db.VarChar(30)
|
||||||
|
insurType String @map("insur_type") @db.VarChar(10)
|
||||||
|
insurYears Int? @map("insur_years")
|
||||||
|
insurVerifyStatus String? @map("insur_verify_status") @db.VarChar(20)
|
||||||
|
insurVerifyDate DateTime? @map("insur_verify_date") @db.Date
|
||||||
|
assessLevel String? @map("assess_level") @db.VarChar(20)
|
||||||
|
careLevel String? @map("care_level") @db.VarChar(20)
|
||||||
|
assessDate DateTime? @map("assess_date") @db.Date
|
||||||
|
assessOrg String? @map("assess_org") @db.VarChar(100)
|
||||||
|
assessEvidenceFile String? @map("assess_evidence_file") @db.VarChar(255)
|
||||||
|
benefitStart DateTime? @map("benefit_start") @db.Date
|
||||||
|
benefitEnd DateTime? @map("benefit_end") @db.Date
|
||||||
|
treatStatus String @default("pending_file") @map("treat_status") @db.VarChar(20)
|
||||||
|
statusSource String @default("manual") @map("status_source") @db.VarChar(10)
|
||||||
|
statusChangeDate DateTime? @map("status_change_date") @db.Date
|
||||||
|
hospStart DateTime? @map("hosp_start") @db.Date
|
||||||
|
hospEnd DateTime? @map("hosp_end") @db.Date
|
||||||
|
photoTierOverride Json? @map("photo_tier_override")
|
||||||
|
needAssess Json? @map("need_assess")
|
||||||
|
note String? @db.Text
|
||||||
|
bizLine String @default("ltci") @map("biz_line") @db.VarChar(20)
|
||||||
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
|
createdBy String? @map("created_by") @db.VarChar(36)
|
||||||
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
|
deletedAt DateTime? @map("deleted_at")
|
||||||
|
|
||||||
|
@@unique([tenantCode, idCardNo])
|
||||||
|
@@index([tenantCode, name])
|
||||||
|
@@map("ltc_elder")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 待遇状态变更日志
|
||||||
|
model ElderStatusLog {
|
||||||
|
id String @id @default(uuid(7)) @db.VarChar(36)
|
||||||
|
elderId String @map("elder_id") @db.VarChar(36)
|
||||||
|
tenantCode String @map("tenant_code") @db.VarChar(64)
|
||||||
|
fromStatus String @map("from_status") @db.VarChar(20)
|
||||||
|
toStatus String @map("to_status") @db.VarChar(20)
|
||||||
|
changeReason String @map("change_reason") @db.VarChar(200)
|
||||||
|
source String @default("manual") @db.VarChar(10)
|
||||||
|
operatorId String @map("operator_id") @db.VarChar(36)
|
||||||
|
evidenceFile String? @map("evidence_file") @db.VarChar(255)
|
||||||
|
changedAt DateTime @default(now()) @map("changed_at")
|
||||||
|
|
||||||
|
@@index([elderId])
|
||||||
|
@@map("ltc_elder_status_log")
|
||||||
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { getRequestContext } from '../common/context/request-context.js';
|
|||||||
/** 不带 tenantCode 的模型(租户表自身)。 */
|
/** 不带 tenantCode 的模型(租户表自身)。 */
|
||||||
const TENANT_FREE = new Set(['Tenant', 'Agency', 'SvcNational', 'SvcLocal', 'SvcMapping', 'LocConfig']);
|
const TENANT_FREE = new Set(['Tenant', 'Agency', 'SvcNational', 'SvcLocal', 'SvcMapping', 'LocConfig']);
|
||||||
/** 软删模型:读操作统一注入 deletedAt IS NULL。 */
|
/** 软删模型:读操作统一注入 deletedAt IS NULL。 */
|
||||||
const SOFT_DELETE = new Set(['User', 'Role', 'Resource', 'Org', 'DictType', 'DictItem', 'Config', 'Notice', 'Staff', 'SvcOrg']);
|
const SOFT_DELETE = new Set(['User', 'Role', 'Resource', 'Org', 'DictType', 'DictItem', 'Config', 'Notice', 'Staff', 'SvcOrg', 'Elder']);
|
||||||
const READ_OPS = new Set(['findMany', 'findFirst', 'findUnique', 'count', 'aggregate', 'groupBy']);
|
const READ_OPS = new Set(['findMany', 'findFirst', 'findUnique', 'count', 'aggregate', 'groupBy']);
|
||||||
/** 没有 where 子句的操作(create 的租户由 service 在 data 里显式写入)。 */
|
/** 没有 where 子句的操作(create 的租户由 service 在 data 里显式写入)。 */
|
||||||
const NO_WHERE_OPS = new Set(['create', 'createMany']);
|
const NO_WHERE_OPS = new Set(['create', 'createMany']);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user