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

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

initial load of FOIAVistA 6/30/08 version

File size: 4.2 KB
Line 
1IBCRCI ;ALB/ARH - RATES: CALCULATION ITEM/EVENT COST FNCTNS ; 22-MAY-96
2 ;;2.0;INTEGRATED BILLING;**52,106,245**;21-MAR-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified
4 ;
5 ; standard callable functions to get item charge/cost
6 ;
7 ; notice that each function works for all Charge Methods and both types of Sets (Item/Event)
8 ; - if the Charge Set is based on event then the event charge will be calculated (item passed will not be used)
9 ; - the charges are the unit charges so UNIT should only be defined (or not 1) if the Charge Method is Quantity
10 ;
11ITCHG(CS,ITEM,EVDT,MOD) ; returns total base unit charge for a specific charge set, item/event and date
12 ; works for both types of Charge Set (Item and Event) and all Charge Methods
13 ; does not factor in division, units or rate schedule adjustment
14 ; if charges for the Set are based on event rather than item, will get active events, ITEM is not required/used
15 ; Input: CS = Charge Set ifn, ITEM = billable item pointer, MOD = cpt modifier
16 ; Output: total item charge on EVDT ^ effective date of charge ^ total base charge
17 ;
18 N IBX,IBITMARR,IBCHGARR,IBITEM,IBI,IBLN,IBCHG,IBCHGB,IBCI,IBEFDT S IBX=0,EVDT=$G(EVDT)\1
19 I '$D(^IBE(363.1,+$G(CS),0))!(EVDT'?7N) G ITCHGQ
20 I +$G(ITEM),'$$ITBICHK^IBCRU2(+CS,+ITEM) G ITCHGQ
21 ;
22 I $$CSITMS^IBCRCU1(CS)=2 D CSALL^IBCRCU1(CS,EVDT,.IBITMARR)
23 I +$G(ITEM),'$G(IBITMARR) S IBITMARR=EVDT,IBITMARR(ITEM)=""
24 I '$G(IBITMARR) G ITCHGQ
25 ;
26 S (IBCHG,IBCHGB,IBCI,IBITEM)=0 F S IBITEM=$O(IBITMARR(IBITEM)) Q:'IBITEM D
27 . D ITMCHG^IBCRCC(CS,IBITEM,EVDT,$G(MOD),.IBCHGARR)
28 . S IBI=0 F S IBI=$O(IBCHGARR(IBI)) Q:'IBI D
29 .. S IBLN=IBCHGARR(IBI) S IBCHG=IBCHG+$P(IBLN,U,3),IBCI=+IBLN,IBCHGB=IBCHGB+$P(IBLN,U,4)
30 ;
31 I +IBCI S IBEFDT=$P($G(^IBA(363.2,+IBCI,0)),U,3)
32 I +IBCHG S IBX=+$FN(+IBCHG,"",2)_U_$G(IBEFDT) I +IBCHGB S IBX=IBX_U_+$FN(+IBCHGB,"",2)
33 ;
34ITCHGQ Q IBX
35 ;
36ITCOST(RS,CS,ITEM,EVDT,MOD,DIV,UNIT) ; returns total adjusted unit cost/charge for a specific schedule/set, item/event, date
37 ; this is the actual cost of one item/event, does factor in division, units and rate schedule adjustment
38 ; units should be 1 or undefined unless the Charge Method of the rate is Quantity/Miles/Minutes/Hours
39 ; if the Charge Set is region specific, Division passed must be within that region or no charge
40 ; Input: CS = Charge Set ifn, ITEM = billable item pointer, MOD = cpt modifier, UNIT = 1 unless Quantity
41 ; Output: total adjusted item charge/cost on EVDT ^ effective date of charge
42 ;
43 N IBCOST,IBBCOST,IBDT S IBCOST=0,EVDT=$G(EVDT)\1,UNIT=$S(+$G(UNIT):UNIT,1:1)
44 I '$D(^IBE(363.1,+$G(CS),0))!(EVDT'?7N) G ITCOSTQ
45 I $$CSDV^IBCRU3(CS,+$G(DIV))<0 G ITCOSTQ
46 S UNIT=$$CPTUNITS^IBCRCU1(CS,UNIT)
47 ;
48 S IBCOST=$$ITCHG(CS,$G(ITEM),EVDT,$G(MOD)),IBDT=$P(IBCOST,U,2),IBBCOST=$P(IBCOST,U,3)
49 S IBCOST=+IBCOST*UNIT
50 I +IBBCOST S IBCOST=IBCOST+IBBCOST
51 I +$G(RS) S IBCOST=+$$RATECHG^IBCRCC(RS,+IBCOST,EVDT)
52 I +IBCOST S IBCOST=+$FN(+IBCOST,"",2)_U_IBDT
53 ;
54ITCOSTQ Q IBCOST
55 ;
56BICOST(RT,BT,EVDT,BE,ITEM,MOD,DIV,UNIT,CT) ; returns the total unit cost of a particular item/event for a specific Rate Type and Bill Type, i.e. payer
57 ; this includes all cost for the item and payer, which may include more than one charge set or rate schedule
58 ; ITEM is not required if it is an Event CS, BE is required only as a screen for a specific event, if desired
59 ;
60 N IBX,IBY,IBCOST,IBDT,IBARR,IBRS,IBCS S (IBX,IBCOST)=0,IBDT=""
61 I $G(BE)'=""!(+$G(ITEM)) D RT^IBCRU3($G(RT),$G(BT),$G(EVDT),.IBARR,$G(BE),$G(CT))
62 ;
63 S IBRS=0 F S IBRS=$O(IBARR(IBRS)) Q:'IBRS D
64 . S IBCS=0 F S IBCS=$O(IBARR(IBRS,IBCS)) Q:'IBCS I +IBARR(IBRS,IBCS) D
65 .. 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)
66 .. S IBCOST=+IBCOST+IBY
67 S IBX=IBCOST_U_IBDT
68 Q IBX
69 ;
70BILLCOST(IBIFN,EVDT,BE,ITEM,MOD,UNIT) ; returns total cost of a particular item or event for a specific bill
71 ; cost may include more than one set or schedule charge if the item/event is defined for more than one set
72 ; or schedule assigned to the rate type/event type of the bill
73 ;
74 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)
75 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))
76 Q IBX
Note: See TracBrowser for help on using the repository browser.