创建存储过程,包及包体
2016-01-17 15:07
218 查看
--创建包 create or replace package PAK_ExecuteAttendingDoctor is type cp_results is ref cursor; procedure ExecuteAttendingDoctor(start_time in varchar2,end_time in varchar2,cp_results out cp_results); end PAK_ExecuteAttendingDoctor;
--创建包体 create or replace package body PAK_ExecuteAttendingDoctor is procedure ExecuteAttendingDoctor(start_time in varchar2, end_time in varchar2, cp_results out cp_results) is begin open cp_results for select distinct * from (select t.dept_code, t.dept_name from dcp_sys_user t where t.dept_code > 0 and t.dept_code is not null group by t.dept_code, t.dept_name) mm, (select a.execute_dept, a.attending_doctor, nvl(a.fhrs, 0) fhrs, nvl(b.nrrs, 0) nrrs, nvl(c.wcrs, 0) wcrs, round(nvl(b.nrrs / a.fhrs, 0), 4) nrl, round(nvl(c.wcrs / b.nrrs, 0), 4) wcl, nvl(d.xdyzzs, 0) xdyzzs, nvl(xdlcljyzs, 0) xdlcljyzs, round(nvl(xdlcljyzs / d.xdyzzs, 0), 4) xdl from --按医生统计符合人数 (select execute_dept, attending_doctor, count(patient_no) fhrs from lcp_patient_visit v where v.conform_master_id > 0 and v.admission_date >= to_date(start_time, 'yyyy-mm-dd') and v.admission_date <= to_date(end_time, 'yyyy-mm-dd hh24:mi:ss') group by v.execute_dept, v.attending_doctor) a, ----纳入人数--- (select execute_dept, v1.attending_doctor, count(patient_no) nrrs from lcp_patient_visit v1 where v1.cp_master_id > 0 and v1.admission_date >= to_date(start_time, 'yyyy-mm-dd') and v1.admission_date <= to_date(end_time, 'yyyy-mm-dd hh24:mi:ss') group by v1.execute_dept, v1.attending_doctor) b, ----完成人数----- (select execute_dept, v2.attending_doctor, count(patient_no) wcrs from lcp_patient_visit v2 where v2.cp_master_id > 0 and v2.cp_state = 11 and v2.admission_date >= to_date(start_time, 'yyyy-mm-dd') and v2.admission_date <= to_date(end_time, 'yyyy-mm-dd hh24:mi:ss') group by v2.execute_dept, v2.attending_doctor) c, ----下达医嘱总数----- (select count(*) xdyzzs, v.execute_dept, v.attending_doctor from lcp_patient_log_order t, lcp_patient_visit v where t.patient_no in (select t.patient_no from lcp_patient_visit t where t.cp_state in (1, 11, 21) and t.admission_date >= to_date(start_time, 'yyyy-mm-dd') and t.admission_date <= to_date(end_time, 'yyyy-mm-dd hh24:mi:ss')) and t.patient_no = v.patient_no group by v.execute_dept, v.attending_doctor) d, ----下达临床路径医嘱数----- (select count(*) xdlcljyzs, v.execute_dept, v.attending_doctor from lcp_patient_log_order t, lcp_patient_visit v where t.patient_no in (select t.patient_no from lcp_patient_visit t where t.cp_state in (1, 11, 21) and t.admission_date >= to_date(start_time, 'yyyy-mm-dd') and t.admission_date <= to_date(end_time, 'yyyy-mm-dd hh24:mi:ss')) and t.cp_node_order_item_id > 0 and t.patient_no = v.patient_no group by v.execute_dept, v.attending_doctor) e where a.execute_dept = b.execute_dept(+) and a.attending_doctor = b.attending_doctor(+) and a.execute_dept = c.execute_dept(+) and a.attending_doctor = c.attending_doctor(+) and a.execute_dept = d.execute_dept(+) and a.attending_doctor = d.attending_doctor(+) and a.execute_dept = e.execute_dept(+) and a.attending_doctor = e.attending_doctor(+)) aa where mm.dept_name = aa.execute_dept order by aa.execute_dept, nrrs desc; end ExecuteAttendingDoctor; end PAK_ExecuteAttendingDoctor;
相关文章推荐
- Web 通信 之 长连接、长轮询(long polling)
- MFC只运行一个实例
- css中的display属性
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- MySQL主从同步
- 浅析Java中CountDownLatch用法
- CodeForces 584D Dima and Lisa
- JavaWeb_SpringMVC和titles的简单整合
- Mac OS下安装配置Scala
- Eclipse下Preferences解析
- sql语句中case-when用法
- zookeeper原理(转)
- 2016.01.17—-即便没有读者,你也要写博客
- 对《Netty权威指南》中的Http+xml协议栈开发的个人再整理
- 请教一个pip install 出现报asciii码错误的问题
- 【WC2002】奶牛浴场
- Android中下拉刷新和加载更多的实现方式
- hadoop基础:第三部分 分布式文件系统
- UVA 18451 阅读题
- HDU4452Running Rabbits(模拟)