Repository navigation
Expand file tree
/
Copy pathViews.sql
More file actions
66 lines (53 loc) · 1.73 KB
/
Copy pathViews.sql
File metadata and controls
66 lines (53 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
CREATE VIEW Patients_Insurance_Details AS
SELECT
pi.first_name AS patient_first_name,
pi.last_name AS patient_last_name,
ii.insurance_name,
ii.insurance_policy,
ii.coverage_amount
FROM
patientsinfo pi
INNER JOIN
insuranceinfo ii ON pi.insurance_id = ii.insurance_id;
select *from emr.patientswithinsurance;
#2nd
CREATE VIEW AppointmentSchedule AS
SELECT ai.appointment_id, pi.First_Name, pi.Last_Name, di.Dentist_name, ai.appointment_date, ai.appointment_time
FROM AppointmentInfo ai
INNER JOIN PatientsInfo pi ON ai.Patient_id = pi.patient_id
INNER JOIN DentistInfo di ON ai.Dentist_id = di.Dentist_id;
SELECT * FROM emr.patientsWithInsurance;
#3rd
CREATE VIEW BillingInformation AS
SELECT
bi.Invoice_id,
pi.First_Name,
pi.Last_Name,
ai.appointment_date,
ai.appointment_time,
bi.Treatment_name,
bi.Treatment_Description,
bi.Insurance_payment,
bi.Patient_payment,
bi.Balance_due,
bi.payment_due_date
FROM BillingInvoice bi
INNER JOIN PatientsInfo pi ON bi.patient_id = pi.patient_id
INNER JOIN AppointmentInfo ai ON bi.appointment_id = ai.appointment_id;
SELECT * FROM emr.patientsWithInsurance;
#4th
CREATE VIEW PrescriptionInformation AS
SELECT
pi.First_Name AS PatientFirstName,
pi.Last_Name AS PatientLastName,
di.Dentist_name AS DentistName,
pi.Address AS PatientAddress,
pi.Phone_number AS PatientPhone,
pr.Medication_Name AS MedicationName,
pr.Dosage AS MedicationDosage,
pr.Start_Date AS PrescriptionStart,
pr.End_Date AS PrescriptionEnd
FROM PrescriptionInfo pr
INNER JOIN PatientsInfo pi ON pr.Patient_id = pi.patient_id
INNER JOIN DentistInfo di ON pr.Dentist_id = di.Dentist_id;
SELECT * FROM PrescriptionInformation;