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

IBCRCI.m

Go to the documentation of this file.
  1. IBCRCI ;ALB/ARH - RATES: CALCULATION ITEM/EVENT COST FNCTNS ; 22-MAY-96
  1. ;;2.0;INTEGRATED BILLING;**52,106,245,458**;21-MAR-94;Build 4
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. ; standard callable functions to get item charge/cost
  1. ;
  1. ; notice that each function works for all Charge Methods and both types of Sets (Item/Event)
  1. ; - if the Charge Set is based on event then the event charge will be calculated (item passed will not be used)
  1. ; - the charges are the unit charges so UNIT should only be defined (or not 1) if the Charge Method is Quantity
  1. ;
  1. ITCHG(CS,ITEM,EVDT,MOD) ; returns total base unit charge for a specific charge set, item/event and date
  1. ; works for both types of Charge Set (Item and Event) and all Charge Methods
  1. ; does not factor in division, units or rate schedule adjustment
  1. ; if charges for the Set are based on event rather than item, will get active events, ITEM is not required/used
  1. ; Input: CS = Charge Set ifn, ITEM = billable item pointer, MOD = cpt modifier
  1. ; Output: total item charge on EVDT ^ effective date of charge ^ total base charge
  1. ;
  1. N IBX,IBITMARR,IBCHGARR,IBITEM,IBI,IBLN,IBCHG,IBCHGB,IBCI,IBEFDT S IBX=0,EVDT=$G(EVDT)\1
  1. I '$D(^IBE(363.1,+$G(CS),0))!(EVDT'?7N) G ITCHGQ
  1. I +$G(ITEM),'$$ITBICHK^IBCRU2(+CS,+ITEM) G ITCHGQ
  1. ;
  1. I $$CSITMS^IBCRCU1(CS)=2 D CSALL^IBCRCU1(CS,EVDT,.IBITMARR)
  1. I +$G(ITEM),'$G(IBITMARR) S IBITMARR=EVDT,IBITMARR(ITEM)=""
  1. I '$G(IBITMARR) G ITCHGQ
  1. ;
  1. S (IBCHG,IBCHGB,IBCI,IBITEM)=0 F S IBITEM=$O(IBITMARR(IBITEM)) Q:'IBITEM D
  1. . D ITMCHG^IBCRCC(CS,IBITEM,EVDT,$G(MOD),.IBCHGARR)
  1. . S IBI=0 F S IBI=$O(IBCHGARR(IBI)) Q:'IBI D
  1. .. S IBLN=IBCHGARR(IBI) S IBCHG=IBCHG+$P(IBLN,U,3),IBCI=+IBLN,IBCHGB=IBCHGB+$P(IBLN,U,4)
  1. ;
  1. I +IBCI S IBEFDT=$P($G(^IBA(363.2,+IBCI,0)),U,3)
  1. I +IBCHG S IBX=+$FN(+IBCHG,"",2)_U_$G(IBEFDT) I +IBCHGB S IBX=IBX_U_+$FN(+IBCHGB,"",2)
  1. ;
  1. ITCHGQ Q IBX
  1. ;
  1. ITCOST(RS,CS,ITEM,EVDT,MOD,DIV,UNIT) ; returns total adjusted unit cost/charge for a specific schedule/set, item/event, date
  1. ; this is the actual cost of one item/event, does factor in division, units and rate schedule adjustment
  1. ; units should be 1 or undefined unless the Charge Method of the rate is Quantity/Miles/Minutes/Hours
  1. ; if the Charge Set is region specific, Division passed must be within that region or no charge
  1. ; Input: CS = Charge Set ifn, ITEM = billable item pointer, MOD = cpt modifier, UNIT = 1 unless Quantity
  1. ; Output: total adjusted item charge/cost on EVDT ^ effective date of charge
  1. ;
  1. N IBCOST,IBBCOST,IBDT S IBCOST=0,EVDT=$G(EVDT)\1,UNIT=$S(+$G(UNIT):UNIT,1:1)
  1. I '$D(^IBE(363.1,+$G(CS),0))!(EVDT'?7N) G ITCOSTQ
  1. I $$CSDV^IBCRU3(CS,+$G(DIV))<0 G ITCOSTQ
  1. S UNIT=$$CPTUNITS^IBCRCU1(CS,UNIT)
  1. ;
  1. S IBCOST=$$ITCHG(CS,$G(ITEM),EVDT,$G(MOD)),IBDT=$P(IBCOST,U,2),IBBCOST=$P(IBCOST,U,3)
  1. S IBCOST=+IBCOST*UNIT
  1. I +IBBCOST S IBCOST=IBCOST+IBBCOST
  1. I +$G(RS) S IBCOST=+$$RATECHG^IBCRCC(RS,+IBCOST,EVDT)
  1. I +IBCOST S IBCOST=+$FN(+IBCOST,"",2)_U_IBDT
  1. ;
  1. ITCOSTQ Q IBCOST
  1. ;
  1. BICOST(RT,BT,EVDT,BE,ITEM,MOD,DIV,UNIT,CT,BLBS) ; returns the total unit cost of a particular item/event for a specific Rate Type and Bill Type, i.e. payer
  1. ; this includes all cost for the item and payer, which may include more than one charge set or rate schedule
  1. ; ITEM is not required if it is an Event CS, BE is required only as a screen for a specific event, if desired
  1. ;
  1. N IBX,IBY,IBCOST,IBDT,IBARR,IBRS,IBCS S (IBX,IBCOST)=0,IBDT=""
  1. I $G(BE)'=""!(+$G(ITEM)) D RT^IBCRU3($G(RT),$G(BT),$G(EVDT),.IBARR,$G(BE),$G(CT))
  1. ;
  1. S IBRS=0 F S IBRS=$O(IBARR(IBRS)) Q:'IBRS D
  1. . S IBCS=0 F S IBCS=$O(IBARR(IBRS,IBCS)) Q:'IBCS I +IBARR(IBRS,IBCS) D
  1. .. I $G(BE)="INPATIENT DRG",'$$CHGICU^IBCRBC2(IBCS,+$G(BLBS)) Q
  1. .. S IBY=$$ITCOST(IBRS,IBCS,$G(ITEM),$G(EVDT),$G(MOD),$G(DIV),$G(UNIT)) I +$P(IBY,U,2)>IBDT S IBDT=+$P(IBY,U,2)
  1. .. S IBCOST=+IBCOST+IBY
  1. S IBX=IBCOST_U_IBDT
  1. Q IBX
  1. ;
  1. BILLCOST(IBIFN,EVDT,BE,ITEM,MOD,UNIT) ; returns total cost of a particular item or event for a specific bill
  1. ; cost may include more than one set or schedule charge if the item/event is defined for more than one set
  1. ; or schedule assigned to the rate type/event type of the bill
  1. ;
  1. N IBX,IB0,IBRT,IBBT S IBX=0,IB0=$G(^DGCR(399,+$G(IBIFN),0)),IBRT=+$P(IB0,U,7),IBBT=$P(IB0,U,5)
  1. I IB0'="" S IBX=$$BICOST(IBRT,IBBT,$G(EVDT),$G(BE),$G(ITEM),$G(MOD),$P(IB0,U,22),$G(UNIT),$P(IB0,U,27))
  1. Q IBX