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

IBFBNP1.m

Go to the documentation of this file.
  1. IBFBNP1 ;ALB/RED- EDI-CPAC build 1st and 3rd party copayments ;10/01/15
  1. ;;2.0;INTEGRATED BILLING;**554**;21-MAR-94;Build 81
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. Q
  1. NRUN ; main entry point - nightly run job to look at existing FB payments and add/edit entries in file #360
  1. ;Start by looking for recent FB payments
  1. ;
  1. N FBSITE,IBVEN,IBSERVDT,IBCATC,IBSITE,IBMTC,FBARRLTC,IBDTPD,IBDUZ,IBREC,IBRECZ,IBDOS,IBTYP,IBADMDT,OTPTBIL,IBSTDT
  1. N IBBILL,IBCLAIM,IBFBDT,IBIENS,IBLOG,IENROOT,IENS,IBSERV,FRSTPRT,IBFBINS,IBDOST,FBA,FBC,IBCARETY,DFN,%,FBSITE
  1. S FBARRLTC="" D MKARRLTC^FBPCR4 ;build array needed later for POV in LTC co-pay
  1. S (IBCATC,IBMTC,FRSTPRT)=0 ;(CAT C FLAG and IBMTC = Determine if patient is pending adjudication or category C and has agreed to pay the deductible
  1. ;
  1. D SITE^FBAACO S IBSITE=$P(FBSITE(1),U,3)
  1. ;S IBN=$$PT^IBEFUNC(IBDFN) D UTIL^IBCA3,UTIL^IBOA32 ; check for all outstanding bills, build ^UTILITY($J
  1. S IBSTDT=$P(^IBE(350.9,1,7),U,2)\1-1 ; set to last time Autobiller was ran -1 day (MOVED TO NODE 7, PIECE 2)
  1. I IBSTDT<1 S IBSTDT=$$FMADD^XLFDT(DT,-5) ;default to today-5 if not set
  1. F S IBSTDT=$O(^FBAAC("AK",IBSTDT)) Q:'IBSTDT D PAYMT
  1. Q
  1. PAYMT ;
  1. N DFN,IBAUTH,IBPOV,IBINV
  1. S (DFN,IBPOV,IBINV,IBDOS,IBCARETY)=0 F S DFN=$O(^FBAAC("AK",IBSTDT,DFN)) Q:'DFN D
  1. . S IBVEN=0 F S IBVEN=$O(^FBAAC("AK",IBSTDT,DFN,IBVEN)) Q:'IBVEN D
  1. .. S IBSERVDT=0 F S IBSERVDT=$O(^FBAAC("AK",IBSTDT,DFN,IBVEN,IBSERVDT)) Q:'IBSERVDT D
  1. ... S IBSERV=0 F S IBSERV=$O(^FBAAC("AK",IBSTDT,DFN,IBVEN,IBSERVDT,IBSERV)) Q:'IBSERV D
  1. .... ; Set the temporary payment array to service date and the zero node (IBFB=patient;vendor;service prov IEN;service date IEN), Auth, Invoice and POV
  1. .... Q:$G(^FBAAC(DFN,1,IBVEN,1,IBSERVDT,1,IBSERV,0))="" ; quit if the zero node of the payment is undefined
  1. .... Q:$G(^FBAAC(DFN,1,IBVEN,1,IBSERVDT,1,IBSERV,"FBREJ"))]"" ;payment was rejected
  1. .... S IBDTPD=$$GET1^DIQ(162.03,IBSERV_","_IBSERVDT_","_IBVEN_","_DFN_",",12,"I")
  1. .... Q:'IBDTPD ; quit if the date paid is NULL/Empty
  1. .... S IBDOS=$$GET1^DIQ(162.02,IBSERVDT_","_IBVEN_","_DFN_",",.01,"I")
  1. .... S IBAUTH=$$GET1^DIQ(162.03,IBSERV_","_IBSERVDT_","_IBVEN_","_DFN_",",15.5,"I") ; New location as per FB*3.5*154
  1. .... S IBTYP=$$GET1^DIQ(162.03,IBSERV_","_IBSERVDT_","_IBVEN_","_DFN_",",27,"I") I $G(IBTYP)["7078" S IBADMDT=$P($G(^FB7078(+IBTYP,0)),U,15) ; Find admission date
  1. .... S IBINV=$$GET1^DIQ(162.03,IBSERV_","_IBSERVDT_","_IBVEN_","_DFN_",",14,"I")
  1. .... Q:'IBINV ;Quit if there is no Invoice for this record
  1. .... S IBCARETY=$$GET1^DIQ(162.03,IBSERV_","_IBSERVDT_","_IBVEN_","_DFN_",",23,"I") ;Fee Program pointer to #161.8
  1. .... I "^2^3^6^7^"'[IBCARETY Q ;Fee Program categories
  1. .... S IBPOV=$$GET1^DIQ(162.03,IBSERV_","_IBSERVDT_","_IBVEN_","_DFN_",",16,"I")
  1. .... Q:'IBPOV
  1. .... S IBCATC=$$CATC^FBPCR(DFN,IBDOS,IBPOV) ;determine 3rd party copayment requirements
  1. .... S IBFBINS=$$INSURED^IBCNS1(DFN,IBDOS) ; Check for active insurance as per date of service
  1. .... D ADMIT,CHKOTPT,FILE
  1. Q
  1. ;
  1. ADMIT ; check for inpatient 1st party bills
  1. Q:$G(IBADMDT)=""
  1. S IBBILL=0
  1. K ^TMP("IBRBF",$J) ; kill of temp global before call
  1. D FPINPT^IBEFURF(DFN,IBADMDT)
  1. S IBBILL=$O(^TMP("IBRBF",$J,"FP",0))
  1. K ^TMP("IBRBF",$J)
  1. Q
  1. ;
  1. ;
  1. FILE ; check payment against file #360
  1. ;
  1. N FDA,IBEDIT,IBRECZ,IBOAUTH,IBOCLM,IBOBILL,IBFLAG
  1. S (IBOAUTH,IBEDIT,IBREC,IBFLAG,IENS,IBCLAIM)=0,IBBILL=$G(IBBILL)
  1. I $G(IBAUTH)="" S IBAUTH="0"
  1. ; check to see if the patient has that invoice, if so use that record
  1. I IBINV,$D(^IBFB(360,"F",DFN,IBINV)) S IBREC=$O(^IBFB(360,"F",DFN,IBINV,0)) ;Check patient and invoice xref for existing record
  1. ;
  1. ; check to see if there is a record existing with no Auth that we can link to properly
  1. I 'IBAUTH,$D(^IBFB(360,"C",DFN)) D
  1. . S IBRECZ=0 ; set a temporary record number to check against former records by looping through "C" xref
  1. . F S IBRECZ=$O(^IBFB(360,"C",DFN,IBRECZ)) Q:IBRECZ="" D
  1. .. S IBOCLM=$P($G(^IBFB(360,IBRECZ,1)),U) ;Claim IEN exists for this record
  1. .. S IBOBILL=$P($G(^IBFB(360,IBRECZ,1)),U,4) ; Bill IEN exists for this record
  1. .. I IBOCLM!IBOBILL S IBREC=IBRECZ,IBRECZ="a" Q ;Found a record to edit, set missing Auth to zero and quit
  1. .. Q
  1. ;
  1. I ('FRSTPRT&'IBFBINS)!('IBCATC&'IBFBINS) Q ; Quit if no insurance and not Cat C or First party
  1. ;
  1. ; edit an existing record
  1. I IBREC D
  1. . K FDA
  1. . ; S IBCLAIM=+$$GET1^DIQ(360,IBREC_",",1.01,"I")
  1. . ; D STUB ;check/create stub record in file #356
  1. . I $$GET1^DIQ(360,IBREC_",",1.03,"I")="" S FDA(360,IBREC_",",1.03)=$G(IBINV) ;Invoice number
  1. . I $$GET1^DIQ(360,IBREC_",",.05,"I")="" S FDA(360,IBREC_",",.05)=IBDOS ;Initial treatment date
  1. . I IBBILL,$$GET1^DIQ(360,IBREC_",",1.04,"I")="" S FDA(360,IBREC_",",1.04)=IBBILL ;1st Party Co-pay - Admission
  1. . ; I IBCLAIM,$$GET1^DIQ(360,IBREC_",",1.01,"I")'=IBCLAIM S FDA(360,IBREC_",",1.01)=IBCLAIM ;Claim number
  1. . I $$GET1^DIQ(360,IBREC_",",2.03,"I")="" S FDA(360,IBREC_",",2.03)="FR" ;Set facility revenue worklist queue
  1. . Q:'$D(FDA)
  1. . S IBFLAG=1 ; flag used for log file
  1. . D UPDATE^DIE("","FDA")
  1. . I 'IBCATC S IBBILL=$$GET1^DIQ(360,IBREC_",",1.04,"I") I IBBILL D SETOTPT
  1. .;
  1. ;
  1. ; if the patient or the Invoice isn't present add a new record
  1. I 'IBREC D
  1. . K FDA,IENROOT
  1. . S IBFLAG=1 ; flag used for log file
  1. . S IBIENS="+1,",IENS=$P(^IBFB(360,0),U,3)+1
  1. . S FDA(360,IBIENS,.01)=IENS,FDA(360,IBIENS,.02)=$G(DFN),FDA(360,IBIENS,.03)=$G(IBAUTH)
  1. . S FDA(360,IBIENS,1.03)=$G(IBINV),FDA(360,IBIENS,.05)=IBDOS ;Invoice, Initial treatment date
  1. . I IBBILL S FDA(360,IBIENS,1.04)=IBBILL ;1st Party Co-pay - Admission
  1. . I OTPTBIL S FDA(360,IBIENS,1.04)=OTPTBIL ;1st Party Co-pay - outpt
  1. . S FDA(360,IBIENS,2.03)="FR" ;Set facility revenue worklist queue
  1. . S (IENROOT,IENROOT(1))="" ; adding new entry)
  1. . D UPDATE^DIE("","FDA","IENROOT")
  1. . I IENROOT(1)'="" S IBREC=IENROOT(1)
  1. . ; D STUB K FDA
  1. . ; S FDA(360,IBREC_",",1.01)=IBCLAIM
  1. . ; D UPDATE^DIE("","FDA")
  1. I IBREC,'FRSTPRT D
  1. . Q:$P($G(^IBFB(360,IBREC,3)),U,2)=3
  1. . K FDA
  1. . S IBFLAG=1 ; flag used for log file
  1. . S FDA(360,IBREC_",",3.02)=3
  1. . D UPDATE^DIE("","FDA")
  1. ;
  1. I FRSTPRT D
  1. . Q:$P($G(^IBFB(360,IBREC,3)),U,2)=1
  1. . K FDA
  1. . S IENROOT="",IBFLAG=1 ; flag used for log file
  1. . S FDA(360,IBREC_",",3.02)=1
  1. . D UPDATE^DIE("","FDA","IENROOT")
  1. ;
  1. I IBBILL!(OTPTBIL) D ; set pointer for Inpt or outpt 1st party copay
  1. . I IBBILL Q:$P(^IB(IBBILL,0),U,23)=IBREC ; exists and valid
  1. . I OTPTBIL Q:$P(^IB(OTPTBIL,0),U,23)=IBREC
  1. . K FDA
  1. . S IBFLAG=1 ; flag used for log file
  1. . ;S FDA(350,IBBILL_",",.23)=IBREC ; set Non-Va Care value to the pointer to file 360
  1. . D UPDATE^DIE("","FDA")
  1. ;
  1. LOG ; set log (audit) file entries
  1. N FDA,IBEVENT,IBMOD,IBDUZ
  1. Q:'IBFLAG ;No changes were made
  1. D NOW^%DTC S IBFBDT=%
  1. S IBMOD=0,IBDUZ=$G(DUZ) I $G(IBDUZ)="" S IBDUZ=".5" ; Set user to postmaster (if ran via taskman)
  1. S FDA(360.04,"+1,"_IBREC_",",.01)=IBFBDT,FDA(360.04,"+1,"_IBREC_",",.03)=$G(IBDUZ)
  1. S IBMOD=0,IBLOG=$P($G(^IBFB(360,IBREC,4,0)),U,3)+1
  1. I IBLOG="" S IBMOD=1
  1. S IBEVENT=$S(IBMOD=0:"Auth log-FR queue",1:"Auth mod-FR queue"),FDA(360.04,"+1,"_IBREC_",",.02)=IBEVENT
  1. D UPDATE^DIE("","FDA")
  1. Q
  1. ;
  1. STUB ; look for third party claim pointer in file #356
  1. Q ;REMOVE SUBROUTINE
  1. K IENROOT
  1. I IBCLAIM,$$GET1^DIQ(360,IBREC_",",1.03,"I")'=IBINV S IBCLAIM=0 ;1 invoice per claim
  1. I IBCLAIM,$D(^IBFB(360,"AD",IBCLAIM)),$O(^IBFB(360,"AD",IBCLAIM,0))'=IBREC S IBCLAIM=0 ;Claim already exists for another record
  1. I 'IBCLAIM!($$GET1^DIQ(356,IBCLAIM_",",.33,"I")="") D Q ; invalid pointer to file #356 or it's not present (add if needed)
  1. . K FDC,ZIENS,ZIEN
  1. . I 'IBCLAIM S ZIENS="+1,",ZIEN=$P(^IBT(356,0),U,3)+1,IENROOT="" D
  1. .. S FDC(356,ZIENS,.01)=IBSITE_ZIEN,FDC(356,ZIENS,.02)=DFN ;IEN and Patient
  1. .. S FDC(356,ZIENS,.06)=IBDOS,FDC(356,ZIENS,.2)=1 ;Date of service and Active
  1. . ;Edit an existing claim with no pointer
  1. . I IBCLAIM S ZIENS=IBCLAIM_","
  1. . S FDC(356,ZIENS,.33)=IBREC ;Link back to file #360 (IB-FB INTERFACE TRACKING FILE)
  1. . I IBCARETY D
  1. .. I IBCARETY=2 S FDC(356,ZIENS,.18)=6 Q ;Outpatient
  1. .. I IBCARETY=3 S FDC(356,ZIENS,.18)=8 Q ;Pharmacy
  1. .. I IBCARETY=6!(IBCARETY=7) S FDC(356,ZIENS,.18)=7 Q ;Inpatient
  1. . I IBCLAIM D UPDATE^DIE("","FDC") ;edit
  1. . I 'IBCLAIM D
  1. .. D UPDATE^DIE("","FDC","IENROOT")
  1. .. I IENROOT(1)'="" S IBCLAIM=IENROOT(1) ;New
  1. Q
  1. ;
  1. SETOTPT ; Look for first party claim pointer in file #360 to an exist Bill IEN
  1. N FDA
  1. ;
  1. Q:'$D(^IB(IBBILL,0)) ; invalid pointer to file #350 or it's not present
  1. ;Q:$P(^IB(IBBILL,0),U,23)=IBREC ; pointer is present and valid
  1. ;S FDA(350,IBBILL_",",.23)=IBREC ; set Non-Va Care value to the pointer to file 360
  1. D UPDATE^DIE("","FDA")
  1. Q
  1. ;
  1. CHKOTPT ; check for Outpatient 1st party bills
  1. K ^TMP("IBRBF",$J) ; kill of temp global before call
  1. S (FRSTPRT,OTPTBIL)=0
  1. D FPOPV^IBEFURF(DFN,IBDOS) Q:'$D(^TMP("IBRBF",$J))
  1. S OTPTBIL=$O(^TMP("IBRBF",$J,"FP",0)),FRSTPRT=1 ;set outpt 1st party copay IEN and first party flag
  1. K ^TMP("IBRBF",$J)
  1. ;
  1. ;END OF IBFBNP1