Question 1
Purpose : I can find the details of all the patients who have approached the clinic
Question : Display all the information of the patients
Query : select * from patients
Output :
Question 2
Purpose : I can find out the reason why many people are visiting me, so that I can make necessary arrangements
Question : List the problems that are most common with the one occurring most at the top
Query : select problem_description,count(*) as num_patients from Problem p ,Patient_Problem pp where p.problem_id = pp.problem_id group by problem_description order by num_patients desc;
Output :
Question 3
Purpose : To find out the work schedule of the assistants
Question : Display the free or busy shift for an assistant physician or nurse
Query : select nu.nurse_fname,n.shift_id,n.day,n.hours from Nurse nu, Nurse_Work_Shift n where n.nurse_id = nu.nurse_id and nu.nurse_id = '1' group by nu.nurse_fname,n.shift_id,n.day,n.hours; or select p.physician_fname,ph.shift_id,ph.day,ph.hours from physician p, Physician_Work_Shift ph where ph.physician_id = p.physician_id and p.physician_id = '1' group by p.physician_fname,ph.shift_id,ph.day,ph.hours;
Output :
Question 4
Purpose : To know the success rate or efficiency of the clinic
Question : Number of Patients who have been cured or discharged
Query : select count(*) as discharge_patients from Patient p, Patient_Bed pb where pb.patient_id = p.patient_id and p.patient_id not in (select patient_id from Patient_Bed where free_date = NULL);
Output :
Question 5
Purpose : To identify if there is wrong with the treatment administered is wrong
Question : Display all the medicines refused
Query : select distinct me.medicine_name,a.comment_reason from medicines me, Medlist_Contains mc, Administrations a, Treatments t where a.treatment_id = t.treatment_id and t.medlist_id = mc.medlist_id and mc.medicine_id = me.medicine_id and a.admin_id not in ( select a.admin_id from Administrations where a.comment_reason =
'Success');
Output :
Question 6
Purpose : To figure out what patient needs in his medication
Question : Specific medications for a specific time
Query : select p.patient_fname,me.medicine_name from medicines me, Medlist_Contains mc, Administrations a, Treatments t, Patient p where a.treatment_id = t.treatment_id and t.medlist_id = mc.medlist_id and mc.medicine_id = me.medicine_id and p.patient_id = t.patient_id and mc.frequency = 'Once/Day';
Output :
Question 7
Purpose : To find out who takes care of whom
Question : Display all the patients assigned to a specific nurse/physician
Query : select p.patient_fname,n.nurse_fname,'Nurse' as Role from Patient p, Nurse_Assigned_By_Doctor nu, Nurse n, Treatments t where nu.doctor_id = t.doctor_id and t.patient_id = p.patient_id union select p.patient_fname,ph.physician_fname,'Physician' as Role from Patient p, Physician_Assigned_By_Doctor nu, Physician ph, Treatments t where nu.doctor_id = t.doctor_id and t.patient_id = p.patient_id;
Output
Question 8
Purpose : To know the work load and performance of a doctor
Question : Display Patients assigned to a specific Doctor
Query : select d.doctor_fname, p.patient_fname from Patient p,Doctor d, Treatments t where d.doctor_id = t.doctor_id and t.patient_id = p.patient_id and d.doctor_id = '1';
Output :
Question 9
Purpose: To understand the occupancy of the clinic
Question : Patient who has been admitted for most days
Query :
select p.patient_fname, DATEDIFF(hour,pp.start_date,pp.end_date) as hours_in_hospital from Patient p,Patient_Problem pp where p.patient_id = pp. patient_id and pp.patient_id not in ( select pp.patient_id from Patient_Problem where pp.end_date =
NULL) order by hours_in_hospital desc;
Output :
Question 10
Question : Display all information about a MEDICATION
Purpose : To know about how a patient was treated
Query : select distinct p.patient_fname,d.doctor_fname,t.frequency,t.size,nu.nurse_fname from Patient p,Doctor d,Treatments t,Medlist_Contains mc,Medicines m,Nurse nu,Administrations a where p.patient_id = t.patient_id and t.doctor_id = d.doctor_id and mc.medicine_id = m.medicine_id and nu.nurse_id = a.nurse_id;
Output:
Question 11
Purpose : To analyze the cases that the clinic is encountering regarding the diseases with which people are approaching us more.
Question : Display list of Patients with specific disease and the medications
Query : select pr.problem_description,p.patient_fname,m.medicine_name from Problem pr,Patient_Problem pp,Medlist_Contains mc,Medicines m,Treatments t,Patient p where p.patient_id = pp.patient_id and t.patient_id = p.patient_id and mc.medlist_id = t.medlist_id and mc.medicine_id = m.medicine_id and pr.problem_id = pp.problem_id group by pr.problem_description,p.patient_fname,m.medicine_name;
Output :
Question 12
Purpose : To know the status of bed occupancy
Question : List the patients who are using a specific bed
Query : select p.patient_fname,b.bed_id
from Bed b,Patient_Bed pb,Patient p where b.bed_id = pb.bed_id and p.patient_id = pb.patient_id group by b.bed_id,p.patient_fname;
Output :
Question 13
Purpose: Helps in finding medicines which can be administered
Question : To find the medicines which are available
Query : select medicine_name,available_quantity from Medicines where available_quantity > 200 order by available_quantity;
Output:
Question 14
Purpose : To find out how doctors are treating the patients
Question: List the most given medication given by doctors
Query: select d.doctor_fname,m.medicine_name from Medicines m,Treatments t, Medlist_Contains mc, Doctor d where m.medicine_id = mc.medicine_id and mc.medlist_id = t.medlist_id and t.doctor_id = d.doctor_id;
Output:
Question 15
Purpose: To give the patient information and recognize who served the patient more
Question : Display the nurses who delivered the maximum medication to a patient
Query: select p.patient_fname,n.nurse_fname from Patient p,Treatments t, Administrations a, Nurse n,Patient_Problem pp where p.patient_id = pp.patient_id and a.patient_id = t.patient_id and a.nurse_id = n.nurse_id group by p.patient_fname,n.nurse_fname order by p.patient_fname;
Output :
Question 16
Purpose : To find the way how patients are being diagnosed mostly
Question : List the most common Diagnosis process
Query : select description,count(description) as number from Diagnosis group by description order by number desc;
Output :
Question 17
Purpose : To know the work schedule of the staff
Question : Calculate the total shift hours of all the nurses
Query : select n.nurse_fname,SUM(ns.hours) as work_hours from Nurse_Work_Shift ns,Nurse n group by n.nurse_fname order by work_hours desc;
Output:
Question 18
Purpose : To know the worst case scenarios where our doctors were wrong.
Question : List the patients who refused medication and their problem
Query: select p.patient_fname,pr.problem_description from Administrations a,Patient p,Patient_Problem pp,Problem pr where a.patient_id = p.patient_id and pp.problem_id = pr.problem_id
and pp.patient_id = p.patient_id and a.patient_id not in (select patient_id from Administrations where comment_reason =
'Success');
Output :
Question 19
Purpose : Helps in maintaining the patient records and history
Question: Give the treatment descriptions to all the patients
Query: select p.patient_fname,pr.problem_description,t.treatment_description from Treatments t,Patient p,Patient_Problem pp,Problem pr where t.patient_id = p.patient_id and pp.problem_id = pr.problem_id and pp.patient_id = p.patient_id;
Output :
Question 20
Purpose : To figure out the Patients who need the most care as they have multiple medications
Question : Find out the patient names who have medication more than twice a day
Query : select p.patient_fname,me.medicine_name from Medicines me,Medlist_Contains mc,Treatments t,Patient p where me.medicine_id = mc.medicine_id and t.patient_id = p.patient_id and t.medlist_id = mc.medlist_id and mc.medicine_id not in (select medicine_id from Medlist_Contains where frequency like
'Once%' and frequency like 'Twice%');
Output :