Wednesday, January 14, 2015

ORacle Query Writing Way

Patient View tab : this data get using sysdate (and trunc(consult_dt)=trunc(sysdate) order by reg_no) :

select distinct reg_no,fnc_patientname(reg_no) patname,consult_by,consult_no,consult_dt,
(select cal_dob from op_registration where reg_no=c.reg_no) dob,
(select findings from eh_patexamination where consult_no=c.consult_no) cc
from op_consultation  c
where consult_by='E011001000425'
and consult_dt =(select max(consult_dt) from op_consultation where consult_by=c.consult_by and reg_no=c.reg_no )
order by reg_no;



select distinct reg_no,fnc_patientname(reg_no) patname,consult_by,consult_no,
consult_dt,(select TO_CHAR(cal_dob,'DD/MM/YYYY')age from op_registration where reg_no=c.reg_no) dob, (select findings from eh_patexamination
where consult_no=c.consult_no) cc from op_consultation  c where consult_by='E011001000425'
and trunc(consult_dt) =trunc(sysdate) order by reg_no

This is use for previous date appointment :
select distinct reg_no,fnc_patientname(reg_no) patname,consult_by,consult_no,
consult_dt,(select TO_CHAR(cal_dob,'DD/MM/YYYY')age from op_registration where reg_no=c.reg_no) dob, (select findings from eh_patexamination
where consult_no=c.consult_no) cc from op_consultation  c where consult_by='E011001000425'
and trunc(consult_dt)<trunc(sysdate) order by reg_no

No comments:

Post a Comment