IBAMTV ;ALB/CPM - BACK-BILLING SUPPORT FOR IVM ; 31-MAY-94
;;2.0;INTEGRATED BILLING;**15,153**;21-MAR-94
;;Per VHA Directive 10-93-142, this routine should not be modified.
;
; Input: DFN -- Pointer to the patient in file #2
; DGMTP -- Zeroth node of previous MT in file #408.31
; DGMTA -- Zeroth node of verified MT in file #408.31
;
; - begin back-billing from the original completed date.
S IBSTART=$P(DGMTA,"^",7) G:'IBSTART!(IBSTART'
DT IBEND=DT
S IBZ="" F S IBZ=$O(^IB("AFDT",DFN,IBZ)) Q:'IBZ I -IBZ'>IBEND S IBZ1=0 F S IBZ1=$O(^IB("AFDT",DFN,IBZ,IBZ1)) Q:'IBZ1 D
.S IBDA=0 F S IBDA=$O(^IB("AF",IBZ1,IBDA)) Q:'IBDA D
..Q:'$D(^IB(IBDA,0)) S IBX=^(0)
..Q:$P(IBX,"^",8)["ADMISSION" ; skip event records
..Q:$P(IBX,"^",9)'=IBDA ; look only at original actions
..S (IBN,IBORIG)=$$LAST^IBECEAU(IBDA),IBND=$G(^IB(IBN,0)),IBND1=$G(^(1))
..I IBN=IBDA&($P(IBX,"^",5)=10)!($P($G(^IBE(350.1,+$P(IBND,"^",3),0)),"^",5)=2) Q ; already cancelled
..I $P(IBND,"^",15)IBEND) Q ; out of range
..Q:$$BIL^DGMTUB(DFN,$P(IBND,"^",14)) ; still Means Test billable
..D CANCH^IBECEAU4(IBN,IBCRES)
..S IBN=$$LAST^IBECEAU(IBDA),IBND=$G(^IB(IBN,0)),IBX=$G(^IB(IBORIG,0))
..I IBN=IBDA&($P(IBX,"^",5)=10)!($P($G(^IBE(350.1,+$P(IBND,"^",3),0)),"^",5)=2) S IBFOUND=1 D ADJCL
;
I IBFOUND D CANBULL
K IBCRES,IBST,IBEND,IBZ,IBZ1,IBDA,IBX,IBN,IBND,IBND1,IBJOB,IBWHER,IBDUZ,IBFOUND,IBORIG
Q
;
CANBULL ; Generate the cancellation bulletin.
K IBT S IBPT=$$PT^IBEFUNC(DFN)
S XMSUB="CANCELLATION OF BACK-BILLED MEANS TEST CHARGES"
S IBT(1)="An IVM-verified Means Test was just deleted for the following patient:"
S IBT(2)=" " S IBC=2
S IBDUZ=DUZ D PAT^IBAERR1
S IBC=IBC+1,IBT(IBC)=" "
S IBC=IBC+1,IBT(IBC)="All back-billed Means Test charges for this patient were cancelled."
S IBC=IBC+1,IBT(IBC)="You should review this patient's Means Test billing history and billing"
S IBC=IBC+1,IBT(IBC)="clock for accuracy, starting on "_$$DAT1^IBOUTL(+DGMTA)_"."
D SEND^IBACVA2
K IBDUZ
Q
;
ADJCL ; Roll back the billing clock for cancelled charges.
; Input: IBX -- Zeroth node of charge which has been cancelled.
; DFN -- Pointer to the patient in file #2
;
N IBCL,IBCLD,IBUN,IBCLDAY,IBCHG,IBCLP,IBAP
Q:$P(IBX,"^",8)["OPT COPAY" ; no adjustments needed for opt copays
S IBCL=$$OLDCL^IBAMTV2(DFN,$P(IBX,"^",14)) Q:'IBCL ; no clock
S IBCLD=$G(^IBE(351,IBCL,0)) Q:'IBCLD
;
; - handle per diem charges
I $P($G(^IBE(350.1,+$P(IBX,"^",3),0)),"^",11)=3 D
.S IBUN=$P(IBX,"^",6),IBCLDAY=$P(IBCLD,"^",9)
.S $P(^IBE(351,IBCL,0),"^",9)=$S(IBCLDAY>IBUN:IBCLDAY-IBUN,1:0) D UPD
;
; - handle inpt copay charges
I $P($G(^IBE(350.1,+$P(IBX,"^",3),0)),"^",11)=2 D
.S IBCHG=$P(IBX,"^",7) Q:'IBCHG
.F IBCLP=8:-1:5 S IBAP=$P(IBCLD,"^",IBCLP) D Q:'IBCHG
..I IBCHG>IBAP S IBCHG=IBCHG-IBAP,$P(^IBE(351,IBCL,0),"^",IBCLP)=0 D UPD Q
..S $P(^IBE(351,IBCL,0),"^",IBCLP)=IBAP-IBCHG,IBCHG=0 D UPD
;
Q
;
UPD ; Update user and edit date on the Billing Clock.
D NOW^%DTC S $P(^IBE(351,IBCL,1),"^",3,4)=DUZ_"^"_%
Q