Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: IBARXEU3

IBARXEU3.m

Go to the documentation of this file.
  1. IBARXEU3 ;ALB/AAS - RX COPAY EXEMPTION PROCESS AR CANCELS ; 8-JAN-93
  1. ;;Version 2.0 ; INTEGRATED BILLING ;**16,34**; 21-MAR-94
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. CANCEL ; Cancel Rx copay charges when veteran becomes exempt.
  1. ; Required variable input:
  1. ; DFN -- Pointer to the patient in file #2
  1. ; IBSTAT -- patient is non-exempt (0) or exempt (1)
  1. ; IBEVTA -- Zeroth node in #354.1 of CURRENT exemption
  1. ; IBEVTP -- Zeroth node in #354.1 of PRIOR exemption
  1. ;
  1. N IBDT,IBEDT,IBCODA,IBCODP,IBSITE,IBAFY,IBATYP,IBCHRG,IBXX
  1. N IBCRES,IBERR,IBFAC,IBIL,IBL,IBLAST,IBLDT,IBN,IBND,IBNN,IBNOW,IBFOUND
  1. N IBPARNT,IBPARNT1,IBSEQNO,IBUNIT,IBVLAST,IBCODVL,IBANVD,IBFIL
  1. ;
  1. ; - veteran must be currently exempt,
  1. I 'IBSTAT G CANCELQ
  1. ;
  1. ; - due to income < pension,
  1. S IBCODP=$$ACODE^IBARXEU0(IBEVTP),IBCODA=$$ACODE^IBARXEU0(IBEVTA)
  1. G:IBCODA'=120 CANCELQ
  1. ;
  1. ; - when s/he was previously non-exempt, due to no income data,
  1. I $S(IBCODP="":0,IBCODP=210:0,1:1) G CANCELQ
  1. ;
  1. ; - after having been exempt due to income < pension.
  1. S IBVLAST=$$LST^IBARXEU0(DFN,+IBEVTP-.01),IBCODVL=$$ACODE^IBARXEU0(IBVLAST)
  1. G:IBCODVL'=120 CANCELQ
  1. ;
  1. ; - calculate 'anniversary date' from original exemption
  1. S IBANVD=$$PLUS^IBARXEU0(+IBVLAST)
  1. ;
  1. ; - 'filing' date of new exemption must be within 90 days of this date
  1. S IBFIL=$P($G(^DGMT(408.31,+$$LST^DGMTCOU1(DFN,+IBEVTA,3),0)),"^",7)
  1. I $$FMDIFF^XLFDT(IBFIL,IBANVD)>90 G CANCELQ
  1. ;
  1. ; - set start date for cancelling at beginning of non-exempt period.
  1. ; - end date: today (if the new exemption is the most current), or
  1. ; the end of the exemption just started (day before
  1. ; the most current exemption)
  1. S IBBDT=+IBEVTA I IBEVTP,+IBEVTP<+IBEVTA S IBBDT=+IBEVTP
  1. S:IBBDT<$$STDATE^IBARXEU IBBDT=$$STDATE^IBARXEU
  1. S IBXX=$$LST^IBARXEU0(DFN)
  1. S IBEDT=$S(+IBXX=+IBEVTA:DT,1:$$FMADD^XLFDT(+IBXX,-1))
  1. ;
  1. ; - move the start date up past the last cancellation end date
  1. S X=-$O(^IBA(354.1,"ACAN",DFN,""))
  1. I X'<IBBDT S IBBDT=X
  1. ;
  1. ; - quit if the start date slipped ahead of the end date
  1. I IBEDT<IBBDT G CANCELQ
  1. ;
  1. ; - quit if there are no charges to cancel
  1. S X=$O(^IB("APTDT",DFN,(IBBDT-.01))) I 'X!(X>(IBEDT+.9)) G CANCELQ
  1. ;
  1. ; - cancel the charges in billing
  1. S Y=1 D ARPARM^IBAUTL I Y<0 G CANCELQ
  1. ;
  1. S IBDATE=IBBDT-.0001,IBFOUND=0
  1. F S IBDATE=$O(^IB("APTDT",DFN,IBDATE)) Q:'IBDATE!((IBEDT+.9)<IBDATE) D
  1. .S IBNN=0 F S IBNN=$O(^IB("APTDT",DFN,IBDATE,IBNN)) Q:'IBNN D BILL
  1. ;
  1. ; - cancel bills in AR, if at least one charge was cancelled
  1. I IBFOUND S IBARCAN=1 D ARCAN^IBARXEU4(DFN,IBSTAT,IBBDT,IBEDT)
  1. ;
  1. CANCELQ Q
  1. ;
  1. BILL ; -- process cancelling one bill
  1. S X=$G(^IB(IBNN,0)) Q:X=""
  1. Q:+$P(X,"^",4)'=52 ;quit if not pharmacy co-pay
  1. ;
  1. ; -- find parent
  1. S IBPARNT=$P(X,"^",9)
  1. ;
  1. S IBPARDT=$P($G(^IB(IBPARNT,1)),"^",2) ; get date of parent charge
  1. I $S(IBPARDT="":1,IBPARDT<IBBDT:1,IBPARDT>(IBEDT+.9):1,1:0) Q ; ignore charges started before or after date range
  1. ;
  1. ; -- get most recent ibaction
  1. S IBPARNT1=IBPARNT F S IBPARNT1=$P($G(^IB(IBPARNT,0)),"^",9) Q:IBPARNT1=IBPARNT S IBPARNT=IBPARNT1 ;gets parent of parents
  1. S IBLAST=$$LAST^IBECEAU(IBPARNT)
  1. ;
  1. Q:$P(^IBE(350.1,$P(^IB(IBLAST,0),"^",3),0),"^",5)=2 ;quit if already cancelled
  1. ;
  1. S IBCRES=$O(^IBE(350.3,"B","RX COPAY INCOME EXEMPTION",0)) ; get cancellation reason
  1. ;
  1. D CANRX
  1. Q
  1. ;
  1. CANRX ; -- do actual cancellation without calling ar
  1. ; input : iblast := last entry for parnt
  1. ; ibparnt := parent charge
  1. ; ibnd := ^(0) node of iblast
  1. ;
  1. I $D(^IB(IBLAST,0)),$P(^IBE(350.1,$P(^IB(IBLAST,0),"^",3),0),"^",5)=2 G CANRXQ ;already cancelled
  1. S IBND=$G(^IB(+IBLAST,0)),IBDUZ=DUZ
  1. ;
  1. S IBATYP=$P(^IBE(350.1,+$P($G(^IB(IBPARNT,0)),"^",3),0),"^",6) ;cancellation action type for parent
  1. I '$D(^IBE(350.1,+IBATYP,0)) G CANRXQ
  1. S IBSEQNO=$P(^IBE(350.1,+IBATYP,0),"^",5) I 'IBSEQNO G CANRXQ
  1. S IBIL=$P($G(^IB(IBPARNT,0)),"^",11)
  1. S IBUNIT=$S($P(IBND,"^",6):$P(IBND,"^",6),$D(^IB(IBPARNT,0)):$P(^(0),"^",6),1:0) I IBUNIT<1 G CANRXQ
  1. S IBCHRG=$S($P(IBND,"^",7):$P(IBND,"^",7),$D(^IB(IBPARNT,0)):$P(^(0),"^",7),1:0) I IBCHRG<1 G CANRXQ
  1. ;
  1. D ADD^IBAUTL I +Y<1 G CANRXQ
  1. S $P(^IB(IBN,1),"^",1)=IBDUZ,$P(^IB(IBN,0),"^",2,13)=DFN_"^"_IBATYP_"^"_$P(IBND,"^",4)_"^11^"_IBUNIT_"^"_IBCHRG_"^"_$P(IBND,"^",8)_"^"_IBPARNT_"^"_IBCRES_"^"_IBIL_"^^"_IBFAC
  1. K ^IB("AC",1,IBN)
  1. S DA=IBN,DIK="^IB(" D IX^DIK
  1. S IBFOUND=1
  1. ;
  1. ; -- update parent to cancelled
  1. ; note: parent status=10, cancellation due to exemption reason only
  1. ; on charge cancelled so reports work right.
  1. S DIE="^IB(",DA=IBPARNT,DR=".05////10;.1////"_IBCRES D ^DIE K DIE,DA,DR
  1. CANRXQ Q