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

IBCAPP2.m

Go to the documentation of this file.
  1. IBCAPP2 ;ALB/GEF - Claims Auto Processing ;14-OCT-10
  1. ;;2.0;INTEGRATED BILLING;**432,447,516,547,727**;21-MAR-94;Build 34
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; IBMRANOT = 1 when dealing with the COB Management Worklist.
  1. ; It is set by the entry action in the option file.
  1. ;
  1. CAP ; Build list from CAP x-ref entrypoint. Called from BLD^IBCECOB1 for non-MRA worklist
  1. N IBDA,IBIFN
  1. S IBIFN=0 F S IBIFN=$O(^DGCR(399,"CAP",1,IBIFN)) Q:'IBIFN D
  1. .; screen all eob's for the claim to see if claim can be on worklist
  1. .; IBDA= ien of 1st eob to pass all checks - or - 0 if none passed - or - -1 if process as paper EOB
  1. .S IBDA=$$MELG(IBIFN,IBMRADUP) Q:'IBDA
  1. .D BLD1(IBIFN,$S(IBDA=-1:"",1:IBDA))
  1. Q
  1. ;
  1. BLD1(IBIFN,IBDA) ;
  1. N IB3611,IBTXT,IBX,IBPY,I,IB364,IBDT,IBAPY,IBB,IBB364,IBBPY,IBDAY,IBEUT
  1. N IBINS1,IBINS2,IBMRACNT,Z,Z0,IBMUT,IBNBAL,IBNDI1,IBNDI2,IBNDI3,IBNDM
  1. N IBPTRSP,IBQ,IBSEQ,IBSRVC,IBEXPY,IBFND,IBINS,IBNDS,IBOAM,IBPTNM,IBDENDUP,IBDIV
  1. ;
  1. Q:$D(^TMP("IBCOBSTX",$J,IBIFN)) ;show each bill once on the worklist
  1. S IBB=$G(^DGCR(399,IBIFN,0))
  1. ;
  1. ; MRD;IB*2.0*516 - Use Division to sort claims. If user has specified
  1. ; one or more divisions to include, then quit if this claim's division
  1. ; is not on that list.
  1. ;
  1. S IBDIV=$P(IBB,U,22) I IBDIV="" S IBDIV="UNKNOWN"
  1. I $D(^TMP("IBBIL-DIV",$J)),'$D(^TMP("IBBIL-DIV",$J,IBDIV)) Q
  1. ;
  1. S IBNDS=$G(^DGCR(399,IBIFN,"S")),IBNDI1=$G(^("I1")),IBNDI2=$G(^("I2")),IBNDI3=$G(^("I3")),IBNDM=$G(^("M"))
  1. S IBMUT=+$P(IBNDS,U,8),IBEUT=+$P(IBNDS,U,2)
  1. S IBINS="",IBSEQ=$$COBN^IBCEF(IBIFN),IB364="UNKNOWN",IBDT="UNKNOWN"
  1. ; IB*2.0*547 - allow users to search for particular payer sequence, default is B for Both
  1. I $G(IBSRCH)="P",IBSEQ'=1 Q ; quit of user wants primary claims and current sequence not primary
  1. I $G(IBSRCH)="S",IBSEQ=1 Q ; quit if user wants secondary/tertiary and current sequence is primary
  1. S IB3611=$S($G(IBDA)'="":$G(^IBM(361.1,IBDA,0)),1:"")
  1. I $G(IB3611)'="" S IB364=$P(IB3611,U,19),IBDT=+$P(IB3611,U,6),IBSEQ=$P(IB3611,U,15)
  1. F I=1:1:3 S Z="IBNDI"_I I @Z D
  1. . N Q
  1. . S Q=(IBSEQ=I)
  1. . I Q S IBINS1=+@Z_U_$P($G(^DIC(36,+@Z,0)),U)
  1. . S IBINS=IBINS_$S(IBINS="":"",1:", ")_$P($G(^DIC(36,+@Z,0)),U)
  1. ;
  1. ; IB*2.0*547 - removed below code since only applicable for MRW, not CBW. For CBW, always should be secondary insurance.
  1. ; Get the payer/insurance company that comes after Medicare WNR
  1. ; If WNR is Primary, get the secondary ins. co.
  1. ; If WNR is secondary, get the tertiary ins. co.
  1. ;D I $P($G(IBINS2),U,2)="" S $P(IBINS2,U,2)="UNKNOWN"
  1. ;. I $$WNRBILL^IBEFUNC(IBIFN,1) S IBINS2=+IBNDI2_U_$P($G(^DIC(36,+IBNDI2,0)),U) Q
  1. ;. S IBINS2=+IBNDI3_U_$P($G(^DIC(36,+IBNDI3,0)),U)
  1. S IBINS2=+IBNDI2_U_$P($G(^DIC(36,+IBNDI2,0)),U)
  1. ;
  1. S IBFND=0
  1. ; biller entry not ALL and no biller, then get entered/edited by user
  1. I $D(^TMP("IBBIL",$J)) D Q:'IBFND
  1. . S IBFND=$S($D(^TMP("IBBIL",$J,IBMUT)):IBMUT,$D(^TMP("IBBIL",$J,IBEUT)):IBEUT,1:0)
  1. S Z=$S(IBFND:IBFND,IBMUT:IBMUT,1:IBEUT)
  1. S IBMUT=$P($G(^VA(200,+Z,0)),U)_"~"_Z
  1. S:'$P(IBMUT,"~",2) IBMUT="UNKNOWN~0"
  1. S IBBPY=+$$COBN^IBCEF(IBIFN),IBQ=1
  1. ;IBQ;1=EOB without subsequent insurer,0=COB,2=0 balance
  1. D ;I IBQ Q
  1. . ;Check for no reimbursable subsequent insurance
  1. . F I=IBBPY+1:1:3 D Q:'IBQ
  1. .. S Z="IBNDI"_I,Z=$G(@Z)
  1. .. I $P($G(^DIC(36,+Z,0)),U,2)="N" S IBQ=0 Q
  1. . ;Check if next ins doesn't exist or next bill# already created
  1. . S Z="IBNDI"_(IBBPY+1),Z=$G(@Z)
  1. . I Z,'$P($G(^DGCR(399,IBIFN,"M1")),U,5+IBBPY) S IBQ=0
  1. ;
  1. ; Days since transmission of latest bill in COB - IBDAY
  1. S IBDAY=+$P($G(^DGCR(399,IBIFN,"TX")),U,2) I IBDAY S IBDAY=$$FMDIFF^XLFDT(DT,IBDAY,1)
  1. ; if no Last Electronic Extract Date on file 399, get it from file 364
  1. I 'IBDAY D I IBDAY S IBDAY=$$FMDIFF^XLFDT(DT,IBDAY,1) ;calc. the difference
  1. . S IBB364=$$LAST364^IBCEF4(IBIFN) I IBB364'="" S IBDAY=+$P($P($G(^IBA(364,IBB364,0)),U,4),".",1)
  1. ;
  1. S IBAPY=$$TPR^PRCAFN(IBIFN) ; payment on this bill from A/R IA#380
  1. S:$G(IBDA)'="" IBEXPY=+$G(^IBM(361.1,IBDA,1)) ; payer paid amount
  1. S IBPY=$S(IBAPY:IBAPY,1:+$G(IBEXPY))
  1. S IBOAM=+$G(^DGCR(399,IBIFN,"U1")) ; total charges for bill
  1. ; Don't include claim if AR STATUS is COLLECTED/CLOSED and no subsequent payer and not one of the TRICARE/Champus claims that needs to be evaluated for Pt Payment,remove from list and quit
  1. I $P($$BILL^RCJIBFN2(IBIFN),U,2)=22 S IBX=$$EOB^IBCNSBL2(IBIFN,IBOAM,IBPY,.IBTXT) I '$D(IBTXT) D RMV(IBIFN) Q
  1. S IBNBAL=IBOAM-IBPY
  1. S IBPTRSP=$S(IBNBAL>0:IBNBAL,1:0)
  1. I IBNBAL'>0 S IBQ=2
  1. S IBPTNM=$P($G(^DPT(+$P($G(^DGCR(399,IBIFN,0)),U,2),0)),U) I IBPTNM="" S IBPTNM="UNKNOWN"
  1. S IBSRVC=$P($G(^DGCR(399,IBIFN,"U")),U)
  1. ; IB*2.0*547 - added primary insurance as a possible sort, had to split into 2 lines (too long)
  1. S Z0=$S(IBSRT="B":IBMUT,IBSRT="D":-IBDAY,IBSRT="I":$P(IBINS2,U,2)_"~"_$P(IBINS2,U),IBSRT="M":$$EXTERNAL^DILFD(361.1,.13,"",$P(IB3611,"^",13)),IBSRT="R":-IBPTRSP,IBSRT="P":IBPTNM,IBSRT="S":+IBSRVC,1:+IBDT)
  1. S:IBSRT="K" Z0=$P($G(^DIC(36,+IBNDI1,0)),U)_"~"_+IBNDI1
  1. S:((IBSRT="M")&(Z0="")) Z0="UNKNOWN" ;USE UNKNOWN IF NOT SET - BI;IB*2.0*432
  1. ;
  1. ; MRD;IB*2.0*516 - Added Division as a subscript.
  1. ;S ^TMP("IBCOBST",$J,Z0,IBIFN)=IBSRVC_U_IBOAM_U_IBAPY_U_$S(IBNBAL>0:IBNBAL,1:0)_U_$P(IBB,U,5)_U_$P(IBB,U,19)_U_IBBPY_U_$P(IBMUT,"~")_U_IBINS_U_$G(IBDA)_U_$$HIS(IBIFN)_U_$G(IBDAY)_U_$G(IBDT)_U_IBQ_U_$G(IB364)_U_IBSEQ_U_$G(IBEXPY)_U_IBPTRSP
  1. ;S ^TMP("IBCOBST",$J,Z0,IBIFN,1)=$S($G(IB3611)="":"No EEOB Received ",1:$$EXTERNAL^DILFD(361.1,.13,"",$P(IB3611,"^",13))_", "_$$FMTE^XLFDT($P($P(IB3611,"^",6),"."))_"^"_$P(IB3611,"^",16))
  1. S ^TMP("IBCOBST",$J,IBDIV,Z0,IBIFN)=IBSRVC_U_IBOAM_U_IBAPY_U_$S(IBNBAL>0:IBNBAL,1:0)_U_$P(IBB,U,5)_U_$P(IBB,U,19)_U_IBBPY_U_$P(IBMUT,"~")_U_IBINS_U_$G(IBDA)_U_$$HIS(IBIFN)_U_$G(IBDAY)_U_$G(IBDT)_U_IBQ_U_$G(IB364)_U_IBSEQ_U_$G(IBEXPY)_U_IBPTRSP
  1. S ^TMP("IBCOBST",$J,IBDIV,Z0,IBIFN,1)=$S($G(IB3611)="":"No EEOB Received ",1:$$EXTERNAL^DILFD(361.1,.13,"",$P(IB3611,"^",13))_", "_$$FMTE^XLFDT($P($P(IB3611,"^",6),"."))_"^"_$P(IB3611,"^",16))
  1. S ^TMP("IBCOBSTX",$J,IBIFN)=$G(IBDA) ;keep track of compiled IBIFN's
  1. ;
  1. ; Save some data when there are multiple MRA's on file for this bill
  1. S IBMRACNT=$$MRACNT^IBCEMU1(IBIFN,$G(IBMRANOT)) ;WCJ IB*2.0*432
  1. ; MRD;IB*2.0*516 - Added Division as a subscript.
  1. ;I IBMRACNT>1 S $P(^TMP("IBCOBST",$J,Z0,IBIFN,1),U,1)="Multiple "_$S($G(IBMRANOT):"EOBs",1:"MRA's")_" on file" ;WCJ IB*2.0*432
  1. ;S $P(^TMP("IBCOBST",$J,Z0,IBIFN,1),U,3)=IBMRACNT
  1. ;S $P(^TMP("IBCOBST",$J,Z0,IBIFN,1),U,4)=$G(IBDENDUP)
  1. ;S:$G(IBDA)'="" $P(^TMP("IBCOBST",$J,Z0,IBIFN,1),U,4)=$$DENDUP^IBCEMU4(IBDA,1)
  1. I IBMRACNT>1 S $P(^TMP("IBCOBST",$J,IBDIV,Z0,IBIFN,1),U,1)="Multiple "_$S($G(IBMRANOT):"EOBs",1:"MRA's")_" on file" ;WCJ IB*2.0*432
  1. S $P(^TMP("IBCOBST",$J,IBDIV,Z0,IBIFN,1),U,3)=IBMRACNT
  1. S $P(^TMP("IBCOBST",$J,IBDIV,Z0,IBIFN,1),U,4)=$G(IBDENDUP)
  1. S:$G(IBDA)'="" $P(^TMP("IBCOBST",$J,IBDIV,Z0,IBIFN,1),U,4)=$$DENDUP^IBCEMU4(IBDA,1)
  1. Q
  1. ;
  1. HIS(IBIFN) ; COB history
  1. N A,B,IBST,IBBIL,IBHIS
  1. S IBHIS="",A=0 F S A=$O(^IBM(361.1,"ABS",IBIFN,A)) Q:'A S B=0 F S B=$O(^IBM(361.1,"ABS",IBIFN,A,B)) Q:'B D
  1. . S IBST=$P($G(^IBM(361.1,B,0)),U,4),IBBIL=$P($G(^DGCR(399,IBIFN,"M1")),U,4+A) ;WCJ IB*2.0*432 added $G
  1. . Q:IBBIL=""
  1. . S IBHIS=IBHIS_$S(IBHIS="":"",1:";")_$S(A=1:"PRIMARY",A=2:"SECONDARY",1:"TERTIARY")_" "_$S(IBST:"MRA",1:"EOB")_" RECEIVED - "_IBBIL
  1. I '$D(^IBM(361.1,"ABS",IBIFN)) F A=1:1:3 S IBBIL=$P($G(^DGCR(399,IBIFN,"M1")),U,4+A) I IBBIL'="" S IBHIS=IBHIS_$S(IBHIS="":"",1:";")_$S(A=1:"PRIMARY",A=2:"SECONDARY",A=3:"TERTIARY",1:"UNKNOWN")_" No EOB RECEIVED - "_IBBIL
  1. Q IBHIS
  1. ;
  1. MELG(IBIFN,IBMRADUP) ; function to check all EOBs for a claim and determine if they are
  1. ; eligible for inclusion on the COB management worklist, uses both B & C x-ref
  1. ; IBIFN - claim ien (required)
  1. ; IBMRADUP - indicates user said NO to "include denied for duplicate" prompt
  1. ;
  1. ; Returns EOB ien to use for display, if at least 1 EOB passed all checks
  1. ; if multiple EOBs passed but some have filing errors, returns the 1st EOB found that does NOT have filing errors
  1. ; if all EOBs have filing errors, tries to find one that is a PROCESSED status and return that one for CBW display
  1. ; Returns -1 if claim should appear on the worklist with no EOB
  1. ; Returns 0 if no EOBs passed the checks and claim should not appear on the worklist, also removes it
  1. ;
  1. ; IBCK = Total number of EOBs found for this claim ien
  1. ; IBECT = Total number of EOBs that failed the EOB TYPE check
  1. ; IBCT = Total number of EOBs for a claim that passed ALL the checks
  1. ;
  1. N IBDA,IBCT,IBEOBNDX,IBEOB,IB3611,IBCK,IBETC
  1. S IBCT=0,IBCK=0,IBETC=0
  1. F IBEOBNDX="B","C" D
  1. .S IBDA=0 F S IBDA=$O(^IBM(361.1,IBEOBNDX,IBIFN,IBDA)) Q:'+IBDA D
  1. ..Q:$D(IBEOB(IBDA))
  1. ..S IB3611=$G(^IBM(361.1,IBDA,0)),IBCK=IBCK+1
  1. ..;Q:$D(^IBM(361.1,IBDA,"ERR")) ;TPF;EBILL-2436;IB*2.0*727 ALLOW EOB CLAIMS WITH MSE TO BE DISPLAYED AGAIN ON CBW
  1. ..; if this is a denied EOB and user does NOT want to include denied as duplicates and this EOB was denied as duplicate, don't include
  1. ..I $P(IB3611,U,13)=2,'$G(IBMRADUP),$$DENDUP^IBCEMU4(IBDA,1) Q
  1. ..; eob type must be correct for this worklist
  1. ..I $P(IB3611,U,4)=1 S IBETC=IBETC+1 Q
  1. ..; allow filing errors on worklist, but try to find at least 1 Processed EOB w/out errors
  1. ..I $D(^IBM(361.1,IBDA,"ERR")) S:$P($G(^IBM(361.1,IBDA,0)),U,13)'=1 IBEOB("DER",IBDA)="" S:$P($G(^IBM(361.1,IBDA,0)),U,13)=1 IBEOB("PER",IBDA)="" Q
  1. ..S IBEOB(IBDA)="",IBCT=IBCT+1
  1. ; if no EOB was found to check, return -1 to process as no EOB
  1. Q:IBCK=0 -1
  1. ; if no EOB passed, check to see if the EOBs were all MRA primaries that failed the EOB type check (2ndary/tertiaries were paper)
  1. I IBCT=0,$$WNRBILL^IBEFUNC(IBIFN,1),$$COBN^IBCEF(IBIFN)>1,(IBCK=IBETC) Q -1
  1. ; if no EOB's passed, check for filing errors and use that EOB, with Processed EOB's taking priority over denied
  1. I IBCT=0,$D(IBEOB("PER")) Q $O(IBEOB("PER",0))
  1. I IBCT=0,$D(IBEOB("DER")) Q $O(IBEOB("DER",0))
  1. ; if no EOB passed and not MRA primary w/subsequent paper EOB's or filing errors, do not put on CBW
  1. Q:IBCT=0 0
  1. ; if one or more EOBs passed, return the 1st one that passed the checks as the one to use for CBW display
  1. Q $O(IBEOB(0))
  1. ;
  1. RMV(DA) ;remove from worklist claims that are erroneously there
  1. N DIE,DR
  1. S DIE="^DGCR(399,",DR="35////@" D ^DIE ; Should never have been on the WORKLIST
  1. Q
  1. ;
  1. FILERR(IBIFN) ; function to check EOBs for a claim to see if any had filing errors.
  1. ; IBIFN - claim ien (required)
  1. ;
  1. ; Returns 0 if none of EOBs had filing errors
  1. ; Returns 1 if at lease one of EOBs had filing errors
  1. ;
  1. N IBDA,IBEOBNDX,IBEOB,IB3611,IBFILERR
  1. S IBFILERR=0
  1. F IBEOBNDX="B","C" D
  1. . S IBDA=0 F S IBDA=$O(^IBM(361.1,IBEOBNDX,IBIFN,IBDA)) Q:'+IBDA D Q:IBFILERR
  1. .. Q:$D(IBEOB(IBDA))
  1. .. S IBEOB(IBDA)=""
  1. .. S IB3611=$G(^IBM(361.1,IBDA,0))
  1. .. ; I $P(IB3611,U,4)=1 Q ; don't care about MRAs ; I take that back, I do care about MRAs
  1. .. I ".1.2."'[("."_$P(IB3611,U,13)_".") Q ; only care if processed (1) or denied (2)
  1. .. I $D(^IBM(361.1,IBDA,"ERR")) S IBFILERR=1 Q
  1. Q IBFILERR