RCDPEAA4 ;AITC/CJE - AUTO POST AWAITING RESOLUTION (APAR) - LIST OF UNPOSTED EEOBS ;Jun 06, 2014@19:11:19
;;4.5;Accounts Receivable;**321**;;Build 48;Build 99
;Per VA Directive 6402, this routine should not be modified.
Q
;
BLD(P1,P2,RCPROG) ;EP from RCDPEAA1
; Build,SORT and output the EEOB list to be displayed on APAR
; screen
; Input: P1 - "RCDPE_APAR_EEOB_PASS1"
; P2 - "RCDPE_APAR_EEOB_PASS2"
; RCPROG - "RCDPE-APAR_EEOB_WL"
; ^TMP($J,P1,ERAIEN) - Global array of all the ERA records that
; passed the filter criteria
; Output: ^TMP($J,P2,A1,A2) - B1^B2^B3^B4^B5^B6^B7^B8^B9
; See ERALINES for detail
; VALMCNT - Total number of lines in the listman body
N AMTPST,AUTOPDT,BALANCE,ERAIEN,I34441,I344491,IENS,OSEQ,RCDA1,RCDT,RCPT,RCSEQ,RCT,REASON
N TOTPOSTD,XX,YY
S (RCT,TOTPOSTD,BALANCE,VALMCNT)=0
S ERAIEN=0
;
; 2nd Pass get the data and sort the lines EEOB data lines to be displayed
F D Q:'ERAIEN
. S ERAIEN=$O(^TMP($J,P1,ERAIEN))
. Q:'ERAIEN
. S RCSEQ=0
. F D Q:'RCSEQ
. . S RCSEQ=$O(^RCY(344.49,ERAIEN,1,"B",RCSEQ))
. . Q:'RCSEQ
. . Q:RCSEQ#1'=0
. . S RCDA1=+$O(^RCY(344.49,ERAIEN,1,"B",RCSEQ,0))
. . Q:'RCDA1
. . S I344491=RCDA1_","_ERAIEN_"," ; IENS for subfile 344.491
. . S AMTPST=$$GET1^DIQ(344.491,I344491,.03,"I") ; Amount to post on Receipt
. . Q:+AMTPST=0 ; Ignore zero value lines
. . S OSEQ=$$GET1^DIQ(344.491,I344491,.09,"E") ; Original ERA sequence #s
. . S I34441=+OSEQ_","_ERAIEN_"," ; IENS for subfile 344.41
. . S RCPT=$$GET1^DIQ(344.41,I34441,.25,"I") ; Internal Receipt IEN (file 344)
. . S REASON=$$GET1^DIQ(344.41,I34441,5) ; External Auto-Post Reject Reason
. . ;
. . ; If we have a receipt, add the Amount to Post to the total posted amount
. . S:RCPT'="" TOTPOSTD=TOTPOSTD+AMTPST
. . ;
. . ; If we have don't have a receipt, calculate the unposted balance
. . I RCPT="" D
. . . S XX=$$GET1^DIQ(344.49,ERAIEN_",",.03,"I") ; Total Payment Received
. . . S BALANCE=XX-TOTPOSTD
. . ;
. . ; Only display EEOBs that do not have a receipt and aren't marked for auto-post
. . S YY=$$GET1^DIQ(344.41,I34441,6,"I") ; Mark for Auto-Post flag of the ERA detail ln
. . I RCPT="",'YY D
. . . S RCT=RCT+1
. . . S XX=$$GET1^DIQ(344.4,ERAIEN_",",.01,"I") ; ERA Number
. . . S $P(RCARRY(RCT),"^",1)=XX
. . . S $P(RCARRY(RCT),"^",2)=+OSEQ ; Original ERA Detail Sequence Numbers
. . . S XX=$$GET1^DIQ(344.491,I344491,.02,"E") ; Claim Number
. . . S $P(RCARRY(RCT),"^",3)=XX
. . . S $P(RCARRY(RCT),"^",4)=RCDA1 ; Internal IEN for subfile 344.491
. . . S $P(RCARRY(RCT),"^",5)=REASON ; Reason on APAR
. I $D(RCARRY) D
. . S RCDT=$$GET1^DIQ(344.4,ERAIEN_",",.07,"I") ; ERA File Date/Time for sort
. . S AUTOPDT=$$GET1^DIQ(344.4,ERAIEN_",",4.01,"I") ; Internal Auto-Post Date
. . S XX=$$GET1^DIQ(344.4,ERAIEN_",",.03,"I") ; Payer ID
. . S YY=$$GET1^DIQ(344.4,ERAIEN_",",.06,"I") ; Payer Name
. . D ERALINES(ERAIEN,.RCARRY,BALANCE,TOTPOSTD,AUTOPDT,RCDT,XX,YY,P2)
. . K RCARRY
. S (BALANCE,TOTPOSTD)=0 ; Reset posted and unposted balances
;
; Final Pass - build the display lines and load the listman template
D BOUT(P2,.VALMCNT)
Q
;
ERALINES(RCDA,RCARRY,BALANCE,TOTPOSTD,POSTDT,FILEDT,PAYID,PAYNM,P2) ; Build sorted list
; Input: RCDA - Top file ien for files 344.4 and 344.49
; RCARRY(CTR) - A1^A2^A3^A4 Where:
; A1 - ERA Number
; A2 - Original Sequence Numbers
; A3 - Claim Number
; A4 - Internal IEN for subfile 344.491
; A5 - Reason on APAR
; BALANCE - Amount that is left to be posted
; TOTPOSTD - Total amount posted thus far against the ERA
; POSTDT - Latest auto-posted date
; FILEDT - Date/Time the ERA was filed
; PAYID - Payer id
; PAYNM - Payer name
; P2 - "RCDPE_APAR_EEOB_PASS2"
; REASON - External Auto-Post Reject Reason
; Output: ^TMP($J,P2,A1,A2) = B1^B2^B3^B4^B5^B6^B7^B8^B9 Where:
; A1 - Uppercased value of the selected sort field
; A2 - Internal IEN of the ERA record
; B1 - Line Number
; B2 - ERA #.Sequence # (max 19 10+"."+8 characters)
; B3 - Claim # (max 15 characters)
; B4 - Posted Amount (max 15 characters)
; B5 - External Post Date (8 characters)
; B6 - Unposted Balance (max 15 characters)
; B7 - Payer Name/Payer ID (max 76 characters)
; B8 - Internal IEN for subfile 344.491
; B9 - Auto-Post Reject Reason
; B10 - Date ERA Filed
N A1,DLINE,RCT,REASON,X,XX
S RCT=""
F D Q:RCT=""
. S RCT=$O(RCARRY(RCT))
. Q:RCT=""
. S REASON=$P(RCARRY(RCT),"^",5)
. S A1=$$SORTP(BALANCE,TOTPOSTD,PAYNM,REASON,FILEDT) ; Get Sort Value
. I A1="" S A1=" " ; Set null sort value to space to avoid subscript error
. S DLINE=RCT ; Line Number
. S XX=$P(RCARRY(RCT),U,1)_"."_$P(RCARRY(RCT),U,2) ; ERA #.Sequence #
. S $P(DLINE,"^",2)=XX
. S $P(DLINE,"^",3)=$P(RCARRY(RCT),U,3) ; Claim #
. S $P(DLINE,"^",4)=TOTPOSTD ; Posted Amount
. S $P(DLINE,"^",5)=$$FMTE^XLFDT(POSTDT,"2ZD") ; External Post Date
. S $P(DLINE,"^",6)=BALANCE ; Unposted Balance
. S $P(DLINE,"^",7)=PAYNM_"/"_PAYID ; Payer Name/ID
. S $P(DLINE,"^",8)=$P(RCARRY(RCT),"^",4) ; Internal IEN for subfile 344.491
. S $P(DLINE,"^",9)=REASON ; Auto-Post Reject Reason
. S $P(DLINE,"^",10)=$$FMTE^XLFDT($P(FILEDT,".",1),"2ZD") ; External Date ERA Filed
. S ^TMP($J,P2,A1,RCDA,RCT)=DLINE
Q
;
BOUT(P2,VALMCNT) ; Build the display lines and load into the listman template
; Input: P2 - "RCDPE_APAR_EEOB_PASS2"
; ^TMP($J,P2,A1,A2) - B1^B2^B3^B4^B5^B6^B7^B8
; See ERALINES for detail
; Output: VALMCNT - Total # of body lines
; ^TMP("RCDPE-APAR_EEOB_WL",$J,VALMCNT,0) - Listman Body line
; ^TMP("RCDPE-APAR_EEOB_WL",$J,"IDX",VALMCNT,RCSEQ) - Line selection index
; ^TMP("RCDPE-APAR_EEOB_WLDX",$J,RCSEQ) - A1^A2^A3^...An Where
; A1 - Line selection #
; A2 - Internal IEN for 344.4
; A3 - Internal IEN for 344.491
; A4 - Unposted Balance
; A5 - Posted Amount
N A1,BALANCE,COUNT,DLINE,ERAIEN,RCT,TOTPOSTDX,XX
S A1="",COUNT=0
F D Q:A1=""
. S A1=$O(^TMP($J,P2,A1))
. Q:A1=""
. S ERAIEN=""
. F D Q:ERAIEN=""
. . S ERAIEN=$O(^TMP($J,P2,A1,ERAIEN))
. . Q:ERAIEN=""
. . S RCT=""
. . F D Q:RCT=""
. . . S RCT=$O(^TMP($J,P2,A1,ERAIEN,RCT))
. . . Q:RCT=""
. . . S XX=^TMP($J,P2,A1,ERAIEN,RCT)
. . . S COUNT=COUNT+1 ; Selection #
. . . S DLINE=$J(COUNT,3)
. . . S DLINE=DLINE_$J("",7)_$$LJ^XLFSTR($P(XX,"^",2),17) ; ERA #.Sequence #
. . . S DLINE=DLINE_$$LJ^XLFSTR($P(XX,"^",3),14) ; Claim #
. . . S TOTPOSTD=$P(XX,"^",4)
. . . S DLINE=DLINE_$J(TOTPOSTD,13,2)_" " ; Posted Amount
. . . ; S DLINE=DLINE_$P(XX,"^",5)_" " ; Posted Date
. . . S DLINE=DLINE_$P(XX,"^",10)_" " ; Date ERA filed
. . . S BALANCE=$P(XX,"^",6)
. . . S DLINE=DLINE_$J(BALANCE,13,2)_" " ; Unpaid Balance
. . . ; S DLINE=DLINE_$P(XX,"^",10) ; Date ERA filed
. . . S DLINE=DLINE_$P(XX,"^",5) ; Posted Date
. . . ;
. . . ; Line 1 of displayed EEOB item
. . . D SET(DLINE,COUNT,ERAIEN,$P(XX,"^",8),BALANCE,TOTPOSTD,.VALMCNT)
. . . ;
. . . ; Line 2 of displayed EEOB item: payer name/payer id
. . . S DLINE=$J("",5)_$$PAYTIN^RCDPRU2($P(XX,"^",7),75)
. . . D SET(DLINE,COUNT,ERAIEN,$P(XX,"^",8),BALANCE,TOTPOSTD,.VALMCNT)
. . . ;
. . . ; Line 3 of displayed EEOB item: Auto-Post Reject Reason
. . . S DLINE=$J("",5)_$P(XX,"^",9)
. . . D SET(DLINE,COUNT,ERAIEN,$P(XX,"^",8),BALANCE,TOTPOSTD,.VALMCNT)
Q
;
SORTP(BALANCE,TOTPOSTD,PAYNM,REASON,FILEDT) ; Get the value for the selected sort
; Input: BALANCE - Unpaid Balance
; TOTPOSTD - Posted Amount
; POSTDT - Internal Posted Datge
; PAYNM - Payer Name
; REASON - External Auto-Post Reject Reason
; FILEDT - Internal Date/Time the ERA was filed
; ^TMP("RCDPE_APAR_EEOB_PARAMS",$J,"SORT")- Selected sort (P/D/A/T)
; Returns: External value for the selected sort type
N VALUE,XX,YY
S XX=^TMP("RCDPE_APAR_EEOB_PARAMS",$J,"SORT")
S YY=$P(XX,"^",2),XX=$P(XX,"^",1)
S YY=$S(YY="H":-1,1:1)
I XX="N" Q $$UP^XLFSTR(PAYNM) ; Sort by Payer Name
I XX="R" Q $$UP^XLFSTR(REASON) ; Sort by Auto-post Reject Reason
I XX="D" Q FILEDT*YY ; Sort by Date/Time ERA filed
I XX="U" Q BALANCE*YY ; Sort by Unposted Balance
Q TOTPOSTD*YY ; Sort by Posted Amount
;
SET(DLINE,RCSEQ,ERAIEN,RCDA1,BALANCE,TOTPOSTD,VALMCNT) ; Set ListManager arrays
; Input: DLINE - Line to be displayed in the listman body
; RCSEQ - Line Selection number
; ERAIEN - Internal IEN for 344.4 or 344.49
; RCDA1 - Inernal IEN for subfile 344.491
; BALANCE - Unposted Balance
; TOTPOSTD - Posted Amount
; VALMCNT - Current listman body line count
; Output: VALMCNT - Updated listman body line count
; ^TMP("RCDPE-APAR_EEOB_WL",$J,VALMCNT,0) - Listman Body line
; ^TMP("RCDPE-APAR_EEOB_WL",$J,"IDX",VALMCNT,RCSEQ) - Line selection index
; ^TMP("RCDPE-APAR_EEOB_WLDX",$J,RCSEQ) - A1^A2^A3^...An Where
; A1 - Line selection #
; A2 - Internal IEN for 344.4
; A3 - Internal IEN for 344.491
; A4 - Unposted Balance
; A5 - Posted Amount
S VALMCNT=VALMCNT+1
S ^TMP("RCDPE-APAR_EEOB_WL",$J,VALMCNT,0)=DLINE
S ^TMP("RCDPE-APAR_EEOB_WL",$J,"IDX",VALMCNT,RCSEQ)=ERAIEN
S ^TMP("RCDPE-APAR_EEOB_WLDX",$J,RCSEQ)=VALMCNT_U_ERAIEN_U_RCDA1_U_$G(BALANCE)_U_$G(TOTPOSTD)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRCDPEAA4 9616 printed Oct 16, 2024@17:44:59 Page 2
RCDPEAA4 ;AITC/CJE - AUTO POST AWAITING RESOLUTION (APAR) - LIST OF UNPOSTED EEOBS ;Jun 06, 2014@19:11:19
+1 ;;4.5;Accounts Receivable;**321**;;Build 48;Build 99
+2 ;Per VA Directive 6402, this routine should not be modified.
+3 QUIT
+4 ;
BLD(P1,P2,RCPROG) ;EP from RCDPEAA1
+1 ; Build,SORT and output the EEOB list to be displayed on APAR
+2 ; screen
+3 ; Input: P1 - "RCDPE_APAR_EEOB_PASS1"
+4 ; P2 - "RCDPE_APAR_EEOB_PASS2"
+5 ; RCPROG - "RCDPE-APAR_EEOB_WL"
+6 ; ^TMP($J,P1,ERAIEN) - Global array of all the ERA records that
+7 ; passed the filter criteria
+8 ; Output: ^TMP($J,P2,A1,A2) - B1^B2^B3^B4^B5^B6^B7^B8^B9
+9 ; See ERALINES for detail
+10 ; VALMCNT - Total number of lines in the listman body
+11 NEW AMTPST,AUTOPDT,BALANCE,ERAIEN,I34441,I344491,IENS,OSEQ,RCDA1,RCDT,RCPT,RCSEQ,RCT,REASON
+12 NEW TOTPOSTD,XX,YY
+13 SET (RCT,TOTPOSTD,BALANCE,VALMCNT)=0
+14 SET ERAIEN=0
+15 ;
+16 ; 2nd Pass get the data and sort the lines EEOB data lines to be displayed
+17 FOR
Begin DoDot:1
+18 SET ERAIEN=$ORDER(^TMP($JOB,P1,ERAIEN))
+19 if 'ERAIEN
QUIT
+20 SET RCSEQ=0
+21 FOR
Begin DoDot:2
+22 SET RCSEQ=$ORDER(^RCY(344.49,ERAIEN,1,"B",RCSEQ))
+23 if 'RCSEQ
QUIT
+24 if RCSEQ#1'=0
QUIT
+25 SET RCDA1=+$ORDER(^RCY(344.49,ERAIEN,1,"B",RCSEQ,0))
+26 if 'RCDA1
QUIT
+27 ; IENS for subfile 344.491
SET I344491=RCDA1_","_ERAIEN_","
+28 ; Amount to post on Receipt
SET AMTPST=$$GET1^DIQ(344.491,I344491,.03,"I")
+29 ; Ignore zero value lines
if +AMTPST=0
QUIT
+30 ; Original ERA sequence #s
SET OSEQ=$$GET1^DIQ(344.491,I344491,.09,"E")
+31 ; IENS for subfile 344.41
SET I34441=+OSEQ_","_ERAIEN_","
+32 ; Internal Receipt IEN (file 344)
SET RCPT=$$GET1^DIQ(344.41,I34441,.25,"I")
+33 ; External Auto-Post Reject Reason
SET REASON=$$GET1^DIQ(344.41,I34441,5)
+34 ;
+35 ; If we have a receipt, add the Amount to Post to the total posted amount
+36 if RCPT'=""
SET TOTPOSTD=TOTPOSTD+AMTPST
+37 ;
+38 ; If we have don't have a receipt, calculate the unposted balance
+39 IF RCPT=""
Begin DoDot:3
+40 ; Total Payment Received
SET XX=$$GET1^DIQ(344.49,ERAIEN_",",.03,"I")
+41 SET BALANCE=XX-TOTPOSTD
End DoDot:3
+42 ;
+43 ; Only display EEOBs that do not have a receipt and aren't marked for auto-post
+44 ; Mark for Auto-Post flag of the ERA detail ln
SET YY=$$GET1^DIQ(344.41,I34441,6,"I")
+45 IF RCPT=""
IF 'YY
Begin DoDot:3
+46 SET RCT=RCT+1
+47 ; ERA Number
SET XX=$$GET1^DIQ(344.4,ERAIEN_",",.01,"I")
+48 SET $PIECE(RCARRY(RCT),"^",1)=XX
+49 ; Original ERA Detail Sequence Numbers
SET $PIECE(RCARRY(RCT),"^",2)=+OSEQ
+50 ; Claim Number
SET XX=$$GET1^DIQ(344.491,I344491,.02,"E")
+51 SET $PIECE(RCARRY(RCT),"^",3)=XX
+52 ; Internal IEN for subfile 344.491
SET $PIECE(RCARRY(RCT),"^",4)=RCDA1
+53 ; Reason on APAR
SET $PIECE(RCARRY(RCT),"^",5)=REASON
End DoDot:3
End DoDot:2
if 'RCSEQ
QUIT
+54 IF $DATA(RCARRY)
Begin DoDot:2
+55 ; ERA File Date/Time for sort
SET RCDT=$$GET1^DIQ(344.4,ERAIEN_",",.07,"I")
+56 ; Internal Auto-Post Date
SET AUTOPDT=$$GET1^DIQ(344.4,ERAIEN_",",4.01,"I")
+57 ; Payer ID
SET XX=$$GET1^DIQ(344.4,ERAIEN_",",.03,"I")
+58 ; Payer Name
SET YY=$$GET1^DIQ(344.4,ERAIEN_",",.06,"I")
+59 DO ERALINES(ERAIEN,.RCARRY,BALANCE,TOTPOSTD,AUTOPDT,RCDT,XX,YY,P2)
+60 KILL RCARRY
End DoDot:2
+61 ; Reset posted and unposted balances
SET (BALANCE,TOTPOSTD)=0
End DoDot:1
if 'ERAIEN
QUIT
+62 ;
+63 ; Final Pass - build the display lines and load the listman template
+64 DO BOUT(P2,.VALMCNT)
+65 QUIT
+66 ;
ERALINES(RCDA,RCARRY,BALANCE,TOTPOSTD,POSTDT,FILEDT,PAYID,PAYNM,P2) ; Build sorted list
+1 ; Input: RCDA - Top file ien for files 344.4 and 344.49
+2 ; RCARRY(CTR) - A1^A2^A3^A4 Where:
+3 ; A1 - ERA Number
+4 ; A2 - Original Sequence Numbers
+5 ; A3 - Claim Number
+6 ; A4 - Internal IEN for subfile 344.491
+7 ; A5 - Reason on APAR
+8 ; BALANCE - Amount that is left to be posted
+9 ; TOTPOSTD - Total amount posted thus far against the ERA
+10 ; POSTDT - Latest auto-posted date
+11 ; FILEDT - Date/Time the ERA was filed
+12 ; PAYID - Payer id
+13 ; PAYNM - Payer name
+14 ; P2 - "RCDPE_APAR_EEOB_PASS2"
+15 ; REASON - External Auto-Post Reject Reason
+16 ; Output: ^TMP($J,P2,A1,A2) = B1^B2^B3^B4^B5^B6^B7^B8^B9 Where:
+17 ; A1 - Uppercased value of the selected sort field
+18 ; A2 - Internal IEN of the ERA record
+19 ; B1 - Line Number
+20 ; B2 - ERA #.Sequence # (max 19 10+"."+8 characters)
+21 ; B3 - Claim # (max 15 characters)
+22 ; B4 - Posted Amount (max 15 characters)
+23 ; B5 - External Post Date (8 characters)
+24 ; B6 - Unposted Balance (max 15 characters)
+25 ; B7 - Payer Name/Payer ID (max 76 characters)
+26 ; B8 - Internal IEN for subfile 344.491
+27 ; B9 - Auto-Post Reject Reason
+28 ; B10 - Date ERA Filed
+29 NEW A1,DLINE,RCT,REASON,X,XX
+30 SET RCT=""
+31 FOR
Begin DoDot:1
+32 SET RCT=$ORDER(RCARRY(RCT))
+33 if RCT=""
QUIT
+34 SET REASON=$PIECE(RCARRY(RCT),"^",5)
+35 ; Get Sort Value
SET A1=$$SORTP(BALANCE,TOTPOSTD,PAYNM,REASON,FILEDT)
+36 ; Set null sort value to space to avoid subscript error
IF A1=""
SET A1=" "
+37 ; Line Number
SET DLINE=RCT
+38 ; ERA #.Sequence #
SET XX=$PIECE(RCARRY(RCT),U,1)_"."_$PIECE(RCARRY(RCT),U,2)
+39 SET $PIECE(DLINE,"^",2)=XX
+40 ; Claim #
SET $PIECE(DLINE,"^",3)=$PIECE(RCARRY(RCT),U,3)
+41 ; Posted Amount
SET $PIECE(DLINE,"^",4)=TOTPOSTD
+42 ; External Post Date
SET $PIECE(DLINE,"^",5)=$$FMTE^XLFDT(POSTDT,"2ZD")
+43 ; Unposted Balance
SET $PIECE(DLINE,"^",6)=BALANCE
+44 ; Payer Name/ID
SET $PIECE(DLINE,"^",7)=PAYNM_"/"_PAYID
+45 ; Internal IEN for subfile 344.491
SET $PIECE(DLINE,"^",8)=$PIECE(RCARRY(RCT),"^",4)
+46 ; Auto-Post Reject Reason
SET $PIECE(DLINE,"^",9)=REASON
+47 ; External Date ERA Filed
SET $PIECE(DLINE,"^",10)=$$FMTE^XLFDT($PIECE(FILEDT,".",1),"2ZD")
+48 SET ^TMP($JOB,P2,A1,RCDA,RCT)=DLINE
End DoDot:1
if RCT=""
QUIT
+49 QUIT
+50 ;
BOUT(P2,VALMCNT) ; Build the display lines and load into the listman template
+1 ; Input: P2 - "RCDPE_APAR_EEOB_PASS2"
+2 ; ^TMP($J,P2,A1,A2) - B1^B2^B3^B4^B5^B6^B7^B8
+3 ; See ERALINES for detail
+4 ; Output: VALMCNT - Total # of body lines
+5 ; ^TMP("RCDPE-APAR_EEOB_WL",$J,VALMCNT,0) - Listman Body line
+6 ; ^TMP("RCDPE-APAR_EEOB_WL",$J,"IDX",VALMCNT,RCSEQ) - Line selection index
+7 ; ^TMP("RCDPE-APAR_EEOB_WLDX",$J,RCSEQ) - A1^A2^A3^...An Where
+8 ; A1 - Line selection #
+9 ; A2 - Internal IEN for 344.4
+10 ; A3 - Internal IEN for 344.491
+11 ; A4 - Unposted Balance
+12 ; A5 - Posted Amount
+13 NEW A1,BALANCE,COUNT,DLINE,ERAIEN,RCT,TOTPOSTDX,XX
+14 SET A1=""
SET COUNT=0
+15 FOR
Begin DoDot:1
+16 SET A1=$ORDER(^TMP($JOB,P2,A1))
+17 if A1=""
QUIT
+18 SET ERAIEN=""
+19 FOR
Begin DoDot:2
+20 SET ERAIEN=$ORDER(^TMP($JOB,P2,A1,ERAIEN))
+21 if ERAIEN=""
QUIT
+22 SET RCT=""
+23 FOR
Begin DoDot:3
+24 SET RCT=$ORDER(^TMP($JOB,P2,A1,ERAIEN,RCT))
+25 if RCT=""
QUIT
+26 SET XX=^TMP($JOB,P2,A1,ERAIEN,RCT)
+27 ; Selection #
SET COUNT=COUNT+1
+28 SET DLINE=$JUSTIFY(COUNT,3)
+29 ; ERA #.Sequence #
SET DLINE=DLINE_$JUSTIFY("",7)_$$LJ^XLFSTR($PIECE(XX,"^",2),17)
+30 ; Claim #
SET DLINE=DLINE_$$LJ^XLFSTR($PIECE(XX,"^",3),14)
+31 SET TOTPOSTD=$PIECE(XX,"^",4)
+32 ; Posted Amount
SET DLINE=DLINE_$JUSTIFY(TOTPOSTD,13,2)_" "
+33 ; S DLINE=DLINE_$P(XX,"^",5)_" " ; Posted Date
+34 ; Date ERA filed
SET DLINE=DLINE_$PIECE(XX,"^",10)_" "
+35 SET BALANCE=$PIECE(XX,"^",6)
+36 ; Unpaid Balance
SET DLINE=DLINE_$JUSTIFY(BALANCE,13,2)_" "
+37 ; S DLINE=DLINE_$P(XX,"^",10) ; Date ERA filed
+38 ; Posted Date
SET DLINE=DLINE_$PIECE(XX,"^",5)
+39 ;
+40 ; Line 1 of displayed EEOB item
+41 DO SET(DLINE,COUNT,ERAIEN,$PIECE(XX,"^",8),BALANCE,TOTPOSTD,.VALMCNT)
+42 ;
+43 ; Line 2 of displayed EEOB item: payer name/payer id
+44 SET DLINE=$JUSTIFY("",5)_$$PAYTIN^RCDPRU2($PIECE(XX,"^",7),75)
+45 DO SET(DLINE,COUNT,ERAIEN,$PIECE(XX,"^",8),BALANCE,TOTPOSTD,.VALMCNT)
+46 ;
+47 ; Line 3 of displayed EEOB item: Auto-Post Reject Reason
+48 SET DLINE=$JUSTIFY("",5)_$PIECE(XX,"^",9)
+49 DO SET(DLINE,COUNT,ERAIEN,$PIECE(XX,"^",8),BALANCE,TOTPOSTD,.VALMCNT)
End DoDot:3
if RCT=""
QUIT
End DoDot:2
if ERAIEN=""
QUIT
End DoDot:1
if A1=""
QUIT
+50 QUIT
+51 ;
SORTP(BALANCE,TOTPOSTD,PAYNM,REASON,FILEDT) ; Get the value for the selected sort
+1 ; Input: BALANCE - Unpaid Balance
+2 ; TOTPOSTD - Posted Amount
+3 ; POSTDT - Internal Posted Datge
+4 ; PAYNM - Payer Name
+5 ; REASON - External Auto-Post Reject Reason
+6 ; FILEDT - Internal Date/Time the ERA was filed
+7 ; ^TMP("RCDPE_APAR_EEOB_PARAMS",$J,"SORT")- Selected sort (P/D/A/T)
+8 ; Returns: External value for the selected sort type
+9 NEW VALUE,XX,YY
+10 SET XX=^TMP("RCDPE_APAR_EEOB_PARAMS",$JOB,"SORT")
+11 SET YY=$PIECE(XX,"^",2)
SET XX=$PIECE(XX,"^",1)
+12 SET YY=$SELECT(YY="H":-1,1:1)
+13 ; Sort by Payer Name
IF XX="N"
QUIT $$UP^XLFSTR(PAYNM)
+14 ; Sort by Auto-post Reject Reason
IF XX="R"
QUIT $$UP^XLFSTR(REASON)
+15 ; Sort by Date/Time ERA filed
IF XX="D"
QUIT FILEDT*YY
+16 ; Sort by Unposted Balance
IF XX="U"
QUIT BALANCE*YY
+17 ; Sort by Posted Amount
QUIT TOTPOSTD*YY
+18 ;
SET(DLINE,RCSEQ,ERAIEN,RCDA1,BALANCE,TOTPOSTD,VALMCNT) ; Set ListManager arrays
+1 ; Input: DLINE - Line to be displayed in the listman body
+2 ; RCSEQ - Line Selection number
+3 ; ERAIEN - Internal IEN for 344.4 or 344.49
+4 ; RCDA1 - Inernal IEN for subfile 344.491
+5 ; BALANCE - Unposted Balance
+6 ; TOTPOSTD - Posted Amount
+7 ; VALMCNT - Current listman body line count
+8 ; Output: VALMCNT - Updated listman body line count
+9 ; ^TMP("RCDPE-APAR_EEOB_WL",$J,VALMCNT,0) - Listman Body line
+10 ; ^TMP("RCDPE-APAR_EEOB_WL",$J,"IDX",VALMCNT,RCSEQ) - Line selection index
+11 ; ^TMP("RCDPE-APAR_EEOB_WLDX",$J,RCSEQ) - A1^A2^A3^...An Where
+12 ; A1 - Line selection #
+13 ; A2 - Internal IEN for 344.4
+14 ; A3 - Internal IEN for 344.491
+15 ; A4 - Unposted Balance
+16 ; A5 - Posted Amount
+17 SET VALMCNT=VALMCNT+1
+18 SET ^TMP("RCDPE-APAR_EEOB_WL",$JOB,VALMCNT,0)=DLINE
+19 SET ^TMP("RCDPE-APAR_EEOB_WL",$JOB,"IDX",VALMCNT,RCSEQ)=ERAIEN
+20 SET ^TMP("RCDPE-APAR_EEOB_WLDX",$JOB,RCSEQ)=VALMCNT_U_ERAIEN_U_RCDA1_U_$GET(BALANCE)_U_$GET(TOTPOSTD)
+21 QUIT
+22 ;