Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: IBCRBC

IBCRBC.m

Go to the documentation of this file.
  1. IBCRBC ;ALB/ARH - RATES: BILL CALCULATION OF CHARGES ; 22-MAY-1996
  1. ;;2.0;INTEGRATED BILLING;**52,80,106,51,137,245,370,516**;21-MAR-94;Build 123
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; Variable DGPTUPDT may be defined on entry/exit for inpt bills so the PTF will only be updated once per session
  1. ; Charges may be filed on the bill and if IBRSARR is passed but does not exist it may be updated
  1. ; otherwise there are no other outputs/results of this call.
  1. ;
  1. BILL(IBIFN,IBRSARR) ; given a bill number calculate and store all charges
  1. ; if IBRSARR is defined it will be used to create charges rather than the standard set for the bills Rate Type
  1. ;
  1. ; MRD;IB*2.0*516 - Added the flag IBNOCALC. This flag is set two
  1. ; places in ^IBCCC -- when the user is CLONing a claim (cancel and
  1. ; copy) or CRDing a claim (correct rejected/denied). The first time
  1. ; this procedure is entered for the new claim, if the IBNOCALC flag is
  1. ; set, it will reset the flag and quit out. That is, it does not re-
  1. ; calculate the charges the first time it otherwise would if the user
  1. ; is doing either a CRD or CLON.
  1. ;
  1. I $G(IBNOCALC) S IBNOCALC=0 Q
  1. ;
  1. N IB0,IBU,IBBRT,IBBTYPE,IBCTYPE,DFN,PTF,IBDGPT,IBRS,IBCS,IBBEVNT Q:'$G(IBIFN)
  1. K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS")
  1. ;
  1. S IB0=$G(^DGCR(399,+IBIFN,0)) Q:IB0="" S IBU=$G(^DGCR(399,+IBIFN,"U")) Q:'IBU
  1. 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
  1. ;
  1. ; if who's responsible is insurer, but bill has no insurer defined quit
  1. I $P(IB0,U,11)="i",'$G(^DGCR(399,+IBIFN,"MP")),'$$MCRWNR^IBEFUNC(+$$CURR^IBCEF2(IBIFN)) Q
  1. ;
  1. ; if inpt bill, PTF Status is Open, not a Fee Basis record and not previously done then Update the PTF record
  1. I IBBTYPE<3,'$D(DGPTUPDT) S PTF=$P(IB0,U,8) Q:'PTF S IBDGPT=$G(^DGPT(+PTF,0)) Q:IBDGPT="" D
  1. . I '$P(IBDGPT,U,6),'$P(IBDGPT,U,4) D UPDT^DGPTUTL S DGPTUPDT=""
  1. ;
  1. ;
  1. D DSPDL^IBCRBC3,DELALLRC^IBCRBF(IBIFN) ; delete all existing auto charges on the bill
  1. ;
  1. ; get standard set of all rate schedules and charge sets available for entire date range of the bill
  1. I '$D(IBRSARR) D RT^IBCRU3(IBBRT,IBBTYPE,$P(IBU,U,1,2),.IBRSARR,"",IBCTYPE) I 'IBRSARR G END
  1. ;
  1. ; process charge sets - set all charges for the bill into array
  1. S IBRS=0 F S IBRS=$O(IBRSARR(IBRS)) Q:'IBRS D
  1. . S IBCS=0 F S IBCS=$O(IBRSARR(IBRS,IBCS)) Q:'IBCS I +IBRSARR(IBRS,IBCS) D
  1. .. S IBBEVNT=+$P($G(^IBE(363.1,+IBCS,0)),U,3) Q:'IBBEVNT S IBBEVNT=$$EMUTL^IBCRU1(IBBEVNT) Q:IBBEVNT=""
  1. .. ;
  1. .. I IBBEVNT["INPATIENT BEDSECTION STAY" D INPTBS^IBCRBC1(IBIFN,IBRS,IBCS)
  1. .. I IBBEVNT["INPATIENT DRG" D INPTDRG^IBCRBC11(IBIFN,IBRS,IBCS)
  1. .. I IBBEVNT["OUTPATIENT VISIT DATE" D OPTVST^IBCRBC1(IBIFN,IBRS,IBCS)
  1. .. I IBBEVNT["PRESCRIPTION" D RX^IBCRBC1(IBIFN,IBRS,IBCS)
  1. .. I IBBEVNT["PROSTHETICS" D PI^IBCRBC1(IBIFN,IBRS,IBCS)
  1. .. I IBBEVNT["PROCEDURE" D CPT^IBCRBC1(IBIFN,IBRS,IBCS)
  1. ;
  1. I '$D(^TMP($J,"IBCRCC")) G END
  1. ;
  1. D SORTCI^IBCRBC3 I '$D(^TMP($J,"IBCRCS")) G END
  1. ;
  1. D ADDBCHGS^IBCRBC3(IBIFN)
  1. ;
  1. D MAILADD(IBIFN,IBBTYPE)
  1. ;
  1. END I $D(^TMP("IBCRRX",$J)) D CLEANRX^IBCRBC3(IBIFN)
  1. K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS")
  1. Q
  1. ;
  1. MAILADD(IBIFN,BTYPE) ; update the bill mailing address: it may be based on the types of charges
  1. ; an outpatient bill may go to either the opt or rx mailing addresses depending on the types of charges
  1. N DA,IB01,IB02
  1. I $G(BTYPE)>2,+$G(IBIFN),$D(^IBA(362.4,"C",+IBIFN)),+$$CHGTYPE^IBCU(+IBIFN)=3 S DA=IBIFN D MAILA^IBCU5 D
  1. . I '$D(ZTQUEUED),'$G(IBAUTO) W !!,"Updating Bill Mailing Address"
  1. Q
  1. ;
  1. BILLITEM(IBIFN,IBITMARR) ; add selected unassociated item charges to the bill
  1. N IBRS,IBCS,IBBEVNT K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS")
  1. ;
  1. S IBRS=0 F S IBRS=$O(IBITMARR(IBRS)) Q:'IBRS D
  1. . S IBCS=0 F S IBCS=$O(IBITMARR(IBRS,IBCS)) Q:'IBCS D
  1. .. S IBBEVNT=+$P($G(^IBE(363.1,+IBCS,0)),U,3) Q:'IBBEVNT S IBBEVNT=$$EMUTL^IBCRU1(IBBEVNT) Q:IBBEVNT=""
  1. .. ;
  1. .. I IBBEVNT["UNASSOCIATED" D UNASSOC^IBCRBC11(IBIFN,IBRS,IBCS,.IBITMARR)
  1. ;
  1. I $D(^TMP($J,"IBCRCC")) D SORTCI^IBCRBC3
  1. ;
  1. I $D(^TMP($J,"IBCRCS")) D ADDBCHGS^IBCRBC3(IBIFN)
  1. ;
  1. K ^TMP($J,"IBCRCC"),^TMP($J,"IBCRCS")
  1. Q
  1. ;
  1. ;
  1. ;
  1. ; There are 3 types of charges/items:
  1. ; - ITEM: charge for an individual item: specific item has one or more charge entries in 363.2
  1. ; for the charge to be applied to the bill the specific item must be found on the bill
  1. ;
  1. ; - EVENT: charge for an event, not an item: items are defined in 363.2
  1. ; all charge items active on a date in the set define the charge for the event
  1. ; the item does not need to be defined on the bill for the charge to be applied to the bill
  1. ; the charge set on a date becomes the events charge, so effective date cuts across item and applies to event
  1. ; all charge items with the same effective date are used to calculate the event charge for that date
  1. ; each charge item effective date in the set overrides all previous entries in the set regardless of item
  1. ;
  1. ; - VA COST: charge for an individual item but no entries in 363.2
  1. ; instead the charge is calculated/obtained when it is needed from an interface with the source package
  1. ;
  1. ;
  1. ; Auto calculation and filing of a bills charges
  1. ;
  1. ; IBCRBC (BILL) - determine if charges can be calculated and which rates (RS/CS) should be used
  1. ; then find billable items/events, calculate and store the charges
  1. ; called anytime a bills charges need to be updated
  1. ;
  1. ; IBCRBC1 (event) - gather billable items/events for each billable event type
  1. ; then accumulate all charges for the bill for each billable event/item
  1. ;
  1. ; IBCRCGx (event) - pull billable items/events from the bill
  1. ; IBCRBC2 (BITMCHRG) - calculate charges for billable item/event
  1. ;
  1. ; IBCRBC3 (SORTCI) - sort accumulated charges into order to store on bill, combine if possible
  1. ; IBCRBC3 (ADDBCHRGS) - store the sorted accumulated charges on the bill
  1. ;
  1. ;
  1. ; The Billable Event of the Charge Set is directly related to the Type of charge assigned
  1. ; to the charges calculated for that Charge Set. So, Billable Event (363.1,.03) <-> Type (399,42,.1)
  1. ;
  1. ;
  1. ; ^TMP($J,"IBCRCC") - array containing raw charges for a bill and related data, created in IBRCBC2
  1. ; ^TMP($J,"IBCRCC",X) = 1 charge item ifn
  1. ; 2 charge set ifn
  1. ; 3 rate schedule ifn
  1. ; 4 item ptr (to source)
  1. ; 5 cpt modifier ptr
  1. ; 6 revenue code ptr
  1. ; 7 billable bedsection (bill)
  1. ; 8 event date (visit or st from or admission)
  1. ; 9 charge per unit/qty
  1. ; 10 units/qty (qty of item)
  1. ; 11 total charge per unit/qty
  1. ; 12 adjusted total charge per unit/qty
  1. ; 13 units (# item on bill)
  1. ; 14 CPT ptr
  1. ; 15 division ptr
  1. ; 16 item type (source)
  1. ; 17 item ptr (to source)
  1. ; 18 charge component
  1. ; 19 billable bedsection (for item)
  1. ; 20 procedure provider
  1. ; 21 procedures associated clinic
  1. ; 22 procedures Outpatient Encounter, pointer to #409.68
  1. ; 23 list of all the procedures modifiers, separated by ','
  1. ;
  1. ; ^TMP($J,"IBCRCC",X,"CC",x) = comments explaining charge adjustements
  1. ;
  1. ; ^TMP($J,"IBCRCS") - array of charges from IBCRCC in sorted order and with only data needed to save on bill
  1. ; ^TMP($J,"IBCRCS", BS, RV, X) = 1 revenue code ptr
  1. ; 2 bedsection ptr
  1. ; 3 charge per units (adjusted total charge)
  1. ; 4 units (# item on bill)
  1. ; 5 CPT ptr
  1. ; 6 division ptr
  1. ; 7 item type
  1. ; 8 item ptr
  1. ; 9 charge component
  1. ;
  1. ;
  1. ;
  1. ; Inpatient Bill Dates use follow rules:
  1. ; - admission date is counted as billable
  1. ; - the discharge date is not billable and is not counted
  1. ;
  1. ; - if admission movement is found in the Patient Movement file then the dates of admission and discharge
  1. ; will be used as the outside limits of the LOS, even if date range of the bill is longer (LOS^IBCU64)
  1. ;
  1. ; - a day is counted as billable to the bedsection the patient was in at the end of the day (ie. counted
  1. ; in LOS of next movement after midnight)
  1. ; - if there is a movement on any given date that date is included in the LOS of the bedsection the patient
  1. ; moved into (same as admission date)
  1. ; - if there is a movement on any given date that date is NOT included in the LOS of the bedsection the
  1. ; patient moved out of (same as discharge date)
  1. ;
  1. ; - if the time frame of the bill is:
  1. ; - either interim-first or interim-continuous the last date on the bill should be billed
  1. ; - if the last date is counted it is added to the LOS of the bedsection the patient was in at the end
  1. ; of the day
  1. ; - either NOT interim-first or interim-continuous (final bills) the last date on the bill
  1. ; should NOT be billed (i.e. this is considered the discharge date)
  1. ;
  1. ; - start with first bedsection after begin date, day is counted in the bedsection the patient is in at midnight
  1. ; - continuous: last bedsection counted is the bedsection the patient is in at midnight of the end date
  1. ; - final:last bedsection counted is the bedsection the patient is in at midnight of the day before the end date
  1. ;