IBRUTL ;ALB/CPM - INTEGRATED BILLING - A/R INTERFACE UTILITIES ; 03-MAR-92
;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
;;Per VHA Directive 10-93-142, this routine should not be modified.
;
IB(IEN,RETN) ; Are there any IB Actions on hold for this bill?
; Input: IEN -- ien of Bill(#399), A/R(#430)
; RETN (opt) -- Want array of IB Actions? (1-Yes,0-No)
; if yes, returns IBA(num)=ibn
; Returns: 1 -- Yes, 0 -- No
;
N ATYPE,BTYPE,BILLS,DFN,IBFR,IB0,IBTO,IBU,IBN,IBND,IBNUM,IBOK
S:'$D(RETN) RETN=0 S BILLS=0
;
; - determine patient, bill type and billing dates
S IB0=$G(^DGCR(399,IEN,0)),IBU=$G(^("U")),DFN=+$P(IB0,"^",2)
S BTYPE=$S(+$P(IB0,"^",5)<3:"I",1:"O"),IBFR=+IBU,IBTO=$P(IBU,"^",2)
;
; - loop through all bills on hold, and set flag if there is an
; - IB Action of the same type as the UB-82 which has been billed
; - within the statement dates of the UB-82. Store all actions
; - in the array IBA if required.
S (IBN,IBNUM)=0 F S IBN=$O(^IB("AH",DFN,IBN)) Q:'IBN D I IBOK Q:'RETN S IBNUM=IBNUM+1,IBA(IBNUM)=IBN
. S IBOK=0,IBND=$G(^IB(IBN,0)) Q:'IBND
. S ATYPE=$S($P($G(^IBE(350.1,+$P(IBND,"^",3),0)),"^")["OPT":"O",1:"I") Q:ATYPE'=BTYPE
. Q:$P(IBND,"^",15)<IBFR!($P(IBND,"^",14)>IBTO) S (IBOK,BILLS)=1
;
Q BILLS
;
;
HOLD(X,IBN,IBDUZ,IBSEQNO) ; Place IB Action on hold?
; Input: X -- Zeroth node of IB Action
; IBN -- ien of IB Action
; IBDUZ -- User ID
; IBSEQNO -- 1 (New Action), 3 (Update Action)
; Returns: 1 -- Yes, 0 -- No
;
N DFN,IBINS,IBINDT,IBOUTP,HOLD,IBHOLDP,IBDUZ,I
S IBHOLDP=$P($G(^IBE(350.9,1,1)),"^",20),DFN=+$P(X,"^",2)
;
I $P(X,"^",5)=8 G HOLDQ ; action is already on hold
I '$P($G(^IBE(350.1,+$P(X,"^",3),0)),"^",10) G HOLDQ ; action can't be placed on hold
;
; - see if patient has insurance on Event date
S IBINDT=$P($G(^IB(+$P(X,"^",16),0)),"^",17),IBOUTP=1
D ^IBCNS S:IBHOLDP HOLD=IBINS
;
; - generate bulletin if patient has insurance, bulletin not suppressed
I IBINS,'$P($G(^IBE(350.9,1,0)),"^",15) D ^IBRBUL
;
; - update action to 'Hold' if parameter is set and vet has insurance
I IBHOLDP,IBINS S DIE="^IB(",DA=IBN,DR=".05////8" D ^DIE,UP3^IBR:IBSEQNO=3 K DA,DIE,DR,IBI,IBJ
;
HOLDQ Q +$G(HOLD)
IBRUTL ;ALB/CPM - INTEGRATED BILLING - A/R INTERFACE UTILITIES ; 03-MAR-92
+1 ;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
+2 ;;Per VHA Directive 10-93-142, this routine should not be modified.
+3 ;
IB(IEN,RETN) ; Are there any IB Actions on hold for this bill?
+1 ; Input: IEN -- ien of Bill(#399), A/R(#430)
+2 ; RETN (opt) -- Want array of IB Actions? (1-Yes,0-No)
+3 ; if yes, returns IBA(num)=ibn
+4 ; Returns: 1 -- Yes, 0 -- No
+5 ;
+6 NEW ATYPE,BTYPE,BILLS,DFN,IBFR,IB0,IBTO,IBU,IBN,IBND,IBNUM,IBOK
+7 IF '$DATA(RETN)
SET RETN=0
SET BILLS=0
+8 ;
+9 ; - determine patient, bill type and billing dates
+10 SET IB0=$GET(^DGCR(399,IEN,0))
SET IBU=$GET(^("U"))
SET DFN=+$PIECE(IB0,"^",2)
+11 SET BTYPE=$SELECT(+$PIECE(IB0,"^",5)<3:"I",1:"O")
SET IBFR=+IBU
SET IBTO=$PIECE(IBU,"^",2)
+12 ;
+13 ; - loop through all bills on hold, and set flag if there is an
+14 ; - IB Action of the same type as the UB-82 which has been billed
+15 ; - within the statement dates of the UB-82. Store all actions
+16 ; - in the array IBA if required.
+17 SET (IBN,IBNUM)=0
FOR
SET IBN=$ORDER(^IB("AH",DFN,IBN))
IF 'IBN
QUIT
Begin DoDot:1
+18 SET IBOK=0
SET IBND=$GET(^IB(IBN,0))
IF 'IBND
QUIT
+19 SET ATYPE=$SELECT($PIECE($GET(^IBE(350.1,+$PIECE(IBND,"^",3),0)),"^")["OPT":"O",1:"I")
IF ATYPE'=BTYPE
QUIT
+20 IF $PIECE(IBND,"^",15)<IBFR!($PIECE(IBND,"^",14)>IBTO)
QUIT
SET (IBOK,BILLS)=1
End DoDot:1
IF IBOK
IF 'RETN
QUIT
SET IBNUM=IBNUM+1
SET IBA(IBNUM)=IBN
+21 ;
+22 QUIT BILLS
+23 ;
+24 ;
HOLD(X,IBN,IBDUZ,IBSEQNO) ; Place IB Action on hold?
+1 ; Input: X -- Zeroth node of IB Action
+2 ; IBN -- ien of IB Action
+3 ; IBDUZ -- User ID
+4 ; IBSEQNO -- 1 (New Action), 3 (Update Action)
+5 ; Returns: 1 -- Yes, 0 -- No
+6 ;
+7 NEW DFN,IBINS,IBINDT,IBOUTP,HOLD,IBHOLDP,IBDUZ,I
+8 SET IBHOLDP=$PIECE($GET(^IBE(350.9,1,1)),"^",20)
SET DFN=+$PIECE(X,"^",2)
+9 ;
+10 ; action is already on hold
IF $PIECE(X,"^",5)=8
GOTO HOLDQ
+11 ; action can't be placed on hold
IF '$PIECE($GET(^IBE(350.1,+$PIECE(X,"^",3),0)),"^",10)
GOTO HOLDQ
+12 ;
+13 ; - see if patient has insurance on Event date
+14 SET IBINDT=$PIECE($GET(^IB(+$PIECE(X,"^",16),0)),"^",17)
SET IBOUTP=1
+15 DO ^IBCNS
IF IBHOLDP
SET HOLD=IBINS
+16 ;
+17 ; - generate bulletin if patient has insurance, bulletin not suppressed
+18 IF IBINS
IF '$PIECE($GET(^IBE(350.9,1,0)),"^",15)
DO ^IBRBUL
+19 ;
+20 ; - update action to 'Hold' if parameter is set and vet has insurance
+21 IF IBHOLDP
IF IBINS
SET DIE="^IB("
SET DA=IBN
SET DR=".05////8"
DO ^DIE
IF IBSEQNO=3
DO UP3^IBR
KILL DA,DIE,DR,IBI,IBJ
+22 ;
HOLDQ QUIT +$GET(HOLD)