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

RCBMILLC.m

Go to the documentation of this file.
  1. RCBMILLC ;WISC/RFJ-millennium bill (calculations top routine) ;27 Jun 2001 11:10 AM
  1. ;;4.5;Accounts Receivable;**170,174**;Mar 20, 1995
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. Q
  1. ;
  1. ;
  1. BILLFUND(RCBILLDA,RCDATEND) ; for a bill up to a given date,
  1. ; calculate the amount that should be paid to MCCF and HSIF
  1. ; returns:
  1. ; tmp("rcbmilldata",$j,rcbillda,rctranda) = transaction type (P I D)
  1. ; piece 2 = principal amt of transaction
  1. ; piece 3 = amount owed to mccf
  1. ; piece 4 = amount owed to hsif
  1. ; piece 5 = for payment, amount already paid to mccf
  1. ; piece 6 = for payment, amount already paid to hsif
  1. ;
  1. ; returns amt owed to mccf for bill
  1. ; amt owed to hsif for bill
  1. ; amt paid to mccf for bill
  1. ; amt paid to hsif for bill
  1. ;
  1. N AMTPAID,AMTOHSIF,AMTOMCCF,CHARGES,PRINCPAL,RCBALANC,RCCHARGE,RCDATA1,RCEFFDAT,RCTOHSIF,RCTOMCCF,RCTOTAL,RCTRANDA,RCVALUE
  1. K ^TMP($J,"RCBMILLDATA",RCBILLDA)
  1. ;
  1. I '$G(RCDATEND) N RCDATEND S RCDATEND=9999999
  1. ;
  1. ; this is the effective date for splitting the dollars
  1. ; should be in the form 3020204 for feb 4, 2002
  1. S RCEFFDAT=3020204
  1. ;
  1. ; this is the standard charge amount. the total increase or
  1. ; decrease adjustment must be evenly divisable by this amount
  1. ; for splitting into separate funds
  1. S RCCHARGE=7
  1. ;
  1. ; this is the amount of RCCHARGE that goes to mccf and hsif
  1. S RCTOMCCF=2
  1. S RCTOHSIF=RCCHARGE-RCTOMCCF
  1. ;
  1. ; initialize the amounts owed to mccf and hsif for a bill
  1. ; these variables are returned with the quit at the end
  1. S RCTOTAL("OWED TO MCCF")=0
  1. S RCTOTAL("OWED TO HSIF")=0
  1. S RCTOTAL("PAID TO MCCF")=0
  1. S RCTOTAL("PAID TO HSIF")=0
  1. ;
  1. ; initialize running balance, used internally to track amounts
  1. S RCBALANC("MCCF AFTER EFF DATE")=0
  1. ;
  1. ; if it is an old bill that has an orignal amt, set it up
  1. S RCBALANC("MCCF BEFORE EFF DATE")=0
  1. S RCBALANC("HSIF")=0
  1. I $P($G(^PRCA(430,RCBILLDA,0)),"^",3) D
  1. . S RCVALUE=$P(^PRCA(430,RCBILLDA,0),"^",3)
  1. . S AMTOMCCF("BEFORE EFF DATE")=RCVALUE
  1. . S AMTOMCCF("AFTER EFF DATE")=0
  1. . S RCTRANDA=0
  1. . D SETTEMP^RCBMILLD("I*",RCVALUE,.AMTOMCCF,0)
  1. ;
  1. S RCTRANDA=0 F S RCTRANDA=$O(^PRCA(433,"C",RCBILLDA,RCTRANDA)) Q:'RCTRANDA D
  1. . ;
  1. . ; make sure the transaction is before the ending date
  1. . S RCDATA1=$G(^PRCA(433,RCTRANDA,1))
  1. . I $P(RCDATA1,"^",9)>RCDATEND Q
  1. . ;
  1. . ; get the principal of the transaction, this call
  1. . ; also verifies this is a valid "complete" transaction
  1. . S RCVALUE=$$TRANBAL^RCRJRCOT(RCTRANDA)
  1. . ; if no principal, quit
  1. . I '$P(RCVALUE,"^") Q
  1. . ;
  1. . ;
  1. . ; * * * I N C R E A S E * * *
  1. . I $P(RCDATA1,"^",2)=1 D Q
  1. . . ; the date of the transaction must be after the effective
  1. . . ; date or all of the principal goes to mccf
  1. . . I $P(RCDATA1,"^",9)<RCEFFDAT D Q
  1. . . . S AMTOMCCF("BEFORE EFF DATE")=$P(RCVALUE,"^")
  1. . . . S AMTOMCCF("AFTER EFF DATE")=0
  1. . . . D SETTEMP^RCBMILLD("I*",$P(RCVALUE,"^"),.AMTOMCCF,0)
  1. . . ;
  1. . . ; the principal amount has to be evenly divisable by [the standard
  1. . . ; charge: in rccharge]. if not all principal goes to mccf
  1. . . I $P(RCVALUE,"^")#RCCHARGE'=0 D Q
  1. . . . S AMTOMCCF("BEFORE EFF DATE")=$P(RCVALUE,"^")
  1. . . . S AMTOMCCF("AFTER EFF DATE")=0
  1. . . . D SETTEMP^RCBMILLD("I*",$P(RCVALUE,"^"),.AMTOMCCF,0)
  1. . . ;
  1. . . ; after the effective date
  1. . . S AMTOMCCF("BEFORE EFF DATE")=0
  1. . . ;
  1. . . ; the amount to MCCF is the number of times [the standard charge:
  1. . . ; in rccharge] goes into the principal, multiplied by the amount
  1. . . ; that goes to mccf: in rctomccf
  1. . . S AMTOMCCF("AFTER EFF DATE")=($P(RCVALUE,"^")/RCCHARGE)*RCTOMCCF
  1. . . ;
  1. . . ; the amount to MCCF is the difference
  1. . . S AMTOHSIF=$P(RCVALUE,"^")-AMTOMCCF("AFTER EFF DATE")
  1. . . ;
  1. . . D SETTEMP^RCBMILLD("I",$P(RCVALUE,"^"),.AMTOMCCF,AMTOHSIF)
  1. . ;
  1. . ;
  1. . ; * * * D E C R E A S E * * *
  1. . I $P(RCDATA1,"^",2)=35 D Q
  1. . . ; the date of the transaction must be after the effective
  1. . . ; date or all of the principal comes from mccf
  1. . . I $P(RCDATA1,"^",9)<RCEFFDAT D Q
  1. . . . S AMTOMCCF("BEFORE EFF DATE")=-$P(RCVALUE,"^")
  1. . . . S AMTOMCCF("AFTER EFF DATE")=0
  1. . . . D SETTEMP^RCBMILLD("D*",-$P(RCVALUE,"^"),.AMTOMCCF,0)
  1. . . ;
  1. . . ; calculate the number of copayment charges that make up
  1. . . ; the principal. this number is used to calculate the
  1. . . ; dollars to hsif
  1. . . S CHARGES=$P(RCVALUE,"^")\RCCHARGE
  1. . . ;
  1. . . ; calculate the amount that should go to hsif
  1. . . S AMTOHSIF=+$J(CHARGES*RCTOHSIF,0,2)
  1. . . ;
  1. . . ; remainder goes to mccf
  1. . . S AMTOMCCF=$P(RCVALUE,"^")-AMTOHSIF
  1. . . ;
  1. . . ; if the amount coming from hsif exceeds the amount owed to hsif,
  1. . . ; move it to mccf
  1. . . I AMTOHSIF>RCBALANC("HSIF") S AMTOHSIF=RCBALANC("HSIF"),AMTOMCCF=$P(RCVALUE,"^")-AMTOHSIF
  1. . . ;
  1. . . ; if the amount to mccf exceeds amount owed to mccf,
  1. . . ; move more to hsif
  1. . . I AMTOMCCF>(RCBALANC("MCCF AFTER EFF DATE")+RCBALANC("MCCF BEFORE EFF DATE")) D
  1. . . . S AMTOMCCF=RCBALANC("MCCF AFTER EFF DATE")+RCBALANC("MCCF BEFORE EFF DATE")
  1. . . . S AMTOHSIF=$P(RCVALUE,"^")-AMTOMCCF
  1. . . ;
  1. . . ; split the amount before and after effective date,
  1. . . ; default is allocate all to after effective date
  1. . . S AMTOMCCF("AFTER EFF DATE")=AMTOMCCF
  1. . . S AMTOMCCF("BEFORE EFF DATE")=0
  1. . . ;
  1. . . ; if the amount to mccf after the effective date exceeds the amount owed to mccf after the
  1. . . ; effective date, place more in mccf before the effective date
  1. . . I AMTOMCCF("AFTER EFF DATE")>RCBALANC("MCCF AFTER EFF DATE") D
  1. . . . S AMTOMCCF("BEFORE EFF DATE")=AMTOMCCF("AFTER EFF DATE")-RCBALANC("MCCF AFTER EFF DATE")
  1. . . . S AMTOMCCF("AFTER EFF DATE")=RCBALANC("MCCF AFTER EFF DATE")
  1. . . ;
  1. . . ; make amounts negative for decrease
  1. . . S AMTOMCCF("BEFORE EFF DATE")=-AMTOMCCF("BEFORE EFF DATE")
  1. . . S AMTOMCCF("AFTER EFF DATE")=-AMTOMCCF("AFTER EFF DATE")
  1. . . ;
  1. . . D SETTEMP^RCBMILLD("D",-$P(RCVALUE,"^"),.AMTOMCCF,-AMTOHSIF)
  1. . ;
  1. . ;
  1. . ; * * * P A Y M E N T S * * *
  1. . ; if it is a payment transaction, get the amount
  1. . ; already paid to the funds
  1. . I $P(RCDATA1,"^",2)=2!($P(RCDATA1,"^",2)=34) D Q
  1. . . ; calculate the amount of this payment that should go to MCCF
  1. . . ; for transactions created prior to the effective date
  1. . . S AMTOMCCF("BEFORE EFF DATE")=RCBALANC("MCCF BEFORE EFF DATE")
  1. . . I AMTOMCCF("BEFORE EFF DATE")>$P(RCVALUE,"^") S AMTOMCCF("BEFORE EFF DATE")=$P(RCVALUE,"^")
  1. . . ;
  1. . . ; recalculate principal remaining after the mandatory amount
  1. . . ; is given to MCCF
  1. . . S PRINCPAL=$P(RCVALUE,"^")-AMTOMCCF("BEFORE EFF DATE")
  1. . . ;
  1. . . ; calculate the number of copayment charges that make up
  1. . . ; the principal remaining. this number is used to calculate the
  1. . . ; dollars to hsif. calculate the remainder after the standard
  1. . . ; charge is allocated to mccf and hsif.
  1. . . S CHARGES=PRINCPAL\RCCHARGE
  1. . . S PRINCPAL=PRINCPAL#RCCHARGE
  1. . . ;
  1. . . ; calculate the amount that should go to mccf
  1. . . ; it is the number of standard charges times the
  1. . . ; amount of each standard charge allocated to mccf
  1. . . S AMTOMCCF("AFTER EFF DATE")=+$J(CHARGES*RCTOMCCF,0,2)
  1. . . ;
  1. . . ; if the remainder is less than the standard charge
  1. . . ; allocated to mccf, add it also
  1. . . I PRINCPAL<RCTOMCCF S AMTOMCCF("AFTER EFF DATE")=AMTOMCCF("AFTER EFF DATE")+PRINCPAL
  1. . . ;
  1. . . ; if the remainder is more than the standard charge
  1. . . ; allocated to mccf, add one more standard charge to
  1. . . ; mccf and give the rest to hsif
  1. . . I PRINCPAL>RCTOMCCF S AMTOMCCF("AFTER EFF DATE")=AMTOMCCF("AFTER EFF DATE")+RCTOMCCF
  1. . . ;
  1. . . ; if the amount to mccf exceeds the amount owed to mccf,
  1. . . ; place more in hsif
  1. . . I AMTOMCCF("AFTER EFF DATE")>RCBALANC("MCCF AFTER EFF DATE") D
  1. . . . S AMTOMCCF("AFTER EFF DATE")=RCBALANC("MCCF AFTER EFF DATE")
  1. . . ;
  1. . . ; balance of payment goes to hsif
  1. . . S AMTOHSIF=$P(RCVALUE,"^")-AMTOMCCF("BEFORE EFF DATE")-AMTOMCCF("AFTER EFF DATE")
  1. . . ;
  1. . . ; get the amount paid to the funds
  1. . . S AMTPAID=$G(^PRCA(433,RCTRANDA,9))
  1. . . ;
  1. . . ; make amounts negative for payment
  1. . . S AMTOMCCF("BEFORE EFF DATE")=-AMTOMCCF("BEFORE EFF DATE")
  1. . . S AMTOMCCF("AFTER EFF DATE")=-AMTOMCCF("AFTER EFF DATE")
  1. . . ;
  1. . . D SETTEMP^RCBMILLD("P",-$P(RCVALUE,"^"),.AMTOMCCF,-AMTOHSIF,$P(AMTPAID,"^"),$P(AMTPAID,"^",2))
  1. . ;
  1. . ;
  1. . ; * * * R E E S T A B L I S H * * *
  1. . ; if it is a restablish transaction, add the amount to mccf
  1. . I $P(RCDATA1,"^",2)=43 D Q
  1. . . S AMTOMCCF("BEFORE EFF DATE")=$P(RCVALUE,"^")
  1. . . S AMTOMCCF("AFTER EFF DATE")=0
  1. . . D SETTEMP^RCBMILLD("R",$P(RCVALUE,"^"),.AMTOMCCF,0)
  1. ;
  1. Q RCTOTAL("OWED TO MCCF")_"^"_RCTOTAL("OWED TO HSIF")_"^"_RCTOTAL("PAID TO MCCF")_"^"_RCTOTAL("PAID TO HSIF")