1 | IBEFUR ;ALB/ARH - UTILITY: FIND RELATED FIRST AND THIRD PARTY BILLS ; 3/7/00
|
---|
2 | ;;2.0;INTEGRATED BILLING;**130**;21-MAR-94
|
---|
3 | ;;Per VHA Directive 10-93-142, this routine should not be modified.
|
---|
4 | ;
|
---|
5 | ; Called by Accounts Receivable report option
|
---|
6 | ;
|
---|
7 | ; for a specific Third Party bill, return all related Third Party bills
|
---|
8 | ; matchs with the selected bill are based on: (selected bill is included in list returned)
|
---|
9 | ; 1) Event Date (399,.03), returns all bills with same Event Date
|
---|
10 | ;
|
---|
11 | ; 2) PTF # (399,.08), returns all bills with the same PTF number
|
---|
12 | ; 3) PTF # (399,.08), returns all bills with Outpatient Visit Dates (399,43) within the admission date range
|
---|
13 | ;
|
---|
14 | ; 4) Opt Visit Dates (399,43), returns all bills with one or more matching Opt Visit Dates
|
---|
15 | ; 5) Opt Visit Dates (399,43), returns all bills for any PTF (399,.08) stay covering any of the Opt Visit Dates
|
---|
16 | ;
|
---|
17 | ; 6) Prescriptions (362.4): returns all bills with one or more matching Rx # and fill date
|
---|
18 | ;
|
---|
19 | ; ^TMP("IBRBT", $J, selected bill ifn) = PATIENT HAS ANY RX COVERAGE ON FROM DATE OF BILL (0/1)
|
---|
20 | ; ^TMP("IBRBT", $J, selected bill ifn, matching bill ifn) =
|
---|
21 | ; BILL FROM ^ BILL TO ^ CANCELLED (0/1) ^ AR BILL NUMBER ^
|
---|
22 | ; PAYER SEQUENCE ^ PAYER IS MEDICARE SUPPLEMENTAL (0/1) ^ PAYER NAME
|
---|
23 | ;
|
---|
24 | TPTP(IBIFN) ; given a specific Third Party bill, find all related Third Party Bills
|
---|
25 | N IB0,DFN,IBEVDT,IBPTF,IBADM,IBDIS,IBOPV,IBPTF1,IBXRF,IBRXN,IBRXDT,IBX Q:'$G(IBIFN)
|
---|
26 | S IB0=$G(^DGCR(399,+IBIFN,0)) Q:IB0="" S DFN=$P(IB0,U,2),IBEVDT=$P(IB0,U,3),IBPTF=$P(IB0,U,8)
|
---|
27 | ;
|
---|
28 | K ^TMP("IBRBT",$J,IBIFN) S IBX=$$LN1^IBEFURT(IBIFN) D SAVELN1^IBEFURT(IBIFN,IBX)
|
---|
29 | ;
|
---|
30 | I +IBEVDT D TPEVDT^IBEFURT(DFN,IBEVDT,IBIFN) ; find all bills with the same Event Date (399,.03)
|
---|
31 | ;
|
---|
32 | IT I +IBPTF D TPPTF^IBEFURT(IBPTF,IBIFN) ; find all bills with the same PTF number (399,.08)
|
---|
33 | ;
|
---|
34 | ; find any bills with Outpatient Visit Dates within the date range of the admission (PTF)
|
---|
35 | I +IBPTF S IBADM=$P($G(^DGPT(+IBPTF,0)),U,2),IBDIS=+$G(^DGPT(+IBPTF,70)) S:'IBDIS IBDIS=DT D
|
---|
36 | . D TPOPV^IBEFURT(DFN,IBADM,IBDIS,IBIFN)
|
---|
37 | ;
|
---|
38 | OT ; find all bills that have one or more of the same Opt Visit Dates (399,43)
|
---|
39 | S IBX=0 F S IBX=$O(^DGCR(399,+IBIFN,"OP",IBX)) Q:'IBX S IBOPV=+$G(^DGCR(399,+IBIFN,"OP",IBX,0)) D
|
---|
40 | . D TPOPV^IBEFURT(DFN,IBOPV,IBOPV,IBIFN)
|
---|
41 | ;
|
---|
42 | ; find any bills for inpatient admissions whose date range includes one or more of the Opt Visit Dates
|
---|
43 | S IBX=0 F S IBX=$O(^DGCR(399,+IBIFN,"OP",IBX)) Q:'IBX S IBOPV=+$G(^DGCR(399,+IBIFN,"OP",IBX,0)) D
|
---|
44 | . S IBADM=$$ADM^IBCU64(DFN,IBOPV) I +IBADM S IBPTF1=$P(IBADM,U,4) I +IBPTF1 D
|
---|
45 | .. D TPPTF^IBEFURT(IBPTF1,IBIFN)
|
---|
46 | ;
|
---|
47 | RT ; find all bills that have one or more of the same Prescription: same Rx number and fill date (362.4,.01,.03)
|
---|
48 | S IBXRF="AIFN"_IBIFN,IBRXN="" F S IBRXN=$O(^IBA(362.4,IBXRF,IBRXN)) Q:'IBRXN D
|
---|
49 | . S IBX=0 F S IBX=$O(^IBA(362.4,IBXRF,IBRXN,IBX)) Q:'IBX S IBRXDT=$P($G(^IBA(362.4,IBX,0)),U,3) D
|
---|
50 | .. D TPRX^IBEFURT(DFN,IBRXN,IBRXDT,IBIFN)
|
---|
51 | Q
|
---|
52 | ;
|
---|
53 | ; ==============================================================================================================
|
---|
54 | ;
|
---|
55 | ; Called by Accounts Receivable report option
|
---|
56 | ;
|
---|
57 | ; for a specific Third Party bill, return all related First Party Charges
|
---|
58 | ; only a single record of a charge event is returned, defining the charges current status, although there may
|
---|
59 | ; have been cancellations or updates to the original charge
|
---|
60 | ; o Inpatient Events may have multiple charge events (Copay and Per Diem)
|
---|
61 | ; o Opt and Rx Events have only a single charge event (Copay)
|
---|
62 | ;
|
---|
63 | ; matchs with the selected bill are based on:
|
---|
64 | ; 1) Event Date (399,.03), returns Inpatient charges whose Parent Event (350,.16) has that Event Date (350,.17)
|
---|
65 | ; 2) PTF # (399,.08), returns Outpatient charge for Opt Visits Dates within timeframe of admission
|
---|
66 | ;
|
---|
67 | ; 3) Opt Visit Date (399,43), returns the Outpatient charge for that Event Date (350,.17)
|
---|
68 | ; 4) Opt Visit Date (399,43), returns Inpatient charges for any admission that includes that Opt Visit Date
|
---|
69 | ;
|
---|
70 | ; 5) Rx Record (362.4,.05) and Rx Date (362.4,.03) and Outpatient Pharmacy, returns the Rx charge for the fill
|
---|
71 | ; 6) Opt Visit Date (399,43) and Outpatient Pharmacy, returns any First Party Rx charge on one of the
|
---|
72 | ; selected bills Opt Visit Dates that is not billed on any Third Party bill
|
---|
73 | ;
|
---|
74 | ; ^TMP("IBRBF", $J , selected bill ifn ) = ""
|
---|
75 | ; ^TMP("IBRBF", $J , selected bill ifn , charge ifn) =
|
---|
76 | ; BILL FROM ^ BILL TO ^ CANCELLED? (1/0)^ AR BILL NUMBER ^ TOTAL CHARGE ^ ACTION TYPE (SHORT) ^ # DAYS ON HOLD
|
---|
77 | ;
|
---|
78 | TPFP(IBIFN) ; given a specific Third Party Bill, find all related First Party Bills
|
---|
79 | N IBX,IBY,IB0,DFN,IBEVDT,IBPTF,IBADM,IBOPV,IBXRF,IBRXN,IBRXIFN,IBRXDT,IBFROM,IBTO Q:'$G(IBIFN)
|
---|
80 | S IB0=$G(^DGCR(399,+IBIFN,0)) Q:IB0="" S DFN=$P(IB0,U,2),IBEVDT=$P(IB0,U,3)
|
---|
81 | ;
|
---|
82 | K ^TMP("IBRBF",$J,IBIFN) D SAVELN1^IBEFURF(IBIFN)
|
---|
83 | ;
|
---|
84 | IF ; find all First Party charges for the Inpatient Event Date (Admission Date) on the Third Party bill
|
---|
85 | D FPINPT^IBEFURF(DFN,IBEVDT,IBIFN)
|
---|
86 | ;
|
---|
87 | ; find any First Party Outpatient charges for Visit Dates within the date range of the admission (PTF)
|
---|
88 | S IBPTF=$P(IB0,U,8) I +IBPTF S IBADM=$$PTFADM^IBCU64(+IBPTF) I +IBADM S IBADM=$$AD^IBCU64(IBADM) D
|
---|
89 | . S IBX=$P(IBADM,U,2)\1 I 'IBX S IBX=DT
|
---|
90 | . D FPOPV^IBEFURF(DFN,+IBADM\1,IBX,IBIFN)
|
---|
91 | ;
|
---|
92 | OF ; find First Party charges for the Opt Visit Dates on the Third Party Bill
|
---|
93 | S IBX=0 F S IBX=$O(^DGCR(399,+IBIFN,"OP",IBX)) Q:'IBX S IBOPV=+$G(^DGCR(399,+IBIFN,"OP",IBX,0)) D
|
---|
94 | . D FPOPV^IBEFURF(DFN,IBOPV,IBOPV,IBIFN)
|
---|
95 | ;
|
---|
96 | ; find any charges for inpatient admissions whose date range includes one or more of the Opt Visit Dates
|
---|
97 | S IBX=0 F S IBX=$O(^DGCR(399,+IBIFN,"OP",IBX)) Q:'IBX S IBOPV=+$G(^DGCR(399,+IBIFN,"OP",IBX,0)) D
|
---|
98 | . S IBADM=$$ADM^IBCU64(DFN,IBOPV) I 'IBADM Q
|
---|
99 | . D FPINPT^IBEFURF(DFN,+IBADM,IBIFN)
|
---|
100 | ;
|
---|
101 | RF ; find First Party charges for any Rx's on the selected Third Party bill
|
---|
102 | ; based on Rx IFN (52) and fill date (362.4,.05,.03)
|
---|
103 | S IBXRF="AIFN"_IBIFN,IBRXN="" F S IBRXN=$O(^IBA(362.4,IBXRF,IBRXN)) Q:'IBRXN D
|
---|
104 | . S IBX=0 F S IBX=$O(^IBA(362.4,IBXRF,IBRXN,IBX)) Q:'IBX D
|
---|
105 | .. S IBY=$G(^IBA(362.4,IBX,0)),IBRXIFN=$P(IBY,U,5),IBRXDT=$P(IBY,U,3) Q:'IBRXIFN
|
---|
106 | .. D FPRX^IBEFURF(IBRXIFN,IBRXDT,IBIFN)
|
---|
107 | ;
|
---|
108 | ; find First Party Charges for any RX filled on one of the Third Party bill's Opt Visit Dates
|
---|
109 | ; that is not billed on any Third Party bill
|
---|
110 | S IBFROM=$G(^DGCR(399,IBIFN,"U")),IBTO=$P(IBFROM,U,2),IBFROM=+IBFROM K IBX
|
---|
111 | D RXDISP^IBCSC5C(DFN,IBFROM,IBTO,.IBX,"","",1,1) ; get all Rx's for patient in date range
|
---|
112 | S IBRXN="" F S IBRXN=$O(IBX(IBRXN)) Q:IBRXN="" S IBRXDT=0 F S IBRXDT=$O(IBX(IBRXN,IBRXDT)) Q:'IBRXDT D
|
---|
113 | . I '$D(^DGCR(399,"AOPV",DFN,IBRXDT,IBIFN)) Q ; rx not on bills opt visit date
|
---|
114 | . I +$$RXTP^IBEFURT(DFN,IBRXN,IBRXDT) Q ; rx billed on a third party bill
|
---|
115 | . S IBRXIFN=$P(IBX(IBRXN,IBRXDT),U,1)
|
---|
116 | . D FPRX^IBEFURF(IBRXIFN,IBRXDT,IBIFN)
|
---|
117 | Q
|
---|