CREATE OR REPLACE Procedure p_康复项目比对弹窗_IOU(
Id_In In 个人医嘱记录.Id%Type,
诊疗类别_In In 个人医嘱记录.诊疗类别%Type
)
as
--分别创建项目id 与 记录id 的结果集游标
cursor 记录id is select jl.id from 治疗项目 xm,治疗记录 jl,个人医嘱记录 yz
where xm.id = jl.治疗项目id(+) and jl.医嘱id = yz.id(+) and yz.id = Id_In;
cursor 评定方案id is select fa.id from 评定方案 fa,个人医嘱记录 yz where fa.医嘱id = yz.id and yz.id = Id_In;
v_记录id 治疗记录.id%type;
v_评定方案id 评定方案.id%type;
Begin
if (诊疗类别_In = 'E') then
--打开游标
open 记录id;
loop
--循环遍历结果集 id 直到为空时退出循环
fetch 记录id into v_记录id;
EXIT WHEN 记录id%NOTFOUND;
--查询治疗记录的执行状态 如果为0 那么打开项目比对
select 执行状态 from 治疗记录 where id = v_记录id;
end loop;
elsif (诊疗类别_In = 'P') then
open 评定方案id;
loop
fetch 评定方案id into v_评定方案id;
exit when 评定方案id%notfound;
select 执行状态 from 评定方案 where id = v_评定方案id;
end loop;
end if;
End;