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

RCDPURE1.m

Go to the documentation of this file.
  1. RCDPURE1 ;WISC/RFJ - Process a Receipt ;Jun 06, 2014@19:11:19
  1. ;;4.5;Accounts Receivable;**114,148,153,169,204,173,214,217,296,298,304,321,367**;Mar 20, 1995;Build 11
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. Q
  1. ;
  1. ;
  1. PROCESS(RCRECTDA,RCSCREEN) ; process a receipt, update ar, generate cr/tr documents to fms
  1. ; the receipt and deposit must be locked before calling this label
  1. ; if $g(rcscreen) = 1 show messages during processing
  1. ; if $g(rcscreen) = 2 store messages during processing
  1. ;
  1. N RCPAYDA,RCDPFPAY,RCERROR,RCMSG,RCEFT,RCERA,RCPAYDT0,RCPAYDT1,RCSUSPAR,RCI,RCJ,RCCMTFLG
  1. K ^TMP($J,"RCDPEMSG"),^TMP("RCDPE-RECEIPT-ERROR",$J)
  1. S RCCMTFLG=""
  1. ;
  1. ; === No comments === PRCA*4.5*304
  1. ; If there are entries in suspense with no comments, AND, posting manually, not through auto-posting, display the list of entries
  1. I RCSCREEN=1 D Q:RCCMTFLG
  1. . S RCSUSPAR="",RCPAYDA=0
  1. . F S RCPAYDA=$O(^RCY(344,RCRECTDA,1,RCPAYDA)) Q:'RCPAYDA D
  1. . . S RCPAYDT0=$G(^RCY(344,RCRECTDA,1,RCPAYDA,0))
  1. . . S RCPAYDT1=$G(^RCY(344,RCRECTDA,1,RCPAYDA,1))
  1. . . ; If there is no Bill linked, and the pay amount is not 0 and there is no comment, add to the list
  1. . . I $P(RCPAYDT0,U,9)="",($P(RCPAYDT0,U,4)'=0),($P(RCPAYDT1,U,2)="") S RCSUSPAR(RCPAYDA)=""
  1. . ;
  1. . S RCI="" I $O(RCSUSPAR(RCI)) D Q
  1. . . I '$G(RCSCREEN) Q
  1. . . S RCMSG="The following line items are in suspense: "
  1. . . S RCJ="" F S RCJ=$O(RCSUSPAR(RCJ)) Q:'RCJ D
  1. . . . S RCMSG=RCMSG_RCJ_","
  1. . . S RCMSG=$E(RCMSG,1,$L(RCMSG)-1)
  1. . . D MSG(RCMSG,RCSCREEN,"!!")
  1. . . S RCMSG="Please add the appropriate comment(s) to these line items before re-processing this receipt."
  1. . . D MSG(RCMSG,RCSCREEN,"!!")
  1. . . S RCCMTFLG=1
  1. ;
  1. ; first mark the receipt as processed/closed to prevent changing the
  1. ; data if the receipt does not fully process. this will lock the
  1. ; cancel payment, edit payment, etc. options. once a receipt is
  1. ; processed, even partially, it should not be changed.
  1. D MARKPROC^RCDPUREC(RCRECTDA,"")
  1. ;
  1. ; Special processing needed for EFT-related receipts
  1. ; RCEFT = 1 if EFT deposit, = 2 if receipt detail transfer, 0 if no EFT
  1. S RCEFT=+$$EDILB^RCDPEU(RCRECTDA)
  1. S RCERA=$P($G(^RCY(344,RCRECTDA,0)),U,18)
  1. ;
  1. ; === no payments ===
  1. ; if there are no payments for the receipt, quit
  1. I '$O(^RCY(344,RCRECTDA,1,0)) D Q
  1. . I $G(RCSCREEN) S RCMSG="Receipt does not have any payments and has been marked as processed/closed." D MSG(RCMSG,RCSCREEN,"!!")
  1. . S ^TMP("RCDPE-RECEIPT-ERROR",$J)=RCMSG ;prca*4.5*298 used by auto-post process
  1. . I RCERA D UPDERA(RCERA)
  1. ;
  1. ; check to see if the payments have dollar amounts
  1. S RCPAYDA=0 F S RCPAYDA=$O(^RCY(344,RCRECTDA,1,RCPAYDA)) Q:'RCPAYDA I $P($G(^(RCPAYDA,0)),"^",4) S RCDPFPAY=1 Q
  1. I '$G(RCDPFPAY) D Q
  1. . I $G(RCSCREEN) S RCMSG="Receipt does not have any payments and has been marked as processed/closed." D MSG(RCMSG,RCSCREEN,"!!")
  1. . S ^TMP("RCDPE-RECEIPT-ERROR",$J)=RCMSG ;prca*4.5*298 used by auto-post process
  1. . I RCERA D UPDERA(RCERA)
  1. ;
  1. ; === update AR accounts ===
  1. I $G(RCSCREEN) S RCMSG="Updating AR accounts..." D MSG(RCMSG,RCSCREEN,"!!")
  1. ;
  1. ; loop payments and apply to account in AR
  1. S RCPAYDA=0 F S RCPAYDA=$O(^RCY(344,RCRECTDA,1,RCPAYDA)) Q:'RCPAYDA D I RCERROR Q
  1. . S RCERROR=$$PROCESS^RCBEPAY(RCRECTDA,RCPAYDA)
  1. . S:RCERROR ^TMP("RCDPE-RECEIPT-ERROR",$J)=RCERROR ;prca*4.5*298 used by auto-post process
  1. ;
  1. ; an error occurred during processing a payment
  1. I $G(RCERROR) D Q
  1. . I '$G(RCSCREEN) Q
  1. . S RCMSG="+-----------------------------------------------------------------------------+" D MSG(RCMSG,RCSCREEN,"!!")
  1. . S RCMSG="| An ERROR has occurred when processing payment "_RCPAYDA_" on receipt "_$P(^RCY(344,RCRECTDA,0),"^")_".",RCMSG=$E(RCMSG_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
  1. . S RCMSG="| The error message returned during processing is:",RCMSG=$E(RCMSG_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
  1. . S RCMSG="|"_$J("",77)_"|" D MSG(RCMSG,RCSCREEN,"!")
  1. . S RCMSG=$E("| "_$P(RCERROR,"^",2)_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
  1. . S RCMSG="|"_$J("",77)_"|" D MSG(RCMSG,RCSCREEN,"!")
  1. . S RCMSG=$E("| You will need to correct the error before you can completely process the"_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
  1. . S RCMSG=$E("| receipt. Once the receipt is completely processed, the FMS "_$S(RCEFT'=2:"Cash Receipt",1:"'TR'")_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
  1. . S RCMSG=$E("| document will be generated."_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
  1. . S RCMSG="+-----------------------------------------------------------------------------+" D MSG(RCMSG,RCSCREEN,"!")
  1. ;
  1. ; all payments processed correctly
  1. I RCERA D UPDERA(RCERA)
  1. I $G(RCSCREEN) D MSG(" Done.",RCSCREEN)
  1. ;
  1. ; *296 - no cr document for event type 'a' or 'p' or 't'
  1. N RCDPETY S RCDPETY=$P($G(^RCY(344,RCRECTDA,0)),"^",4)
  1. I (RCDPETY=15)!(RCDPETY=16)!(RCDPETY=13) D 215 Q
  1. ;
  1. ; if no deposit ticket and not related to EFT or is a HAC payment, do not send to fms
  1. I '$P(^RCY(344,RCRECTDA,0),"^",6),$S('RCEFT:1,1:$$HACEFT^RCDPEU(+$P(^RCY(344,RCRECTDA,0),U,17))) D Q
  1. . D 215
  1. . I $G(RCSCREEN) S RCMSG="Receipt does not have a deposit ticket and will NOT be sent to FMS." D MSG(RCMSG,RCSCREEN,"!!")
  1. . S ^TMP("RCDPE-RECEIPT-ERROR",$J)="" ;prca*4.5*298 used by auto-post process
  1. ;
  1. ; === send fms cash receipt document ===
  1. N GECSDATA,FMSDOCNO,RESULT,REFMS
  1. ; lookup fms document number to see if the receipt has been
  1. ; sent to fms (field 200 in file 344)
  1. S FMSDOCNO=$P($G(^RCY(344,RCRECTDA,2)),"^")
  1. ; if there is an entry, find the code sheet in gcs to rebuild
  1. ; gecsdata will be the ien for file 2100.1
  1. I FMSDOCNO'="" S REFMS=1 N DIQ2 D DATA^GECSSGET(FMSDOCNO,0)
  1. ;
  1. I $G(RCSCREEN)&$G(GECSDATA) S RCMSG="Re-Transmitting CR document to FMS... " D MSG(RCMSG,RCSCREEN,"!!")
  1. I $G(RCSCREEN)&'$G(GECSDATA) S RCMSG="Transmitting CR document to FMS... " D MSG(RCMSG,RCSCREEN,"!!")
  1. ;
  1. ; build and send the tr/cr document to fms
  1. I RCEFT'=2 D ; Send CR doc
  1. . S RESULT=$$BUILDCR^RCXFMSCR(RCRECTDA,+$G(GECSDATA),RCEFT)
  1. E D ; Send TR doc
  1. . S RESULT=$$GETTR^RCXFMST1(RCRECTDA,+$G(GECSDATA))
  1. ; error in building code sheet
  1. I 'RESULT D:$G(RCSCREEN) MSG("ERROR - "_$P(RESULT,"^",2),RCSCREEN,"!!") Q
  1. ;
  1. ; no document to send
  1. I $P(RESULT,"^")=-1,$G(RCSCREEN) S RCMSG="NOTE - "_$P(RESULT,"^",2) S $P(RESULT,"^",2)="" D MSG(RCMSG,RCSCREEN,"!!") S ^TMP("RCDPE-RECEIPT-ERROR",$J)=""
  1. ; document built and sent
  1. I $P(RESULT,"^")=1,$G(RCSCREEN) D
  1. . N Z,DIE,DR,DA
  1. . D MSG("Done. FMS document number "_$P(RESULT,"^",2),RCSCREEN,"!!")
  1. . I +$O(^RCY(344.4,"ARCT",RCRECTDA,0)) S DIE="^RCY(344.4,",DR=".14////1",DA=+$O(^RCY(344.4,"ARCT",RCRECTDA,0)) D ^DIE
  1. . I $P($G(^RCY(344,RCRECTDA,0)),U,17) S Z=$P($G(^RCY(344.31,+$P(^RCY(344,RCRECTDA,0),U,17),0)),U,15) I Z'="" S DA=RCRECTDA,DIE="^RCY(344,",DR=".16////"_Z D ^DIE
  1. I $G(RCSCREEN) D
  1. . N Y
  1. . I '$G(REFMS)&(DT>$$LDATE^RCRJR(DT)) S Y=$E($$FPS^RCAMFN01(DT,1),1,5)_"01" D DD^%DT W !! S RCMSG=" * * * * Transmission will be held until "_Y_" * * * *" D MSG(RCMSG,RCSCREEN,"!!")
  1. ;
  1. ;
  1. ; store the fms document number (receipt already marked processed/
  1. ; closed at the top of the routine just before posting the dollars.
  1. D MARKPROC^RCDPUREC(RCRECTDA,$P(RESULT,"^",2))
  1. I RCEFT=2 D MSG("No 215 report generated for this receipt",RCSCREEN,"!!") G Q215
  1. ;
  1. ;
  1. 215 ; === print 215 report ===
  1. I $G(RCSCREEN) D MSG("Queuing 215 report...",RCSCREEN,"!!")
  1. N DEVICE
  1. S DEVICE=$$OPTCK^RCDPRPL2("215REPORT",3)
  1. I DEVICE="" D:$G(RCSCREEN) MSG(" Use Customize Option to set up the default printer.",RCSCREEN) Q
  1. ;
  1. S ZTIO=DEVICE,ZTDTH=$H,ZTRTN="DQ^RCDPR215",ZTSAVE("RECEIPDA")=RCRECTDA,ZTSAVE("RCTYPE")="A"
  1. D ^%ZTLOAD,^%ZISC
  1. Q215 I $G(RCSCREEN) D MSG(" Done.",RCSCREEN)
  1. Q
  1. ;
  1. UPDERA(RCERA) ; Update detail posted status for ERA entry RCERA
  1. ;
  1. N DA,DIE,DR
  1. S DA=+$G(RCERA),DR=".14////1",DIE="^RCY(344.4," D:DA ^DIE
  1. Q
  1. ;
  1. MSG(RCMSG,RCSCREEN,PRELINE,POSTLINE) ; Write message or set into msg array
  1. ; RCMSG = text to write RCSCREEN = screen flag
  1. ; PRELINE = the line feeds to print before the text
  1. ; POSTLINE = the line feeds to print after the text
  1. Q:'RCSCREEN
  1. N RCPRE,RCPOST,Z
  1. S RCPRE=$L($G(PRELINE),"!")-1,RCPOST=$L($G(POSTLINE),"!")-1
  1. I RCSCREEN=1 D G MSGQ
  1. . F Z=1:1:RCPRE W !
  1. . W RCMSG
  1. . F Z=1:1:RCPOST W !
  1. F Z=1:1:RCPRE S ^TMP($J,"RCDPEMSG",+$O(^TMP("RCDPEMSG",""),-1)+1)=""
  1. S ^TMP($J,"RCDPEMSG",+$O(^TMP("RCDPEMSG",""),-1)+1)=RCMSG
  1. F Z=1:1:RCPOST S ^TMP($J,"RCDPEMSG",+$O(^TMP("RCDPEMSG",""),-1)+1)=""
  1. MSGQ Q
  1. ;
  1. ; PRCA*4.5*298 updated EDIT4 removing DIPA
  1. EDIT4(DA,DR,RCDR1,RCDR2,RCDR3) ; Modify DR string for type of payment edit
  1. ; for EDI Lockbox
  1. ; Input: DA,DR Output: RCDR1,RCDR2,RCDR3
  1. ; If type unchanged, or neither old/new are EDI Lockbox, no chk needed
  1. ; If old type is EDI Lockbox and scratch pad exists, no change allowed
  1. ; If changed to EDI Lockbox and detail already exists, no chg allowed without UNMATCH EFT key
  1. ; If changed to EDI Lockbox, ask for related EFT
  1. N RCDR,RCLST,RCM,RCM1,RCM2,RCM3,RCN4,RCNE,RCNO,RCO4,RCOE,RCP,RCSTRT,Z,Z0
  1. S (RCDR1,RCDR2,RCDR3)=""
  1. ;
  1. S RCP=10 F Z=2:1 Q:DR'[("@"_RCP)&(DR'[("@"_(RCP+1)))&(DR'[("@"_(RCP+2)))&(DR'[("@"_(RCP+3)))&(DR'[("@"_(RCP+4))) S RCP=RCP*Z
  1. ;
  1. S Z=$L(DR,".04;"),RCSTRT=1,RCLST=Z
  1. I Z>2 D ; Find .04, not n.04
  1. . F S Z0=$P(DR,".04;",RCSTRT) Q:Z0=""!'$E(Z0,$L(Z0)) S RCSTRT=RCSTRT+1
  1. ;
  1. ; If unchanged/changed from/to other than EDI Lockbox, jump over edits
  1. S RCDR1="S RCP="_RCP_" D SETV^RCDPURE1;"_$P(DR,".04;",1,RCSTRT)
  1. S RCDR2="@"_RCP_";.04;S RCNO=0,RCN4=X D TYP^RCDPUREC(.Y);.17////^S X=RCNE;S Y=""@"_(RCP+2)_""""
  1. ; Reset field .04 and .17 if not a valid type change
  1. S RCDR2=RCDR2_";@"_(RCP+1)_";.04////^S X=RCO4;I RCOE="""" S Y=""@"_(RCP+3)_""";"
  1. S RCDR2=RCDR2_".17////^S X=RCOE;@"_(RCP+3)_";"
  1. ; PRCA*4.5*321 Modified error message logic in $S ; PRCA*4.5*367 - Added RECEIPT TOTAL if type is CHAMPVA
  1. S RCDR2=RCDR2_"W !,*7,$S(RCN4=14&RCNO:RCM2,RCO4=14:RCM1,1:RCM),! S Y=""@"_RCP_""";@"_(RCP+4)_";.06///@;.22;S Y=""@99"";@"_(RCP+2)
  1. S RCDR3=$P(DR,".04;",RCSTRT+1,RCLST)
  1. Q
  1. ;
  1. ; PRCA*4.5*298 updated SETV removing DIPA, added comments
  1. SETV ; Set up variables needed to edit change of receipt type, used in DR strings to edit AR BATCH PAYMENT (#344)
  1. ; RCO4 = existing (#.04) TYPE OF PAYMENT value, RCOE = existing (#.17) EFT RECORD value
  1. N X S X=$G(^RCY(344,DA,0)),RCO4=$P(X,U,4),RCOE=$P(X,U,17)
  1. S RCM="RCDPEPP key required for this action" ; PCRA*4.5*321
  1. S RCM1="RCDPEPP key required once detail has been loaded from the ERA" ; PCRA*4.5*321
  1. S RCM2="Must have an EFT for an EDI Lockbox payment type"
  1. S RCM3=">>If receipt is for an ERA and a paper check, select the ERA now"
  1. Q
  1. ;
  1. WL(DA) ; Function returns 0 if the worklist did not create the receipt
  1. ; or the ien of the worklist entry if it did (344.4 and 344.49 are DINUMED)
  1. N Z
  1. S Z=+$O(^RCY(344.4,"AREC",DA,0))
  1. Q Z
  1. ;
  1. HAC(RC) ; Returns 1 if the receipt in RC is related to a HAC EFT
  1. N Z,HAC
  1. S HAC=0
  1. ; ERA related to an EFT detail record
  1. S Z=+$G(^RCY(344.31,+$P($G(^RCY(344,RC,0)),U,17),0))
  1. ; Deposit # in EFT transmission starts with HAC
  1. I Z S Z=$P($G(^RCY(344.3,+Z,0)),U,6) I $E(Z,1,3)="HAC" S HAC=1
  1. Q HAC
  1. ;