elder-yudao-pro/mysql_script/health/V008__health_measurement.sql

41 lines
2.9 KiB
MySQL
Raw Normal View History

-- 连续健康测量记录:历史只追加,不修改老人基础档案字段。
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `health_measurement` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录编号',
`elderly_profile_id` bigint NOT NULL COMMENT '老人档案编号',
`collector_member_id` bigint DEFAULT NULL COMMENT '本人录入时的会员编号',
`source_type` tinyint NOT NULL COMMENT '1 老人本人录入,2 管理员录入',
`measured_at` datetime NOT NULL COMMENT '测量时间',
`height_cm` decimal(5,1) DEFAULT NULL COMMENT '身高 cm',
`weight_kg` decimal(5,1) DEFAULT NULL COMMENT '体重 kg',
`bmi` decimal(5,2) DEFAULT NULL COMMENT '由身高体重计算',
`systolic_pressure` smallint DEFAULT NULL COMMENT '收缩压 mmHg',
`diastolic_pressure` smallint DEFAULT NULL COMMENT '舒张压 mmHg',
`heart_rate` smallint DEFAULT NULL COMMENT '心率 次/分',
`waist_cm` decimal(5,1) DEFAULT NULL COMMENT '腰围 cm',
`hip_cm` decimal(5,1) DEFAULT NULL COMMENT '臀围 cm',
`calf_cm` decimal(5,1) DEFAULT NULL COMMENT '小腿围 cm',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
PRIMARY KEY (`id`),
KEY `idx_measurement_profile_time` (`tenant_id`,`elderly_profile_id`,`measured_at`),
KEY `idx_measurement_member_time` (`tenant_id`,`collector_member_id`,`measured_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='老人连续健康测量记录';
START TRANSACTION;
SET @health_menu = (SELECT id FROM system_menu WHERE parent_id=0 AND path='/health' AND deleted=b'0' LIMIT 1);
INSERT INTO system_menu (name,permission,type,sort,parent_id,path,icon,component,component_name,status,visible,keep_alive,always_show)
SELECT '健康测量记录','health:measurement:query',2,3,@health_menu,'measurement','ep:trend-charts','health/measurement/index','HealthMeasurement',0,b'1',b'1',b'1'
WHERE @health_menu IS NOT NULL AND NOT EXISTS (SELECT 1 FROM system_menu WHERE permission='health:measurement:query' AND deleted=b'0');
SET @measurement_menu = (SELECT id FROM system_menu WHERE permission='health:measurement:query' AND deleted=b'0' LIMIT 1);
INSERT INTO system_menu (name,permission,type,sort,parent_id,path,status,visible,keep_alive,always_show)
SELECT '录入测量记录','health:measurement:create',3,1,@measurement_menu,'',0,b'1',b'1',b'1'
WHERE @measurement_menu IS NOT NULL AND NOT EXISTS (SELECT 1 FROM system_menu WHERE permission='health:measurement:create' AND deleted=b'0');
COMMIT;