| 1 | RCDPEM0 ;ALB/TMK - ERA MATCHING TO EFT (cont) ;05-NOV-02 | 
|---|
| 2 | ;;4.5;Accounts Receivable;**173,208,220**;Mar 20, 1995 | 
|---|
| 3 | ;;Per VHA Directive 10-93-142, this routine should not be modified. | 
|---|
| 4 | Q | 
|---|
| 5 | ; | 
|---|
| 6 | MATCH(RCZ,RCPROC) ; Match EFT to ERA | 
|---|
| 7 | ; RCZ = ien of file 344.31 | 
|---|
| 8 | ; RCPROC = 1 if called from EFT-EOB automatch, 0 if from manual match | 
|---|
| 9 | N RCER,RCRZ,RCMATCH,RCER,RC0,RC3444,RC34431,DIE,DA,DR,X,Y,Z,Z0 | 
|---|
| 10 | ; Find ERA to match to EFT by trace, date, amt | 
|---|
| 11 | S RC34431=$G(^RCY(344.31,RCZ,0)) Q:$P(RC34431,U,8)!$O(^RCY(344,"AEFT",RCZ,0))  ; Already matched | 
|---|
| 12 | S RCRZ=0 F  S RCRZ=$O(^RCY(344.4,"ATRID",$P(RC34431,U,4),$P(RC34431,U,3),RCRZ)) Q:'RCRZ  S RC3444=$G(^RCY(344.4,RCRZ,0)) I '$O(^RCY(344.31,"AERA",RCRZ,0)),'$P(RC3444,U,9) D  Q:$D(Z(1)) | 
|---|
| 13 | . S Z($S(+$P(RC34431,U,7)=+$P(RC3444,U,5):1,1:-1),RCRZ)="" ;Total match? | 
|---|
| 14 | ; | 
|---|
| 15 | S RCMATCH=+$O(Z(""),-1),RCRZ=+$O(Z(RCMATCH,0)) | 
|---|
| 16 | S $P(^TMP($J,"RCDPETOT",344.31,RCZ),U)=RCMATCH | 
|---|
| 17 | ; | 
|---|
| 18 | I 'RCMATCH D  Q  ; Match failure | 
|---|
| 19 | . S ^TMP($J,"RCTOT","NO_MATCH")=$G(^TMP($J,"RCTOT","NO_MATCH"))+1 | 
|---|
| 20 | ; | 
|---|
| 21 | I RCMATCH<0 D | 
|---|
| 22 | . ; Bulletin for totals don't match warning | 
|---|
| 23 | . S ^TMP($J,"RCTOT","TOTMIS")=$G(^TMP($J,"RCTOT","TOTMIS"))+1 | 
|---|
| 24 | . N XMSUBJ,XMBODY,XMB,XMINSTR,XMTYPE,XMFULL,XMTO,XMZ,XMERR,RCER,RCT,RCM,RCLESS | 
|---|
| 25 | . S RCT=0 | 
|---|
| 26 | . D BLD^RCDPEM1("RCER",.RCT,344.31,RC34431) | 
|---|
| 27 | . S RCT=RCT+1,RCER(RCT)="" | 
|---|
| 28 | . K RCM S RCM=RCT | 
|---|
| 29 | . S RCLESS=($P(RC34431,U,7)<$P($G(^RCY(344.4,RCRZ,0)),U,5)) | 
|---|
| 30 | . S RCT=RCT+1,RCER(RCT)="  TOTALS ON ERA AND EFT DON'T MATCH.",RCT=RCT+1,RCER(RCT)="  EFT TOTAL IS "_$S(RCLESS:"LESS",1:"GREATER")_" THAN ERA AMOUNT TOTAL" | 
|---|
| 31 | . I RCLESS D | 
|---|
| 32 | .. S RCT=RCT+1,RCER(RCT)="  DECREASE ADJUSTMENT IS NEEDED BEFORE THE ERA RECEIPT CAN BE PROCESSED." | 
|---|
| 33 | . I 'RCLESS D | 
|---|
| 34 | .. S RCT=RCT+1,RCER(RCT)="  A SUSPENSE LINE IS NEEDED ON THE RECEIPT TO ACCOUNT FOR THE DIFFERENCE." | 
|---|
| 35 | . S RCT=RCT+1,RCER(RCT)="  IF YOU USE THE ERA WORKLIST SCRATCH PAD, THIS WILL BE GENERATED FOR YOU." | 
|---|
| 36 | . ; | 
|---|
| 37 | . S RCT=RCT+1,RCER(RCT)="  EFT WAS MATCHED TO ERA ENTRY #: "_RCRZ_" ($"_$J(+$P($G(^RCY(344.4,RCRZ,0)),U,5),"",2)_")." | 
|---|
| 38 | . S XMTO("I:G.RCDPE PAYMENTS")="" | 
|---|
| 39 | . S XMBODY="RCER" | 
|---|
| 40 | . S XMSUBJ="EDI LBOX TOTALS MISMATCH ON EFT-ERA MATCH" | 
|---|
| 41 | . D | 
|---|
| 42 | .. N DUZ S DUZ=.5,DUZ(0)="@" | 
|---|
| 43 | .. D SENDMSG^XMXAPI(.5,XMSUBJ,XMBODY,.XMTO,,.XMZ) | 
|---|
| 44 | . ; Update log | 
|---|
| 45 | . F  S RCM=$O(RCER(RCM)) Q:'RCM  S RCT=RCT+1,RCM(RCT)=RCER(RCM) | 
|---|
| 46 | . D STORERR(344.31,RCZ,.RCM) | 
|---|
| 47 | ; | 
|---|
| 48 | I RCMATCH D | 
|---|
| 49 | . S DIE="^RCY(344.31,",DA=RCZ,DR=".08////"_RCMATCH_";.1////"_RCRZ D ^DIE | 
|---|
| 50 | . S DIE="^RCY(344.4,",DA=RCRZ,DR=".09////"_RCMATCH D ^DIE | 
|---|
| 51 | . S ^TMP($J,"RCTOT","MATCH")=$G(^TMP($J,"RCTOT","MATCH"))+1 | 
|---|
| 52 | ; | 
|---|
| 53 | Q | 
|---|
| 54 | ; | 
|---|
| 55 | ADDDEP(RCD,RCDDT,RCZ) ; Add deposit | 
|---|
| 56 | ; RCD = deposit # | 
|---|
| 57 | ; RCDDT = deposit date FM format | 
|---|
| 58 | ; RCZ = ien of entry in file 344.3 | 
|---|
| 59 | ; Function returns IEN of new deposit entry | 
|---|
| 60 | ; | 
|---|
| 61 | N RCDEP,RC0,DIE,DR,DA,X,Y | 
|---|
| 62 | S RCDEP=+$$ADDDEPT^RCDPUDEP(RCD,RCDDT) | 
|---|
| 63 | I RCDEP D | 
|---|
| 64 | . D LOCKDEP^RCDPEM(RCDEP,1) | 
|---|
| 65 | . S RC0=$G(^RCY(344.3,RCZ,0)) | 
|---|
| 66 | . S DIE="^RCY(344.1,",DA=RCDEP,DR=".04////"_+$P(RC0,U,8)_$S($P(RC0,U,4)'="":";.05////"_$P(RC0,U,4),1:"")  D ^DIE | 
|---|
| 67 | . S DIE="^RCY(344.3,",DR=".03////"_RCDEP,DA=RCZ D ^DIE | 
|---|
| 68 | . S $P(^TMP($J,"RCDPETOT",344.3,RCZ),U,5)=RCDEP | 
|---|
| 69 | Q RCDEP | 
|---|
| 70 | ; | 
|---|
| 71 | ADDREC(RCDEP,RCZ) ; Add receipt, send CR to FUND 528704, Rev src cd 8NZZ | 
|---|
| 72 | ;   for total EFT amt | 
|---|
| 73 | ; RCDEP = ien of the deposit file entry | 
|---|
| 74 | ; RCZ = ien in file 344.3 | 
|---|
| 75 | ; Function returns IEN of new receipt entry | 
|---|
| 76 | ; | 
|---|
| 77 | N RCER,RCTRANDA,RECTDA,RCQUIT,RCDPDATA,RCTOTCT,RC0,DIE,DA,DR,X,Y | 
|---|
| 78 | S RC0=$G(^RCY(344.3,RCZ,0)) | 
|---|
| 79 | S $P(^TMP($J,"RCDPETOT",344.3,RCZ),U,3)=0 | 
|---|
| 80 | ; Single receipt - multiple transactions for EFT payments | 
|---|
| 81 | S RECTDA=+$$ADDRECT^RCDPUREC($P(RC0,U,7),RCDEP,+$O(^RC(341.1,"AC",14,0))) | 
|---|
| 82 | ; Create detail lines for deposit amount, process whole receipt to send | 
|---|
| 83 | ;   CR document for deposit amount | 
|---|
| 84 | I RECTDA D | 
|---|
| 85 | . N STATUS,RC00,RCT | 
|---|
| 86 | . S $P(^TMP($J,"RCDPETOT",344.3,RCZ),U)=RECTDA,^TMP($J,"RCTOT","EFT_RECPT")=$G(^TMP($J,"RCTOT","EFT_RECPT"))+1 | 
|---|
| 87 | . L +^RCY(344,RECTDA) | 
|---|
| 88 | . ;  check to see if receipt has been processed (fms document) | 
|---|
| 89 | . D DIQ344^RCDPRPLM(RECTDA,"200;") | 
|---|
| 90 | . ;  code sheet already sent once, this is a retransmission, check it | 
|---|
| 91 | . I RCDPDATA(344,RECTDA,200,"E")'="" S RCQUIT=0 D  Q:RCQUIT | 
|---|
| 92 | .. S STATUS=$$STATUS^GECSSGET(RCDPDATA(344,RECTDA,200,"E")) | 
|---|
| 93 | .. ;  okay to continue if status is Error, Rejected, or not defined (-1) | 
|---|
| 94 | .. I $E(STATUS)="E"!($E(STATUS)="R")!(STATUS=-1) Q | 
|---|
| 95 | .. S RCER(1)=$$SETERR(2),RCER(2)="  Receipt already sent to FMS - No change" | 
|---|
| 96 | .. D BULL^RCDPEM1(344.3,RC0,.RCER) | 
|---|
| 97 | .. S $P(^TMP($J,"RCDPETOT",344.3,RCZ),U,4)=+$G(^TMP($J,"RCXM",0)) | 
|---|
| 98 | .. D STORERR(344.3,RCZ,.RCER) | 
|---|
| 99 | .. L -^RCY(344,RECTDA) | 
|---|
| 100 | .. L -^RCY(344.1,RCDEP) | 
|---|
| 101 | .. S RCQUIT=1 K RCER | 
|---|
| 102 | . ;  mark receipt as processed (closed) to prevent editing | 
|---|
| 103 | . D MARKPROC^RCDPUREC(RECTDA,"") | 
|---|
| 104 | . S DIE="^RCY(344,",DR=".04////"_+$O(^RC(341.1,"AC",14,0)),DA=RECTDA D ^DIE ; Add EDI Lockbox payment type | 
|---|
| 105 | . ; | 
|---|
| 106 | . ; Add receipt line for each payer's EFT | 
|---|
| 107 | . S RCT=0 F  S RCT=$O(^RCY(344.31,"B",RCZ,RCT)) Q:'RCT  D  Q:$O(RCER(0)) | 
|---|
| 108 | .. S RC00=$G(^RCY(344.31,RCT,0)),DR="" | 
|---|
| 109 | .. S RCTRANDA=$S('$P(RC00,U,14):$$ADDTRAN^RCDPURET(RECTDA),1:$P(RC00,U,14)) ; detail line | 
|---|
| 110 | .. I 'RCTRANDA D  Q | 
|---|
| 111 | ... S RCER(1)=$$SETERR(2),RCER(2)="  The receipt for the EFT deposit was not created correctly",RCER(3)="  You may have to add the detail manually to send the FMS CR doc to revenue" | 
|---|
| 112 | ... S RCER(4)="  source code 8NZZ in fund "_$S(DT<$$ADDPTEDT^PRCAACC():"5287.4",1:"528704")_".  Receipt # is "_$P($G(^RCY(344,RECTDA,0)),U),RCER(5)="  Trace # being processed at time of error was: "_$P(RC00,U,4)_"." | 
|---|
| 113 | ... D BULL^RCDPEM1(344.3,RC0,.RCER) | 
|---|
| 114 | ... S $P(^TMP($J,"RCDPETOT",344.3,RCZ),U,4)=+$G(^TMP($J,"RCXM",0)) | 
|---|
| 115 | ... D STORERR(344.3,RCZ,.RCER) | 
|---|
| 116 | .. ; | 
|---|
| 117 | .. S DR=DR_";1.02////Auto added EDI Lockbox deposit;.06////"_$P(RC00,U,12)_";.04////"_$J(+$P(RC00,U,7),"",2)_";.14////"_RCTRANDA | 
|---|
| 118 | .. N N S N=+$O(^VA(200,"B","EDILOCKBOX,AUTOMATIC",0)) S:N=0 N=.5 | 
|---|
| 119 | .. S DR=DR_";.12////"_N | 
|---|
| 120 | .. S DA(1)=RECTDA,DA=RCTRANDA,DIE="^RCY(344,"_DA(1)_",1," | 
|---|
| 121 | .. S:$E(DR)=";" DR=$P(DR,";",2,999) D ^DIE | 
|---|
| 122 | .. S DR=".14////"_RCTRANDA_";.09////"_RECTDA,DIE="^RCY(344.31,",DA=RCT D ^DIE | 
|---|
| 123 | .. ; | 
|---|
| 124 | . ;Post to FUND 528704/RSC 8NZZ | 
|---|
| 125 | . D PROCESS^RCDPURE1(RECTDA,2) | 
|---|
| 126 | . ;Save details for status report | 
|---|
| 127 | . N Z,TOT | 
|---|
| 128 | . S (TOT,Z)=0 F  S Z=$O(^RCY(344,RECTDA,1,Z)) Q:'Z  S TOT=TOT+$P($G(^RCY(344,RECTDA,1,Z,0)),U,4) | 
|---|
| 129 | . S $P(^TMP($J,"RCDPETOT",344.3,RCZ),U,2)=TOT | 
|---|
| 130 | . ; | 
|---|
| 131 | . I $P($G(^RCY(344,RECTDA,2)),U)="" D  ; Receipt not processed fully | 
|---|
| 132 | .. N CT,Z | 
|---|
| 133 | .. S RCER(1)=$$SETERR(2),RCER(2)="  The receipt "_$P($G(^RCY(344,RECTDA,0)),U)_" for the EFT deposit was not processed fully" S:TOT RCER(3)="  You must manually process it to create the FMS CR doc to rev src code 8NZZ" | 
|---|
| 134 | .. S Z=0,CT=+$O(RCER(" "),-1) F  S Z=$O(^TMP($J,"RCDPEMSG",Z)) Q:'Z  S CT=CT+1,RCER(CT)=$G(^TMP($J,"RCDPEMSG",Z)) | 
|---|
| 135 | .. D BULL^RCDPEM1(344.3,RC0,.RCER) | 
|---|
| 136 | .. S $P(^TMP($J,"RCDPETOT",344.3,RCZ),U,4)=+$G(^TMP($J,"RCXM",0)) | 
|---|
| 137 | .. D STORERR(344.3,RCZ,.RCER) | 
|---|
| 138 | . ; | 
|---|
| 139 | . S DIE="^RCY(344.3,",DR=".11////^S X=DT;.12////"_$J(+TOT,"",2),DA=RCZ D ^DIE | 
|---|
| 140 | . S ^TMP($J,"RCTOT","SUSPAMT")=$G(^TMP($J,"RCTOT","SUSPAMT"))+TOT | 
|---|
| 141 | . S $P(^TMP($J,"RCDPETOT",344.3,RCZ),U,3)="1" | 
|---|
| 142 | ; | 
|---|
| 143 | I RECTDA L -^RCY(344,RECTDA) | 
|---|
| 144 | Q RECTDA | 
|---|
| 145 | ; | 
|---|
| 146 | SETERR(RCPROC) ; Set up first line of error message to be stored | 
|---|
| 147 | ; RCPROC = 1 if called from EFT-EOB automatch, 0 if from manual match | 
|---|
| 148 | ;        =2 if called from EFT deposit creation | 
|---|
| 149 | N LINE1 | 
|---|
| 150 | I RCPROC S LINE1=$$FMTE^XLFDT($$NOW^XLFDT(),2)_" - PROCESS TO "_$S(RCPROC=1:"CREATE RECEIPT FROM ERA",1:"SEND EFT DEPOSIT TO FMS") | 
|---|
| 151 | Q LINE1 | 
|---|
| 152 | ; | 
|---|
| 153 | STORERR(RCFILE,RCZ,RCER) ; Store error text in word processing field | 
|---|
| 154 | ; RCFILE = 344.3 or 344.31 | 
|---|
| 155 | ; RCZ = ien of the entry in file RCFILE | 
|---|
| 156 | ; RCER = array containing the error text (passed by ref) | 
|---|
| 157 | D WP^DIE(RCFILE,RCZ_",",2,"A","RCER") | 
|---|
| 158 | Q | 
|---|
| 159 | ; | 
|---|