IBCU81 ;ALB/ARH - THIRD PARTY BILLING UTILITIES (AUTOMATED BILLER) ;02 JUL 93
;;2.0;INTEGRATED BILLING;**55,91,106,124,160,174,260,347**;21-MAR-94;Build 24
;;Per VHA Directive 2004-038, this routine should not be modified.
;
EABD(IBETYP,IBTDT) ; -- compute earliest auto bill date: date entered plus days delay for event type
;the difference betwieen this and EABD^IBTUTL is that the autobill of the event type may be turned off
;and this procedure will still return a date
; -- input IBETYPE = pointer to type of entry file
; IBTDT = episode date, if not passed in uses DT
;
N X,X1,X2,Y,IBETYPD S Y="" I '$G(IBETYP) G EABDQ
S IBETYPD=$G(^IBE(356.6,+IBETYP,0)) I '$G(IBTDT) S IBTDT=DT
S X2=+$P(IBETYPD,"^",6) ;set earliest autobill date to entered date plus days delay
S X1=IBTDT D C^%DTC S Y=X\1
EABDQ Q Y
;
EVBILL(IBTRN) ;check if event is auto billable, return EABD if it is, the difference between this and BILL^IBTUTL is that
;this procedure will return a date if the auto biller is turned off for this event type
;returns "^error message" if it is not billable
N X,Y,Z,E,IBTRND S (X,Y,E)="" S IBTRND=$G(^IBT(356,+$G(IBTRN),0)) I IBTRND="" G BILLQ
;
; -- billed and bill not cancelled and not inpt interim first or continuous
S Z=$$BILLED^IBCU8(IBTRN),Y=$P(Z,U,2) I +Z,'Y S E="^Event already billed on "_$P($G(^DGCR(399,+Z,0)),U,1)_"." G BILLQ
;
; -- special type (not riem. ins), not billable, inactive
I +$P(IBTRND,U,12) S E="^Bill may not be Reimbursable Insurance, possibly "_$$EXSET^IBEFUNC(+$P(IBTRND,U,12),356,.12)_"." G BILLQ
I +$P(IBTRND,U,19) S E="^Event has a Reason Not Billable: "_$P($G(^IBE(356.8,+$P(IBTRND,U,19),0)),U,1)_"." G BILLQ
I '$P(IBTRND,U,20) S E="^Event is Inactive." G BILLQ
I 'Y S Y=+$G(^IBT(356,+$G(IBTRN),1)) I 'Y S Y=DT
S X=$$EABD(+$P(IBTRND,U,18),Y)
BILLQ Q X_E
;
RXRF(IBTRN) ; returns rx # and fill date for given claims tracking rx entry
N IBX,IBY,IBZ,X S (X,IBY)=""
S IBX=$G(^IBT(356,+$G(IBTRN),0)) I IBX'="" S IBY=$$FILE^IBRXUTL(+$P(IBX,U,8),.01)
I IBY'="",$P(IBX,U,10)=0 S IBZ=$$FILE^IBRXUTL(+$P(IBX,U,8),"22","I") I +IBZ S X=IBY_"^"_IBZ
I IBY'="",+$P(IBX,U,10) S IBZ=+$$ZEROSUB^IBRXUTL(+$P(IBX,U,2),+$P(IBX,U,8),+$P(IBX,U,10)) I +IBZ S X=IBY_"^"_IBZ
Q X
;
NABSCT(IBTRN) ; -- true if CT outpatient visit should NOT be auto billed, based only on stop (1) and clinic (2) auto billable
; returns true only for those stops (352.3) and clinics (352.4) specifically flagged as not auto billable
N IBX,IBY,IBTRND S IBX=0,IBTRND="" I +$G(IBTRN) S IBTRND=$G(^IBT(356,+IBTRN,0))
I +$P(IBTRND,U,4) S IBY=$$SCE^IBSDU(+$P(IBTRND,U,4)) I +IBY D
. I +$P(IBY,U,3),$$NABST^IBEFUNC($P(IBY,U,3),DT) S IBX=1 Q
. I +$P(IBY,U,4),$$NABCT^IBEFUNC($P(IBY,U,4),DT) S IBX=2
Q IBX
;
NBOE(IBOE,IBOE0) ; returns true if outpatient encounter is non-billable, "" otherwise
; input: IBOE - pointer to encounter (409.68)
; IBOE0 - 0-node of the encounter (optional)
; output: "" or x^message, where x=1 if SC, x=2 if NB Stop code, x=3 if NB Clinic, x=4 if NB Appt Status
N IBOED,IBOEP,IBX,IBCK,IBZ,IBPB,IBAPST,IBDT,DFN
S IBX=""
I $G(IBOE0)="" S IBOE0=$$SCE^IBSDU(IBOE)
I 'IBOE0 G NBOEQ
S DFN=$P(IBOE0,"^",2),IBDT=+IBOE0
F IBZ=7,12,13 S IBCK(IBZ)=""
S IBZ=$$BILLCK^IBAMTEDU(IBOE,IBOE0,.IBCK,.IBPB)
S IBAPST="" I $G(IBPB)=13 S IBAPST=$E($$EXPAND^IBTRE(409.68,.12,$P(IBOE0,U,12)),1,10)
; check out sc and other questions
I $G(IBPB)="" S IBAPST=$$CL^IBTRKR41(IBOE0) I $L(IBAPST) S IBPB=$S(IBAPST="SC TREATMENT":11,1:13)
S:$G(IBPB)'="" IBX=$S(IBPB=11:"1^SC VISIT",IBPB=7:"2^NB STOP CODE",IBPB=12:"3^NB CLINIC",IBPB=13:"4^"_IBAPST,1:"")
NBOEQ Q IBX
;
OEDX(IBOE,IBDXA,IBDXB) ; returns arrays containing encounters diagnosis (includes duplicates)
; IBDXA(ORDER,DATE/TIME,IBOE,DX IFN)=DX ^ PCE ORDER ^ IBOE ^ DATE/TIME ^ TRUE IF NON-BILLABLE ^ NB MES ^ CLINIC
; IBDXB(IBDX) = 1 for each billable dx found
;
N IBNBOE,X,IBPOV,IBDXN,IBPCE,IBPCEI,IBDT,IBOE0,IBZERR
Q:'$G(IBOE)
S IBOE0=$$SCE^IBSDU(+IBOE),IBDT=+IBOE0 Q:'IBDT
I '$$BDSRC^IBEFUNC3($P(IBOE0,U,5)) Q ; non-billable visit data source
S IBNBOE=$$NBOE(IBOE,IBOE0)
;
D GETDX^SDOE(IBOE,"IBPOV","IBZERR")
S IBDXN=0 F S IBDXN=$O(IBPOV(IBDXN)) Q:'IBDXN D
. S IBPCE=IBPOV(IBDXN),IBPCEI=$P(IBPCE,U,12)
. S IBDXA($S(IBPCEI="P":1,IBPCEI="S":2,1:999),IBDT,IBOE,IBDXN)=+IBPCE_U_IBPCEI_U_IBOE_U_IBDT_U_$P(IBNBOE,U,1)_U_$P(IBNBOE,U,2)_U_+$P(IBOE0,U,4)
. I 'IBNBOE S IBDXB(+IBPCE)=1
;
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCU81 4510 printed Oct 16, 2024@18:21:38 Page 2
IBCU81 ;ALB/ARH - THIRD PARTY BILLING UTILITIES (AUTOMATED BILLER) ;02 JUL 93
+1 ;;2.0;INTEGRATED BILLING;**55,91,106,124,160,174,260,347**;21-MAR-94;Build 24
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
EABD(IBETYP,IBTDT) ; -- compute earliest auto bill date: date entered plus days delay for event type
+1 ;the difference betwieen this and EABD^IBTUTL is that the autobill of the event type may be turned off
+2 ;and this procedure will still return a date
+3 ; -- input IBETYPE = pointer to type of entry file
+4 ; IBTDT = episode date, if not passed in uses DT
+5 ;
+6 NEW X,X1,X2,Y,IBETYPD
SET Y=""
IF '$GET(IBETYP)
GOTO EABDQ
+7 SET IBETYPD=$GET(^IBE(356.6,+IBETYP,0))
IF '$GET(IBTDT)
SET IBTDT=DT
+8 ;set earliest autobill date to entered date plus days delay
SET X2=+$PIECE(IBETYPD,"^",6)
+9 SET X1=IBTDT
DO C^%DTC
SET Y=X\1
EABDQ QUIT Y
+1 ;
EVBILL(IBTRN) ;check if event is auto billable, return EABD if it is, the difference between this and BILL^IBTUTL is that
+1 ;this procedure will return a date if the auto biller is turned off for this event type
+2 ;returns "^error message" if it is not billable
+3 NEW X,Y,Z,E,IBTRND
SET (X,Y,E)=""
SET IBTRND=$GET(^IBT(356,+$GET(IBTRN),0))
IF IBTRND=""
GOTO BILLQ
+4 ;
+5 ; -- billed and bill not cancelled and not inpt interim first or continuous
+6 SET Z=$$BILLED^IBCU8(IBTRN)
SET Y=$PIECE(Z,U,2)
IF +Z
IF 'Y
SET E="^Event already billed on "_$PIECE($GET(^DGCR(399,+Z,0)),U,1)_"."
GOTO BILLQ
+7 ;
+8 ; -- special type (not riem. ins), not billable, inactive
+9 IF +$PIECE(IBTRND,U,12)
SET E="^Bill may not be Reimbursable Insurance, possibly "_$$EXSET^IBEFUNC(+$PIECE(IBTRND,U,12),356,.12)_"."
GOTO BILLQ
+10 IF +$PIECE(IBTRND,U,19)
SET E="^Event has a Reason Not Billable: "_$PIECE($GET(^IBE(356.8,+$PIECE(IBTRND,U,19),0)),U,1)_"."
GOTO BILLQ
+11 IF '$PIECE(IBTRND,U,20)
SET E="^Event is Inactive."
GOTO BILLQ
+12 IF 'Y
SET Y=+$GET(^IBT(356,+$GET(IBTRN),1))
IF 'Y
SET Y=DT
+13 SET X=$$EABD(+$PIECE(IBTRND,U,18),Y)
BILLQ QUIT X_E
+1 ;
RXRF(IBTRN) ; returns rx # and fill date for given claims tracking rx entry
+1 NEW IBX,IBY,IBZ,X
SET (X,IBY)=""
+2 SET IBX=$GET(^IBT(356,+$GET(IBTRN),0))
IF IBX'=""
SET IBY=$$FILE^IBRXUTL(+$PIECE(IBX,U,8),.01)
+3 IF IBY'=""
IF $PIECE(IBX,U,10)=0
SET IBZ=$$FILE^IBRXUTL(+$PIECE(IBX,U,8),"22","I")
IF +IBZ
SET X=IBY_"^"_IBZ
+4 IF IBY'=""
IF +$PIECE(IBX,U,10)
SET IBZ=+$$ZEROSUB^IBRXUTL(+$PIECE(IBX,U,2),+$PIECE(IBX,U,8),+$PIECE(IBX,U,10))
IF +IBZ
SET X=IBY_"^"_IBZ
+5 QUIT X
+6 ;
NABSCT(IBTRN) ; -- true if CT outpatient visit should NOT be auto billed, based only on stop (1) and clinic (2) auto billable
+1 ; returns true only for those stops (352.3) and clinics (352.4) specifically flagged as not auto billable
+2 NEW IBX,IBY,IBTRND
SET IBX=0
SET IBTRND=""
IF +$GET(IBTRN)
SET IBTRND=$GET(^IBT(356,+IBTRN,0))
+3 IF +$PIECE(IBTRND,U,4)
SET IBY=$$SCE^IBSDU(+$PIECE(IBTRND,U,4))
IF +IBY
Begin DoDot:1
+4 IF +$PIECE(IBY,U,3)
IF $$NABST^IBEFUNC($PIECE(IBY,U,3),DT)
SET IBX=1
QUIT
+5 IF +$PIECE(IBY,U,4)
IF $$NABCT^IBEFUNC($PIECE(IBY,U,4),DT)
SET IBX=2
End DoDot:1
+6 QUIT IBX
+7 ;
NBOE(IBOE,IBOE0) ; returns true if outpatient encounter is non-billable, "" otherwise
+1 ; input: IBOE - pointer to encounter (409.68)
+2 ; IBOE0 - 0-node of the encounter (optional)
+3 ; output: "" or x^message, where x=1 if SC, x=2 if NB Stop code, x=3 if NB Clinic, x=4 if NB Appt Status
+4 NEW IBOED,IBOEP,IBX,IBCK,IBZ,IBPB,IBAPST,IBDT,DFN
+5 SET IBX=""
+6 IF $GET(IBOE0)=""
SET IBOE0=$$SCE^IBSDU(IBOE)
+7 IF 'IBOE0
GOTO NBOEQ
+8 SET DFN=$PIECE(IBOE0,"^",2)
SET IBDT=+IBOE0
+9 FOR IBZ=7,12,13
SET IBCK(IBZ)=""
+10 SET IBZ=$$BILLCK^IBAMTEDU(IBOE,IBOE0,.IBCK,.IBPB)
+11 SET IBAPST=""
IF $GET(IBPB)=13
SET IBAPST=$EXTRACT($$EXPAND^IBTRE(409.68,.12,$PIECE(IBOE0,U,12)),1,10)
+12 ; check out sc and other questions
+13 IF $GET(IBPB)=""
SET IBAPST=$$CL^IBTRKR41(IBOE0)
IF $LENGTH(IBAPST)
SET IBPB=$SELECT(IBAPST="SC TREATMENT":11,1:13)
+14 if $GET(IBPB)'=""
SET IBX=$SELECT(IBPB=11:"1^SC VISIT",IBPB=7:"2^NB STOP CODE",IBPB=12:"3^NB CLINIC",IBPB=13:"4^"_IBAPST,1:"")
NBOEQ QUIT IBX
+1 ;
OEDX(IBOE,IBDXA,IBDXB) ; returns arrays containing encounters diagnosis (includes duplicates)
+1 ; IBDXA(ORDER,DATE/TIME,IBOE,DX IFN)=DX ^ PCE ORDER ^ IBOE ^ DATE/TIME ^ TRUE IF NON-BILLABLE ^ NB MES ^ CLINIC
+2 ; IBDXB(IBDX) = 1 for each billable dx found
+3 ;
+4 NEW IBNBOE,X,IBPOV,IBDXN,IBPCE,IBPCEI,IBDT,IBOE0,IBZERR
+5 if '$GET(IBOE)
QUIT
+6 SET IBOE0=$$SCE^IBSDU(+IBOE)
SET IBDT=+IBOE0
if 'IBDT
QUIT
+7 ; non-billable visit data source
IF '$$BDSRC^IBEFUNC3($PIECE(IBOE0,U,5))
QUIT
+8 SET IBNBOE=$$NBOE(IBOE,IBOE0)
+9 ;
+10 DO GETDX^SDOE(IBOE,"IBPOV","IBZERR")
+11 SET IBDXN=0
FOR
SET IBDXN=$ORDER(IBPOV(IBDXN))
if 'IBDXN
QUIT
Begin DoDot:1
+12 SET IBPCE=IBPOV(IBDXN)
SET IBPCEI=$PIECE(IBPCE,U,12)
+13 SET IBDXA($SELECT(IBPCEI="P":1,IBPCEI="S":2,1:999),IBDT,IBOE,IBDXN)=+IBPCE_U_IBPCEI_U_IBOE_U_IBDT_U_$PIECE(IBNBOE,U,1)_U_$PIECE(IBNBOE,U,2)_U_+$PIECE(IBOE0,U,4)
+14 IF 'IBNBOE
SET IBDXB(+IBPCE)=1
End DoDot:1
+15 ;
+16 QUIT
+17 ;