RCDPEAP2 ;AITC/CJE - AUTO POST MATCHING EFT ERA PAIR - CONT. ;Jun 06, 2014@19:11:19
 ;;4.5;Accounts Receivable;**424**;Mar 20, 1995;Build 11
 ;Per VA Directive 6402, this routine should not be modified.
 ;Read ^IBM(361.1) via Private IA 4051
 ;
 Q
 ; PRCA*4.5*424 Added whole subroutine POST0 below
POST0(RCERA) ; Auto-post zero balance ERA (EP from AUTOPOST^RCDPEAP)
 ; Input - RCERA internal entry number of ERA from file #344.4
 ; Output - None
 ;
 ; Make sure the ERA passes all auto-posting rules
 Q:'$$AUTOCHK^RCDPEAP1(RCERA)
 ;
 ; Update the audit log
 D AUDITLOG^RCDPEAP(RCERA,2,"Auto Posting: ERA posted successfully")
 ;
 ; Update ERA detail post status, set ERA auto-post status to 'complete',update latest auto-post date
 ; set match status to MATCH-0 PAYMENT
 S DIE="^RCY(344.4,"
 S DR=".09///3;.14///1;4.01////"_DT_";4.02///2"
 S DA=RCERA
 D ^DIE
 ;
 ; Update auto-post date for each claim line
 N RCLINE,RCSCD0
 S RCLINE=0
 F  S RCLINE=$O(^RCY(344.4,RCERA,1,RCLINE)) Q:'RCLINE  D
 . S RCSCD0=$G(^RCY(344.4,RCERA,1,RCLINE,0))
 . Q:+$P(RCSCD0,U,3)
 . ;
 . ; Update ERA line with auto-post date
 . N DA,DIE,DR
 . S DA(1)=RCERA,DA=RCLINE,DIE="^RCY(344.4,"_DA(1)_",1,",DR="9///"_DT
 . D ^DIE
 Q
 ;
PAYEREXC(RCERA) ;EP from RCDPEM0
 ; Check to see if the payer is excluded from auto-posting
 ;PRCA*4.5*424 moved method from RCDPEM0
 ; Input:   RCERA   - IEN of the ERA being evaluated
 ; Returns: 1 - Payer is excluded, 0 otherwise
 N NAM0,RCERATYP,RCXCLDE,TIN0,XX
 S NAM0=$$GET1^DIQ(344.4,RCERA_",",.06,"E")  ; PRCA*4.5*345 - Added line - Payer Name
 S TIN0=$$GET1^DIQ(344.4,RCERA_",",.03,"E")  ; PRCA*4.5*345 - Added line - Payer TIN
 S XX=$$GETPAY^RCDPEU1(NAM0,TIN0)            ; PRCA*4.5*345 - Get the IEN from 344.6
 ;
 ; Determine if ERA should be excluded using the site parameters
 I $$CHKTYPE^RCDPEU1(XX,"T") S RCERATYP=2   ; PRCA*4.5*349 - Check if this is TRICARE ERA
 E  S RCERATYP=$$PHARM^RCDPEAP1(RCERA)      ; Else it must be a Medical or Rx ERA
 S RCXCLDE=0
 S:RCERATYP=0 RCXCLDE=$$EXCLUDE^RCDPEAP1(RCERA) ; PRCA*4.5*345 - Changed to =0 from 'RCERATYP
 S:RCERATYP=1 RCXCLDE=$$EXCLDRX^RCDPEAP1(RCERA) ; PRCA*4.5*345 - Changed to =1 from RCERATYP
 S:RCERATYP=2 RCXCLDE=$$EXCLDTR^RCDPEAP1(RCERA) ; PRCA*4.5*349 - Added Line
 Q RCXCLDE                                  ; Quit if the Payer is excluded from Auto-Post
 Q
 ;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRCDPEAP2   2400     printed  Sep 23, 2025@19:20:20                                                                                                                                                                                                    Page 2
RCDPEAP2  ;AITC/CJE - AUTO POST MATCHING EFT ERA PAIR - CONT. ;Jun 06, 2014@19:11:19
 +1       ;;4.5;Accounts Receivable;**424**;Mar 20, 1995;Build 11
 +2       ;Per VA Directive 6402, this routine should not be modified.
 +3       ;Read ^IBM(361.1) via Private IA 4051
 +4       ;
 +5        QUIT 
 +6       ; PRCA*4.5*424 Added whole subroutine POST0 below
POST0(RCERA) ; Auto-post zero balance ERA (EP from AUTOPOST^RCDPEAP)
 +1       ; Input - RCERA internal entry number of ERA from file #344.4
 +2       ; Output - None
 +3       ;
 +4       ; Make sure the ERA passes all auto-posting rules
 +5        if '$$AUTOCHK^RCDPEAP1(RCERA)
               QUIT 
 +6       ;
 +7       ; Update the audit log
 +8        DO AUDITLOG^RCDPEAP(RCERA,2,"Auto Posting: ERA posted successfully")
 +9       ;
 +10      ; Update ERA detail post status, set ERA auto-post status to 'complete',update latest auto-post date
 +11      ; set match status to MATCH-0 PAYMENT
 +12       SET DIE="^RCY(344.4,"
 +13       SET DR=".09///3;.14///1;4.01////"_DT_";4.02///2"
 +14       SET DA=RCERA
 +15       DO ^DIE
 +16      ;
 +17      ; Update auto-post date for each claim line
 +18       NEW RCLINE,RCSCD0
 +19       SET RCLINE=0
 +20       FOR 
               SET RCLINE=$ORDER(^RCY(344.4,RCERA,1,RCLINE))
               if 'RCLINE
                   QUIT 
               Begin DoDot:1
 +21               SET RCSCD0=$GET(^RCY(344.4,RCERA,1,RCLINE,0))
 +22               if +$PIECE(RCSCD0,U,3)
                       QUIT 
 +23      ;
 +24      ; Update ERA line with auto-post date
 +25               NEW DA,DIE,DR
 +26               SET DA(1)=RCERA
                   SET DA=RCLINE
                   SET DIE="^RCY(344.4,"_DA(1)_",1,"
                   SET DR="9///"_DT
 +27               DO ^DIE
               End DoDot:1
 +28       QUIT 
 +29      ;
PAYEREXC(RCERA) ;EP from RCDPEM0
 +1       ; Check to see if the payer is excluded from auto-posting
 +2       ;PRCA*4.5*424 moved method from RCDPEM0
 +3       ; Input:   RCERA   - IEN of the ERA being evaluated
 +4       ; Returns: 1 - Payer is excluded, 0 otherwise
 +5        NEW NAM0,RCERATYP,RCXCLDE,TIN0,XX
 +6       ; PRCA*4.5*345 - Added line - Payer Name
           SET NAM0=$$GET1^DIQ(344.4,RCERA_",",.06,"E")
 +7       ; PRCA*4.5*345 - Added line - Payer TIN
           SET TIN0=$$GET1^DIQ(344.4,RCERA_",",.03,"E")
 +8       ; PRCA*4.5*345 - Get the IEN from 344.6
           SET XX=$$GETPAY^RCDPEU1(NAM0,TIN0)
 +9       ;
 +10      ; Determine if ERA should be excluded using the site parameters
 +11      ; PRCA*4.5*349 - Check if this is TRICARE ERA
           IF $$CHKTYPE^RCDPEU1(XX,"T")
               SET RCERATYP=2
 +12      ; Else it must be a Medical or Rx ERA
          IF '$TEST
               SET RCERATYP=$$PHARM^RCDPEAP1(RCERA)
 +13       SET RCXCLDE=0
 +14      ; PRCA*4.5*345 - Changed to =0 from 'RCERATYP
           if RCERATYP=0
               SET RCXCLDE=$$EXCLUDE^RCDPEAP1(RCERA)
 +15      ; PRCA*4.5*345 - Changed to =1 from RCERATYP
           if RCERATYP=1
               SET RCXCLDE=$$EXCLDRX^RCDPEAP1(RCERA)
 +16      ; PRCA*4.5*349 - Added Line
           if RCERATYP=2
               SET RCXCLDE=$$EXCLDTR^RCDPEAP1(RCERA)
 +17      ; Quit if the Payer is excluded from Auto-Post
           QUIT RCXCLDE
 +18       QUIT 
 +19      ;