SQL Views for Medical Billing
Total Page:16
File Type:pdf, Size:1020Kb
SQL Views for Cortex Medical Billing SQL Views To execute a view in the SQL Query Analyzer window “Select * from view_name”. To narrow the results of a view you may add a WHERE clause. The column named in the WHERE clause must match the column name in the view in the following order: 1. A column name that follows the view name 2. A column name in the SELECT statement of the view To find out the name of a column in a view, double click on the view name in Enterprise Manager. EXAMPLE: CREATE VIEW ClientPayment_view( ClPaymentServiceNumber,ClPaymentAmount ) AS SELECT ClientPayment.ClientServiceNumber, SUM(ClientPayment.Amount) FROM ClientPayment GROUP BY ClientPayment.ClientServiceNumber In this example, in order to execute a SQL query with a WHERE clause on the ClientPayment_view you must use the column name “ClPaymentServiceNumber” or “ClPaymentAmount”. If the column names (ClPaymentServiceNumber,ClPaymentAmount) did *NOT* follow the view name you could use the column names in the SELECT statement (ClientServiceNumber, Amount). Example SELECT statement with WHERE clause: “ CONFIDENTIAL Page 1 of 4 SQL Views for Cortex Medical Billing SELECT * FROM ClientPayment_view WHERE ClPaymentServiceNumber = '0000045'” When writing a view where you only want one record returned to sum a field like amount (i.e., SUM(Amount)) you cannot return any other columns from the table where the data will differ, like EnteredDate, because the query is forced to return each record separately, it can no longer combine them. View Name Crystal Report Join Returned Crystal Report ClaimPaidAmount_view Claim.Number Sum of Service Adjustments, Sum of Payments, Sum of Payment Adjustments, Sum of Paid Amount ClientPayment_view ClientService.Number SUM(ClientPayment.Amount) MB303 Client Aging Report MB313 Account Details for Client ClientPaymentAdj_view ClientService.Number SUM(ClientAdjustment.Amount) MB303 Client Aging WHERE Report ClientAdjustment.Transtype MB313 Account Details = 'P' for payment for Client ClientPmtAdj_view ClientPayment.Number SUM(ClientAdjustment.Amount) MB214 Total Client WHERE Payments by Client ClientAdjustment.Transtype = 'P' for payment ClientServiceAdj_view ClientService.Number SUM(ClientAdjustment.Amount) MB303 Client Aging WHERE Report ClientAdjustment.TransType = MB313 Account Details ‘S’ for Service for Client ClientStmtPayment_view ClientStatement.Numbe SUM(ClientPayment.Amount) r ClientStmtPymtsAndAdj_view ClientStatement.Numbe (SUM(ClientPayment.Amount) MB312 Client Statement r and SUM(ClientAdjustment.Amount) ClientStmtServiceAdj_view ClientStatement.Numbe SUM(ClientAdjustment.Amount) MB312 Client Statement r WHERE ClientAdjustment.TransType = ‘S’ for Service CONFIDENTIAL Page 2 of 4 SQL Views for Cortex Medical Billing View Name Crystal Report Join Returned Crystal Report LastCashReceipt_view Patient.Number MAX(CashReceipt.Number) MB124 Contract Payment Patients Who Didn't Pay in Last 30 Days PatientPayment_view Service.Number SUM(Payment.Amount) MB102 Contract Payment Patient Accounts MB120 Patient Ledger MB123 Account Summary for Patient MB124 Contract Payment Patients Who Didn't Pay in Last 30 Days PatientPaymentAdj_view Service.Number SUM(Adjustment.Amount) MB102 Contract Payment WHERE Patient Accounts Adjustment.TransType = MB120 Patient Ledger 'P' for payment MB123 Account Summary for Patient MB124 Contract Payment Patients Who Didn't Pay in Last 30 Days PatientPayorGuarantor_view Patient.Number (PatientNumber, PayorNumber, MB112 Patient SubscriberAddress1, Statement (on report SubscriberAddress2, but not used) SubscriberCity, SubscriberName, SubscriberState, SubscriberZipCode, Type ) FROM PatientPayor WHERE Type = 'G' PatientPayorPrimary_view Patient.Number (PatientNumber, PayorNumber, MB112 Patient SubscriberAddress1, Statement (on report SubscriberAddress2, but not used) CONFIDENTIAL Page 3 of 4 SQL Views for Cortex Medical Billing View Name Crystal Report Join Returned Crystal Report SubscriberCity, SubscriberName, SubscriberState, SubscriberZipCode, Type ) PatientServiceAdj_view Service.Number SUM(Adjustment.Amount) MB102 Contract Payment WHERE Patient Accounts Adjustment.Transtype = MB120 Patient Ledger 'S' for Service MB123 Account Summary for Patient MB124 Contract Payment Patients Who Didn't Pay in Last 30 Days PaymentAdj_view Payment.Number SUM(Adjustment.Amount) WHERE Adjustment.TransType = 'P' for payment viewClientAdjustment_Payment Any column to link to All ClientAdjustment columns a column in WHERE ClientAdjustment (ClientAdjustment.TransType=' table P') for Payment viewClientAdjustment_Service ClientService.PayorNu All ClientAdjustment columns mber WHERE (ClientAdjustment.TransType=' S') CONFIDENTIAL Page 4 of 4 .