IBCU8 ;ALB/ARH - THIRD PARTY BILLING UTILITIES (AUTOMATED BILLER) ;02 JUL 93
;;2.0;INTEGRATED BILLING;**137**;21-MAR-94
;;Per VHA Directive 10-93-142, this routine should not be modified.
;
BCDT(DATE,TYPE) ;returns end date of bill cycle for beginning DATE and TYPE
;result is the billing date range, inclusive
N X,Y,IBBC S X="" S DATE=$E($G(DATE),1,7) I DATE'?7N G BCDTE
S IBBC=$G(^IBE(356.6,+$G(TYPE),0))
; I '$P(IBBC,U,4) G BCDTE
S IBBC=$P(IBBC,U,5),X=DATE,Y=IBBC-1
I IBBC="" S Y=$E(DATE,4,5),X=$E(DATE,1,3)+(Y\12)_$S(Y>11:"01",Y>8:Y+1,1:"0"_(Y+1))_"01",Y=-1
S X=$$FMADD^XLFDT(X,Y) ;S Y=$$FYCY(DATE) F I=2,4 I X>$P(Y,U,I) S X=$P(Y,U,I)
BCDTE Q X
;
MBC(DATE,TYPE) ;returns maximum date range possible for bill cycle of DATE and TYPE
;result is the billing date range, inclusive
N X,Y,I,IBBC S X="" S DATE=$E($G(DATE),1,7) I DATE'?7N G MBCE
S IBBC=$G(^IBE(356.6,+$G(TYPE),0))
; I '$P(IBBC,U,4) G MBCE
S IBBC=$P(IBBC,U,5)
I IBBC'="" S Y=IBBC-1,X=$$FMADD^XLFDT(DATE,-Y)_"^"_$$FMADD^XLFDT(DATE,Y) G MBCE
S Y=$E(DATE,4,5),X=$E(DATE,1,3)+(Y\12)_$S(Y>11:"01",Y>8:Y+1,1:"0"_(Y+1))_"01",Y=-1
S X=$E(DATE,1,5)_"01^"_$$FMADD^XLFDT(X,Y)
MBCE ;check dates against bill range rules
I +X S Y=$$STRGCHK(+X,$P(X,U,2)) I 'Y D ;reset dates for CY and FY
. I '$P(Y,U,3) S X="" Q
. ;S Y=$$FYCY(DATE)
. ;F I=1,3 I $P(Y,U,I)>$P(X,U,1) S $P(X,U,1)=$P(Y,U,I)
. ;F I=2,4 I $P(Y,U,I)<$P(X,U,2) S $P(X,U,2)=$P(Y,U,I)
Q X
;
FYCY(DATE) ;returns calandar and fiscal years for particular date
N X,Y,Y2 S X="" S DATE=$G(DATE)\1 I DATE'?7N G FYCYE
S (Y,Y2)=$E(DATE,1,3) I $E(DATE,4,5)>9 S Y2=Y+1
S X=Y_"0101^"_Y_"1231^"_(Y2-1)_"1001^"_Y2_"0930"
FYCYE Q X
;
STRGCHK(DT1,DT2) ;genaric edit checks for STATEMENT FROM and TO dates, returns true if dates passes
N X S X=1 S DT1=$G(DT1)\1,DT2=$G(DT2)\1 I DT1'?7N!(DT2'?7N) G STRGCHKE
I DT1>(DT+.2359) S X="0^Can not bill for future treatment" G STRGCHKE
I DT1>DT2 S X="0^End date can not preceed start date" G STRGCHKE
;I $E(DT1,2,3)'=$E(DT2,2,3) S X="0^Must be in the same calandar year^"_$E(DT1,1,3)_"1231" G STRGCHKE
;I $E(DT1,4,5)<10,$E(DT2,4,5)>9 S X="0^Must be in the same fiscal year^"_$E(DT1,1,3)_"0930"
STRGCHKE Q X
;
CMPLT(IBTRN) ;returns true if event is ready to be billed NOT FINISHED
N X
N X,IBTRND S X=1 I '$G(IBTRN) G CMPLTE
S IBTRND=$G(^IBT(356,+IBTRN,0))
I +$P(IBTRND,U,31)>2 S X="0^Release of information not obtained" G CMPLTE
CMPLTE Q X
;
BILLED(IBTRN) ;returns bill IFN if Claims Tracking event is already associated with an uncancelled bill
;for inpatients interim with no final bill, returns last bill^last bill date, 0 otherwise
;based on most recent STATEMENT TO date
N X,Y,IBIFN S X=0 I +$G(IBTRN) S IBIFN="" F S IBIFN=$O(^IBT(356.399,"ACB",IBTRN,IBIFN)) Q:'IBIFN D I +X,$P(X,U,2)="" Q
. S Y=$G(^DGCR(399,+IBIFN,0)) I $P(Y,U,13)'=7 S X=IBIFN I $P(Y,U,4)<3,($P(Y,U,6)=2!($P(Y,U,6)=3)) S X=IBIFN_U_$P($G(^DGCR(399,+IBIFN,"U")),U,2)
Q X
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCU8 2982 printed Dec 13, 2024@02:20:58 Page 2
IBCU8 ;ALB/ARH - THIRD PARTY BILLING UTILITIES (AUTOMATED BILLER) ;02 JUL 93
+1 ;;2.0;INTEGRATED BILLING;**137**;21-MAR-94
+2 ;;Per VHA Directive 10-93-142, this routine should not be modified.
+3 ;
BCDT(DATE,TYPE) ;returns end date of bill cycle for beginning DATE and TYPE
+1 ;result is the billing date range, inclusive
+2 NEW X,Y,IBBC
SET X=""
SET DATE=$EXTRACT($GET(DATE),1,7)
IF DATE'?7N
GOTO BCDTE
+3 SET IBBC=$GET(^IBE(356.6,+$GET(TYPE),0))
+4 ; I '$P(IBBC,U,4) G BCDTE
+5 SET IBBC=$PIECE(IBBC,U,5)
SET X=DATE
SET Y=IBBC-1
+6 IF IBBC=""
SET Y=$EXTRACT(DATE,4,5)
SET X=$EXTRACT(DATE,1,3)+(Y\12)_$SELECT(Y>11:"01",Y>8:Y+1,1:"0"_(Y+1))_"01"
SET Y=-1
+7 ;S Y=$$FYCY(DATE) F I=2,4 I X>$P(Y,U,I) S X=$P(Y,U,I)
SET X=$$FMADD^XLFDT(X,Y)
BCDTE QUIT X
+1 ;
MBC(DATE,TYPE) ;returns maximum date range possible for bill cycle of DATE and TYPE
+1 ;result is the billing date range, inclusive
+2 NEW X,Y,I,IBBC
SET X=""
SET DATE=$EXTRACT($GET(DATE),1,7)
IF DATE'?7N
GOTO MBCE
+3 SET IBBC=$GET(^IBE(356.6,+$GET(TYPE),0))
+4 ; I '$P(IBBC,U,4) G MBCE
+5 SET IBBC=$PIECE(IBBC,U,5)
+6 IF IBBC'=""
SET Y=IBBC-1
SET X=$$FMADD^XLFDT(DATE,-Y)_"^"_$$FMADD^XLFDT(DATE,Y)
GOTO MBCE
+7 SET Y=$EXTRACT(DATE,4,5)
SET X=$EXTRACT(DATE,1,3)+(Y\12)_$SELECT(Y>11:"01",Y>8:Y+1,1:"0"_(Y+1))_"01"
SET Y=-1
+8 SET X=$EXTRACT(DATE,1,5)_"01^"_$$FMADD^XLFDT(X,Y)
MBCE ;check dates against bill range rules
+1 ;reset dates for CY and FY
IF +X
SET Y=$$STRGCHK(+X,$PIECE(X,U,2))
IF 'Y
Begin DoDot:1
+2 IF '$PIECE(Y,U,3)
SET X=""
QUIT
+3 ;S Y=$$FYCY(DATE)
+4 ;F I=1,3 I $P(Y,U,I)>$P(X,U,1) S $P(X,U,1)=$P(Y,U,I)
+5 ;F I=2,4 I $P(Y,U,I)<$P(X,U,2) S $P(X,U,2)=$P(Y,U,I)
End DoDot:1
+6 QUIT X
+7 ;
FYCY(DATE) ;returns calandar and fiscal years for particular date
+1 NEW X,Y,Y2
SET X=""
SET DATE=$GET(DATE)\1
IF DATE'?7N
GOTO FYCYE
+2 SET (Y,Y2)=$EXTRACT(DATE,1,3)
IF $EXTRACT(DATE,4,5)>9
SET Y2=Y+1
+3 SET X=Y_"0101^"_Y_"1231^"_(Y2-1)_"1001^"_Y2_"0930"
FYCYE QUIT X
+1 ;
STRGCHK(DT1,DT2) ;genaric edit checks for STATEMENT FROM and TO dates, returns true if dates passes
+1 NEW X
SET X=1
SET DT1=$GET(DT1)\1
SET DT2=$GET(DT2)\1
IF DT1'?7N!(DT2'?7N)
GOTO STRGCHKE
+2 IF DT1>(DT+.2359)
SET X="0^Can not bill for future treatment"
GOTO STRGCHKE
+3 IF DT1>DT2
SET X="0^End date can not preceed start date"
GOTO STRGCHKE
+4 ;I $E(DT1,2,3)'=$E(DT2,2,3) S X="0^Must be in the same calandar year^"_$E(DT1,1,3)_"1231" G STRGCHKE
+5 ;I $E(DT1,4,5)<10,$E(DT2,4,5)>9 S X="0^Must be in the same fiscal year^"_$E(DT1,1,3)_"0930"
STRGCHKE QUIT X
+1 ;
CMPLT(IBTRN) ;returns true if event is ready to be billed NOT FINISHED
+1 NEW X
+2 NEW X,IBTRND
SET X=1
IF '$GET(IBTRN)
GOTO CMPLTE
+3 SET IBTRND=$GET(^IBT(356,+IBTRN,0))
+4 IF +$PIECE(IBTRND,U,31)>2
SET X="0^Release of information not obtained"
GOTO CMPLTE
CMPLTE QUIT X
+1 ;
BILLED(IBTRN) ;returns bill IFN if Claims Tracking event is already associated with an uncancelled bill
+1 ;for inpatients interim with no final bill, returns last bill^last bill date, 0 otherwise
+2 ;based on most recent STATEMENT TO date
+3 NEW X,Y,IBIFN
SET X=0
IF +$GET(IBTRN)
SET IBIFN=""
FOR
SET IBIFN=$ORDER(^IBT(356.399,"ACB",IBTRN,IBIFN))
if 'IBIFN
QUIT
Begin DoDot:1
+4 SET Y=$GET(^DGCR(399,+IBIFN,0))
IF $PIECE(Y,U,13)'=7
SET X=IBIFN
IF $PIECE(Y,U,4)<3
IF ($PIECE(Y,U,6)=2!($PIECE(Y,U,6)=3))
SET X=IBIFN_U_$PIECE($GET(^DGCR(399,+IBIFN,"U")),U,2)
End DoDot:1
IF +X
IF $PIECE(X,U,2)=""
QUIT
+5 QUIT X