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

BAR50EP1.m

Go to the documentation of this file.
BAR50EP1 ; IHS/SD/TPF - AR ERA NONPAYMENT CHECKER ; 01/30/2009
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**5,6,10,21,22,23,24,26**;OCT 26,2005;Build 17
 ;;P.OTTIS HEAT#82698 NOV 2012 LEADING ZEROES IN CHKECK # (POS)
 ;;        FEB 13 ADDED INFO ON NONPAY DETAILS; SHOW CLMPYMT
 ;;        MAR 13 EXCLUDED COL BATCHES OLDER THAN 365 DAYS
 ;P.OTTIS REFINED 'OVERRIDE' FLAG WITH MESSAGE
 ;        10/10/13 FIXED ERR MSG FOR ERROR=NIPAC
 ;        DON'T DISPLAY ERR FOR MATCHED CLAIMS 11/27/13 
 ;HEAT147572 P.OTT ALLOW TRIBAL SITES ERA POSTING OF NEG BAL
 ;        2/4/2014 BLOCK ERROR NIPAC (TDN/IPAC MISSING IN RPMS BATCH AND ITEM) FOR TRIBAL SITES
 Q
NONPAYCH(IMPDA) ;EP - CHECK PAYMENTS NOT MATCHED WITH A REVERSAL
 N CLMDA,ERACHECK,CLSTATUS,POSTAS,CNT,CLIENS
 N BPR02
 I $G(BARDBG) W !!!,"LOOKING FOR NON-MATCHED PAYMENTS AGAINST NONPAYMENT BATCHES"
 S CLMDA=0,CLMPYMT=0 F  S CLMDA=$O(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA)) Q:'CLMDA  D
 .S CLMPYMT=CLMPYMT+$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U,4)
 S CLMDA=0
 F CNT=1:1 S CLMDA=$O(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA)) Q:'CLMDA  D
 . W:'(CNT#1000) "."
 . Q:$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U,2)="P"  ;DON'T CHECK POSTED CLAIMS
 . Q:$$OVERIDE^BAR50EP1(CLMDA)                         ;MRS:BAR*1.8*10 D159-1 AND 2
 . S BPR02=+$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,2)),U,5)  ;BPR MONETARY AMOUNT BAR*1.8*6 SCR119 IHS/SD/TPF
 . S CLIENS=CLMDA_","_IMPDA_","
 . S ERACHECK=$$GET1^DIQ(90056.0205,CLIENS,201,"E")  ;CHECK/EFT TRACE
 . S CLSTATUS=$P($$GET1^DIQ(90056.0205,CLIENS,.11,"E")," ")  ;E-CLAIM STATUS CODE (CLP02)
 . I CLSTATUS="" S CLSTATUS=$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,2)),U,4)
 . Q:(U_"1"_U_"2"_U_"3"_U_"19"_U_"20"_U_"21"_U)'[(U_CLSTATUS_U)  ;PRIMARY,SECONDARY,TERTIARY AS WELL AS THOSE 19,20,21 FORWARDED TO ADDITIONAL PAYER BAR*1.8*6 IM29637
 . S POSTAS=$$GET1^DIQ(90056.0205,CLIENS,501,"I")
 . Q:POSTAS=138!(POSTAS=139)
 . D NONPAY(ERACHECK,IMPDA,CLMDA,BPR02)  ;BAR*1.8*6 SCR119 
 Q
NONPAY(ERACHECK,IMPDA,CLMDA,BPR02) ;EP - SEE IF TDN/IPAC = NONPAYMENT
 N TDNIPAC,BARCOLDA,ERRORS,BARITMDA,NONPAY,NOITEM,NOHEAD,BARXCHK ;P.OTT
 S BARXCHK=$$BARXCHK^BAREDP09(ERACHECK) ;P.OTT
 S (NOITEM,NOHEAD,NONPAY)=0
 S BARCOLDA=$O(^BARCOL(DUZ(2),"D",BARXCHK,""))
 I 'BARCOLDA,(BPR02=0) Q  ;
 I 'BARCOLDA D  Q
 . S ERRORS("NB")=""  ;NO BATCH FOUND FOR ERA CHECK
 . D ADDREAS^BAR50P04(IMPDA,CLMDA,.ERRORS)
 . K ERRORS
 ;CHECK ALL ERACHECK BATCHES/ITEMS FOR A NONPAYMENT
 NEW BARTODAY,%H
 S X=DT D H^%DTC ;GET $H-FORMAT
 S BARTODAY=%H
 S BARCOLDA="" F  S BARCOLDA=$O(^BARCOL(DUZ(2),"D",BARXCHK,BARCOLDA)) Q:BARCOLDA=""  D
 . NEW X,BARCBDT,BARCB
 . S X=$$GET1^DIQ(90051.01,BARCOLDA_",",4,"I")
 . D H^%DTC ;GET $H-FORMAT
 . S BARCBDT=%H
 . IF BARTODAY-BARCBDT>365 D  Q  ;TOO OLD
 . . S BARCB=$$GET1^DIQ(90051.01,BARCOLDA_",",.01,"A")
 . . ;S BARMSG="IGNORING COLL. BATCH "_BARCB_" EIN# "_BARCOLDA_" TOO OLD: ("_X_")"
 . . ;D INS^BAR50DET(BARMSG,0)
 . S TDNIPAC=$$GET1^DIQ(90051.01,BARCOLDA_",",28,"E")
 . I TDNIPAC="" S NOHEAD=1
 . Q:TDNIPAC'=""&(TDNIPAC'="NONPAYMENT")
 . I TDNIPAC="NONPAYMENT",(CLMPYMT'=0) D  Q
 . . S ERRORS("P NP")=""
 . . I $G(BARDBG) D DETAILS(0) ;COL LEVEL
 . S BARITMDA="" F  S BARITMDA=$O(^BARCOL(DUZ(2),"D",BARXCHK,BARCOLDA,BARITMDA)) Q:BARITMDA=""  D
 . . S TDNIPAC=$$GET1^DIQ(90051.1101,BARITMDA_","_BARCOLDA_",",20,"E")
 . . I TDNIPAC="" S NOITEM=1
 . . I TDNIPAC="NONPAYMENT",(CLMPYMT'=0) D  Q
 . . . S ERRORS("P NP")=""
 . . . I $G(BARDBG) D DETAILS(1) ;DETAIL LEVEL
 . . Q
 . ;IF THERE ARE NO TDN FOR BOTH TOP LEVEL AND ITEM LEVEL THEN THIS IS ONE WITH MISSING TDN
 . ;ONE OR THE OTHER HAS TO BE POPULATED
 . I NOITEM,NOHEAD D
 . . I '$$IHS^BARUFUT(DUZ(2)) Q  ;2/4/2014 NOT FOR TRIBAL SITES
 . . S ERRORS("NIPAC")=""     ;TDN/IPAC MISSING IN RPMS BATCH AND ITEM
 . . NEW BARMSG
 . . I $G(BARDBG) D
 . . . S BARMSG="BATCH "_BARCOLDA_": ERA CHECK: "_ERACHECK_" NO TDN FOR BOTH TOP LEVEL AND ITEM LEVEL"
 . . . D INS^BAR50DET(BARMSG,0) ;10/10/2013
 . S (NOITEM,NOHEAD)=0
 I $D(ERRORS) D
 . NEW BARTMP,I
 . I $G(BARDBG) D
 . . S BARMSG="PROBLEM WITH ERA CHECK: "_ERACHECK D INS^BAR50DET(BARMSG,0) ;10/10/2013
 . . D SHOWERR
 . D ADDREAS^BAR50P04(IMPDA,CLMDA,.ERRORS)
 . K ERRORS
 Q
 ;
OVERIDE(X) ;EP; EXTRINSIC FUNCTION TO CHECK FOR OVERRIDES MRS:BAR*1.8*10 D159-2
 ; ENTERS WITH X = CLAIM IEN
 N BAROR,I
 S BAROR=0           ;NOT AN OVERRIDE
 ;NODE 44 = USER STATUS OVVERRIDE
 ;     45 = PLB CHECK
 ;     46 = REVERSAL
 ;     47 = NEGATIVE PAYMENT
 F I=44:1:47 I $D(^BAREDI("I",DUZ(2),IMPDA,30,X,4,"B",I)) D
 .I I=44 S BAROR="1^USER STATUS OVERRIDE" Q
 .I I=45 S BAROR="1^PLB CHECK" Q
 .;I I=46 S BAROR="1^REVERSAL" Q  ;bar*1.8*26 IHS/SD/SDR HEAT170856
 .;I I=47 S BAROR="1^NEGATIVE PAYMENT" Q  ;bar*1.8*26 IHS/SD/SDR HEAT170856
 Q BAROR
DETAILS(BARLEVEL) ;
 S BARMSG="ERA CHK#: "_ERACHECK I ERACHECK'=BARXCHK S BARMSG=BARMSG_" (A/R CHK# "_BARXCHK_")"
 S BARMSG=BARMSG_" COLL DA: "_BARCOLDA
 S BARMSG=BARMSG_" ERA PAYMENT: "_CLMPYMT
 D INS^BAR50DET(BARMSG,0)
 I BARLEVEL=1 S BARMSG="    ITEM#: "_BARITMDA D INS^BAR50DET(BARMSG,0)
 S BARMSG="ERR CODE(S): "
 I $D(ERRORS("P NP")) S BARMSG=BARMSG_"P NP"
 I $D(ERRORS("NEGP")) S BARMSG=BARMSG_"; NEGP" 
 D INS^BAR50DET(BARMSG,0)
 Q
SHOWERR ;
 NEW I,J,BARTMP,BARERRC
 S BARERRC=$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U,2)  ;CLAIM STATUS
 I BARERRC="M" QUIT  ;DON'T DISPLAY ERR FOR MATCHED CLAIMS 11/27/13
 S BARTMP="",I="" F  S I=$O(ERRORS(I)) Q:I=""  S J="" F  S J=$O(^BARERR("B",I,J)) Q:J=""  D
 . S BARMSG=$P($G(^BARERR(J,0)),U,2)
 . D INS^BAR50DET(BARMSG,0)
 Q