-- 会诊邀请对象表
CREATE TABLE hisdev.consultation_invited (
    id BIGINT NOT NULL PRIMARY KEY,
    consultation_request_id BIGINT NOT NULL,
    invited_department_id BIGINT,
    invited_department_name VARCHAR(100),
    invited_physician_id BIGINT,
    invited_physician_name VARCHAR(50),
    invited_status SMALLINT DEFAULT 0,
    confirm_time TIMESTAMP,
    confirm_opinion TEXT,
    create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    create_by VARCHAR(64),
    update_by VARCHAR(64),
    tenant_id BIGINT,
    is_deleted SMALLINT DEFAULT 0
);

-- 添加注释
COMMENT ON TABLE hisdev.consultation_invited IS '会诊邀请对象表';
COMMENT ON COLUMN hisdev.consultation_invited.id IS '主键ID';
COMMENT ON COLUMN hisdev.consultation_invited.consultation_request_id IS '会诊申请ID（外键）';
COMMENT ON COLUMN hisdev.consultation_invited.invited_department_id IS '邀请科室ID';
COMMENT ON COLUMN hisdev.consultation_invited.invited_department_name IS '邀请科室名称';
COMMENT ON COLUMN hisdev.consultation_invited.invited_physician_id IS '邀请医生ID';
COMMENT ON COLUMN hisdev.consultation_invited.invited_physician_name IS '邀请医生姓名';
COMMENT ON COLUMN hisdev.consultation_invited.invited_status IS '邀请状态（0-待确认，1-已确认，2-已拒绝）';
COMMENT ON COLUMN hisdev.consultation_invited.confirm_time IS '确认时间';
COMMENT ON COLUMN hisdev.consultation_invited.confirm_opinion IS '确认意见';
COMMENT ON COLUMN hisdev.consultation_invited.create_time IS '创建时间';
COMMENT ON COLUMN hisdev.consultation_invited.update_time IS '更新时间';
COMMENT ON COLUMN hisdev.consultation_invited.create_by IS '创建人';
COMMENT ON COLUMN hisdev.consultation_invited.update_by IS '更新人';
COMMENT ON COLUMN hisdev.consultation_invited.tenant_id IS '租户ID';
COMMENT ON COLUMN hisdev.consultation_invited.is_deleted IS '删除标识（0-未删除，1-已删除）';

-- 创建索引
CREATE INDEX idx_consultation_request_id ON hisdev.consultation_invited(consultation_request_id);
CREATE INDEX idx_invited_physician_id ON hisdev.consultation_invited(invited_physician_id);
CREATE INDEX idx_tenant_id ON hisdev.consultation_invited(tenant_id);

