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

RCDPESR4.m

Go to the documentation of this file.
  1. RCDPESR4 ;ALB/TMK/PJH - Server interface 835ERA processing ;Jun 06, 2014@19:11:19
  1. ;;4.5;Accounts Receivable;**173,216,208,230,269,271,298,321,424**;Mar 20, 1995;Build 11
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ;Reference to $$VALECME^BPSUTIL2 supported by IA# 6139
  1. ;
  1. ERAEOBIN(RCTXN,RCD,RCGBL,RCEFLG) ; Store/process 835ERA or 835XFR
  1. ; transaction coming into the site
  1. ; RCTXN = data on the hdr record of the msg text
  1. ; RCD = array with formatted hdr data
  1. ; RCGBL = name of the array or global where the msg is stored
  1. ; RCEFLG = error flag returned if passed by REF
  1. ;
  1. N RCLAST,RCBILL,RCTDA,RCMSG,RCERR
  1. S (RCTDA,RCEFLG)=0
  1. ;
  1. ;
  1. F L +^RCY(344.5,"AMSEQ",+$P(RCTXN,U,13)):30 Q:$T
  1. S RCMSG=$$EXTERA(RCTXN,.RCLAST,.RCBILL) ; Extract from mail msg
  1. ;
  1. ; If full msg received (99^$ record exists), file it
  1. I 'RCLAST,'$G(RCERR) D ;No $ as last character of msg
  1. . S RCERR=2
  1. ;
  1. I RCLAST S RCTDA=+$$ADD(RCGBL,RCD("MSG#"),RCMSG,.RCBILL,.RCERR,.RCD)
  1. ;
  1. I $G(RCERR)>0 D
  1. . D ERRUPD^RCDPESR1(RCGBL,.RCD,$P(RCTXN,U),.RCERR)
  1. . I RCTDA D ; Store exception msgs in file 344.5
  1. .. N A,C,Z
  1. .. S C=1,A(1)="Date: "_$$FMTE^XLFDT($$NOW^XLFDT(),2)
  1. .. I $G(^TMP("RCERR",$J,"TEXT"))'="" S C=C+1,A(C)=^TMP("RCERR",$J,"TEXT"),C=C+1,A(C)=" "
  1. .. S Z=0 F S Z=$O(^TMP("RCERR",$J,"MSG",Z)) Q:'Z S C=C+1,A(C)=^(Z)
  1. .. I $O(A(0)) D WP^DIE(344.5,RCTDA_",",5,"A","A")
  1. . S RCEFLG=1
  1. ;
  1. L -^RCY(344.5,"AMSEQ",+$P(RCTXN,U,13))
  1. I $P(RCTXN,U)'["XFR",$P(RCTXN,U,12)'="" D TAXERR^RCDPESR1("ERA",$P(RCTXN,U,6)_" Payer ID: "_$P(RCTXN,U,7),$P(RCTXN,U,11),$P(RCTXN,U,12)) ; Send bad tax id bulletin
  1. ;
  1. Q
  1. ;
  1. EXTERA(RCTXN,RCLAST,RCBILL) ;Extract 835ERA or 835XFR transaction
  1. ;INPUT:
  1. ; RCTXN = data on 835ERA/835XFR hdr record
  1. ; RCLAST = passed by REF and returned=1 if entire record exists
  1. ;
  1. ;OUTPUT:
  1. ; ^TMP("RCMSG",$J,1,"D",line #)=formatted hdr data
  1. ; ^TMP("RCMSG",$J,2,"D",line #)=raw msg data
  1. ; if passed by ref, RCLAST = 1 if '99' record found
  1. ; if passed by ref, RCBILL(AR bill number) is returned
  1. ; with a 'list' of bills included in the ERA. If an
  1. ; entry = 1, 3rd party bill was found in file 430.
  1. ; If the entry = 2, the 3rd party bill found was not active
  1. ; Function returns existing ien in file 344.5 for multi part ERAs
  1. ;
  1. ;N CT,CT1,LINE,HCT,RCH,RCMSG,RCREFORM,RCINS,RCSTAT,B,RCSD,C5
  1. N B,C5,CT,CT1,HCT,LINE,RCH,RCINS,RCMSG,RCREFORM,RCSD,RCSRV,RCSTAT ;PRCA*4.5*424 removed RCSTART added RCSRV
  1. S (HCT,RCH)=0
  1. ;
  1. ;
  1. ; Check if sequence control # already exists or if a new record needed
  1. S RCMSG=+$O(^RCY(344.5,"AMSEQ",+$P(RCTXN,U,13),0))
  1. S CT=0
  1. I 'RCMSG D ; Build display data for the first sequence only
  1. . S HCT=HCT+1 S LINE(HCT)="Payer Name: "_$P(RCTXN,U,6)
  1. . S HCT=HCT+1 S LINE(HCT)="Payer ID: "_$P(RCTXN,U,7)
  1. . S HCT=HCT+1,LINE(HCT)="Trace #: "_$P(RCTXN,U,8)
  1. . S HCT=HCT+1,LINE(HCT)="Date Paid: "_$$FDT^RCDPESR9($P(RCTXN,U,9))_" Total Amt Paid: "_$J($P(RCTXN,U,10)/100,0,2)
  1. . I $P(RCTXN,U)["XFR",$P(RCTXN,U,19)'="" S HCT=HCT+1,LINE(HCT)="Contact Info: "_$P(RCTXN,U,19)
  1. . M ^TMP("RCMSG",$J,1,"D")=LINE
  1. . S CT=CT+1,^TMP("RCMSG",$J,2,"D",CT)=RCTXN
  1. ;
  1. S CT1=CT
  1. S ^TMP("RCMSG",$J,0)=RCTXN
  1. ;
  1. S RCSD=$NA(^TMP($J,"RCSRVDT")) K @RCSD ;service dates
  1. S C5=0
  1. S RCLAST=0,RCSRV=0 ; PRCA*4.5*321
  1. F X XMREC Q:XMER<0 D Q:RCLAST
  1. . Q:XMRG=""
  1. . I +XMRG=99,$P(XMRG,U,2)="$" S RCLAST=1 Q
  1. . S CT=CT+1
  1. . ;Statement Start Date - 05 Record is mandatory
  1. . I +XMRG=5,$P(XMRG,U,2)'="" D ;
  1. . . S C5=CT
  1. . . S @RCSD@(C5)=+$P(XMRG,U,9) ; PRCA*4.5*424
  1. . . S RCSRV=0
  1. . ; save the service date for possible ECME# look up
  1. . ;PRCA*4.5*321 BEGIN
  1. . I +XMRG=40,$$VALECME^BPSUTIL2($P(XMRG,U,2)),C5,'RCSRV D
  1. . . I $P(XMRG,U,19) S @RCSD@(C5)=+$P(XMRG,U,19),RCSRV=1
  1. . S ^TMP("RCMSG",$J,2,"D",CT)=XMRG
  1. ;
  1. ; reformat bill# if needed
  1. S RCREFORM=""
  1. S CT=CT1
  1. F S CT=$O(^TMP("RCMSG",$J,2,"D",CT)) Q:'CT S XMRG=$G(^(CT)) D
  1. . Q:XMRG=""
  1. . I +XMRG=5,$P(XMRG,U,2)'="" D
  1. .. S RCREFORM="",RCSTAT=1
  1. .. ; Check if bill is in AR & is a 3rd party bill
  1. .. S RCBILL=$$BILL^RCDPESR1($P(XMRG,U,2),$G(@RCSD@(CT)),.RCINS) ; look up claim ien by claim# or ECME#
  1. .. I '$G(RCINS)!(RCBILL<0) S (RCBILL,RCSTAT)=0
  1. .. I RCBILL S B=$P($G(^PRCA(430,RCBILL,0)),U) I B'=$P(XMRG,U,2) S $P(XMRG,U,2)=B,RCREFORM=B
  1. .. I RCBILL,$P(^PRCA(430.3,+$P($G(^PRCA(430,+RCBILL,0)),U,8),0),U,3)'=102 S RCSTAT=2
  1. .. S RCBILL($P(XMRG,U,2))=RCSTAT
  1. . I RCREFORM'="",+XMRG>5 S $P(XMRG,U,2)=RCREFORM,^TMP("RCMSG",$J,2,"D",CT)=XMRG
  1. ;
  1. K @RCSD
  1. Q RCMSG
  1. ;
  1. ADD(RCGBL,RCDMSG,RCMSG,RCBILL,RCERR,RCD) ; Add msg(s) in @RCGBL to
  1. ; file 344.5
  1. ; RCGBL = name of the global used to store the msg data
  1. ; RCDMSG = Mailman msg number the ERA arrived in.
  1. ; RCMSG = ien of the existing entry in file 344.5 for multipart ERAs
  1. ; RCBILL(AR bill number) = list of bills included, pass by REF
  1. ; RCD = array with formatted hdr data
  1. ;
  1. ; Errors returned in RCERR and RCERR(n)
  1. ; Function returns entry # of msg added or "" if none added
  1. ;
  1. ;
  1. N RCHDR,RCTYP,RCIEN
  1. S RCHDR=$G(^TMP("RCMSGH",$J,0))
  1. S RCTYP=$P(RCHDR,U)
  1. S RCIEN=$S($G(RCMSG):RCMSG,1:$$ADDTXN(RCHDR,RCDMSG)) ;File msg hdr
  1. I RCIEN'>0 S RCERR=3 ;msg hdr can't be filed
  1. I '$G(RCERR) D LOADDET(RCIEN,RCGBL,RCHDR,.RCBILL,.RCD,.RCERR)
  1. I '$G(RCERR),'$O(RCERR(0)),RCTYP["835ERA",'$P($G(^RCY(344.5,RCIEN,0)),U,8) D TASKERA^RCDPESR2(RCIEN) ;Task to upd VistA for complete 835ERA only
  1. ;
  1. Q $S($G(RCIEN)>0&'$G(RCERR):RCIEN,1:"")
  1. ;
  1. ADDTXN(RCDATA,RCDMSG) ; Add a trxn for msg in RCDATA to file 344.5
  1. ; RCDATA = data on the msg hdr record
  1. ; RCDMSG = Mailman msg number the ERA arrived in
  1. ;Function returns ien of the new entry in file 344.5 or "" if an error
  1. ;
  1. N A,RCY,DLAYGO,DIC,DD,DO,DA,X,Y,Z
  1. ;
  1. ;
  1. S (X,A)=RCDMSG ;Use msg ID as basis for the .01 field
  1. F Z=1:1 Q:'$D(^RCY(344.5,"B",A)) S A=X_"."_Z
  1. S X=A
  1. S DIC(0)="L",DIC="^RCY(344.5,",DLAYGO=344.5
  1. S DIC("DR")=".02////"_$E($P(RCDATA,U),1,6)_";.03///^S X=""NOW"";.04////0;.06////"_$S($P(RCDATA,U)'["XFR":1,1:0)_$S($P(RCDATA,U,13)'="":";.09////"_+$P(RCDATA,U,13)_";.08////1",1:"")_";.1////2;.11////"_RCDMSG
  1. I $P(RCDATA,U,6)'="" S DIC("DR")=DIC("DR")_";3.01////"_$P(RCDATA,U,6)
  1. D FILE^DICN K DO,DD,DLAYGO,DA,DIC
  1. S RCY=+Y
  1. ;
  1. ;
  1. Q $S(RCY>0:+RCY,1:"")
  1. ;
  1. LOADDET(RCTDA,RCGBL,RCHDR,RCBILL,RCD,RCERR) ; Load the rest of the text
  1. ; into the msg
  1. ; RCTDA = ien in file 344.5
  1. ; RCGBL = name of the array holding the detail msg text to be loaded
  1. ; RCHDR = data on ERA hdr record
  1. ; RCBILL(AR bill number) = list of bills included, pass by REF
  1. ; RCD = array with formatted hdr data
  1. ;
  1. ; OUTPUT: RCERR if any errors found, pass by REF
  1. ;
  1. ;
  1. N RCE,RCDATA,RCMSG,RCFROM,Z,Z0
  1. K ^TMP("RCTEXT",$J),^TMP("RCRAW",$J)
  1. M ^TMP("RCTEXT",$J)=@RCGBL@(1,"D")
  1. M ^TMP("RCRAW",$J)=@RCGBL@(2,"D")
  1. ;
  1. S RCDATA=$G(^RCY(344.5,RCTDA,0)),RCMSG=$G(RCD("MSG#")),RCFROM=$G(RCD("FROM"))
  1. ;
  1. ; For multi-part ERA, don't update if sequence already filed
  1. ; Add seq # if not already there
  1. I $P(RCHDR,U)'["XFR",$P(RCHDR,U,13) Q:$D(^RCY(344.5,RCTDA,"S","B",+$P(RCHDR,U,14)))
  1. ;
  1. D STOREM(+$G(RCTDA),"^TMP(""RCTEXT"",$J)","^TMP(""RCRAW"",$J)",.RCE)
  1. ;
  1. I $D(RCE("DIERR")) D ; Extract error
  1. . N DIE,DA,DR,X,Y
  1. . D EXTERR^RCDPESR1(.RCERR,.RCE)
  1. . S:$L($G(RCE)) RCERR(+$O(RCERR(""),-1)+1)=RCE
  1. . I $D(^RCY(344.5,RCTDA,0)) S DIE="^RCY(344.5,",DR=".1////4",DA=RCTDA D ^DIE
  1. E D ; No error - store rest of data
  1. . N Z,RCT,RCCT,RCX,RCB ; Add bills included in ERA
  1. . S RCT=0,RCCT=0,RCX=$J("",4)
  1. . S Z="" F S Z=$O(RCBILL(Z)) Q:Z="" D
  1. .. N DO,DD,DIC,DLAYGO,X,Y
  1. .. S:RCT=4 RCCT=RCCT+1,RCB(RCCT)=RCX,RCT=0,RCX=$J("",4) S RCX=RCX_$E($S(+RCBILL(Z):"",1:"*")_Z_$J("",15),1,15),RCT=RCT+1
  1. .. S DIC(0)="L",DIC("DR")=".02////"_$S($G(RCBILL(Z)):1,1:0),X=Z,DA(1)=RCTDA,DIC="^RCY(344.5,"_DA(1)_",""B"",",DLAYGO=344.54 D FILE^DICN K DO,DD,DLAYGO,DIC
  1. .. ;
  1. . I $L(RCX)>4 S RCCT=RCCT+1,RCB(RCCT)=RCX
  1. . ; Add list of bills to display data
  1. . I $O(RCB(0)) D WP^DIE(344.5,RCTDA_",",1,"A","RCB")
  1. . ; Add seq #
  1. . S DA(1)=RCTDA,DIC="^RCY(344.5,"_DA(1)_",""S"",",DIC(0)="L",X=$P(RCHDR,U,14),DIC("DR")=".02////"_$S($P(RCHDR,U,15)="Y":1,1:0)_";.03///^S X=""NOW"";.04////"_RCMSG,X=+$P(RCHDR,U,14),DLAYGO=344.53
  1. . D FILE^DICN K DO,DD,DLAYGO,DIC
  1. . ;
  1. . I $P(RCHDR,U)["835XFR" D XFR^RCDPESR5(RCTDA,RCFROM,RCMSG,.RCD) Q
  1. . ;
  1. . ; Proceed only if not a transfer record
  1. . I $P(RCDATA,U,9)'="" D ; Determine if all sequences received yet
  1. .. N RCOK,RCLAST
  1. .. S RCOK=1,RCLAST=0
  1. .. F Z=1:1 Q:'RCOK!RCLAST D
  1. ... I 'RCLAST,'$D(^RCY(344.5,RCTDA,"S","B",Z)) S RCOK=0 Q
  1. ... S Z0=+$O(^RCY(344.5,RCTDA,"S","B",Z,0)),Z0=$G(^RCY(344.5,RCTDA,"S",Z0,0))
  1. ... I Z0="" S RCOK=0 Q
  1. ... I $P(Z0,U,2) S RCLAST=1 ; Last sequence received and all before it
  1. .. ;
  1. .. I RCOK D
  1. ... N DA,DIE,DR,X,Y
  1. ... S DA=RCTDA,DR=".08////0;.1///@",DIE="^RCY(344.5," D ^DIE
  1. ... I '$O(^RCY(344.5,RCTDA,"B","AV",1,0)) D ; No valid bills found
  1. ....;-----
  1. ....; PRCA*4.5*298 - MailMan message disabled, logic retained - 14 Feb 2014
  1. ....;N RCE
  1. ....;S RCE(1)="No valid bills for this site were found in this ERA"
  1. ....;S RCE(2)="Review/correct the bill #'s on this ERA in your transmission exceptions"
  1. ....;S RCE(3)="Please contact the Implementation Manager group to report this situation",RCE(4)=" "
  1. ....;D BULLERA^RCDPESR0("D"_$S($O(^RCY(344.5,RCTDA,2,0)):"F",1:""),RCTDA,$G(RCD("MSG#")),"EDI LBOX - NO VALID BILLS ON ERA "_$E($G(RCD("PAYFROM")),1,20),.RCE,0)
  1. ....;-----
  1. .... S DA=RCTDA,DR=".08////1;.1////6",DIE="^RCY(344.5," D ^DIE
  1. ;
  1. ;
  1. K ^TMP("RCTEXT",$J),^TMP("RCRAW",$J)
  1. Q
  1. ;
  1. STOREM(RCTDA,RCDISP,RCTEXT,RCE) ;Store msg text in file 344.5
  1. ;INPUT:
  1. ; RCTDA = ien of the entry in file 344.5
  1. ; RCDISP = name of the array where display msg text is retrieved from
  1. ; or "@" to delete the text from the display text field
  1. ; RCTEXT = name of the array where raw msg text is retrieved from
  1. ; or "@" to delete the text from the raw msg field
  1. ;OUTPUT:
  1. ; RCE = array of errors (RCE("DIERR")) returned, pass by REF
  1. ;
  1. N RCZ,X,Y,DIE
  1. K RCE("DIERR")
  1. ;
  1. I $S($G(RCDISP)="@":1,1:$D(@RCDISP)'<10) D
  1. . F RCZ=1:1:20 D WP^DIE(344.5,RCTDA_",",1,"AK",""_RCDISP_"","RCE") Q:$S('$D(RCE("DIERR")):1,+RCE("DIERR")=1:$G(RCE("DIERR",1))'=110,1:1) K:RCZ<20 RCE("DIERR") ; On lock error, retry up to 20 times
  1. ;
  1. I '$O(RCE("DIERR",0)),$S($G(RCTEXT)="@":1,1:$D(@RCTEXT)'<10) D
  1. . F RCZ=1:1:20 D WP^DIE(344.5,RCTDA_",",2,"AK",""_RCTEXT_"","RCE") Q:$S('$D(RCE("DIERR")):1,+RCE("DIERR")=1:$G(RCE("DIERR",1))'=110,1:1) K:RCZ<20 RCE("DIERR") ; On lock error, retry up to 20 times
  1. Q