| [623] | 1 | IBCRBC ;ALB/ARH - RATES: BILL CALCULATION OF CHARGES ; 22-MAY-1996 | 
|---|
|  | 2 | ;;2.0;INTEGRATED BILLING;**52,80,106,51,137,245**;21-MAR-94 | 
|---|
|  | 3 | ;;Per VHA Directive 10-93-142, 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 | ; | 
|---|
|  | 9 | BILL(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 MULTCPT^IBCRBCA1 ; adjust charges for Multiple Surgical Procedure Discount | 
|---|
|  | 46 | D PSB^IBCRBCA2 ;     adjust charges for Primary/Secondary Bundling | 
|---|
|  | 47 | D MODADJ^IBCRBCA3 ;  adjust charges for Modifier Adjustment | 
|---|
|  | 48 | ; | 
|---|
|  | 49 | D SORTCI^IBCRBC3 I '$D(^TMP($J,"IBCRCS")) G END | 
|---|
|  | 50 | ; | 
|---|
|  | 51 | D ADDBCHGS^IBCRBC3(IBIFN) | 
|---|
|  | 52 | ; | 
|---|
|  | 53 | D MAILADD(IBIFN,IBBTYPE) | 
|---|
|  | 54 | ; | 
|---|
|  | 55 | END I $D(^TMP("IBCRRX",$J)) D CLEANRX^IBCRBC3(IBIFN) | 
|---|
|  | 56 | K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS") | 
|---|
|  | 57 | Q | 
|---|
|  | 58 | ; | 
|---|
|  | 59 | MAILADD(IBIFN,BTYPE) ; update the bill mailing address:  it may be based on the types of charges | 
|---|
|  | 60 | ; an outpatient bill may go to either the opt or rx mailing addresses depending on the types of charges | 
|---|
|  | 61 | N DA,IB01,IB02 | 
|---|
|  | 62 | I $G(BTYPE)>2,+$G(IBIFN),$D(^IBA(362.4,"C",+IBIFN)),+$$CHGTYPE^IBCU(+IBIFN)=3 S DA=IBIFN D MAILA^IBCU5 D | 
|---|
|  | 63 | . I '$D(ZTQUEUED),'$G(IBAUTO) W !!,"Updating Bill Mailing Address" | 
|---|
|  | 64 | Q | 
|---|
|  | 65 | ; | 
|---|
|  | 66 | BILLITEM(IBIFN,IBITMARR) ; add selected unassociated item charges to the bill | 
|---|
|  | 67 | N IBRS,IBCS,IBBEVNT K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS") | 
|---|
|  | 68 | ; | 
|---|
|  | 69 | S IBRS=0 F  S IBRS=$O(IBITMARR(IBRS)) Q:'IBRS  D | 
|---|
|  | 70 | . S IBCS=0 F  S IBCS=$O(IBITMARR(IBRS,IBCS)) Q:'IBCS  D | 
|---|
|  | 71 | .. S IBBEVNT=+$P($G(^IBE(363.1,+IBCS,0)),U,3) Q:'IBBEVNT  S IBBEVNT=$$EMUTL^IBCRU1(IBBEVNT) Q:IBBEVNT="" | 
|---|
|  | 72 | .. ; | 
|---|
|  | 73 | .. I IBBEVNT["UNASSOCIATED" D UNASSOC^IBCRBC11(IBIFN,IBRS,IBCS,.IBITMARR) | 
|---|
|  | 74 | ; | 
|---|
|  | 75 | I $D(^TMP($J,"IBCRCC")) D SORTCI^IBCRBC3 | 
|---|
|  | 76 | ; | 
|---|
|  | 77 | I $D(^TMP($J,"IBCRCS")) D ADDBCHGS^IBCRBC3(IBIFN) | 
|---|
|  | 78 | ; | 
|---|
|  | 79 | K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS") | 
|---|
|  | 80 | Q | 
|---|
|  | 81 | ; | 
|---|
|  | 82 | ; | 
|---|
|  | 83 | ; | 
|---|
|  | 84 | ; There are 3 types of charges/items: | 
|---|
|  | 85 | ; - ITEM: charge for an individual item:  specific item has one or more charge entries in 363.2 | 
|---|
|  | 86 | ;   for the charge to be applied to the bill the specific item must be found on the bill | 
|---|
|  | 87 | ; | 
|---|
|  | 88 | ; - EVENT: charge for an event, not an item:  items are defined in 363.2 | 
|---|
|  | 89 | ;   all charge items active on a date in the set define the charge for the event | 
|---|
|  | 90 | ;   the item does not need to be defined on the bill for the charge to be applied to the bill | 
|---|
|  | 91 | ;   the charge set on a date becomes the events charge, so effective date cuts across item and applies to event | 
|---|
|  | 92 | ;   all charge items with the same effective date are used to calculate the event charge for that date | 
|---|
|  | 93 | ;   each charge item effective date in the set overrides all previous entries in the set regardless of item | 
|---|
|  | 94 | ; | 
|---|
|  | 95 | ; - VA COST:  charge for an individual item but no entries in 363.2 | 
|---|
|  | 96 | ;   instead the charge is calculated/obtained when it is needed from an interface with the source package | 
|---|
|  | 97 | ; | 
|---|
|  | 98 | ; | 
|---|
|  | 99 | ; Auto calculation and filing of a bills charges | 
|---|
|  | 100 | ; | 
|---|
|  | 101 | ; IBCRBC (BILL) - determine if charges can be calculated and which rates (RS/CS) should be used | 
|---|
|  | 102 | ;                 then find billable items/events, calculate and store the charges | 
|---|
|  | 103 | ;                 called anytime a bills charges need to be updated | 
|---|
|  | 104 | ; | 
|---|
|  | 105 | ;                 IBCRBC1 (event) - gather billable items/events for each billable event type | 
|---|
|  | 106 | ;                                   then accumulate all charges for the bill for each billable event/item | 
|---|
|  | 107 | ; | 
|---|
|  | 108 | ;                                   IBCRCGx (event) - pull billable items/events from the bill | 
|---|
|  | 109 | ;                                   IBCRBC2 (BITMCHRG) - calculate charges for billable item/event | 
|---|
|  | 110 | ; | 
|---|
|  | 111 | ;                 IBCRBC3 (SORTCI) - sort accumulated charges into order to store on bill, combine if possible | 
|---|
|  | 112 | ;                 IBCRBC3 (ADDBCHRGS) -  store the sorted accumulated charges on the bill | 
|---|
|  | 113 | ; | 
|---|
|  | 114 | ; | 
|---|
|  | 115 | ; The Billable Event of the Charge Set is directly related to the Type of charge assigned | 
|---|
|  | 116 | ; to the charges calculated for that Charge Set.  So, Billable Event (363.1,.03) <-> Type (399,42,.1) | 
|---|
|  | 117 | ; | 
|---|
|  | 118 | ; | 
|---|
|  | 119 | ;  ^TMP($J,"IBCRCC")  -  array containing raw charges for a bill and related data, created in IBRCBC2 | 
|---|
|  | 120 | ;  ^TMP($J,"IBCRCC",X) = 1  charge item ifn | 
|---|
|  | 121 | ;                        2  charge set ifn | 
|---|
|  | 122 | ;                        3  rate schedule ifn | 
|---|
|  | 123 | ;                        4  item ptr (to source) | 
|---|
|  | 124 | ;                        5  cpt modifier ptr | 
|---|
|  | 125 | ;                        6  revenue code ptr | 
|---|
|  | 126 | ;                        7  billable bedsection (bill) | 
|---|
|  | 127 | ;                        8  event date (visit or st from or admission) | 
|---|
|  | 128 | ;                        9  charge per unit/qty | 
|---|
|  | 129 | ;                        10 units/qty (qty of item) | 
|---|
|  | 130 | ;                        11 total charge per unit/qty | 
|---|
|  | 131 | ;                        12 adjusted total charge per unit/qty | 
|---|
|  | 132 | ;                        13 units (# item on bill) | 
|---|
|  | 133 | ;                        14 CPT ptr | 
|---|
|  | 134 | ;                        15 division ptr | 
|---|
|  | 135 | ;                        16 item type (source) | 
|---|
|  | 136 | ;                        17 item ptr (to source) | 
|---|
|  | 137 | ;                        18 charge component | 
|---|
|  | 138 | ;                        19 billable bedsection (for item) | 
|---|
|  | 139 | ;                        20 procedure provider | 
|---|
|  | 140 | ;                        21 procedures associated clinic | 
|---|
|  | 141 | ;                        22 procedures Outpatient Encounter, pointer to #409.68 | 
|---|
|  | 142 | ; | 
|---|
|  | 143 | ;  ^TMP($J,"IBCRCC",X,"CC",x) = comments explaining charge adjustements | 
|---|
|  | 144 | ; | 
|---|
|  | 145 | ;  ^TMP($J,"IBCRCS")  -  array of charges from IBCRCC in sorted order and with only data needed to save on bill | 
|---|
|  | 146 | ;  ^TMP($J,"IBCRCS", BS, RV, X) = 1  revenue code ptr | 
|---|
|  | 147 | ;                                 2  bedsection ptr | 
|---|
|  | 148 | ;                                 3  charge per units (adjusted total charge) | 
|---|
|  | 149 | ;                                 4  units (# item on bill) | 
|---|
|  | 150 | ;                                 5  CPT ptr | 
|---|
|  | 151 | ;                                 6  division ptr | 
|---|
|  | 152 | ;                                 7  item type | 
|---|
|  | 153 | ;                                 8  item ptr | 
|---|
|  | 154 | ;                                 9  charge component | 
|---|
|  | 155 | ; | 
|---|
|  | 156 | ; | 
|---|
|  | 157 | ; | 
|---|
|  | 158 | ; Inpatient Bill Dates use follow rules: | 
|---|
|  | 159 | ; - admission date is counted as billable | 
|---|
|  | 160 | ; - the discharge date is not billable and is not counted | 
|---|
|  | 161 | ; | 
|---|
|  | 162 | ; - if admission movement is found in the Patient Movement file then the dates of admission and discharge | 
|---|
|  | 163 | ;   will be used as the outside limits of the LOS, even if date range of the bill is longer   (LOS^IBCU64) | 
|---|
|  | 164 | ; | 
|---|
|  | 165 | ; - a day is counted as billable to the bedsection the patient was in at the end of the day (ie. counted | 
|---|
|  | 166 | ;   in LOS of next movement after midnight) | 
|---|
|  | 167 | ; - if there is a movement on any given date that date is included in the LOS of the bedsection the patient | 
|---|
|  | 168 | ;   moved into (same as admission date) | 
|---|
|  | 169 | ; - if there is a movement on any given date that date is NOT included in the LOS of the bedsection the | 
|---|
|  | 170 | ;   patient moved out of (same as discharge date) | 
|---|
|  | 171 | ; | 
|---|
|  | 172 | ; - if the time frame of the bill is: | 
|---|
|  | 173 | ;   - either interim-first or interim-continuous the last date on the bill should be billed | 
|---|
|  | 174 | ;     - if the last date is counted it is added to the LOS of the bedsection the patient was in at the end | 
|---|
|  | 175 | ;       of the day | 
|---|
|  | 176 | ;   - either NOT interim-first or interim-continuous (final bills) the last date on the bill | 
|---|
|  | 177 | ;     should NOT be billed (i.e. this is considered the discharge date) | 
|---|
|  | 178 | ; | 
|---|
|  | 179 | ; - start with first bedsection after begin date, day is counted in the bedsection the patient is in at midnight | 
|---|
|  | 180 | ; - continuous: last bedsection counted is the bedsection the patient is in at midnight of the end date | 
|---|
|  | 181 | ; - final:last bedsection counted is the bedsection the patient is in at midnight of the day before the end date | 
|---|
|  | 182 | ; | 
|---|