-- 测试数据：创建医生排班
-- 请根据实际情况修改 doctor_id

-- 为医生ID=1创建未来7天的排班数据
INSERT INTO `la_doctor_roster` (`doctor_id`, `date`, `period`, `status`, `quota`, `max_patients`, `create_time`, `update_time`)
VALUES
-- 今天
(1, CURDATE(), 'morning', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(1, CURDATE(), 'afternoon', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),

-- 明天
(1, DATE_ADD(CURDATE(), INTERVAL 1 DAY), 'morning', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(1, DATE_ADD(CURDATE(), INTERVAL 1 DAY), 'afternoon', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),

-- 后天
(1, DATE_ADD(CURDATE(), INTERVAL 2 DAY), 'morning', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(1, DATE_ADD(CURDATE(), INTERVAL 2 DAY), 'afternoon', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),

-- 第4天
(1, DATE_ADD(CURDATE(), INTERVAL 3 DAY), 'morning', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(1, DATE_ADD(CURDATE(), INTERVAL 3 DAY), 'afternoon', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),

-- 第5天
(1, DATE_ADD(CURDATE(), INTERVAL 4 DAY), 'morning', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(1, DATE_ADD(CURDATE(), INTERVAL 4 DAY), 'afternoon', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),

-- 第6天
(1, DATE_ADD(CURDATE(), INTERVAL 5 DAY), 'morning', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(1, DATE_ADD(CURDATE(), INTERVAL 5 DAY), 'afternoon', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),

-- 第7天
(1, DATE_ADD(CURDATE(), INTERVAL 6 DAY), 'morning', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
(1, DATE_ADD(CURDATE(), INTERVAL 6 DAY), 'afternoon', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());

-- 查询验证
SELECT 
    id,
    doctor_id,
    date,
    period,
    CASE 
        WHEN status = 1 THEN '出诊'
        WHEN status = 2 THEN '停诊'
        WHEN status = 3 THEN '休息'
        WHEN status = 4 THEN '请假'
    END as status_text,
    quota,
    max_patients
FROM la_doctor_roster 
WHERE doctor_id = 1 
  AND date >= CURDATE()
ORDER BY date, period;
