IBCNEDST ;ALB/YMG - HL7 Registration Message Statistics ; 07-MAR-2013
;;2.0;INTEGRATED BILLING;**497,506,549,595,659,664,668,702,737**;21-MAR-94;Build 19
;;Per VA Directive 6402, this routine should not be modified.
;
Q
;
GETSTAT2() ;EP
; IB*2.0*549 - Added method
; Get additional IB Site Parameter fields
; Input: None
; Output: A1^A2^A3^A4^A5 - Where:
; A1 - 350.9, 51.27 - 270 MASTER SWITCH REALTIME
; A2 - 350.9, 51.28 - 270 MASTER SWITCH NIGHTLY
; A3 - 350.9, 51.15 - HL7 MAXIMUM NUMBER
; A4 - 350.9002, .05 - MAXIMUM EXTRACT NUMBER (appt)
; A5 - 350.9002, .05 - MAXIMUM EXTRACT NUMBER (buffer)
; A6 - 350.9, 51.32 - MEDICARE FRESHNESS DAYS ;/vd - IB*2*659
;
N DATA,XX
S DATA=$$GET1^DIQ(350.9,"1,",51.27,"I") ; 270 Master Switch Realtime
S $P(DATA,"^",2)=$$GET1^DIQ(350.9,"1,",51.28,"I") ; 270 Master Switch Nightly
S $P(DATA,"^",3)=$$GET1^DIQ(350.9,"1,",51.15,"I") ; HL7 Maximum Number
S XX=$O(^IBE(350.9,1,51.17,"B",2,"")) ; Find Appointment multiple
S XX=$$GET1^DIQ(350.9002,XX_",1,",.05,"I") ; Maximum Appointment Extract
S $P(DATA,"^",4)=XX
S XX=$O(^IBE(350.9,1,51.17,"B",1,"")) ; Find Buffer multiple
S XX=$$GET1^DIQ(350.9002,XX_",1,",.05,"I") ; Maximum Buffer Extract
S $P(DATA,"^",5)=XX
S $P(DATA,"^",6)=$$GET1^DIQ(350.9,"1,",51.32,"I") ; MEDICARE Freshness Days ;/vd - IB*2*659
Q DATA
;
GETSTAT(MCAUTO) ; get statistical data
; Statistics are to match the eIV Statistical Report (^IBCNEPR8)
; IB*664/DW Added parameter "MCAUTO" - this will be used to split out the count of
; Medicare auto-updated responses from the all other eIV responses that
; were auto updated. We now have two calculated totals. Medicare and
; not Medicare eIV responses that were auto-updated.
;
; returns the following string, delimited by "^":
;
; piece 1 - Number of patients with potential secondary/tertiary insurance as identified by Medicare
; piece 2 - Number of automatically updated patient insurance records processed yesterday only
; piece 3 - Number of 270 inquiries pending receipt of 271 responses
; piece 4 - Number of queued 270 inquiries
; piece 5 - Number of deferred 270 inquiries
; piece 6 - Number of insurance companies with no National ID
; piece 7 - Number of locally disabled payers
; piece 8 - Number of Verified (*) buffer entries ; IB*737/DTG will be zero, not use '*' verified
; piece 9 - Number of buffer entries indicated as having Active insurance (+)
; piece 10 - Number of buffer entries indicated as having Inactive insurance (-)
; piece 11 - Number of buffer entries indicated as policy status undetermined (#)
; piece 12 - Number of buffer entries indicated as requiring correction before 270 can be sent (!)
; piece 13 - Number of buffer entries awaiting processing
; piece 14 - Number of buffer entries indicated as waiting for a 271 response (?)
; piece 15 - Number of buffer entries entered by manual process with no further processing (blank)
; piece 16 - Number of unlinked insurance companies
;
N BUFINFO,PAYINFO,RESPINFO,STARTDTTM,TQINFO,STATS
;
S STARTDTTM=$$FMADD^XLFDT($$NOW^XLFDT(),,-24) ; set to current date/time - 24 hours
; IB*664/DW Added parameter "MCAUTO" to line below
S RESPINFO=$$RESPINFO(STARTDTTM,.MCAUTO) ; get data from file 365
S TQINFO=$$TQINFO() ; get data from file 365.1
S PAYINFO=$$PAYINFO() ; get data from file 36 & 365.12
S BUFINFO=$$BUFINFO() ; get data from file 355.33
S STATS=RESPINFO_U_TQINFO_U_$P(PAYINFO,U)_U_$P(PAYINFO,U,2)
S STATS=STATS_U_BUFINFO_U_$P(PAYINFO,U,3)
Q STATS
;
RESPINFO(DTTM,MCAUTO) ; get data from IIV Response file (file 365)
; DTTM - start date/time
; MCAUTO - total # of auto-updated eIV responses that ARE Medicare related
; IB*664/DW Added parameter "MCAUTO"
;
; returns the following string, delimited by "^":
; piece 1: number of patients with potential secondary/tertiary insurance as identified by Medicare
; piece 2: Number of automatically updated patient insurance records processed yesterday only
; piece 3: Number of 270 inquiries pending receipt of 271 responses
;
; also returns MCAUTO - # of eIV responses from the Medicare payer that were auto-updated
;
N AUTOUPD,DATE,DFN,EBIEN,IEN,INSNAMES,INSTYPE,INQP,POLICY,PAYER,PAYERWNR,PYRNAME,SECINS,Z
; IB*2.0*702/DTG- start Added number of outgoing EICD (A1) 270 transactions.
; Number of outgoing EICD-triggered (A2) 270 transactions.
; Number of outgoing MBI Request 270 transactions.
; Number of incoming MBI positive responses that indicated as having returned the MBI (%).
N IB1P,IB2D,IB3IEN,IBA1,IBA2,IB40,IBTQ,IBTYP,IBQRY,IBAT1,IBAT2,IBSID,IBMBI,IBMBS
S (IB1P,IB2D,IB3IEN,IBA1,IBA2,IB40,IBAT1,IBAT2,IBMBI,IBMBS)=""
S DSTATPA=$G(DSTATPA),DSTATI=$G(DSTATI)
; IB*2.0*702/DTG - end Added
S SECINS=0
S PAYERWNR=$P($G(^IBE(350.9,1,51)),U,25) ; get Medicare payer ien from IB site parameters
;
; IB*664/DW - Added 1st 3 parameters to PATINFO, changed from extrinsic function
D PATINFO(.AUTOUPD,PAYERWNR,.MCAUTO) ; IB*2*595/DM rewrote PATINFO
S DATE=DTTM-0.000001 F S DATE=$O(^IBCN(365,"AD",DATE)) Q:DATE="" D
.;IB*2*595/DM next 4 lines no longer applicable
.; if response received within the last 24 hrs, check if it auto-updated insurance policy
.;S PAYER=0 F S PAYER=$O(^IBCN(365,"AD",DATE,PAYER)) Q:PAYER="" D
.;.S DFN=0 F S DFN=$O(^IBCN(365,"AD",DATE,PAYER,DFN)) Q:DFN="" S AUTOUPD=AUTOUPD+$$PATINFO(DFN)
.;.Q
.I PAYERWNR,$D(^IBCN(365,"AD",DATE,PAYERWNR)) D
..S DFN=0 F S DFN=$O(^IBCN(365,"AD",DATE,PAYERWNR,DFN)) Q:DFN="" D
...; create array of ins. company names for this patient (active policies only)
...K INSNAMES S INSTYPE=0 F S INSTYPE=$O(^DPT(DFN,.312,"B",INSTYPE)) Q:INSTYPE="" D
....S POLICY=0 F S POLICY=$O(^DPT(DFN,.312,"B",INSTYPE,POLICY)) Q:POLICY="" D
.....; skip policies that are not active
.....I $$CHK^IBCNS1(^DPT(DFN,.312,POLICY,0),DT,1) S INSNAMES($$EXTERNAL^DILFD(2.312,.01,,INSTYPE))=""
.....Q
....Q
...S IEN=0 F S IEN=$O(^IBCN(365,"AD",DATE,PAYERWNR,DFN,IEN)) Q:IEN="" D
....S Z="" F S Z=$O(^IBCN(365,IEN,2,"B",Z)) Q:Z="" D
.....S EBIEN=$O(^IBCN(365,IEN,2,"B",Z,""))
.....; make sure eligibility code is "R"
.....I $$GET1^DIQ(365.02,EBIEN_","_IEN_",",.02)'="R" Q
.....S PYRNAME=$E($P($G(^IBCN(365,IEN,2,EBIEN,3)),U,3),1,30) ; grab first 30 chars to compare to 36/.01
.....I PYRNAME'="",'$D(INSNAMES(PYRNAME)) S SECINS=SECINS+1
. ; IB*2.0*702/DTG- start Added number of outgoing EICD (A1) 270 transactions. number of outgoing EICD-triggered (A2) 270 transactions
. ; number of outgoing MBI Request 270 transactions
. I $G(DSTATI)=1 D ;<
. . S IB1P="" F S IB1P=$O(^IBCN(365,"AD",DATE,IB1P)) Q:IB1P="" S IB2D="" D ;<
. . . F S IB2D=$O(^IBCN(365,"AD",DATE,IB1P,IB2D)) Q:IB2D="" S IB3IEN="" D ;<
. . . . F S IB3IEN=$O(^IBCN(365,"AD",DATE,IB1P,IB2D,IB3IEN)) Q:IB3IEN="" D ;<
. . . . . S IENS=IB3IEN_"," K IB40 D GETS^DIQ(365,IENS,"13.02;.05;.1","IE","IB40")
. . . . . I $G(IB40(365,IENS,.1,"I"))'="O" Q
. . . . . S IBSID=$G(IB40(365,IENS,13.02,"I"))
. . . . . S IBTQ=$G(IB40(365,IENS,.05,"I"))
. . . . . S IBTYP=$$GET1^DIQ(365.1,IBTQ_",",.1,"I"),IBQRY=$$GET1^DIQ(365.1,IBTQ_",",.11,"I")
. . . . . ; IBMBI - Number of incoming MBI positive responses that indicated as having returned the MBI (%)
. . . . . I IBTYP=7&(IBSID'="") S IBMBI=$G(IBMBI)+1 Q
;
I $G(DSTATI)=1 D ;<
. S DATE=DTTM-0.000001 F S DATE=$O(^IBCN(365,"AE",DATE)) Q:DATE="" D ;<
. . S IB3IEN="" F S IB3IEN=$O(^IBCN(365,"AE",DATE,IB3IEN)) Q:IB3IEN="" D ;<
. . . S IENS=IB3IEN_"," K IB40 D GETS^DIQ(365,IENS,"13.02;.05;.1","IE","IB40")
. . . I $G(IB40(365,IENS,.1,"I"))'="O" Q
. . . S IBSID=$G(IB40(365,IENS,13.02,"I"))
. . . S IBTQ=$G(IB40(365,IENS,.05,"I"))
. . . S IBTYP=$$GET1^DIQ(365.1,IBTQ_",",.1,"I"),IBQRY=$$GET1^DIQ(365.1,IBTQ_",",.11,"I")
. . . ; IBA1 - Number of outgoing EICD (A1) 270 transactions
. . . ; IBA2 - Number of outgoing EICD-triggered (A2) 270 transactions
. . . ; IBMBS - Number of outgoing MBI Request 270 transactions
. . . I IBTYP=7 S IBMBS=$G(IBMBS)+1 Q
. . . I IBTYP=4 S:IBQRY="I" IBA1=$G(IBA1)+1 S:IBQRY="V" IBA2=$G(IBA2)+1
. . ; IB*2.0*702/DTG - end Added
;
; IB*2.0*702/DTG - start Added
I $G(DSTATI)=1 S DSTAT3=+$G(IBA1)_DSTATPA_+$G(IBA2)_DSTATPA_+$G(IBMBS)_DSTATPA_+$G(IBMBI)
; IB*2.0*702/DTG - end Added
;
; Number of 270 inquiries pending receipt of 271 responses
S (INQP,IEN)=0 F S IEN=$O(^IBCN(365,"AC",2,IEN)) Q:'IEN D ; Transmitted status = 2
. S INQP=INQP+1
Q SECINS_U_AUTOUPD_U_INQP
;
;PATINFO() was fully replace for IB*2*595/DM
;PATINFO(DFN) ; get data from pat. insurance multiple (file 2.312)
;; DFN - file 2 ien
;;
;; returns
;; number of automatically updated patient insurance records for a given patient within last 24 hours
;;
;N AUTOUPD,INSTYPE,POLICY
;I 'DFN Q
;S AUTOUPD=0
;S INSTYPE=0 F S INSTYPE=$O(^DPT(DFN,.312,"B",INSTYPE)) Q:INSTYPE="" D
;.S POLICY=0 F S POLICY=$O(^DPT(DFN,.312,"B",INSTYPE,POLICY)) Q:POLICY="" D
;..; if DATE LAST VERIFIED is no more than one day old and EIV AUTO-UPDATE is set, increment auto-update counter
;..I +$P($G(^DPT(DFN,.312,POLICY,4)),U,4),$$FMDIFF^XLFDT(DT,+$P($G(^DPT(DFN,.312,POLICY,1)),U,3),1)<2 S AUTOUPD=AUTOUPD+1
;..Q
;.Q
;Q AUTOUPD
;;
PATINFO(IBAUTO,PAYERWNR,MCAUTO) ; IB*2*595/DM
; compile an auto-update count for all patient policies from yesterday
; read all response records from yesterday via the "AUTO" cross reference
;
; PAYERWNR - ien of the current Medicare payer from file #350.9
; returns:
; IBAUTO - total count of auto-updated eIV responses that are not Medicare related
; MCAUTO - total count of auto-updated eIV responses that ARE Medicare related
;
; IB*664/DW added 1st three parameters, added logic to split out Medicare auto-updates
;
N IBAUTOX,IBDATE,IBENDDT,IBIEN,IBPYRIEN,IBPATIEN,IBINSIEN
S (IBAUTO,MCAUTO)=0
S IBDATE=$$FMADD^XLFDT($$DT^XLFDT(),-2,23,59,59)
S IBENDDT=$$FMADD^XLFDT($$DT^XLFDT(),-1,23,59,59)
;
F S IBDATE=$O(^IBCN(365,"AUTO",IBDATE)) Q:'IBDATE!(IBDATE>IBENDDT) D
.S IBPYRIEN=0 F S IBPYRIEN=$O(^IBCN(365,"AUTO",IBDATE,IBPYRIEN)) Q:'IBPYRIEN D
..S IBPATIEN=0 F S IBPATIEN=$O(^IBCN(365,"AUTO",IBDATE,IBPYRIEN,IBPATIEN)) Q:'IBPATIEN D
...S IBINSIEN=0 F S IBINSIEN=$O(^IBCN(365,"AUTO",IBDATE,IBPYRIEN,IBPATIEN,IBINSIEN)) Q:'IBINSIEN D
....; IB*2.0*664/DW Count Medicare auto-updates separately
....; IB*664 Added last 2 FOR-LOOPS, original counting was wrong)
....;S IBAUTO=IBAUTO+1
....S IBAUTOX=0 F S IBAUTOX=$O(^IBCN(365,"AUTO",IBDATE,IBPYRIEN,IBPATIEN,IBINSIEN,IBAUTOX)) Q:'IBAUTOX D
.... .Q:IBAUTOX'=1 ;Auto updated records will be a "1"
.... .S IBIEN=0 F S IBIEN=$O(^IBCN(365,"AUTO",IBDATE,IBPYRIEN,IBPATIEN,IBINSIEN,IBAUTOX,IBIEN)) Q:'IBIEN D
.... ..I IBPYRIEN=PAYERWNR S MCAUTO=MCAUTO+1 Q
.... ..S IBAUTO=IBAUTO+1 ; non-Medicare responses
Q
;
TQINFO() ; get data from transmission queue (file 365.1)
; returns the following string, delimited by "^":
; piece 1 - Number of queued 270 inquiries
; piece 2 - Number of deferred 270 inquiries
;
N INQD,INQQ,INQUIRY,INSTS,TQSTATUS
S (INQD,INQQ)=0
;
; Queued inquiries (Ready to Transmit - 1/Retry - 6) and
; Deferred inquiries (Hold - 4)
F INSTS=1,6,4 D
.S INQUIRY=0 F S INQUIRY=$O(^IBCN(365.1,"AC",INSTS,INQUIRY)) Q:'INQUIRY D
..I INSTS'=4 S INQQ=INQQ+1 Q ; counter for queued inquiries
..S INQD=INQD+1 ; counter for deferred inquiries
..Q
.Q
Q INQQ_U_INQD
;
PAYINFO() ; get data from payer (file 365.12) & insurance company (file #36)
; returns the following string, delimited by "^":
; piece 1 - Number of insurance companies with no National ID
; piece 2 - Number of locally disabled payers
; piece 3 - Number of unlinked insurance companies
;
N ACTIVE,APP,DATA,IDLIST,INSCO,INSTID,LOCDIS,NONATID,PAYER,PROFID,UNLINK
S (LOCDIS,NONATID,UNLINK)=0
;
; Determine # of locally disabled payers
; loop through PAYER file
S PAYER=0 F S PAYER=$O(^IBE(365.12,PAYER)) Q:'PAYER D
.;I '$$ACTAPP^IBCNEUT5(PAYER) Q ; no active payer applications
.; Check for National ID
.S DATA=^IBE(365.12,PAYER,0)
.I $P(DATA,U,2)="" Q ;Must have National ID
.;
.; Check for Locally Disabled
.;IB*668/TAZ - Changed Payer Application from IIV to EIV
.S APP=$$PYRAPP^IBCNEUT5("EIV",PAYER) I 'APP Q
.S DATA=$G(^IBE(365.12,PAYER,1,APP,0))
.I $P(DATA,U,2),'$P(DATA,U,3) S LOCDIS=LOCDIS+1 ; nationally active but locally disabled payers
.Q
;
; Loop through INSURANCE COMPANY file for insurance companies not linked to a payer
; and insurance companies with No National ID
; No National ID [defined by VA CBO as no EDI IDs fields (#36,3.02) & (#36,3.04) - 3/4/14]
; This is *Not* a check for the 'VA NATIONAL ID' associated with linked payer.
;
S INSCO=0 F S INSCO=$O(^DIC(36,INSCO)) Q:'INSCO D
.S ACTIVE=$$ACTIVE^IBCNEUT4(INSCO) Q:'ACTIVE I $$EXCLUDE^IBCNEUT4($P(ACTIVE,U,2)) Q ; Exclude Medicaid, etc.
.S PAYER=$P($G(^DIC(36,INSCO,3)),U,10) ; associated payer
.I 'PAYER S UNLINK=UNLINK+1 ; Not linked to a payer. Increment UNLINK
.I ($$GET1^DIQ(36,INSCO_",",3.02)=""),($$GET1^DIQ(36,INSCO_",",3.04)="") S NONATID=NONATID+1
.Q
Q NONATID_U_LOCDIS_U_UNLINK
;
BUFINFO() ; get data from insurance buffer (file 355.33)
; DTTM - start date/time
;
; returns the following string, delimited by "^":
; piece 1 - Number of Verified (*) buffer entries within last 24 hours ; IB*737/DTG stop use of '*' verified
; piece 2 - Number of buffer entries indicated as having Active insurance (+) within last 24 hours
; piece 3 - Number of buffer entries indicated as having Inactive insurance (-) within last 24 hours
; piece 4 - Number of buffer entries indicated as policy status undetermined (#) within last 24 hours
; piece 5 - Number of buffer entries indicated as requiring correction before 270 can be sent (!) within last 24 hours
; piece 6 - Number of buffer entries awaiting processing within last 24 hours
; piece 7 - Number of buffer entries indicated as waiting for a 271 response (?) within last 24 hours
; piece 8 - Number of buffer entries entered by manual process with no further processing (blank) within last 24 hours
;
N ACTIVE,AMBIG,BUFF,DATE,ERROR,INACTIVE,MANUAL,PROCWAIT,RESPWAIT,STATUS,SYM,VERIFIED
S (ACTIVE,AMBIG,ERROR,INACTIVE,MANUAL,PROCWAIT,RESPWAIT,VERIFIED)=0
S DATE=0 F S DATE=$O(^IBA(355.33,"AEST","E",DATE)) Q:DATE="" D
.S BUFF=0 F S BUFF=$O(^IBA(355.33,"AEST","E",DATE,BUFF)) Q:BUFF="" D
..S SYM=$$SYMBOL^IBCNBLL(BUFF)
..;I SYM="*" S VERIFIED=VERIFIED+1 Q ; verified entries ; IB*737/DTG stop use of '*' verified
..I SYM="+" S ACTIVE=ACTIVE+1 Q ; active insurance
..I SYM="$" S ACTIVE=ACTIVE+1 Q ; include "$" (Escalated entries) in with the active insurance - IB*2.0*506 (vd)
..I SYM="-" S INACTIVE=INACTIVE+1 Q ; inactive insurance
..I SYM="#" S AMBIG=AMBIG+1 Q ; ambiguous response
..I SYM="!" S ERROR=ERROR+1 Q ; entries requiring correction
..I SYM="?" S RESPWAIT=RESPWAIT+1 Q ; awaiting response
..I SYM=" " S MANUAL=MANUAL+1 ; manually entered entries (no further processing)
.S PROCWAIT=RESPWAIT+MANUAL ; entries awaiting processing
Q VERIFIED_U_ACTIVE_U_INACTIVE_U_AMBIG_U_ERROR_U_PROCWAIT_U_RESPWAIT_U_MANUAL
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCNEDST 15795 printed Dec 13, 2024@02:14:33 Page 2
IBCNEDST ;ALB/YMG - HL7 Registration Message Statistics ; 07-MAR-2013
+1 ;;2.0;INTEGRATED BILLING;**497,506,549,595,659,664,668,702,737**;21-MAR-94;Build 19
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 QUIT
+5 ;
GETSTAT2() ;EP
+1 ; IB*2.0*549 - Added method
+2 ; Get additional IB Site Parameter fields
+3 ; Input: None
+4 ; Output: A1^A2^A3^A4^A5 - Where:
+5 ; A1 - 350.9, 51.27 - 270 MASTER SWITCH REALTIME
+6 ; A2 - 350.9, 51.28 - 270 MASTER SWITCH NIGHTLY
+7 ; A3 - 350.9, 51.15 - HL7 MAXIMUM NUMBER
+8 ; A4 - 350.9002, .05 - MAXIMUM EXTRACT NUMBER (appt)
+9 ; A5 - 350.9002, .05 - MAXIMUM EXTRACT NUMBER (buffer)
+10 ; A6 - 350.9, 51.32 - MEDICARE FRESHNESS DAYS ;/vd - IB*2*659
+11 ;
+12 NEW DATA,XX
+13 ; 270 Master Switch Realtime
SET DATA=$$GET1^DIQ(350.9,"1,",51.27,"I")
+14 ; 270 Master Switch Nightly
SET $PIECE(DATA,"^",2)=$$GET1^DIQ(350.9,"1,",51.28,"I")
+15 ; HL7 Maximum Number
SET $PIECE(DATA,"^",3)=$$GET1^DIQ(350.9,"1,",51.15,"I")
+16 ; Find Appointment multiple
SET XX=$ORDER(^IBE(350.9,1,51.17,"B",2,""))
+17 ; Maximum Appointment Extract
SET XX=$$GET1^DIQ(350.9002,XX_",1,",.05,"I")
+18 SET $PIECE(DATA,"^",4)=XX
+19 ; Find Buffer multiple
SET XX=$ORDER(^IBE(350.9,1,51.17,"B",1,""))
+20 ; Maximum Buffer Extract
SET XX=$$GET1^DIQ(350.9002,XX_",1,",.05,"I")
+21 SET $PIECE(DATA,"^",5)=XX
+22 ; MEDICARE Freshness Days ;/vd - IB*2*659
SET $PIECE(DATA,"^",6)=$$GET1^DIQ(350.9,"1,",51.32,"I")
+23 QUIT DATA
+24 ;
GETSTAT(MCAUTO) ; get statistical data
+1 ; Statistics are to match the eIV Statistical Report (^IBCNEPR8)
+2 ; IB*664/DW Added parameter "MCAUTO" - this will be used to split out the count of
+3 ; Medicare auto-updated responses from the all other eIV responses that
+4 ; were auto updated. We now have two calculated totals. Medicare and
+5 ; not Medicare eIV responses that were auto-updated.
+6 ;
+7 ; returns the following string, delimited by "^":
+8 ;
+9 ; piece 1 - Number of patients with potential secondary/tertiary insurance as identified by Medicare
+10 ; piece 2 - Number of automatically updated patient insurance records processed yesterday only
+11 ; piece 3 - Number of 270 inquiries pending receipt of 271 responses
+12 ; piece 4 - Number of queued 270 inquiries
+13 ; piece 5 - Number of deferred 270 inquiries
+14 ; piece 6 - Number of insurance companies with no National ID
+15 ; piece 7 - Number of locally disabled payers
+16 ; piece 8 - Number of Verified (*) buffer entries ; IB*737/DTG will be zero, not use '*' verified
+17 ; piece 9 - Number of buffer entries indicated as having Active insurance (+)
+18 ; piece 10 - Number of buffer entries indicated as having Inactive insurance (-)
+19 ; piece 11 - Number of buffer entries indicated as policy status undetermined (#)
+20 ; piece 12 - Number of buffer entries indicated as requiring correction before 270 can be sent (!)
+21 ; piece 13 - Number of buffer entries awaiting processing
+22 ; piece 14 - Number of buffer entries indicated as waiting for a 271 response (?)
+23 ; piece 15 - Number of buffer entries entered by manual process with no further processing (blank)
+24 ; piece 16 - Number of unlinked insurance companies
+25 ;
+26 NEW BUFINFO,PAYINFO,RESPINFO,STARTDTTM,TQINFO,STATS
+27 ;
+28 ; set to current date/time - 24 hours
SET STARTDTTM=$$FMADD^XLFDT($$NOW^XLFDT(),,-24)
+29 ; IB*664/DW Added parameter "MCAUTO" to line below
+30 ; get data from file 365
SET RESPINFO=$$RESPINFO(STARTDTTM,.MCAUTO)
+31 ; get data from file 365.1
SET TQINFO=$$TQINFO()
+32 ; get data from file 36 & 365.12
SET PAYINFO=$$PAYINFO()
+33 ; get data from file 355.33
SET BUFINFO=$$BUFINFO()
+34 SET STATS=RESPINFO_U_TQINFO_U_$PIECE(PAYINFO,U)_U_$PIECE(PAYINFO,U,2)
+35 SET STATS=STATS_U_BUFINFO_U_$PIECE(PAYINFO,U,3)
+36 QUIT STATS
+37 ;
RESPINFO(DTTM,MCAUTO) ; get data from IIV Response file (file 365)
+1 ; DTTM - start date/time
+2 ; MCAUTO - total # of auto-updated eIV responses that ARE Medicare related
+3 ; IB*664/DW Added parameter "MCAUTO"
+4 ;
+5 ; returns the following string, delimited by "^":
+6 ; piece 1: number of patients with potential secondary/tertiary insurance as identified by Medicare
+7 ; piece 2: Number of automatically updated patient insurance records processed yesterday only
+8 ; piece 3: Number of 270 inquiries pending receipt of 271 responses
+9 ;
+10 ; also returns MCAUTO - # of eIV responses from the Medicare payer that were auto-updated
+11 ;
+12 NEW AUTOUPD,DATE,DFN,EBIEN,IEN,INSNAMES,INSTYPE,INQP,POLICY,PAYER,PAYERWNR,PYRNAME,SECINS,Z
+13 ; IB*2.0*702/DTG- start Added number of outgoing EICD (A1) 270 transactions.
+14 ; Number of outgoing EICD-triggered (A2) 270 transactions.
+15 ; Number of outgoing MBI Request 270 transactions.
+16 ; Number of incoming MBI positive responses that indicated as having returned the MBI (%).
+17 NEW IB1P,IB2D,IB3IEN,IBA1,IBA2,IB40,IBTQ,IBTYP,IBQRY,IBAT1,IBAT2,IBSID,IBMBI,IBMBS
+18 SET (IB1P,IB2D,IB3IEN,IBA1,IBA2,IB40,IBAT1,IBAT2,IBMBI,IBMBS)=""
+19 SET DSTATPA=$GET(DSTATPA)
SET DSTATI=$GET(DSTATI)
+20 ; IB*2.0*702/DTG - end Added
+21 SET SECINS=0
+22 ; get Medicare payer ien from IB site parameters
SET PAYERWNR=$PIECE($GET(^IBE(350.9,1,51)),U,25)
+23 ;
+24 ; IB*664/DW - Added 1st 3 parameters to PATINFO, changed from extrinsic function
+25 ; IB*2*595/DM rewrote PATINFO
DO PATINFO(.AUTOUPD,PAYERWNR,.MCAUTO)
+26 SET DATE=DTTM-0.000001
FOR
SET DATE=$ORDER(^IBCN(365,"AD",DATE))
if DATE=""
QUIT
Begin DoDot:1
+27 ;IB*2*595/DM next 4 lines no longer applicable
+28 ; if response received within the last 24 hrs, check if it auto-updated insurance policy
+29 ;S PAYER=0 F S PAYER=$O(^IBCN(365,"AD",DATE,PAYER)) Q:PAYER="" D
+30 ;.S DFN=0 F S DFN=$O(^IBCN(365,"AD",DATE,PAYER,DFN)) Q:DFN="" S AUTOUPD=AUTOUPD+$$PATINFO(DFN)
+31 ;.Q
+32 IF PAYERWNR
IF $DATA(^IBCN(365,"AD",DATE,PAYERWNR))
Begin DoDot:2
+33 SET DFN=0
FOR
SET DFN=$ORDER(^IBCN(365,"AD",DATE,PAYERWNR,DFN))
if DFN=""
QUIT
Begin DoDot:3
+34 ; create array of ins. company names for this patient (active policies only)
+35 KILL INSNAMES
SET INSTYPE=0
FOR
SET INSTYPE=$ORDER(^DPT(DFN,.312,"B",INSTYPE))
if INSTYPE=""
QUIT
Begin DoDot:4
+36 SET POLICY=0
FOR
SET POLICY=$ORDER(^DPT(DFN,.312,"B",INSTYPE,POLICY))
if POLICY=""
QUIT
Begin DoDot:5
+37 ; skip policies that are not active
+38 IF $$CHK^IBCNS1(^DPT(DFN,.312,POLICY,0),DT,1)
SET INSNAMES($$EXTERNAL^DILFD(2.312,.01,,INSTYPE))=""
+39 QUIT
End DoDot:5
+40 QUIT
End DoDot:4
+41 SET IEN=0
FOR
SET IEN=$ORDER(^IBCN(365,"AD",DATE,PAYERWNR,DFN,IEN))
if IEN=""
QUIT
Begin DoDot:4
+42 SET Z=""
FOR
SET Z=$ORDER(^IBCN(365,IEN,2,"B",Z))
if Z=""
QUIT
Begin DoDot:5
+43 SET EBIEN=$ORDER(^IBCN(365,IEN,2,"B",Z,""))
+44 ; make sure eligibility code is "R"
+45 IF $$GET1^DIQ(365.02,EBIEN_","_IEN_",",.02)'="R"
QUIT
+46 ; grab first 30 chars to compare to 36/.01
SET PYRNAME=$EXTRACT($PIECE($GET(^IBCN(365,IEN,2,EBIEN,3)),U,3),1,30)
+47 IF PYRNAME'=""
IF '$DATA(INSNAMES(PYRNAME))
SET SECINS=SECINS+1
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
+48 ; IB*2.0*702/DTG- start Added number of outgoing EICD (A1) 270 transactions. number of outgoing EICD-triggered (A2) 270 transactions
+49 ; number of outgoing MBI Request 270 transactions
+50 ;<
IF $GET(DSTATI)=1
Begin DoDot:2
+51 ;<
SET IB1P=""
FOR
SET IB1P=$ORDER(^IBCN(365,"AD",DATE,IB1P))
if IB1P=""
QUIT
SET IB2D=""
Begin DoDot:3
+52 ;<
FOR
SET IB2D=$ORDER(^IBCN(365,"AD",DATE,IB1P,IB2D))
if IB2D=""
QUIT
SET IB3IEN=""
Begin DoDot:4
+53 ;<
FOR
SET IB3IEN=$ORDER(^IBCN(365,"AD",DATE,IB1P,IB2D,IB3IEN))
if IB3IEN=""
QUIT
Begin DoDot:5
+54 SET IENS=IB3IEN_","
KILL IB40
DO GETS^DIQ(365,IENS,"13.02;.05;.1","IE","IB40")
+55 IF $GET(IB40(365,IENS,.1,"I"))'="O"
QUIT
+56 SET IBSID=$GET(IB40(365,IENS,13.02,"I"))
+57 SET IBTQ=$GET(IB40(365,IENS,.05,"I"))
+58 SET IBTYP=$$GET1^DIQ(365.1,IBTQ_",",.1,"I")
SET IBQRY=$$GET1^DIQ(365.1,IBTQ_",",.11,"I")
+59 ; IBMBI - Number of incoming MBI positive responses that indicated as having returned the MBI (%)
+60 IF IBTYP=7&(IBSID'="")
SET IBMBI=$GET(IBMBI)+1
QUIT
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+61 ;
+62 ;<
IF $GET(DSTATI)=1
Begin DoDot:1
+63 ;<
SET DATE=DTTM-0.000001
FOR
SET DATE=$ORDER(^IBCN(365,"AE",DATE))
if DATE=""
QUIT
Begin DoDot:2
+64 ;<
SET IB3IEN=""
FOR
SET IB3IEN=$ORDER(^IBCN(365,"AE",DATE,IB3IEN))
if IB3IEN=""
QUIT
Begin DoDot:3
+65 SET IENS=IB3IEN_","
KILL IB40
DO GETS^DIQ(365,IENS,"13.02;.05;.1","IE","IB40")
+66 IF $GET(IB40(365,IENS,.1,"I"))'="O"
QUIT
+67 SET IBSID=$GET(IB40(365,IENS,13.02,"I"))
+68 SET IBTQ=$GET(IB40(365,IENS,.05,"I"))
+69 SET IBTYP=$$GET1^DIQ(365.1,IBTQ_",",.1,"I")
SET IBQRY=$$GET1^DIQ(365.1,IBTQ_",",.11,"I")
+70 ; IBA1 - Number of outgoing EICD (A1) 270 transactions
+71 ; IBA2 - Number of outgoing EICD-triggered (A2) 270 transactions
+72 ; IBMBS - Number of outgoing MBI Request 270 transactions
+73 IF IBTYP=7
SET IBMBS=$GET(IBMBS)+1
QUIT
+74 IF IBTYP=4
if IBQRY="I"
SET IBA1=$GET(IBA1)+1
if IBQRY="V"
SET IBA2=$GET(IBA2)+1
End DoDot:3
+75 ; IB*2.0*702/DTG - end Added
End DoDot:2
End DoDot:1
+76 ;
+77 ; IB*2.0*702/DTG - start Added
+78 IF $GET(DSTATI)=1
SET DSTAT3=+$GET(IBA1)_DSTATPA_+$GET(IBA2)_DSTATPA_+$GET(IBMBS)_DSTATPA_+$GET(IBMBI)
+79 ; IB*2.0*702/DTG - end Added
+80 ;
+81 ; Number of 270 inquiries pending receipt of 271 responses
+82 ; Transmitted status = 2
SET (INQP,IEN)=0
FOR
SET IEN=$ORDER(^IBCN(365,"AC",2,IEN))
if 'IEN
QUIT
Begin DoDot:1
+83 SET INQP=INQP+1
End DoDot:1
+84 QUIT SECINS_U_AUTOUPD_U_INQP
+85 ;
+86 ;PATINFO() was fully replace for IB*2*595/DM
+87 ;PATINFO(DFN) ; get data from pat. insurance multiple (file 2.312)
+88 ;; DFN - file 2 ien
+89 ;;
+90 ;; returns
+91 ;; number of automatically updated patient insurance records for a given patient within last 24 hours
+92 ;;
+93 ;N AUTOUPD,INSTYPE,POLICY
+94 ;I 'DFN Q
+95 ;S AUTOUPD=0
+96 ;S INSTYPE=0 F S INSTYPE=$O(^DPT(DFN,.312,"B",INSTYPE)) Q:INSTYPE="" D
+97 ;.S POLICY=0 F S POLICY=$O(^DPT(DFN,.312,"B",INSTYPE,POLICY)) Q:POLICY="" D
+98 ;..; if DATE LAST VERIFIED is no more than one day old and EIV AUTO-UPDATE is set, increment auto-update counter
+99 ;..I +$P($G(^DPT(DFN,.312,POLICY,4)),U,4),$$FMDIFF^XLFDT(DT,+$P($G(^DPT(DFN,.312,POLICY,1)),U,3),1)<2 S AUTOUPD=AUTOUPD+1
+100 ;..Q
+101 ;.Q
+102 ;Q AUTOUPD
+103 ;;
PATINFO(IBAUTO,PAYERWNR,MCAUTO) ; IB*2*595/DM
+1 ; compile an auto-update count for all patient policies from yesterday
+2 ; read all response records from yesterday via the "AUTO" cross reference
+3 ;
+4 ; PAYERWNR - ien of the current Medicare payer from file #350.9
+5 ; returns:
+6 ; IBAUTO - total count of auto-updated eIV responses that are not Medicare related
+7 ; MCAUTO - total count of auto-updated eIV responses that ARE Medicare related
+8 ;
+9 ; IB*664/DW added 1st three parameters, added logic to split out Medicare auto-updates
+10 ;
+11 NEW IBAUTOX,IBDATE,IBENDDT,IBIEN,IBPYRIEN,IBPATIEN,IBINSIEN
+12 SET (IBAUTO,MCAUTO)=0
+13 SET IBDATE=$$FMADD^XLFDT($$DT^XLFDT(),-2,23,59,59)
+14 SET IBENDDT=$$FMADD^XLFDT($$DT^XLFDT(),-1,23,59,59)
+15 ;
+16 FOR
SET IBDATE=$ORDER(^IBCN(365,"AUTO",IBDATE))
if 'IBDATE!(IBDATE>IBENDDT)
QUIT
Begin DoDot:1
+17 SET IBPYRIEN=0
FOR
SET IBPYRIEN=$ORDER(^IBCN(365,"AUTO",IBDATE,IBPYRIEN))
if 'IBPYRIEN
QUIT
Begin DoDot:2
+18 SET IBPATIEN=0
FOR
SET IBPATIEN=$ORDER(^IBCN(365,"AUTO",IBDATE,IBPYRIEN,IBPATIEN))
if 'IBPATIEN
QUIT
Begin DoDot:3
+19 SET IBINSIEN=0
FOR
SET IBINSIEN=$ORDER(^IBCN(365,"AUTO",IBDATE,IBPYRIEN,IBPATIEN,IBINSIEN))
if 'IBINSIEN
QUIT
Begin DoDot:4
+20 ; IB*2.0*664/DW Count Medicare auto-updates separately
+21 ; IB*664 Added last 2 FOR-LOOPS, original counting was wrong)
+22 ;S IBAUTO=IBAUTO+1
+23 SET IBAUTOX=0
FOR
SET IBAUTOX=$ORDER(^IBCN(365,"AUTO",IBDATE,IBPYRIEN,IBPATIEN,IBINSIEN,IBAUTOX))
if 'IBAUTOX
QUIT
Begin DoDot:5
+24 ;Auto updated records will be a "1"
if IBAUTOX'=1
QUIT
+25 SET IBIEN=0
FOR
SET IBIEN=$ORDER(^IBCN(365,"AUTO",IBDATE,IBPYRIEN,IBPATIEN,IBINSIEN,IBAUTOX,IBIEN))
if 'IBIEN
QUIT
Begin DoDot:6
+26 IF IBPYRIEN=PAYERWNR
SET MCAUTO=MCAUTO+1
QUIT
+27 ; non-Medicare responses
SET IBAUTO=IBAUTO+1
End DoDot:6
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+28 QUIT
+29 ;
TQINFO() ; get data from transmission queue (file 365.1)
+1 ; returns the following string, delimited by "^":
+2 ; piece 1 - Number of queued 270 inquiries
+3 ; piece 2 - Number of deferred 270 inquiries
+4 ;
+5 NEW INQD,INQQ,INQUIRY,INSTS,TQSTATUS
+6 SET (INQD,INQQ)=0
+7 ;
+8 ; Queued inquiries (Ready to Transmit - 1/Retry - 6) and
+9 ; Deferred inquiries (Hold - 4)
+10 FOR INSTS=1,6,4
Begin DoDot:1
+11 SET INQUIRY=0
FOR
SET INQUIRY=$ORDER(^IBCN(365.1,"AC",INSTS,INQUIRY))
if 'INQUIRY
QUIT
Begin DoDot:2
+12 ; counter for queued inquiries
IF INSTS'=4
SET INQQ=INQQ+1
QUIT
+13 ; counter for deferred inquiries
SET INQD=INQD+1
+14 QUIT
End DoDot:2
+15 QUIT
End DoDot:1
+16 QUIT INQQ_U_INQD
+17 ;
PAYINFO() ; get data from payer (file 365.12) & insurance company (file #36)
+1 ; returns the following string, delimited by "^":
+2 ; piece 1 - Number of insurance companies with no National ID
+3 ; piece 2 - Number of locally disabled payers
+4 ; piece 3 - Number of unlinked insurance companies
+5 ;
+6 NEW ACTIVE,APP,DATA,IDLIST,INSCO,INSTID,LOCDIS,NONATID,PAYER,PROFID,UNLINK
+7 SET (LOCDIS,NONATID,UNLINK)=0
+8 ;
+9 ; Determine # of locally disabled payers
+10 ; loop through PAYER file
+11 SET PAYER=0
FOR
SET PAYER=$ORDER(^IBE(365.12,PAYER))
if 'PAYER
QUIT
Begin DoDot:1
+12 ;I '$$ACTAPP^IBCNEUT5(PAYER) Q ; no active payer applications
+13 ; Check for National ID
+14 SET DATA=^IBE(365.12,PAYER,0)
+15 ;Must have National ID
IF $PIECE(DATA,U,2)=""
QUIT
+16 ;
+17 ; Check for Locally Disabled
+18 ;IB*668/TAZ - Changed Payer Application from IIV to EIV
+19 SET APP=$$PYRAPP^IBCNEUT5("EIV",PAYER)
IF 'APP
QUIT
+20 SET DATA=$GET(^IBE(365.12,PAYER,1,APP,0))
+21 ; nationally active but locally disabled payers
IF $PIECE(DATA,U,2)
IF '$PIECE(DATA,U,3)
SET LOCDIS=LOCDIS+1
+22 QUIT
End DoDot:1
+23 ;
+24 ; Loop through INSURANCE COMPANY file for insurance companies not linked to a payer
+25 ; and insurance companies with No National ID
+26 ; No National ID [defined by VA CBO as no EDI IDs fields (#36,3.02) & (#36,3.04) - 3/4/14]
+27 ; This is *Not* a check for the 'VA NATIONAL ID' associated with linked payer.
+28 ;
+29 SET INSCO=0
FOR
SET INSCO=$ORDER(^DIC(36,INSCO))
if 'INSCO
QUIT
Begin DoDot:1
+30 ; Exclude Medicaid, etc.
SET ACTIVE=$$ACTIVE^IBCNEUT4(INSCO)
if 'ACTIVE
QUIT
IF $$EXCLUDE^IBCNEUT4($PIECE(ACTIVE,U,2))
QUIT
+31 ; associated payer
SET PAYER=$PIECE($GET(^DIC(36,INSCO,3)),U,10)
+32 ; Not linked to a payer. Increment UNLINK
IF 'PAYER
SET UNLINK=UNLINK+1
+33 IF ($$GET1^DIQ(36,INSCO_",",3.02)="")
IF ($$GET1^DIQ(36,INSCO_",",3.04)="")
SET NONATID=NONATID+1
+34 QUIT
End DoDot:1
+35 QUIT NONATID_U_LOCDIS_U_UNLINK
+36 ;
BUFINFO() ; get data from insurance buffer (file 355.33)
+1 ; DTTM - start date/time
+2 ;
+3 ; returns the following string, delimited by "^":
+4 ; piece 1 - Number of Verified (*) buffer entries within last 24 hours ; IB*737/DTG stop use of '*' verified
+5 ; piece 2 - Number of buffer entries indicated as having Active insurance (+) within last 24 hours
+6 ; piece 3 - Number of buffer entries indicated as having Inactive insurance (-) within last 24 hours
+7 ; piece 4 - Number of buffer entries indicated as policy status undetermined (#) within last 24 hours
+8 ; piece 5 - Number of buffer entries indicated as requiring correction before 270 can be sent (!) within last 24 hours
+9 ; piece 6 - Number of buffer entries awaiting processing within last 24 hours
+10 ; piece 7 - Number of buffer entries indicated as waiting for a 271 response (?) within last 24 hours
+11 ; piece 8 - Number of buffer entries entered by manual process with no further processing (blank) within last 24 hours
+12 ;
+13 NEW ACTIVE,AMBIG,BUFF,DATE,ERROR,INACTIVE,MANUAL,PROCWAIT,RESPWAIT,STATUS,SYM,VERIFIED
+14 SET (ACTIVE,AMBIG,ERROR,INACTIVE,MANUAL,PROCWAIT,RESPWAIT,VERIFIED)=0
+15 SET DATE=0
FOR
SET DATE=$ORDER(^IBA(355.33,"AEST","E",DATE))
if DATE=""
QUIT
Begin DoDot:1
+16 SET BUFF=0
FOR
SET BUFF=$ORDER(^IBA(355.33,"AEST","E",DATE,BUFF))
if BUFF=""
QUIT
Begin DoDot:2
+17 SET SYM=$$SYMBOL^IBCNBLL(BUFF)
+18 ;I SYM="*" S VERIFIED=VERIFIED+1 Q ; verified entries ; IB*737/DTG stop use of '*' verified
+19 ; active insurance
IF SYM="+"
SET ACTIVE=ACTIVE+1
QUIT
+20 ; include "$" (Escalated entries) in with the active insurance - IB*2.0*506 (vd)
IF SYM="$"
SET ACTIVE=ACTIVE+1
QUIT
+21 ; inactive insurance
IF SYM="-"
SET INACTIVE=INACTIVE+1
QUIT
+22 ; ambiguous response
IF SYM="#"
SET AMBIG=AMBIG+1
QUIT
+23 ; entries requiring correction
IF SYM="!"
SET ERROR=ERROR+1
QUIT
+24 ; awaiting response
IF SYM="?"
SET RESPWAIT=RESPWAIT+1
QUIT
+25 ; manually entered entries (no further processing)
IF SYM=" "
SET MANUAL=MANUAL+1
End DoDot:2
+26 ; entries awaiting processing
SET PROCWAIT=RESPWAIT+MANUAL
End DoDot:1
+27 QUIT VERIFIED_U_ACTIVE_U_INACTIVE_U_AMBIG_U_ERROR_U_PROCWAIT_U_RESPWAIT_U_MANUAL
+28 ;