source: FOIAVistA/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBCRBC.m@ 1154

Last change on this file since 1154 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 9.2 KB
Line 
1IBCRBC ;ALB/ARH - RATES: BILL CALCULATION OF CHARGES ; 22-MAY-1996
2 ;;2.0;INTEGRATED BILLING;**52,80,106,51,137,245,370**;21-MAR-94;Build 5
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; Variable DGPTUPDT may be defined on entry/exit for inpt bills so the PTF will only be updated once per session
6 ; Charges may be filed on the bill and if IBRSARR is passed but does not exist it may be updated
7 ; otherwise there are no other outputs/results of this call.
8 ;
9BILL(IBIFN,IBRSARR) ; given a bill number calculate and store all charges
10 ; if IBRSARR is defined it will be used to create charges rather than the standard set for the bills Rate Type
11 ;
12 N IB0,IBU,IBBRT,IBBTYPE,IBCTYPE,DFN,PTF,IBDGPT,IBRS,IBCS,IBBEVNT Q:'$G(IBIFN)
13 K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS")
14 ;
15 S IB0=$G(^DGCR(399,+IBIFN,0)) Q:IB0="" S IBU=$G(^DGCR(399,+IBIFN,"U")) Q:'IBU
16 S IBBRT=+$P(IB0,U,7),IBBTYPE=$S($$INPAT^IBCEF(IBIFN):1,1:3),IBCTYPE=+$P(IB0,U,27),DFN=$P(IB0,U,2) Q:'DFN
17 ;
18 ; if who's responsible is insurer, but bill has no insurer defined quit
19 I $P(IB0,U,11)="i",'$G(^DGCR(399,+IBIFN,"MP")),'$$MCRWNR^IBEFUNC(+$$CURR^IBCEF2(IBIFN)) Q
20 ;
21 ; if inpt bill, PTF Status is Open, not a Fee Basis record and not previously done then Update the PTF record
22 I IBBTYPE<3,'$D(DGPTUPDT) S PTF=$P(IB0,U,8) Q:'PTF S IBDGPT=$G(^DGPT(+PTF,0)) Q:IBDGPT="" D
23 . I '$P(IBDGPT,U,6),'$P(IBDGPT,U,4) D UPDT^DGPTUTL S DGPTUPDT=""
24 ;
25 ;
26 D DSPDL^IBCRBC3,DELALLRC^IBCRBF(IBIFN) ; delete all existing auto charges on the bill
27 ;
28 ; get standard set of all rate schedules and charge sets available for entire date range of the bill
29 I '$D(IBRSARR) D RT^IBCRU3(IBBRT,IBBTYPE,$P(IBU,U,1,2),.IBRSARR,"",IBCTYPE) I 'IBRSARR G END
30 ;
31 ; process charge sets - set all charges for the bill into array
32 S IBRS=0 F S IBRS=$O(IBRSARR(IBRS)) Q:'IBRS D
33 . S IBCS=0 F S IBCS=$O(IBRSARR(IBRS,IBCS)) Q:'IBCS I +IBRSARR(IBRS,IBCS) D
34 .. S IBBEVNT=+$P($G(^IBE(363.1,+IBCS,0)),U,3) Q:'IBBEVNT S IBBEVNT=$$EMUTL^IBCRU1(IBBEVNT) Q:IBBEVNT=""
35 .. ;
36 .. I IBBEVNT["INPATIENT BEDSECTION STAY" D INPTBS^IBCRBC1(IBIFN,IBRS,IBCS)
37 .. I IBBEVNT["INPATIENT DRG" D INPTDRG^IBCRBC11(IBIFN,IBRS,IBCS)
38 .. I IBBEVNT["OUTPATIENT VISIT DATE" D OPTVST^IBCRBC1(IBIFN,IBRS,IBCS)
39 .. I IBBEVNT["PRESCRIPTION" D RX^IBCRBC1(IBIFN,IBRS,IBCS)
40 .. I IBBEVNT["PROSTHETICS" D PI^IBCRBC1(IBIFN,IBRS,IBCS)
41 .. I IBBEVNT["PROCEDURE" D CPT^IBCRBC1(IBIFN,IBRS,IBCS)
42 ;
43 I '$D(^TMP($J,"IBCRCC")) G END
44 ;
45 D SORTCI^IBCRBC3 I '$D(^TMP($J,"IBCRCS")) G END
46 ;
47 D ADDBCHGS^IBCRBC3(IBIFN)
48 ;
49 D MAILADD(IBIFN,IBBTYPE)
50 ;
51END I $D(^TMP("IBCRRX",$J)) D CLEANRX^IBCRBC3(IBIFN)
52 K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS")
53 Q
54 ;
55MAILADD(IBIFN,BTYPE) ; update the bill mailing address: it may be based on the types of charges
56 ; an outpatient bill may go to either the opt or rx mailing addresses depending on the types of charges
57 N DA,IB01,IB02
58 I $G(BTYPE)>2,+$G(IBIFN),$D(^IBA(362.4,"C",+IBIFN)),+$$CHGTYPE^IBCU(+IBIFN)=3 S DA=IBIFN D MAILA^IBCU5 D
59 . I '$D(ZTQUEUED),'$G(IBAUTO) W !!,"Updating Bill Mailing Address"
60 Q
61 ;
62BILLITEM(IBIFN,IBITMARR) ; add selected unassociated item charges to the bill
63 N IBRS,IBCS,IBBEVNT K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS")
64 ;
65 S IBRS=0 F S IBRS=$O(IBITMARR(IBRS)) Q:'IBRS D
66 . S IBCS=0 F S IBCS=$O(IBITMARR(IBRS,IBCS)) Q:'IBCS D
67 .. S IBBEVNT=+$P($G(^IBE(363.1,+IBCS,0)),U,3) Q:'IBBEVNT S IBBEVNT=$$EMUTL^IBCRU1(IBBEVNT) Q:IBBEVNT=""
68 .. ;
69 .. I IBBEVNT["UNASSOCIATED" D UNASSOC^IBCRBC11(IBIFN,IBRS,IBCS,.IBITMARR)
70 ;
71 I $D(^TMP($J,"IBCRCC")) D SORTCI^IBCRBC3
72 ;
73 I $D(^TMP($J,"IBCRCS")) D ADDBCHGS^IBCRBC3(IBIFN)
74 ;
75 K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS")
76 Q
77 ;
78 ;
79 ;
80 ; There are 3 types of charges/items:
81 ; - ITEM: charge for an individual item: specific item has one or more charge entries in 363.2
82 ; for the charge to be applied to the bill the specific item must be found on the bill
83 ;
84 ; - EVENT: charge for an event, not an item: items are defined in 363.2
85 ; all charge items active on a date in the set define the charge for the event
86 ; the item does not need to be defined on the bill for the charge to be applied to the bill
87 ; the charge set on a date becomes the events charge, so effective date cuts across item and applies to event
88 ; all charge items with the same effective date are used to calculate the event charge for that date
89 ; each charge item effective date in the set overrides all previous entries in the set regardless of item
90 ;
91 ; - VA COST: charge for an individual item but no entries in 363.2
92 ; instead the charge is calculated/obtained when it is needed from an interface with the source package
93 ;
94 ;
95 ; Auto calculation and filing of a bills charges
96 ;
97 ; IBCRBC (BILL) - determine if charges can be calculated and which rates (RS/CS) should be used
98 ; then find billable items/events, calculate and store the charges
99 ; called anytime a bills charges need to be updated
100 ;
101 ; IBCRBC1 (event) - gather billable items/events for each billable event type
102 ; then accumulate all charges for the bill for each billable event/item
103 ;
104 ; IBCRCGx (event) - pull billable items/events from the bill
105 ; IBCRBC2 (BITMCHRG) - calculate charges for billable item/event
106 ;
107 ; IBCRBC3 (SORTCI) - sort accumulated charges into order to store on bill, combine if possible
108 ; IBCRBC3 (ADDBCHRGS) - store the sorted accumulated charges on the bill
109 ;
110 ;
111 ; The Billable Event of the Charge Set is directly related to the Type of charge assigned
112 ; to the charges calculated for that Charge Set. So, Billable Event (363.1,.03) <-> Type (399,42,.1)
113 ;
114 ;
115 ; ^TMP($J,"IBCRCC") - array containing raw charges for a bill and related data, created in IBRCBC2
116 ; ^TMP($J,"IBCRCC",X) = 1 charge item ifn
117 ; 2 charge set ifn
118 ; 3 rate schedule ifn
119 ; 4 item ptr (to source)
120 ; 5 cpt modifier ptr
121 ; 6 revenue code ptr
122 ; 7 billable bedsection (bill)
123 ; 8 event date (visit or st from or admission)
124 ; 9 charge per unit/qty
125 ; 10 units/qty (qty of item)
126 ; 11 total charge per unit/qty
127 ; 12 adjusted total charge per unit/qty
128 ; 13 units (# item on bill)
129 ; 14 CPT ptr
130 ; 15 division ptr
131 ; 16 item type (source)
132 ; 17 item ptr (to source)
133 ; 18 charge component
134 ; 19 billable bedsection (for item)
135 ; 20 procedure provider
136 ; 21 procedures associated clinic
137 ; 22 procedures Outpatient Encounter, pointer to #409.68
138 ; 23 list of all the procedures modifiers, separated by ','
139 ;
140 ; ^TMP($J,"IBCRCC",X,"CC",x) = comments explaining charge adjustements
141 ;
142 ; ^TMP($J,"IBCRCS") - array of charges from IBCRCC in sorted order and with only data needed to save on bill
143 ; ^TMP($J,"IBCRCS", BS, RV, X) = 1 revenue code ptr
144 ; 2 bedsection ptr
145 ; 3 charge per units (adjusted total charge)
146 ; 4 units (# item on bill)
147 ; 5 CPT ptr
148 ; 6 division ptr
149 ; 7 item type
150 ; 8 item ptr
151 ; 9 charge component
152 ;
153 ;
154 ;
155 ; Inpatient Bill Dates use follow rules:
156 ; - admission date is counted as billable
157 ; - the discharge date is not billable and is not counted
158 ;
159 ; - if admission movement is found in the Patient Movement file then the dates of admission and discharge
160 ; will be used as the outside limits of the LOS, even if date range of the bill is longer (LOS^IBCU64)
161 ;
162 ; - a day is counted as billable to the bedsection the patient was in at the end of the day (ie. counted
163 ; in LOS of next movement after midnight)
164 ; - if there is a movement on any given date that date is included in the LOS of the bedsection the patient
165 ; moved into (same as admission date)
166 ; - if there is a movement on any given date that date is NOT included in the LOS of the bedsection the
167 ; patient moved out of (same as discharge date)
168 ;
169 ; - if the time frame of the bill is:
170 ; - either interim-first or interim-continuous the last date on the bill should be billed
171 ; - if the last date is counted it is added to the LOS of the bedsection the patient was in at the end
172 ; of the day
173 ; - either NOT interim-first or interim-continuous (final bills) the last date on the bill
174 ; should NOT be billed (i.e. this is considered the discharge date)
175 ;
176 ; - start with first bedsection after begin date, day is counted in the bedsection the patient is in at midnight
177 ; - continuous: last bedsection counted is the bedsection the patient is in at midnight of the end date
178 ; - final:last bedsection counted is the bedsection the patient is in at midnight of the day before the end date
179 ;
Note: See TracBrowser for help on using the repository browser.