Thursday, May 27, 2010

GENERATE A HOSPITAL INFORMATION SYSTEM USING THE HOSPITAL TABLE

Buzz It
1)Patients undergone bloodtest
2)Patients who have taken X-ray
3)Details of in-patients


create table hospital(pid varchar2(4),pname varchar2(7),page number(3),doctor
varchar2(7),p varchar2(10),consfee number(3),btest number(3),xfee number(3),other
number(3),total number(5));
insert into hospital values('p101','Sona',23,'Hasna','Outpatient',100,50,20,10,null);
insert into hospital values('p102','Sithu',18,'Thennu','Outpatient',150,30,45,15,null);
insert into hospital values('p103','Sruthi',32,'Banu','inpatient',200,0,15,20,null);
insert into hospital values('p104','Meher',26,'Rahi','Outpatient',150,23,0,25,null);
insert into hospital values('p105','Thafsi',21,'Renju','inpatient',100,0,40,30,null);
declare
cursor c1 is
select*from hospital where btest>0 order by pname;
btest c1%rowtype;
begin
dbms_output.put_line('ABC HOSPITAL CALICUT,KERALA');
dbms_output.put_line('DETAILS OF PATIENTS UNDERGONE BLOOD TEST');
dbms_output.put_line('-------------------------------------------------------');
dbms_output.put_line(‘PID PNAME P_AGE DOCTOR P BTEST’);
dbms_output.put_line(‘--------------------------------------------------------‘);
open c1;
loop
fetch c1 into btest;
exit when c1%notfound;
dbms_output.put_line('btest.pid,btest.pname,btest.page,btest.doctor,btest.p,btest.btest');
end loop;
close c1;
end;
/

OUTPUT

DETAILS OF PATIENTS UNDERGONE BLOODTEST
------------------------------------------------------------------------------------------------------------
PID PNAME P_AGE DOCTOR P BTEST
-----------------------------------------------------------------------------------------------------------
p101 Sona 23 Hasna Out-patient 50
p102 Sithu 18 Thennu Out-patient 30
p104 Meher 26 Rahi Out-patient 23
-----------------------------------------------------------------------------------------------------------

declare
cursor c1 is
select*from hospital where xfee>0 order by pname;
vxtest c1%rowtype;
begin
dbms_output.put_line('ABC HOSPITAL CALICUT - 3,KERALA');
dbms_output.put_line('--------------------------------------');
dbms_output.put_line(‘PID PNAME P_AGE P XFEE');
dbms_output.put_line('----------------------------------------------------');
open c1;
loop
fetch c1 into vxtest;
exit when c1%notfound;
dbms_output.put_line('vxtest.pid,vxtest.pname,vxtest.page,vxtest.doctor,vxtest.p,vxtest.xfee'
);
end loop;
close c1;
end;
/
OUTPUT

-------------------------------------------------------------------------------------------
PID PNAME P_AGE P XFEE
------------------------------------------------------------------------------------------
p101 Sona 23 Out-patient 20
p102 Sithu 18 Out-patient 45
p103 Sruthi 32 In-patient 15
p105 Thafsi 21 In-patient 40
-------------------------------------------------------------------------------------------


 declare
cursor c1 is
select*from hospital where p='inpatient' order by pname;
vtype c1%rowtype;
begin
dbms_output.put_line('ABC HOSPITAL CALICUT-3,KERALA');
dbms_output.put_line('DETAILS OF THE IN-PATIENTS');
dbms_output.put_line('---------------------------------------------------');
dbms_output.put_line('PID PNAME DOCTOR P CONSFEE BTEST XFEE OTHER
TOTAL');
dbms_output.put_line('---------------------------------------------------');
open c1;
loop
fetch c1 into vtype;
exit when c1%notfound;
vtype.total:=vtype.consfee+vtype.btest+vtype.xfee+vtype.other;
update hospital set total=vtype.total where vtype.pid=pid;
dbms_output.put_line('vtype.pid,vtype.pname,vtype.doctor,vtype.p,vtype.consfee,vtype.btest
,vtype.xfee,vtype.other,vtype.total');
end loop;
close c1;
end;
/

OUTPUT

ABC HOSPITAL CALICUT-3,KERALA
DETAILS OF THE IN-PATIENTS
--------------------------------------------------------------------------------------------------------------
PID PNAME DOCTOR P CONSFEE BTEST XFEE OTHER TOTAL
--------------------------------------------------------------------------------------------------------------
p103 Sruthi Banu In-patient 200 0 15 20 235
p105 Thafsi Renju In-patient 100 0 40 30 170
--------------------------------------------------------------------------------------------------------------
ABC HOSPITAL CALICUT-3,KERALA
ABC HOSPITAL CALICUT,KERALA

0 comments:

Post a Comment