SpeedThink
MIS
Currently, I am using the following query to extract data from an Oracle database via a Hyperion (Brio) query:
SELECT AL2.ACCT, AL3.ENCOUNTER_NO, trunc(AL3.ADMIT_DATE),
trunc(AL3.DISCHARGE_DATE), AL3.DATE_BILLED, AL3.TOTAL_CHARGES, AL3.EXPECTED_REIMBURSEMENT, AL2.TOTAL_PAYMENTS,
AL3.EXPECTED_REIMBURSEMENT - AL2.TOTAL_PAYMENTS,
AL3.EXPECTED_REIMBURSEMENT - AL3.TOTAL_PAYMENTS, AL2.TOTAL_PAYMENTS /AL3.EXPECTED_REIMBURSEMENT, AL3.TOTAL_PAYMENTS - AL2.TOTAL_PAYMENTS,
AL3.TOTAL_CHARGES - Sum (AL2.NONCOVERED_PT_CHARGES +
AL2.NONCOVERED_WO_CHARGES), AL3.TOTAL_CHARGES - Sum
(AL6.ADJUSTMENT_AMOUNT), AL1.PAYMENT_AMOUNT, AL1.PAYMENT_DATE,
AL1.BATCH_NO FROM ENCOUNTER_DETAIL AL1,
ENCOUNTER_PAYOR AL2, PATIENT_ENCOUNTER AL3,
ENCOUNTER_TRANSACTION AL6 WHERE ( AL1.ENCOUNTER_NO =
AL3.ENCOUNTER_NO (+) AND AL2.ENCOUNTER_NO=AL3.ENCOUNTER_NO AND AL6.ENCOUNTER_NO=AL3.ENCOUNTER_NO) AND (AL2.RANK=1 AND
AL2.ACCT Not In ('AC2','AC3','AB4','AB6')
AND AL1.TRANSACTION_CODE in
('2564','2565','2400','2460','2470') AND
AL3.EXPECTED_REIMBURSEMENT(+)>0 AND AL3.EXPECTED_REIMBURSEMENT -
AL3.TOTAL_PAYMENTS>0 AND AL2.TOTAL_PAYMENTS /
AL3.EXPECTED_REIMBURSEMENT<=0.75 AND AL6.TRANSACTION_CODE in ('4003','4009','4010','4011','4015') AND
AL3.DISCHARGE_DATE(+)>='01-01-2004 00:00:00') GROUP BY
AL2.ACCT, AL3.ENCOUNTER_NO, trunc(AL3.ADMIT_DATE),
trunc(AL3.DISCHARGE_DATE), AL3.DATE_BILLED, AL3.TOTAL_CHARGES,
AL3.EXPECTED_REIMBURSEMENT, AL2.TOTAL_PAYMENTS,
AL3.EXPECTED_REIMBURSEMENT - AL2.TOTAL_PAYMENTS,
AL3.EXPECTED_REIMBURSEMENT - AL3.TOTAL_PAYMENTS, AL2.TOTAL_PAYMENTS /
AL3.EXPECTED_REIMBURSEMENT, AL3.TOTAL_PAYMENTS - AL2.TOTAL_PAYMENTS,
AL1.PAYMENT_AMOUNT, AL1.PAYMENT_DATE, AL1.BATCH_NO HAVING
((AL3.TOTAL_CHARGES - Sum (AL6.ADJUSTMENT_AMOUNT)) -
AL3.EXPECTED_REIMBURSEMENT) <> 0 ORDER BY 1, 2, 9
Displayed below is a subset of the results of the SQL Query:
Acct----EncNo----Pymt Amt-------Payment Date
AB1-----136589----162.61---------01/12/05
AB1-----136589----552.58---------01/12/05
AB1-----136589--9,736.66---------01/26/05
AB1-----140856----327.85---------11/24/03
AB1-----140856----584.80---------04/15/04
AB1-----140856-----82.20---------02/01/05
AB2-----136890--1,319.36---------11/29/04
AB2-----136890----513.79---------01/26/05
AB2-----150857--1,829.45---------03/09/04
AB2-----150857--1,389.75---------06/16/04
AB2-----150857----671.45---------07/05/04
As you can see, there are several records for a particular EncNo when there is more than 1 payment! This is not desirable!!
Desired is the SQL Syntax to display all of the data for a particular encounter on just 1 record. For example, "Acct", "EncNo", "date of first payor payment", "amt of first payor payment", "batch no for first payor payment", "date of last payor payment", "amt of last payor payment", and the "batch no for last payor payment" should all be on one record in addition to the data such as "Admit Date," "Date Billed," etc.
Any clue as to how the sql statement should be modified? Would two subqueries be needed? Is this even possible?
I will load the data into Microsoft Access and then plan to run several Append and Update queries on a daily basis to "pull" payment detail from several external Oracle databases. Just curious, what are the advantages/disadvantages with querying data outside of Access and then importing to Access versus initially querying on external tables while within Access (using a link) to initially populate the Access tables?
Thanks in advance!
SELECT AL2.ACCT, AL3.ENCOUNTER_NO, trunc(AL3.ADMIT_DATE),
trunc(AL3.DISCHARGE_DATE), AL3.DATE_BILLED, AL3.TOTAL_CHARGES, AL3.EXPECTED_REIMBURSEMENT, AL2.TOTAL_PAYMENTS,
AL3.EXPECTED_REIMBURSEMENT - AL2.TOTAL_PAYMENTS,
AL3.EXPECTED_REIMBURSEMENT - AL3.TOTAL_PAYMENTS, AL2.TOTAL_PAYMENTS /AL3.EXPECTED_REIMBURSEMENT, AL3.TOTAL_PAYMENTS - AL2.TOTAL_PAYMENTS,
AL3.TOTAL_CHARGES - Sum (AL2.NONCOVERED_PT_CHARGES +
AL2.NONCOVERED_WO_CHARGES), AL3.TOTAL_CHARGES - Sum
(AL6.ADJUSTMENT_AMOUNT), AL1.PAYMENT_AMOUNT, AL1.PAYMENT_DATE,
AL1.BATCH_NO FROM ENCOUNTER_DETAIL AL1,
ENCOUNTER_PAYOR AL2, PATIENT_ENCOUNTER AL3,
ENCOUNTER_TRANSACTION AL6 WHERE ( AL1.ENCOUNTER_NO =
AL3.ENCOUNTER_NO (+) AND AL2.ENCOUNTER_NO=AL3.ENCOUNTER_NO AND AL6.ENCOUNTER_NO=AL3.ENCOUNTER_NO) AND (AL2.RANK=1 AND
AL2.ACCT Not In ('AC2','AC3','AB4','AB6')
AND AL1.TRANSACTION_CODE in
('2564','2565','2400','2460','2470') AND
AL3.EXPECTED_REIMBURSEMENT(+)>0 AND AL3.EXPECTED_REIMBURSEMENT -
AL3.TOTAL_PAYMENTS>0 AND AL2.TOTAL_PAYMENTS /
AL3.EXPECTED_REIMBURSEMENT<=0.75 AND AL6.TRANSACTION_CODE in ('4003','4009','4010','4011','4015') AND
AL3.DISCHARGE_DATE(+)>='01-01-2004 00:00:00') GROUP BY
AL2.ACCT, AL3.ENCOUNTER_NO, trunc(AL3.ADMIT_DATE),
trunc(AL3.DISCHARGE_DATE), AL3.DATE_BILLED, AL3.TOTAL_CHARGES,
AL3.EXPECTED_REIMBURSEMENT, AL2.TOTAL_PAYMENTS,
AL3.EXPECTED_REIMBURSEMENT - AL2.TOTAL_PAYMENTS,
AL3.EXPECTED_REIMBURSEMENT - AL3.TOTAL_PAYMENTS, AL2.TOTAL_PAYMENTS /
AL3.EXPECTED_REIMBURSEMENT, AL3.TOTAL_PAYMENTS - AL2.TOTAL_PAYMENTS,
AL1.PAYMENT_AMOUNT, AL1.PAYMENT_DATE, AL1.BATCH_NO HAVING
((AL3.TOTAL_CHARGES - Sum (AL6.ADJUSTMENT_AMOUNT)) -
AL3.EXPECTED_REIMBURSEMENT) <> 0 ORDER BY 1, 2, 9
Displayed below is a subset of the results of the SQL Query:
Acct----EncNo----Pymt Amt-------Payment Date
AB1-----136589----162.61---------01/12/05
AB1-----136589----552.58---------01/12/05
AB1-----136589--9,736.66---------01/26/05
AB1-----140856----327.85---------11/24/03
AB1-----140856----584.80---------04/15/04
AB1-----140856-----82.20---------02/01/05
AB2-----136890--1,319.36---------11/29/04
AB2-----136890----513.79---------01/26/05
AB2-----150857--1,829.45---------03/09/04
AB2-----150857--1,389.75---------06/16/04
AB2-----150857----671.45---------07/05/04
As you can see, there are several records for a particular EncNo when there is more than 1 payment! This is not desirable!!
Desired is the SQL Syntax to display all of the data for a particular encounter on just 1 record. For example, "Acct", "EncNo", "date of first payor payment", "amt of first payor payment", "batch no for first payor payment", "date of last payor payment", "amt of last payor payment", and the "batch no for last payor payment" should all be on one record in addition to the data such as "Admit Date," "Date Billed," etc.
Any clue as to how the sql statement should be modified? Would two subqueries be needed? Is this even possible?
I will load the data into Microsoft Access and then plan to run several Append and Update queries on a daily basis to "pull" payment detail from several external Oracle databases. Just curious, what are the advantages/disadvantages with querying data outside of Access and then importing to Access versus initially querying on external tables while within Access (using a link) to initially populate the Access tables?
Thanks in advance!