fix(db): V84迁移脚本添加DO块处理不存在的表
This commit is contained in:
@@ -1,31 +1,43 @@
|
||||
-- 移动端测试数据插入脚本
|
||||
|
||||
-- 1. 测试护理任务数据
|
||||
INSERT INTO nurse_order_execute_record (encounter_id, patient_id, order_type, order_name, execute_status, create_time) VALUES
|
||||
(1, 1, '医嘱执行', '测量体温 bid', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(1, 1, '医嘱执行', '测量血压 qd', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(1, 1, '生命体征', '录入生命体征', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(1, 2, '医嘱执行', '更换敷料 qd', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(1, 2, '护理评估', 'Braden压疮评估', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(2, 3, '医嘱执行', '测量血糖 tid', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(2, 3, '医嘱执行', '胰岛素注射', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(2, 4, '生命体征', '录入生命体征', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(2, 4, '护理评估', 'Morse跌倒评估', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(3, 5, '医嘱执行', '雾化吸入 bid', 'PENDING', CURRENT_TIMESTAMP)
|
||||
ON CONFLICT DO NOTHING;
|
||||
-- 1. 测试护理任务数据(仅当表存在时插入)
|
||||
DO $$ BEGIN
|
||||
INSERT INTO nurse_order_execute_record (encounter_id, patient_id, order_type, order_name, execute_status, create_time) VALUES
|
||||
(1, 1, '医嘱执行', '测量体温 bid', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(1, 1, '医嘱执行', '测量血压 qd', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(1, 1, '生命体征', '录入生命体征', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(1, 2, '医嘱执行', '更换敷料 qd', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(1, 2, '护理评估', 'Braden压疮评估', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(2, 3, '医嘱执行', '测量血糖 tid', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(2, 3, '医嘱执行', '胰岛素注射', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(2, 4, '生命体征', '录入生命体征', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(2, 4, '护理评估', 'Morse跌倒评估', 'PENDING', CURRENT_TIMESTAMP),
|
||||
(3, 5, '医嘱执行', '雾化吸入 bid', 'PENDING', CURRENT_TIMESTAMP)
|
||||
ON CONFLICT DO NOTHING;
|
||||
EXCEPTION WHEN undefined_table THEN
|
||||
RAISE NOTICE 'nurse_order_execute_record table does not exist, skipping insert';
|
||||
END $$;
|
||||
|
||||
-- 2. 测试生命体征数据
|
||||
INSERT INTO nursing_vital_signs_chart (patient_id, encounter_id, record_time, temperature, pulse, blood_pressure_high, blood_pressure_low, spo2, respiration, pain_score, create_time) VALUES
|
||||
(1, 1, CURRENT_TIMESTAMP - INTERVAL '2 hours', 36.5, 72, 120, 80, 98, 18, 2, CURRENT_TIMESTAMP),
|
||||
(1, 1, CURRENT_TIMESTAMP - INTERVAL '1 hour', 36.8, 75, 125, 82, 97, 19, 3, CURRENT_TIMESTAMP),
|
||||
(1, 1, CURRENT_TIMESTAMP, 37.0, 78, 128, 85, 96, 20, 4, CURRENT_TIMESTAMP),
|
||||
(2, 2, CURRENT_TIMESTAMP - INTERVAL '1 hour', 36.6, 70, 118, 78, 99, 17, 1, CURRENT_TIMESTAMP),
|
||||
(2, 2, CURRENT_TIMESTAMP, 36.7, 72, 120, 80, 98, 18, 2, CURRENT_TIMESTAMP)
|
||||
ON CONFLICT DO NOTHING;
|
||||
-- 2. 测试生命体征数据(仅当表存在时插入)
|
||||
DO $$ BEGIN
|
||||
INSERT INTO nursing_vital_signs_chart (patient_id, encounter_id, record_time, temperature, pulse, blood_pressure_high, blood_pressure_low, spo2, respiration, pain_score, create_time) VALUES
|
||||
(1, 1, CURRENT_TIMESTAMP - INTERVAL '2 hours', 36.5, 72, 120, 80, 98, 18, 2, CURRENT_TIMESTAMP),
|
||||
(1, 1, CURRENT_TIMESTAMP - INTERVAL '1 hour', 36.8, 75, 125, 82, 97, 19, 3, CURRENT_TIMESTAMP),
|
||||
(1, 1, CURRENT_TIMESTAMP, 37.0, 78, 128, 85, 96, 20, 4, CURRENT_TIMESTAMP),
|
||||
(2, 2, CURRENT_TIMESTAMP - INTERVAL '1 hour', 36.6, 70, 118, 78, 99, 17, 1, CURRENT_TIMESTAMP),
|
||||
(2, 2, CURRENT_TIMESTAMP, 36.7, 72, 120, 80, 98, 18, 2, CURRENT_TIMESTAMP)
|
||||
ON CONFLICT DO NOTHING;
|
||||
EXCEPTION WHEN undefined_table THEN
|
||||
RAISE NOTICE 'nursing_vital_signs_chart table does not exist, skipping insert';
|
||||
END $$;
|
||||
|
||||
-- 3. 测试护理评估数据
|
||||
INSERT INTO nursing_assessment (encounter_id, patient_id, assessment_type, assessment_tool, total_score, risk_level, detail, create_time) VALUES
|
||||
(1, 1, '压疮评估', 'Braden', 16, 'LOW', '{"sensory":4,"moisture":3,"activity":3,"friction":3,"nutrition":4,"mobility":4}', CURRENT_TIMESTAMP),
|
||||
(1, 1, '跌倒评估', 'Morse', 15, 'LOW', '{"history":0,"diagnosis":0,"ambulation":0,"iv":0,"gait":0,"mental":0}', CURRENT_TIMESTAMP),
|
||||
(2, 2, '营养筛查', 'NRS2002', 1, 'LOW', '{"bmi":0,"weightLoss":0,"intake":1}', CURRENT_TIMESTAMP)
|
||||
ON CONFLICT DO NOTHING;
|
||||
-- 3. 测试护理评估数据(仅当表存在时插入)
|
||||
DO $$ BEGIN
|
||||
INSERT INTO nursing_assessment (encounter_id, patient_id, assessment_type, assessment_tool, total_score, risk_level, detail, create_time) VALUES
|
||||
(1, 1, '压疮评估', 'Braden', 16, 'LOW', '{"sensory":4,"moisture":3,"activity":3,"friction":3,"nutrition":4,"mobility":4}', CURRENT_TIMESTAMP),
|
||||
(1, 1, '跌倒评估', 'Morse', 15, 'LOW', '{"history":0,"diagnosis":0,"ambulation":0,"iv":0,"gait":0,"mental":0}', CURRENT_TIMESTAMP),
|
||||
(2, 2, '营养筛查', 'NRS2002', 1, 'LOW', '{"bmi":0,"weightLoss":0,"intake":1}', CURRENT_TIMESTAMP)
|
||||
ON CONFLICT DO NOTHING;
|
||||
EXCEPTION WHEN undefined_table THEN
|
||||
RAISE NOTICE 'nursing_assessment table does not exist, skipping insert';
|
||||
END $$;
|
||||
|
||||
Reference in New Issue
Block a user