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

RCBEIB.m

Go to the documentation of this file.
  1. RCBEIB ;WISC/RFJ-integrated billing entry points ;1 Jun 00
  1. ;;4.5;Accounts Receivable;**157,270,301**;Mar 20, 1995;Build 144
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. Q
  1. ;
  1. ; PRCA*4.5*270 add CRD flag
  1. ; CANCEL(RCBILLDA,RCCANDAT,RCCANDUZ,RCCANAMT,RCCANCOM) ; this entry point is
  1. CANCEL(RCBILLDA,RCCANDAT,RCCANDUZ,RCCANAMT,RCCANCOM,RCCRD) ; this entry point is
  1. ; called when a bill is cancelled in IB
  1. ; input rcbillda = ien of bill to cancel
  1. ; rccandat = (optional) the date the bill was cancelled
  1. ; rccanduz = (optional) the user cancelling the bill
  1. ; rccanamt = (optional) amount being cancelled
  1. ; rccancom = (optional) comments
  1. ; rccrd = (optional) CRD flag, indicates corrected record which FMS must handle differently
  1. ;
  1. ; if the optional fields are passed, they will be stored in the
  1. ; comment field (98) of the bill.
  1. ;
  1. ; returns 1 if bill is cancelled in AR
  1. ; 0^error message if process fails to cancel bill in AR
  1. ;
  1. N ACTDATE,COMMENT,DATA,INTADM,LINE,PIECE,RCBALANC,RCDATA0,RCDATE,RCFCANC,RCLIST,RCOMMENT,RCPAYAMT,RCPAYMNT,RCTRANDA,VALUE,X,XMDUN,XMY,Y
  1. ;
  1. ; lock the bill
  1. L +^PRCA(430,RCBILLDA):10
  1. I '$T Q "0^AR bill is locked by another process"
  1. ;
  1. S RCDATA0=$G(^PRCA(430,RCBILLDA,0))
  1. I RCDATA0="" L -^PRCA(430,RCBILLDA) Q "0^AR bill not found"
  1. ;
  1. ; add comments to bill
  1. S RCOMMENT(1)="Bill was cancelled in IB on "_$$FMTE^XLFDT($$NOW^XLFDT)_".",LINE=2
  1. S Y=$G(RCCANDAT) I Y S Y=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3),LINE=LINE+1,RCOMMENT(LINE)=" Cancel Date: "_Y
  1. S Y=$G(RCCANDUZ) I Y S Y=$P($G(^VA(200,+RCCANDUZ,0)),"^"),LINE=LINE+1,RCOMMENT(LINE)=" Cancel By: "_Y
  1. S Y=$G(RCCANAMT) I Y S Y=$J(Y,0,2),LINE=LINE+1,RCOMMENT(LINE)=" Cancel Amount: "_Y
  1. I $G(RCCANCOM)'="" S LINE=LINE+1,RCOMMENT(LINE)=" Comments: "_RCCANCOM
  1. I LINE'=2 S RCOMMENT(2)="The following information was passed from IB:"
  1. D ADDCOMM^RCBEUBIL(RCBILLDA,.RCOMMENT)
  1. ;
  1. ; test to see if the bill is active in AR
  1. S ACTDATE=$P($G(^PRCA(430,RCBILLDA,6)),"^",21)
  1. ;
  1. ; === bill not activated ===
  1. ; set status to cancelled bill (26)
  1. I 'ACTDATE D CHGSTAT^RCBEUBIL(RCBILLDA,26) L -^PRCA(430,RCBILLDA) Q 1
  1. ;
  1. ; === bill is activated ===
  1. ;
  1. ; get the balance of the bill
  1. S RCBALANC=$$GETTRANS^RCDPBTLM(RCBILLDA)
  1. ;
  1. ; calculate payments made
  1. S RCDATE="",RCPAYAMT=0,RCPAYMNT=""
  1. F S RCDATE=$O(RCLIST(RCDATE)) Q:'RCDATE D
  1. . S RCTRANDA=0
  1. . F S RCTRANDA=$O(RCLIST(RCDATE,RCTRANDA)) Q:'RCTRANDA D
  1. . . I RCLIST(RCDATE,RCTRANDA)'["PAYMENT" Q
  1. . . F PIECE=2:1:6 D
  1. . . . ; total payments
  1. . . . S RCPAYAMT=RCPAYAMT+$P(RCLIST(RCDATE,RCTRANDA),"^",PIECE)
  1. . . . ; total payments by prin ^ int ^ adm ^ mf ^ cc
  1. . . . S $P(RCPAYMNT,"^",PIECE-1)=$P(RCPAYMNT,"^",PIECE-1)+$P(RCLIST(RCDATE,RCTRANDA),"^",PIECE)
  1. ;
  1. ; if the current bill status is active, cancel it
  1. I $P(^PRCA(430,RCBILLDA,0),"^",8)=16!($P(^PRCA(430,RCBILLDA,0),"^",8)=42) D
  1. . ; if there is a principal balance, decrease it
  1. . S COMMENT(1)="Bill cancelled in IB. Automatic decrease adjustment created."
  1. . ;
  1. . ; PRCA*4.5*270 need to let FMS know if this is a corrected record
  1. . ;I $P(RCBALANC,"^") S RCTRANDA=$$INCDEC^RCBEUTR1(RCBILLDA,-$P(RCBALANC,"^"),.COMMENT) I 'RCTRANDA Q
  1. . I $P(RCBALANC,"^") S RCTRANDA=$$INCDEC^RCBEUTR1(RCBILLDA,-$P(RCBALANC,"^"),.COMMENT,"","","",$G(RCCRD)) I 'RCTRANDA Q
  1. . I $D(^PRCA(430,"TCSP",RCBILLDA)) D DECADJ^RCTCSPU(RCBILLDA,RCTRANDA) ;prca*4.5*301 add cs decrease adjustment
  1. . ;
  1. . ; create an int/adm charge (minus)
  1. . ; determine if there is an interest ^ admin ^ mf ^ cc charge
  1. . ; set value = interest ^ admin ^ mf ^ cc (and make negative)
  1. . S INTADM=0,VALUE=""
  1. . F PIECE=2:1:5 S INTADM=INTADM+$P(RCBALANC,"^",PIECE),VALUE=VALUE_(-$P(RCBALANC,"^",PIECE))_"^"
  1. . I INTADM S RCTRANDA=$$INTADM^RCBEUTR1(RCBILLDA,VALUE,.COMMENT) I 'RCTRANDA Q
  1. . I $D(^PRCA(430,"TCSP",RCBILLDA)) D DECADJ^RCTCSPU(RCBILLDA,RCTRANDA) ;prca*4.5*301 add cs decrease adjustment
  1. . ;
  1. . ; mark bill as cancellation (39)
  1. . D CHGSTAT^RCBEUBIL(RCBILLDA,39)
  1. ;
  1. ; recheck status to see if bill was cancelled
  1. ; set rcfcanc to indicate bill could not be canceled
  1. S RCDATA0=$G(^PRCA(430,RCBILLDA,0))
  1. I $P(RCDATA0,"^",8)'=39,$P(RCDATA0,"^",8)'=26 S RCFCANC="AR could not automatically CANCEL the bill. User action is required."
  1. ;
  1. ; if the bill was cancelled in AR and no payments, do not send mail
  1. I $G(RCFCANC)="",'RCPAYAMT L -^PRCA(430,RCBILLDA) Q 1
  1. ;
  1. ;
  1. ; bill could not be cancelled in AR or payments made,
  1. ; send mailman message to user
  1. K ^TMP($J,"RCRJRCORMM")
  1. S ^TMP($J,"RCRJRCORMM",1,0)="Integrated Billing has cancelled bill "_$P(RCDATA0,"^")_"."
  1. S ^TMP($J,"RCRJRCORMM",2,0)=" "
  1. S ^TMP($J,"RCRJRCORMM",3,0)=" BILL: "_$P(RCDATA0,"^")_" STATUS: "_$P($G(^PRCA(430.3,+$P(^PRCA(430,RCBILLDA,0),"^",8),0)),"^")
  1. S DATA=$$ACCNTHDR^RCDPAPLM($P(RCDATA0,"^",9))
  1. S ^TMP($J,"RCRJRCORMM",4,0)=" ACCOUNT: "_$P(DATA,"^")_" "_$P(DATA,"^",2)
  1. S ^TMP($J,"RCRJRCORMM",5,0)=" "
  1. S ^TMP($J,"RCRJRCORMM",6,0)=" Principal Interest Admin"
  1. S ^TMP($J,"RCRJRCORMM",7,0)=" Current Balance: "_$J($P(RCBALANC,"^"),10,2)_$J($P(RCBALANC,"^",2),10,2)_$J($P(RCBALANC,"^",3)+$P(RCBALANC,"^",4)+$P(RCBALANC,"^",5),10,2)
  1. S LINE=7
  1. ;
  1. ; if payments made, show amount paid
  1. I RCPAYAMT S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)=" Payments Made: "_$J(-$P(RCPAYMNT,"^"),10,2)_$J(-$P(RCPAYMNT,"^",2),10,2)_$J(-$P(RCPAYMNT,"^",3)-$P(RCPAYMNT,"^",4)-$P(RCPAYMNT,"^",5),10,2)
  1. ;
  1. ; if comments passed from IB, include them
  1. I $D(RCOMMENT(2)) D
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)=" "
  1. . F X=1:1 Q:'$D(RCOMMENT(X)) S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)=RCOMMENT(X)
  1. ;
  1. ; if the bill could not be cancelled in AR, let user know the error
  1. I $G(RCFCANC)'="" D
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)=" "
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)="* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)=RCFCANC
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)="* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
  1. ;
  1. ; if a payment has been made, let user know it needs to be refunded
  1. I RCPAYAMT D
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)=" "
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)="* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)="In AR, a payment of $ "_$J(-RCPAYAMT,0,2)_" has been collected and needs to be REFUNDED."
  1. . S LINE=LINE+1,^TMP($J,"RCRJRCORMM",LINE,0)="* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
  1. ;
  1. ; send report
  1. S XMY("G.PRCA ADJUSTMENT TRANS")=""
  1. S X=$$SENDMSG^RCRJRCOR("AR User Action Required "_$P(RCDATA0,"^"),.XMY)
  1. K ^TMP($J,"RCRJRCORMM")
  1. ;
  1. L -^PRCA(430,RCBILLDA)
  1. ;
  1. Q $S($G(RCFCANC)'="":"0^"_RCFCANC,1:1)