Medical Billing Database
Noelle Vaughn
Tables Created From Entity Sets:
Patient: pt_id, pt_name (C), birth_date, pt_address (C), phone_no (MV),
gender
Insurance: insurance_id, ins_name, address (C), phone_no
Doctor: doc_name (C), doc_id, NPI, address (C), phone_no
Diagnosis: dx_code, diag_desc
Procedure: px_code, proc_desc
Bill: bill_no, bill_date, due_date, bill_amount, bill_type
Payment: transaction_id, date_received, pmnt_type, bill_no,
payment_amount
Encounter: visit_date, pt_id
Pt_phone: pt_id, pt_phone
Tables Created From Relationship Sets:
Attends: doc_id, pt_id, visit_date
Is_made_during: dx_code, pt_id, visit_date
Is_performed_during: px_code, pt_id, visit_date
Generates: pt_id, bill_no, visit_date
Has: pt_id, insurance_id
Is_submitted_to: bill_no, insurance_id
Makes_a: insurance_id, transaction_id
QUERIES I CREATED TO TEST THE DATABASE
What accounts have unpaid balances?
(SELECT bill.bill_no, bill_amount - (SELECT SUM(payment_amount)
FROM payment WHERE payment.bill_no = bill.bill_no)
FROM bill WHERE bill_amount - (SELECT SUM(payment_amount)
FROM payment WHERE payment.bill_no = bill.bill_no) > 0)
UNION
(SELECT bill.bill_no, bill_amount FROM bill WHERE (SELECT COUNT(*)
FROM payment WHERE payment.bill_no = bill.bill_no) = 0);
Results
bill_no | ?column?
---------+----------
106 | 35.00
115 | 50.00
118 | 100.00
107 | 75.00
109 | 150.00
108 | 150.00
114 | 50.00
117 | 50.00
103 | 50.00
111 | 30.00
110 | 75.00
113 | 50.00
104 | 25.00
116 | 50.00
Which diagnosis codes have been billed most within the past
year?
SELECT is_made_during.dx_code, diag_desc
FROM is_made_during, diagnosis
WHERE is_made_during.dx_code = diagnosis.dx_code
GROUP BY is_made_during.dx_code, diagnosis.diag_desc
HAVING COUNT(*) =
(SELECT MAX(num) FROM
(SELECT COUNT(*) AS num FROM is_made_during GROUP BY
dx_code) AS mycount);
dx_code | diag_desc
---------+------------------------------
V70.0 | routine general medical exam
Which procedure codes were billed most within the past year?
SELECT is_performed_during.px_code, procedure.proc_desc
FROM is_performed_during, procedure
WHERE is_performed_during.px_code = procedure.px_code
GROUP BY is_performed_during.px_code,
procedure.proc_desc
HAVING COUNT(*) =
(SELECT MAX(num) FROM
(SELECT COUNT(*) AS num FROM is_performed_during GROUP
BY px_code) AS mycount);
Results
px_code | proc_desc
---------+-----------------------------------
G0463 | visit for assessment & management
What encounters took place on a certain date?
SELECT pt_id, visit_date
FROM encounter
WHERE visit_date = '2014-10-01';
Results:
pt_id | visit_date
-------+------------
6 | 2014-10-01
7 | 2014-10-01
Which insurance companies have made the most payments within
the past year?
SELECT makes_a.insurance_id, insurance.ins_name
FROM makes_a, insurance
WHERE makes_a.insurance_id = insurance.insurance_id
GROUP BY makes_a.insurance_id, insurance.ins_name
HAVING COUNT(*) =
(SELECT MAX(num) FROM
(SELECT COUNT(*) AS num FROM makes_a
GROUP BY insurance_id) AS mycount);
Results
insurance_id | ins_name
-------------- ----------
1 | Aetna
How many visits has a certain patient had within the past
year?
SELECT COUNT(visit_date)
FROM encounter
WHERE pt_id = '1';
Results
count
-------
3
Medical Billing Database

Medical Billing Database

  • 1.
  • 3.
    Tables Created FromEntity Sets: Patient: pt_id, pt_name (C), birth_date, pt_address (C), phone_no (MV), gender Insurance: insurance_id, ins_name, address (C), phone_no Doctor: doc_name (C), doc_id, NPI, address (C), phone_no Diagnosis: dx_code, diag_desc Procedure: px_code, proc_desc Bill: bill_no, bill_date, due_date, bill_amount, bill_type Payment: transaction_id, date_received, pmnt_type, bill_no, payment_amount Encounter: visit_date, pt_id Pt_phone: pt_id, pt_phone
  • 4.
    Tables Created FromRelationship Sets: Attends: doc_id, pt_id, visit_date Is_made_during: dx_code, pt_id, visit_date Is_performed_during: px_code, pt_id, visit_date Generates: pt_id, bill_no, visit_date Has: pt_id, insurance_id Is_submitted_to: bill_no, insurance_id Makes_a: insurance_id, transaction_id
  • 5.
    QUERIES I CREATEDTO TEST THE DATABASE What accounts have unpaid balances? (SELECT bill.bill_no, bill_amount - (SELECT SUM(payment_amount) FROM payment WHERE payment.bill_no = bill.bill_no) FROM bill WHERE bill_amount - (SELECT SUM(payment_amount) FROM payment WHERE payment.bill_no = bill.bill_no) > 0) UNION (SELECT bill.bill_no, bill_amount FROM bill WHERE (SELECT COUNT(*) FROM payment WHERE payment.bill_no = bill.bill_no) = 0); Results bill_no | ?column? ---------+---------- 106 | 35.00 115 | 50.00 118 | 100.00 107 | 75.00 109 | 150.00 108 | 150.00 114 | 50.00 117 | 50.00 103 | 50.00 111 | 30.00 110 | 75.00 113 | 50.00 104 | 25.00 116 | 50.00
  • 6.
    Which diagnosis codeshave been billed most within the past year? SELECT is_made_during.dx_code, diag_desc FROM is_made_during, diagnosis WHERE is_made_during.dx_code = diagnosis.dx_code GROUP BY is_made_during.dx_code, diagnosis.diag_desc HAVING COUNT(*) = (SELECT MAX(num) FROM (SELECT COUNT(*) AS num FROM is_made_during GROUP BY dx_code) AS mycount); dx_code | diag_desc ---------+------------------------------ V70.0 | routine general medical exam
  • 7.
    Which procedure codeswere billed most within the past year? SELECT is_performed_during.px_code, procedure.proc_desc FROM is_performed_during, procedure WHERE is_performed_during.px_code = procedure.px_code GROUP BY is_performed_during.px_code, procedure.proc_desc HAVING COUNT(*) = (SELECT MAX(num) FROM (SELECT COUNT(*) AS num FROM is_performed_during GROUP BY px_code) AS mycount); Results px_code | proc_desc ---------+----------------------------------- G0463 | visit for assessment & management
  • 8.
    What encounters tookplace on a certain date? SELECT pt_id, visit_date FROM encounter WHERE visit_date = '2014-10-01'; Results: pt_id | visit_date -------+------------ 6 | 2014-10-01 7 | 2014-10-01
  • 9.
    Which insurance companieshave made the most payments within the past year? SELECT makes_a.insurance_id, insurance.ins_name FROM makes_a, insurance WHERE makes_a.insurance_id = insurance.insurance_id GROUP BY makes_a.insurance_id, insurance.ins_name HAVING COUNT(*) = (SELECT MAX(num) FROM (SELECT COUNT(*) AS num FROM makes_a GROUP BY insurance_id) AS mycount); Results insurance_id | ins_name -------------- ---------- 1 | Aetna
  • 10.
    How many visitshas a certain patient had within the past year? SELECT COUNT(visit_date) FROM encounter WHERE pt_id = '1'; Results count ------- 3

Editor's Notes

  • #3 THE ENTITY RELATIONSHIP DIAGRAM
  • #7 The reporting of diagnosis codes is important for statistical healthcare reporting agencies that gather information about diagnoses is demographical areas. This is how they are able to report where epidemics are happening, such as when there was an avian flu outbreak in the midwest several years back.
  • #8 The reporting of procedure codes is important to facilities such as hospitals. They may want to see what types of procedures are being performed, such as nose jobs for example, in that case they may want to bring in more plastic surgeons.
  • #10 Insurance Company query, providers may want to know which insurance companies are making payments, or not because they may want to reconsider their contract with these insurance companies or may want to contact Provider Relations to discuss why their claims are not being paid.
  • #12 Example of a Medical Billing Database on the front-end from a users point of view.