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

RCDPENE1.m

Go to the documentation of this file.
  1. RCDPENE1 ;AITC/CJE - NEGATIVE ERA LINE REPORT ;Dec 20, 2014@18:42
  1. ;;4.5;Accounts Receivable;**424**;Mar 20, 1995;Build 11
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. Q
  1. COMPILE ; Generate the Auto Posting report ^TMP array
  1. ; Input: GLOB - "^TMP("RCDPENER",$J)"
  1. ; RCDISP - 0 - Output to paper or screen, 1 - Output to Excel
  1. ; RCDIV - 1 - All divisions, 2 - Selected divisions
  1. ; RCDIVS()- Array of selected divisions if RCDIV=2
  1. ; RCRANGE - 1^Start Date^End Date
  1. ; RCJOB - $J
  1. ; RCLAIM - "M" - Medical Claims, "P" - Pharmacy Claims, "B" - Both
  1. ; RCPAGE - Initialized to 0
  1. ; RCPARRAY- Array of selected payers
  1. ; RCPROG - "RCDPENER"
  1. ; RCSORT - 0 - Sort by Payer Name, 1 - Sort by Payer TIN
  1. ; RCWHICH - 1 - Filter by Payer Name, 2 - Filter by Payer TIN
  1. ; ^TMP("RCSELPAY",RCJOB) - Selected Payer Names or TINs
  1. ;
  1. ; Output: ^TMP("RCDPENER",$J) Contains report details in ^ delimited format
  1. ; (See SAVE subroutine for details)
  1. ;
  1. N AMT,APDATE,CNT,END,ERAIEN,IEN,OKAY,RCECME,RCRZ,STA,STNAM,STNUM
  1. S APDATE=$$FMADD^XLFDT($P(RCRANGE,U,2),-1)
  1. S APDATE=APDATE+.24 ; File date has time stamp, prevent it from including date/time before selected range
  1. S END=$P(RCRANGE,U,3),CNT=0
  1. ;
  1. ; Scan AC index for ERA within date range of ERA created dates
  1. F S APDATE=$O(^RCY(344.4,"AFD",APDATE)) Q:'APDATE Q:(APDATE\1)>END D
  1. . S ERAIEN=""
  1. . F S ERAIEN=$O(^RCY(344.4,"AFD",APDATE,ERAIEN)) Q:'ERAIEN D
  1. . . ;
  1. . . ; Check division - Note return values are set to UNKNOWN if not available
  1. . . D ERASTA^RCDPEAPQ(ERAIEN,.STA,.STNUM,.STNAM)
  1. . . I RCDIV=2,'$D(RCDIVS(STA)) Q
  1. . . ;
  1. . . ; PRCA*4.5*304 - Check if we include this ERA in report
  1. . . I RCPAY="A",RCLAIM'="A" D Q:'OKAY
  1. . . . S OKAY=$$ISTYPE^RCDPEU1(344.4,ERAIEN,RCLAIM)
  1. . . ;
  1. . . ; Check Payer Name
  1. . . I RCPAY'="A" D Q:'OKAY
  1. . . . S OKAY=$$ISSEL^RCDPEU1(344.4,ERAIEN)
  1. . . ;
  1. . . ; If it does not already exist for this ERA, build X-ref of ERA detail lines to the lines in the worklist
  1. . . I '$D(^TMP("RCDPEAPP2",$J,ERAIEN)) D BUILD^RCDPEAPQ(ERAIEN)
  1. . . ;
  1. . . ; Scan index for negative lines within the ERA and save to ^TMP if there is one
  1. . . S RCRZ=0 I ERAIEN=92933
  1. . . F S RCRZ=$O(^RCY(344.4,ERAIEN,1,RCRZ)) Q:'RCRZ D ;
  1. . . . S AMT=$$GET1^DIQ(344.41,RCRZ_","_ERAIEN_",",.03,"I")
  1. . . . I AMT<0 D SAVE(ERAIEN,RCRZ,RCSORT) ; Save negative claim line detail to ^TMP global
  1. Q
  1. SAVE(ERAIEN,RCRZ,RCSORT) ; EP - Save to ^TMP global
  1. ; Input: ERAIEN - Internal IEN into file 344.4
  1. ; RCRZ - Internal IEN into sub-file 344.41
  1. ; STNAM - Division Name (Primary Sort)
  1. ; STNUM - Station Number
  1. ; ^TMP("RCDPEAPP2",$J,ERAIEN,RCRZ) - Array of detail lines
  1. ; Output: ^TMP("RCDPENER",$J) Contains report details in ^ delimited format
  1. ;
  1. ; 1 - Station Name (STNAM)
  1. ; 2 - Station Number (STNUM)
  1. ; 3 - Payer Name (PAYNAM)
  1. ; 4 - Patient Name (PTNAM)
  1. ; 5 - ERA # (ERANUM)
  1. ; 6 - ERA Date (ERADATE)
  1. ; 7 - Claim # (BILL)
  1. ; 8 - Amount Paid (TOTPAMT)
  1. ; 9 - Claim Balance (TOTBAL)
  1. ; 10 - Claim Status (STATUS)
  1. ; 11 - Trace # (TRACE)
  1. ; 12 - Date of Service (DOS)
  1. ;
  1. N BALANCE,BAMT,BILL,CLAIMIEN,COLLECT,DATE,DOS,EOBIEN,ERADATE,ERANUM ; PRCA*4.5*345
  1. N PAMT,PAYIX1,PAYIX2,PAYNAM,PTNAM,RECEIPT,SEQ,SEQ1,SEQ2,STATUS,STIX
  1. N TIN,TOTBAL,TOTBAMT,TOTPAMT,TRACE,XX
  1. S PAYNAM=$$GET1^DIQ(344.4,ERAIEN,.06,"E") ; Payer Name from ERA Record
  1. S TIN=$$GET1^DIQ(344.4,ERAIEN,.03,"E") ; Payer TIN from ERA Record
  1. S:RCSORT=0 PAYIX1=PAYNAM,PAYIX2=TIN
  1. S:RCSORT=1 PAYIX1=TIN,PAYIX2=PAYNAM
  1. S:PAYNAM="" PAYNAM="UNKNOWN"
  1. S STIX=STNAM_"/"_STNUM
  1. ;
  1. S TRACE=$$GET1^DIQ(344.4,ERAIEN,.02,"E") ; Trace Number
  1. S PTNAM=$$PNM4^RCDPEWL1(ERAIEN,RCRZ) ; Patient name from claim file #399
  1. S ERANUM=$$GET1^DIQ(344.4,ERAIEN,.01,"E") ; ERA Number
  1. S ERADATE=$$GET1^DIQ(344.4,ERAIEN,.07,"I") ; Date received (file date/time)
  1. S ERADATE=$$FMTE^XLFDT(ERADATE,"2DZ")
  1. S XX=$$GET1^DIQ(344.41,RCRZ_","_ERAIEN,.25,"I") ; Receipt IEN
  1. ;
  1. S (TOTBAMT,TOTBAL,COLLECT,CLAIMIEN,TOTPAMT)=0,DOS="UNKNOWN",BILL="",STATUS=""
  1. S EOBIEN=$$GET1^DIQ(344.41,RCRZ_","_ERAIEN,.02,"I") ; IEN for 361.1
  1. I EOBIEN D ;
  1. . S CLAIMIEN=$$GET1^DIQ(361.1,EOBIEN,.01,"I") ; IEN for 399
  1. . S DOS=$$GET1^DIQ(361.1,EOBIEN,1.1,"I") ; Date of Service
  1. . S DOS=$$FMTE^XLFDT(DOS,"2DZ")
  1. . S BILL=$$EXTERNAL^DILFD(344.41,.02,,EOBIEN) ; Bill Number
  1. . ; Get Billed Amount from AR (Original Balance)
  1. . I CLAIMIEN D
  1. . . S TOTBAMT=$J(+$$GET1^DIQ(430,CLAIMIEN,3,"I"),0,2) ; Original Amount
  1. . . S TOTBAL=$J(+$$GET1^DIQ(430,CLAIMIEN,71,"I"),0,2) ; Principal Balance
  1. . . S STATUS=$$GET1^DIQ(430,CLAIMIEN,8,"E") ; Claim Status
  1. S TOTPAMT=$J($$GET1^DIQ(344.41,RCRZ_","_ERAIEN,.03,"I"),0,2) ; Amount Paid on Claim
  1. ; Balance from AR (Principal Balance)
  1. ;
  1. S PTNAM=$S('CLAIMIEN:"",1:$$PNM4^RCDPEWL1(ERAIEN,RCRZ))
  1. S:TOTBAMT COLLECT=$J(TOTPAMT/TOTBAMT*100,0,2)_"%"
  1. S CNT=CNT+1
  1. S XX=STNAM_U_STNUM_U_PAYNAM_U_PTNAM_U_ERANUM_U_ERADATE
  1. S XX=XX_U_BILL_U_TOTPAMT_U_TOTBAL_U_STATUS_U_TRACE_U_DOS
  1. S @GLOB@(STIX,PAYIX1,PAYIX2,CNT)=XX
  1. ;
  1. Q