[613] | 1 | RCDPURE1 ;WISC/RFJ-process a receipt ;1 Jun 99
|
---|
| 2 | ;;4.5;Accounts Receivable;**114,148,153,169,204,173,214,217**;Mar 20, 1995
|
---|
| 3 | ;;Per VHA Directive 10-93-142, this routine should not be modified.
|
---|
| 4 | Q
|
---|
| 5 | ;
|
---|
| 6 | ;
|
---|
| 7 | PROCESS(RCRECTDA,RCSCREEN) ; process a receipt, update ar, generate cr/tr documents to fms
|
---|
| 8 | ; the receipt and deposit must be locked before calling this label
|
---|
| 9 | ; if $g(rcscreen) = 1 show messages during processing
|
---|
| 10 | ; if $g(rcscreen) = 2 store messages during processing
|
---|
| 11 | N RCPAYDA,RCDPFPAY,RCERROR,RCMSG,RCEFT,RCERA
|
---|
| 12 | K ^TMP($J,"RCDPEMSG")
|
---|
| 13 | ;
|
---|
| 14 | ; first mark the receipt as processed/closed to prevent changing the
|
---|
| 15 | ; data if the receipt does not fully process. this will lock the
|
---|
| 16 | ; cancel payment, edit payment, etc. options. once a receipt is
|
---|
| 17 | ; processed, even partially, it should not be changed.
|
---|
| 18 | D MARKPROC^RCDPUREC(RCRECTDA,"")
|
---|
| 19 | ;
|
---|
| 20 | ; Special processing needed for EFT-related receipts
|
---|
| 21 | ; RCEFT = 1 if EFT deposit, = 2 if receipt detail transfer, 0 if no EFT
|
---|
| 22 | S RCEFT=+$$EDILB^RCDPEU(RCRECTDA)
|
---|
| 23 | S RCERA=$P($G(^RCY(344,RCRECTDA,0)),U,18)
|
---|
| 24 | ;
|
---|
| 25 | ; === no payments ===
|
---|
| 26 | ; if there are no payments for the receipt, quit
|
---|
| 27 | I '$O(^RCY(344,RCRECTDA,1,0)) D Q
|
---|
| 28 | . I $G(RCSCREEN) S RCMSG="Receipt does not have any payments and has been marked as processed/closed." D MSG(RCMSG,RCSCREEN,"!!")
|
---|
| 29 | . I RCERA D UPDERA(RCERA)
|
---|
| 30 | ;
|
---|
| 31 | ; check to see if the payments have dollar amounts
|
---|
| 32 | S RCPAYDA=0 F S RCPAYDA=$O(^RCY(344,RCRECTDA,1,RCPAYDA)) Q:'RCPAYDA I $P($G(^(RCPAYDA,0)),"^",4) S RCDPFPAY=1 Q
|
---|
| 33 | I '$G(RCDPFPAY) D Q
|
---|
| 34 | . I $G(RCSCREEN) S RCMSG="Receipt does not have any payments and has been marked as processed/closed." D MSG(RCMSG,RCSCREEN,"!!")
|
---|
| 35 | . I RCERA D UPDERA(RCERA)
|
---|
| 36 | ;
|
---|
| 37 | ; === update AR accounts ===
|
---|
| 38 | I $G(RCSCREEN) S RCMSG="Updating AR accounts..." D MSG(RCMSG,RCSCREEN,"!!")
|
---|
| 39 | ;
|
---|
| 40 | ; loop payments and apply to account in AR
|
---|
| 41 | S RCPAYDA=0 F S RCPAYDA=$O(^RCY(344,RCRECTDA,1,RCPAYDA)) Q:'RCPAYDA D I RCERROR Q
|
---|
| 42 | . S RCERROR=$$PROCESS^RCBEPAY(RCRECTDA,RCPAYDA)
|
---|
| 43 | ;
|
---|
| 44 | ; an error occurred during processing a payment
|
---|
| 45 | I $G(RCERROR) D Q
|
---|
| 46 | . I '$G(RCSCREEN) Q
|
---|
| 47 | . S RCMSG="+-----------------------------------------------------------------------------+" D MSG(RCMSG,RCSCREEN,"!!")
|
---|
| 48 | . 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,"!")
|
---|
| 49 | . S RCMSG="| The error message returned during processing is:",RCMSG=$E(RCMSG_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
|
---|
| 50 | . S RCMSG="|"_$J("",77)_"|" D MSG(RCMSG,RCSCREEN,"!")
|
---|
| 51 | . S RCMSG=$E("| "_$P(RCERROR,"^",2)_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
|
---|
| 52 | . S RCMSG="|"_$J("",77)_"|" D MSG(RCMSG,RCSCREEN,"!")
|
---|
| 53 | . S RCMSG=$E("| You will need to correct the error before you can completely process the"_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
|
---|
| 54 | . 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,"!")
|
---|
| 55 | . S RCMSG=$E("| document will be generated."_$J("",77),1,77)_"|" D MSG(RCMSG,RCSCREEN,"!")
|
---|
| 56 | . S RCMSG="+-----------------------------------------------------------------------------+" D MSG(RCMSG,RCSCREEN,"!")
|
---|
| 57 | ;
|
---|
| 58 | ; all payments processed correctly
|
---|
| 59 | I RCERA D UPDERA(RCERA)
|
---|
| 60 | I $G(RCSCREEN) D MSG(" Done.",RCSCREEN)
|
---|
| 61 | ;
|
---|
| 62 | ; if no deposit ticket and not related to EFT or is a HAC payment, do not send to fms
|
---|
| 63 | I '$P(^RCY(344,RCRECTDA,0),"^",6),$S('RCEFT:1,1:$$HACEFT^RCDPEU(+$P(^RCY(344,RCRECTDA,0),U,17))) D Q
|
---|
| 64 | . D 215
|
---|
| 65 | . I $G(RCSCREEN) S RCMSG="Receipt does not have a deposit ticket and will NOT be sent to FMS." D MSG(RCMSG,RCSCREEN,"!!")
|
---|
| 66 | ;
|
---|
| 67 | ; === send fms cash receipt document ===
|
---|
| 68 | N GECSDATA,FMSDOCNO,RESULT,REFMS
|
---|
| 69 | ; lookup fms document number to see if the receipt has been
|
---|
| 70 | ; sent to fms (field 200 in file 344)
|
---|
| 71 | S FMSDOCNO=$P($G(^RCY(344,RCRECTDA,2)),"^")
|
---|
| 72 | ; if there is an entry, find the code sheet in gcs to rebuild
|
---|
| 73 | ; gecsdata will be the ien for file 2100.1
|
---|
| 74 | I FMSDOCNO'="" S REFMS=1 N DIQ2 D DATA^GECSSGET(FMSDOCNO,0)
|
---|
| 75 | ;
|
---|
| 76 | I $G(RCSCREEN)&$G(GECSDATA) S RCMSG="Re-Transmitting CR document to FMS... " D MSG(RCMSG,RCSCREEN,"!!")
|
---|
| 77 | I $G(RCSCREEN)&'$G(GECSDATA) S RCMSG="Transmitting CR document to FMS... " D MSG(RCMSG,RCSCREEN,"!!")
|
---|
| 78 | ;
|
---|
| 79 | ; build and send the tr/cr document to fms
|
---|
| 80 | I RCEFT'=2 D ; Send CR doc
|
---|
| 81 | . S RESULT=$$BUILDCR^RCXFMSCR(RCRECTDA,+$G(GECSDATA),RCEFT)
|
---|
| 82 | E D ; Send TR doc
|
---|
| 83 | . S RESULT=$$GETTR^RCXFMST1(RCRECTDA,+$G(GECSDATA))
|
---|
| 84 | ; error in building code sheet
|
---|
| 85 | I 'RESULT D:$G(RCSCREEN) MSG("ERROR - "_$P(RESULT,"^",2),RCSCREEN,"!!") Q
|
---|
| 86 | ;
|
---|
| 87 | ; no document to send
|
---|
| 88 | I $P(RESULT,"^")=-1,$G(RCSCREEN) S RCMSG="NOTE - "_$P(RESULT,"^",2) S $P(RESULT,"^",2)="" D MSG(RCMSG,RCSCREEN,"!!")
|
---|
| 89 | ; document built and sent
|
---|
| 90 | I $P(RESULT,"^")=1,$G(RCSCREEN) D
|
---|
| 91 | . N Z,DIE,DR,DA
|
---|
| 92 | . D MSG("Done. FMS document number "_$P(RESULT,"^",2),RCSCREEN,"!!")
|
---|
| 93 | . 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
|
---|
| 94 | . 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
|
---|
| 95 | I $G(RCSCREEN) D
|
---|
| 96 | . 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,"!!")
|
---|
| 97 | ;
|
---|
| 98 | ;
|
---|
| 99 | ; store the fms document number (receipt already marked processed/
|
---|
| 100 | ; closed at the top of the routine just before posting the dollars.
|
---|
| 101 | D MARKPROC^RCDPUREC(RCRECTDA,$P(RESULT,"^",2))
|
---|
| 102 | I RCEFT=2 D MSG("No 215 report generated for this receipt",RCSCREEN,"!!") G Q215
|
---|
| 103 | ;
|
---|
| 104 | ;
|
---|
| 105 | 215 ; === print 215 report ===
|
---|
| 106 | I $G(RCSCREEN) D MSG("Queuing 215 report...",RCSCREEN,"!!")
|
---|
| 107 | N DEVICE
|
---|
| 108 | S DEVICE=$$OPTCK^RCDPRPL2("215REPORT",3)
|
---|
| 109 | I DEVICE="" D:$G(RCSCREEN) MSG(" Use Customize Option to set up the default printer.",RCSCREEN) Q
|
---|
| 110 | ;
|
---|
| 111 | S ZTIO=DEVICE,ZTDTH=$H,ZTRTN="DQ^RCDPR215",ZTSAVE("RECEIPDA")=RCRECTDA,ZTSAVE("RCTYPE")="A"
|
---|
| 112 | D ^%ZTLOAD,^%ZISC
|
---|
| 113 | Q215 I $G(RCSCREEN) D MSG(" Done.",RCSCREEN)
|
---|
| 114 | Q
|
---|
| 115 | ;
|
---|
| 116 | UPDERA(RCERA) ; Update detail posted status for ERA entry RCERA
|
---|
| 117 | ;
|
---|
| 118 | N DA,DIE,DR
|
---|
| 119 | S DA=+$G(RCERA),DR=".14////1",DIE="^RCY(344.4," D:DA ^DIE
|
---|
| 120 | Q
|
---|
| 121 | ;
|
---|
| 122 | MSG(RCMSG,RCSCREEN,PRELINE,POSTLINE) ; Write message or set into msg array
|
---|
| 123 | ; RCMSG = text to write RCSCREEN = screen flag
|
---|
| 124 | ; PRELINE = the line feeds to print before the text
|
---|
| 125 | ; POSTLINE = the line feeds to print after the text
|
---|
| 126 | Q:'RCSCREEN
|
---|
| 127 | N RCPRE,RCPOST,Z
|
---|
| 128 | S RCPRE=$L($G(PRELINE),"!")-1,RCPOST=$L($G(POSTLINE),"!")-1
|
---|
| 129 | I RCSCREEN=1 D G MSGQ
|
---|
| 130 | . F Z=1:1:RCPRE W !
|
---|
| 131 | . W RCMSG
|
---|
| 132 | . F Z=1:1:RCPOST W !
|
---|
| 133 | F Z=1:1:RCPRE S ^TMP($J,"RCDPEMSG",+$O(^TMP("RCDPEMSG",""),-1)+1)=""
|
---|
| 134 | S ^TMP($J,"RCDPEMSG",+$O(^TMP("RCDPEMSG",""),-1)+1)=RCMSG
|
---|
| 135 | F Z=1:1:RCPOST S ^TMP($J,"RCDPEMSG",+$O(^TMP("RCDPEMSG",""),-1)+1)=""
|
---|
| 136 | MSGQ Q
|
---|
| 137 | ;
|
---|
| 138 | EDIT4(DA,DR,RCDR1,RCDR2,RCDR3) ; Modify DR string for type of payment edit
|
---|
| 139 | ; for EDI Lockbox
|
---|
| 140 | ; Input: DA,DR Output: RCDR1,RCDR2,RCDR3
|
---|
| 141 | ; If type unchanged, or neither old/new are EDI Lockbox, no chk needed
|
---|
| 142 | ; If old type is EDI Lockbox and scratch pad exists, no change allowed
|
---|
| 143 | ; If changed to EDI Lockbox and detail already exists, no chg allowed
|
---|
| 144 | ; If changed to EDI Lockbox, ask for related EFT
|
---|
| 145 | N Z,Z0,RCSTRT,RCLST,RCDR,RCOE,RCNE,RCNO,RCM,RCM1,RCM2,RCM3,RCO4,RCN4,RCP,DIPA
|
---|
| 146 | S (RCDR1,RCDR2,RCDR3)=""
|
---|
| 147 | ;
|
---|
| 148 | 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
|
---|
| 149 | ;
|
---|
| 150 | S Z=$L(DR,".04;"),RCSTRT=1,RCLST=Z
|
---|
| 151 | I Z>2 D ; Find .04, not n.04
|
---|
| 152 | . F S Z0=$P(DR,".04;",RCSTRT) Q:Z0=""!'$E(Z0,$L(Z0)) S RCSTRT=RCSTRT+1
|
---|
| 153 | ;
|
---|
| 154 | ; If unchanged/changed from/to other than EDI Lockbox, jump over edits
|
---|
| 155 | S RCDR1="S RCP="_RCP_" D SETV^RCDPURE1;"_$P(DR,".04;",1,RCSTRT)
|
---|
| 156 | S RCDR2="@"_RCP_";.04;S RCNO=0,RCN4=X D TYP^RCDPUREC(.Y);.17////^S X=RCNE;S Y=""@"_(RCP+2)_""""
|
---|
| 157 | ; Reset field .04 and .17 if not a valid type change
|
---|
| 158 | S RCDR2=RCDR2_";@"_(RCP+1)_";.04////^S X=RCO4;I RCOE="""" S Y=""@"_(RCP+3)_""";.17////^S X=RCOE;@"_(RCP+3)_";W !,*7,$S(RCO4=14:$S('RCNO:RCM1,1:RCM2),1:RCM) S Y=""@"_RCP_""";@"_(RCP+2)
|
---|
| 159 | S RCDR3=$P(DR,".04;",RCSTRT+1,RCLST)
|
---|
| 160 | Q
|
---|
| 161 | ;
|
---|
| 162 | SETV ; Set up variables needed to edit change of receipt type
|
---|
| 163 | S DIPA("RCPT")=$G(^RCY(344,DA,0)),RCO4=$P(DIPA("RCPT"),U,4),RCOE=$P(DIPA("RCPT"),U,17)
|
---|
| 164 | S RCM="EDI Lockbox payment type is invalid for this receipt",RCM1="Payment type can't be changed once detail has been loaded from the ERA",RCM2="Must have an EFT for an EFT Lockbox payment type"
|
---|
| 165 | S RCM3=">>If receipt is for an ERA and a paper check, select the ERA now"
|
---|
| 166 | Q
|
---|
| 167 | ;
|
---|
| 168 | WL(DA) ; Function returns 0 if the worklist did not create the receipt
|
---|
| 169 | ; or the ien of the worklist entry if it did (344.4 and 344.49 are DINUMED)
|
---|
| 170 | N Z
|
---|
| 171 | S Z=+$O(^RCY(344.4,"AREC",DA,0))
|
---|
| 172 | Q Z
|
---|
| 173 | ;
|
---|
| 174 | HAC(RC) ; Returns 1 if the receipt in RC is related to a HAC EFT
|
---|
| 175 | N Z,HAC
|
---|
| 176 | S HAC=0
|
---|
| 177 | ; ERA related to an EFT detail record
|
---|
| 178 | S Z=+$G(^RCY(344.31,+$P($G(^RCY(344,RC,0)),U,17),0))
|
---|
| 179 | ; Deposit # in EFT transmission starts with HAC
|
---|
| 180 | I Z S Z=$P($G(^RCY(344.3,+Z,0)),U,6) I $E(Z,1,3)="HAC" S HAC=1
|
---|
| 181 | Q HAC
|
---|
| 182 | ;
|
---|