IBAUTL8A ;ALB/MGD - DUPLICATE COPAY TRANSACTION UTILITIES CONT.; Sep 30, 2020@15:16:44
;;2.0;INTEGRATED BILLING;**630**;21-MAR-94;Build 39
;;Per VA Directive 6402, this routine should not be modified.
;
; ****************************************************************************
; This routine is designed to implement a series of final checks immediately *
; prior to IB releasing a charge over to Accounts Receivable (AR). *
; IBAUTL9 handles the storing of associated information related to any *
; duplicate copays found by IBAUTL8. *
; These updates are part being released in IB*2.0*630. *
; ****************************************************************************
;
IPDNEW(IBN,IBEVDT,IBACTION,IBINTACT) ;
; Perform checks for a new Inpatient Per Diem charge to determine if this charge should be passed over to AR.
; Input: IBN = Pointer to Inpatient Per Diem charge currently being reviewed in the INTEGRATED BILLING ACTION (#350) file
; IBEVDT = Event Date for the charge currently being reviewed in the INTEGRATED BILLING ACTION (#350) file
; IBACTION = Passed by reference. Passed in as 0:Pass to AR
; IBINTACT = Optional - Flag to indicate when the call is being made from an interactive option.
; 1:Interactive
; 0:Non-Interactive
; For more info see COPAYCHK above
;
; Output: IBACTION = 0 if the current charge being reviewed should be passed over to AR
; # The IEN of the existing Copay charge for the Patient/Date of interest.
; The charge being reviewed should NOT be passed over to AR.
;
; Verify incoming value of IBACTION and default to 0 if not defined
S IBACTION=$S(IBACTION'="":IBACTION,1:0)
; Quit if necessary data was not passed in
I +IBN<=0!(+IBEVDT'?7N) Q IBACTION
; If IBINTACT was not passed in, default it to 0:Non-Interactive
S IBINTACT=$S(IBINTACT'="":IBINTACT,1:0)
N IBBFI,IBBFO,IBBFOB,IBLTC,IBBPD,IBDFN,IBRSN,IBCTOT,IBETOT,IBAT1,IBAT2
; Load Patient IEN from IBN passed in
S IBDFN=+$P($G(^IB(IBN,0)),U,2)
; Quit if no IEN in record
I IBDFN<1 Q IBACTION
; Determine if the Patient has already been charged an Inpatient Copay for the Event Date
S IBBFI=$$BFI^IBAUTL8C(IBDFN,IBEVDT,IBN)
; Take actions based on there being an existing Inpatient Copay
I IBBFI D Q:IBACTION
. ; Set IBACTION = IEN of existing Inpatient Copay
. S IBACTION=IBBFI
. ; Check for legal pairings
. ; Load Action Types of the two charges
. S IBAT1=$P($G(^IB(IBN,0)),U,3),IBAT2=$P($G(^IB(IBBFI,0)),U,3)
. ; If 2 copays for a single day are a legal pairing, set IBACTION =0
. ; If the Action Type is CC INPATIENT (133) and the Per Diem is CC PER DIEM (#130)
. I IBAT1=133,IBAT2=130 S IBACTION=0
. ; If the Action Type is one of the copays in Billing Group #2 and the Per Diem
. ; copay is INPATIENT PER DIEM (#45) set IBACTION =0
. I IBAT1=45,("^16^17^18^19^20^21^22^23^"[("^"_IBAT2_"^")) S IBACTION=0
. ; If the Action Type is NHCU COPAY (#24) and the Per Diem is NHCU PER DIEM (#48) set IBACTION =0
. I IBAT1=48,IBAT2=24 S IBACTION=0
. ; Quit if interactive
. Q:IBINTACT
. ; Record related info into ^XTMP for MailMan message
. S IBRSN="AN INPATIENT COPAY CHARGE BILLED AT HIGHER PRECEDENCE"
. D STORE1^IBAUTL9(IBN,IBBFI,IBRSN)
;
; Determine if the Patient has already been charged an Inpatient Per Diem charge for the Event Date
S IBBPD=$$BFPD^IBAUTL8A(IBDFN,IBEVDT,IBN)
; If the Patient has already been charged an Inpatient Per Diem charge for the Event Date
I IBBPD D Q
. ; Set return value to NOT pass the charge over to AR
. S IBACTION=IBBPD
. ; Quit if interactive
. Q:IBINTACT
. ; Load dollar amounts from the 2 charges
. S IBCTOT=+$P($G(^IB(IBN,0)),U,7),IBETOT=+$P($G(^IB(+IBBPD,0)),U,7)
. ; If the current charge being processed is <= to the existing Inpatient Per Diem charge
. I IBCTOT<=IBETOT D Q
. . ; Cancel current charge with CANCELLATION REASON = 4 - ENTERED IN ERROR
. . ; ### Uncomment for Phase 2 D CNCLCHRG^IBAUTL8A(IBN,4)
. . ; Record related info into ^XTMP for MailMan message
. . S IBRSN="EXISTING INPATIENT PER DIEM CHARGE AT SAME OR HIGHER TIER RATE"
. . D STORE1^IBAUTL9(IBN,IBBPD,IBRSN)
. . Q
. ; If the current charge being processed is > than the existing Inpatient Per Diem charge
. I IBCTOT>IBETOT D Q
. . ; IBND has to be set to 0 node for call to CANC^IBECEAU4
. . ; ### N IBND S IBND=$G(^IB(IBN,0))
. . ; IBFAC and IBSITE needed by Cancel operation below
. . ; ### N IBFAC,IBSITE
. . ; Calculate site from site parameters
. . ; ### D SITE^IBAUTL
. . ; Cancel existing charge with Reason = 42 - BILLED AT HIGHER TIER RATE
. . ; UNCOMMENT THIS AND TEST MORE ON WHAT HAPPENS IN THE CANCELLATION PROCESS
. . ; ### I 'IBINTACT D CANC^IBECEAU4(IBBPD,42,1)
. . ; Record related info into ^XTMP for MailMan message
. . S IBRSN="ANOTHER INPATIENT PER DIEM CHARGE BILLED AT HIGHER TIER RATE"
. . D STORE2^IBAUTL9(IBN,IBBPD,IBRSN)
. . Q
. Q
;
; Determine if the Patient has an Outpatient Observation Copay for the Event Date
S IBBFOB=$$BFOB^IBAUTL8A(IBDFN,IBEVDT,IBN)
; if there is an existing Outpatient Observation Copay, Do the following
I +IBBFOB D Q
. ; Set IBACTION = IEN of Outpatient Observation Copay
. S IBACTION=IBBFOB
. ; Quit if interactive
. Q:IBINTACT
. ; ###Uncomment for Phase 2
. ; IBND has to be set to 0 node for call to CANC^IBECEAU4
. ; ### N IBND S IBND=$G(^IB(IBN,0))
. ; IBFAC and IBSITE needed by Cancel operation below
. ; ### N IBFAC,IBSITE
. ; Calculate site from site parameters
. ; ### D SITE^IBAUTL
. ; Cancel the existing Outpatient Observation Copay charge with
. ; CANCELLATION REASON = 42 - BILLED AT HIGHER TIER RATE
. ; ### I 'IBINTACT D CANC^IBECEAU4(IBBFI,42,1)
. ; Record related info into ^XTMP for MailMan message
. S IBRSN="AN INPATIENT PER DIEM CHARGE BILLED AT HIGHER PRECEDENCE"
. D STORE2^IBAUTL9(IBN,IBBFOB,IBRSN)
. Q
;
; Determine if the Patient has an Outpatient Copay for the Event Date
S IBBFO=$$BFO^IBAUTL8A(IBDFN,IBEVDT,IBN)
; If the Patient has already been charged an Outpatient Copay for the Event Date, set IBACTION and quit
I IBBFO D Q
. ; Set IBACTION = IEN of Outpatient Copay
. S IBACTION=IBBFO
. ; Quit if interactive
. Q:IBINTACT
. ; ###Uncomment for Phase 2
. ; IBND has to be set to 0 node for call to CANC^IBECEAU4
. ; ### N IBND S IBND=$G(^IB(IBN,0))
. ; IBFAC and IBSITE needed by Cancel operation below
. ; ### N IBFAC,IBSITE
. ; Calculate site from site parameters
. ; ### D SITE^IBAUTL
. ; Cancel the existing Outpatient Observation Copay charge with
. ; CANCELLATION REASON = 42 - BILLED AT HIGHER TIER RATE
. ; ### I 'IBINTACT D CANC^IBECEAU4(IBBFI,42,1)
. ; Record related info into ^XTMP for MailMan message
. S IBRSN="AN INPATIENT PER DIEM CHARGE BILLED AT HIGHER PRECEDENCE"
. D STORE2^IBAUTL9(IBN,IBBFO,IBRSN)
. Q
;
; Determine if the Patient has an Long Term Care Copay for the Event Date
S IBLTC=$$LTC^IBAUTL8B(IBDFN,IBEVDT,IBN)
; If the patient has been charged a Long Term Care Copay for the Event Date, set IBACTION and quit
I IBLTC D Q
. ; Set IBACTION = IEN of Outpatient Copay
. S IBACTION=IBLTC
. ; Quit if interactive
. Q:IBINTACT
. ; ###Uncomment for Phase 2
. ; IBND has to be set to 0 node for call to CANC^IBECEAU4
. ; ### N IBND S IBND=$G(^IB(IBN,0))
. ; IBFAC and IBSITE needed by Cancel operation below
. ; ### N IBFAC,IBSITE
. ; Calculate site from site parameters
. ; ### D SITE^IBAUTL
. ; Cancel the existing Outpatient Observation Copay charge with
. ; CANCELLATION REASON = 42 - BILLED AT HIGHER TIER RATE
. ; ### I 'IBINTACT D CANC^IBECEAU4(IBBFI,42,1)
. ; Record related info into ^XTMP for MailMan message
. S IBRSN="AN INPATIENT PER DIEM CHARGE BILLED AT HIGHER PRECEDENCE"
. D STORE2^IBAUTL9(IBN,IBLTC,IBRSN)
Q
;
BFO(DFN,IBDATE,IBNEW) ; Patient Billed For Outpatient Copay on a specified date?
; Input: DFN - Pointer to the patient in file #2
; IBDATE - Date of the Inpatient Visit
; IBNEW - IEN of new charge in File #350
; Output: 0 - Not billed the OPT copay on the visit date
; >0 - Pointer to charge in file #350 that was billed
;
; Outpatient Copays charges will be in Billing Group 4 and have Action Types:
; Action Types = 51 - DG OPT COPAY NEW 136 - CC (OPT) NEW
; 203 - CC URGENT CARE (OPT) NEW
;
N IBAMT,IBATYP,IBATYPN,IBCHRG,IBDATA0,IBN,IBSTOPDT
S (IBATYP,IBATYPN)="",IBAMT=0
; Initialize the return variable to 0 - Not billed the Outpatient copay on the visit date
S IBCHRG=0
I '$G(DFN)!('$G(IBDATE)) Q +$G(IBCHRG)
; Set stop date for loop
S IBSTOPDT=$P(IBDATE,".",1)
; Strip off time portion of DATA and reset IBDATE for looping by subtracting .000001
S IBDATE=$P(IBDATE,".",1)-.000001
; Loop through Date/Time entries (earliest to latest) for the single date being checked
F S IBDATE=$O(^IB("ACHDT",DFN,IBDATE)) Q:'IBDATE!($P(IBDATE,".",1)>IBSTOPDT) D
. ; Loop through the individual charges
. S IBN=0
. F S IBN=$O(^IB("ACHDT",DFN,IBDATE,IBN)) Q:'IBN D
. . ; Quit if entry found in ACHDT is the entry we are currently processing
. . Q:IBN=IBNEW
. . ; Load 0 node in File #350 for this record
. . S IBDATA0=$G(^IB(IBN,0))
. . ; Quit if ACTION TYPE is not an Outpatient Copay
. . Q:"^51^136^203^"'[("^"_$P(IBDATA0,U,3)_"^")
. . ; using the ACTION TYPE (#.03) field of the INTEGRATED BILLING ACTION file (#350) set IBATYP = 0 Node of the IB ACTION TYPE file (#350.1)
. . S IBATYP=$G(^IBE(350.1,+$P(IBDATA0,"^",3),0))
. . ; Using IBATYP set IBATYPN = NEW ACTION TYPE (#.09)
. . S IBATYPN=$G(^IBE(350.1,+$P(IBATYP,"^",9),0))
. . ; Quit if any of the key data for the checks is missing
. . I IBDATA0=""!(IBATYP="")!(IBATYPN="") Q
. . ; Check if the BILLING GROUP field (#.11) and the ACTION TYPE (#.03) matches to the
. . ; specific combinations provided by the SMEs.
. . ; Check for Billing Group = 4:OPT COPAY & charge type = an OPT COPAY (51^136^203)
. . I $P(IBATYPN,"^",11)=4,("^51^136^203^"[("^"_$P(IBDATA0,U,3)_"^")) D
. . . ; IF 1:NEW or 3:UPDATE is contained in the SEQUENCE NUMBER field (#.05) in the IB ACTION TYPE file (#350.1)
. . . ; AND the STATUS field (#.05) in the INTEGRATED BILLING ACTION file (#350) is one of the following:
. . . ; 1:INCOMPLETE, 2:COMPLETE, 3:BILLED, 4:UPDATED, 8:ON HOLD, 20:HOLD - RATE
. . . ; THEN set IBCHRG = IEN of the duplicate Outpatient Copay
. . . I "^1^3^"[("^"_$P(IBATYP,"^",5)_"^"),"^1^2^3^4^8^20^"[("^"_+$P(IBDATA0,"^",5)_"^") D
. . . . ; Compare the TOTAL CHARGE of this Outpatient Copay charge to any previously identified
. . . . ; Outpatient Copay for the same date and save the IEN of the highest charge
. . . . I +$P(IBDATA0,U,7)>IBAMT S IBAMT=+$P(IBDATA0,U,7),IBCHRG=IBN
. . . . Q
. . . Q
. . Q
. Q
Q +$G(IBCHRG)
;
BFOB(DFN,IBDATE,IBNEW) ; Patient Billed For Outpatient Observation Copay on a specified date?
; Input: DFN - Pointer to the patient in file #2
; IBDATE - Date of the Outpatient Visit
; IBNEW - IEN of new charge in File #350
; Output: 0 - Not billed the OPT copay on the visit date
; >0 - Pointer to charge in file #350 that was billed
;
; Outpatient Observation Copays charges will have the following Billing Group & Action Types:
; Billing Group = 4 - OPT COPAY
; 74 - DG OBSERVATION COPAY NEW
;
N IBAMT,IBATYP,IBATYPN,IBCHRG,IBDATA0,IBN,Y,IBSTOPDT
S (IBATYP,IBATYPN)="",IBAMT=0
; Initialize the return variable to 0 - Not billed the Outpatient Observation Copay on the visit date
S IBCHRG=0
I '$G(DFN)!'$G(IBDATE) Q +$G(IBCHRG)
; Set stop date for loop
S IBSTOPDT=$P(IBDATE,".",1)
; Strip off time portion of DATA and reset IBDATE for looping by subtracting .000001
S IBDATE=$P(IBDATE,".",1)-.000001
; Loop through Date/Time entries (earliest to latest) for the single date being checked
F S IBDATE=$O(^IB("ACHDT",DFN,IBDATE)) Q:'IBDATE!($P(IBDATE,".",1)>IBSTOPDT) D
. ; Loop through the individual charges
. S IBN=0
. F S IBN=$O(^IB("ACHDT",DFN,IBDATE,IBN)) Q:'IBN D
. . ; Quit it entry found in ACHDT is the entry we are currently processing
. . Q:IBN=IBNEW
. . ; Load 0 node in File #350 for this record
. . S IBDATA0=$G(^IB(IBN,0))
. . ; Quit if ACTION TYPE is not an Outpatient Observation Copay
. . Q:$P(IBDATA0,U,3)'=74
. . ; using the ACTION TYPE (#.03) field of the INTEGRATED BILLING ACTION file (#350) set IBATYP = 0 Node of the IB ACTION TYPE file (#350.1)
. . S IBATYP=$G(^IBE(350.1,+$P(IBDATA0,"^",3),0))
. . ; Using IBATYP set IBATYPN = NEW ACTION TYPE (#.09)
. . S IBATYPN=$G(^IBE(350.1,+$P(IBATYP,"^",9),0))
. . ; Quit if any of the key data for the checks is missing
. . I IBDATA0=""!(IBATYP="")!(IBATYPN="") Q
. . ; IF the BILLING GROUP field (#.11) in the IB ACTION TYPE file (#350.1) is OPT COPAY (#4)
. . ; AND the SEQUENCE NUMBER (#.05) in the IB ACTION TYPE file (#350.1) is
. . ; 1:INCOMPLETE OR 3:BILLED
. . ; AND the STATUS field (#.05) in the INTEGRATED BILLING ACTION file (#350) is one of the following:
. . ; 1:INCOMPLETE, 2:COMPLETE, 3:BILLED, 4:UPDATED, 8:ON HOLD, 20:HOLD - RATE
. . ; THEN set IBCHRG = IEN of the Outpatient Observation Copay
. . I $P(IBATYPN,"^",11)=4,"^1^3^"[("^"_$P(IBATYP,"^",5)_"^"),"^1^2^3^4^8^20^"[("^"_+$P(IBDATA0,"^",5)_"^") D
. . . ; Compare the TOTAL CHARGE of this Outpatient Observation Copay charge to any previously identified
. . . ; Outpatient Observation Copay and save the IEN of the highest charge
. . . I +$P(IBDATA0,U,7)>IBAMT S IBAMT=+$P(IBDATA0,U,7),IBCHRG=IBN
. . Q
. Q
Q +$G(IBCHRG)
;
BFPD(DFN,IBDATE,IBNEW) ; Patient Billed For Per Diem Copay on a specified date?
; Input: DFN - Pointer to the patient in file #2
; IBDATE - Date of the Outpatient Visit
; IBNEW - IEN of charge in File #350
; Output: 0 - Not billed the OPT copay on the visit date
; >0 - Pointer to charge in file #350 that was billed
;
; Valid Per Diem charges have the following Billing Group & Action Types:
; Billing Group = 3 - INPT/NHCU PER DIEM
; 45 DG INPT PER DIEM NEW 48 DG NHCU PER DIEM NEW
; 133 CC (PER DIEM) NEW
;
N IBAMT,IBATYP,IBATYPN,IBCHRG,IBDATA0,IBN,IBSTOPDT
S (IBATYP,IBATYPN)="",IBAMT=0
; Initialize the IBCHRG to 0 - Not billed a Per Diem on the visit date
S IBCHRG=0
I '$G(DFN)!'$G(IBDATE) Q +$G(IBCHRG)
; Set stop date for loop
S IBSTOPDT=$P(IBDATE,".",1)
; Strip off time portion of DATA and reset IBDATE for looping by subtracting .000001
S IBDATE=$P(IBDATE,".",1)-.000001
; Loop through Date/Time entries (earliest to latest) for the single date being checked
F S IBDATE=$O(^IB("ACHDT",DFN,IBDATE)) Q:'IBDATE!($P(IBDATE,".",1)>IBSTOPDT) D
. ; Loop through the individual charges
. S IBN=0
. F S IBN=$O(^IB("ACHDT",DFN,IBDATE,IBN)) Q:'IBN D
. . ; Quit it entry found in ACHDT is the entry we are currently processing
. . Q:IBN=IBNEW
. . ; Load 0 node in File #350 for this record
. . S IBDATA0=$G(^IB(IBN,0))
. . ; Quit if ACTION TYPE is not an Per Diem Copay
. . Q:"^45^48^133^"'[("^"_$P(IBDATA0,U,3)_"^")
. . ; using the ACTION TYPE (#.03) field of the INTEGRATED BILLING ACTION file (#350) set IBATYP = 0 Node of the IB ACTION TYPE file (#350.1)
. . S IBATYP=$G(^IBE(350.1,+$P(IBDATA0,"^",3),0))
. . ; Using IBATYP set IBATYPN = NEW ACTION TYPE (#.09)
. . S IBATYPN=$G(^IBE(350.1,+$P(IBATYP,"^",9),0))
. . ; Quit if any of the key data for the checks is missing
. . I IBDATA0=""!(IBATYP="")!(IBATYPN="") Q
. . ; IF the BILLING GROUP field (#.11) in the IB ACTION TYPE file (#350.1) is INPT/NHCU PER DIEM (#3)
. . ; AND the SEQUENCE NUMBER (#.05) in the IB ACTION TYPE file (#350.1) is
. . ; 1:INCOMPLETE OR 3:BILLED
. . ; AND the STATUS field (#.05) in the INTEGRATED BILLING ACTION file (#350) is one of the following:
. . ; 1:INCOMPLETE, 2:COMPLETE, 3:BILLED, 4:UPDATED, 8:ON HOLD, 20:HOLD - RATE
. . ; THEN set IBCHRG = IEN of the Per Diem copay
. . I $P(IBATYPN,"^",11)=3,"^1^3^"[("^"_$P(IBATYP,"^",5)_"^"),"^1^2^3^4^8^20^"[("^"_+$P(IBDATA0,"^",5)_"^") D
. . . ; Compare the TOTAL CHARGE of this Per Diem Copay charge to any previously identified
. . . ; Per Diem Copay and save the IEN of the highest charge
. . . I +$P(IBDATA0,U,7)>IBAMT S IBAMT=+$P(IBDATA0,U,7),IBCHRG=IBN
. . Q
. Q
Q +$G(IBCHRG)
;
CNCLCHRG(IBN,IBCANRSN) ; Cancel a charge that will never be passed over to AR
; OR an existing charge in AR which is being replaced by a new charge at a higher Tier Rate.
; Input: IBN = IEN of record in the INTEGRATED BILLING ACTION (#350) file to edit
; IBCANRSN = the value to set into the CANCELLATION REASON (#.1) field in internal format
; Output: None
;
; The patch will initially be released as a info gathering patch so the set logic is currently
; commented out.
Q ; ### remove to activate #630 functionality
N IBFDA
; Quit if no valid IBN
Q:+IBN<=0
; If the CANCELLATION REASON was not passed in, set it to 4 - ENTERED IN ERROR
S IBCANRSN=$S(IBCANRSN'="":IBCANRSN,1:4)
; Set STATUS (#.05) to Cancelled (IEN=10)
S IBFDA(350,IBN,.05)=10
; Set CANCELLATION REASON (#.1) to value passed in
S IBFDA(350,IBN,.1)=IBCANRSN
; Cancel charge currently being reviewed
D FILE^DIE(,"IBFDA")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBAUTL8A 17692 printed Dec 13, 2024@02:08:12 Page 2
IBAUTL8A ;ALB/MGD - DUPLICATE COPAY TRANSACTION UTILITIES CONT.; Sep 30, 2020@15:16:44
+1 ;;2.0;INTEGRATED BILLING;**630**;21-MAR-94;Build 39
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ; ****************************************************************************
+5 ; This routine is designed to implement a series of final checks immediately *
+6 ; prior to IB releasing a charge over to Accounts Receivable (AR). *
+7 ; IBAUTL9 handles the storing of associated information related to any *
+8 ; duplicate copays found by IBAUTL8. *
+9 ; These updates are part being released in IB*2.0*630. *
+10 ; ****************************************************************************
+11 ;
IPDNEW(IBN,IBEVDT,IBACTION,IBINTACT) ;
+1 ; Perform checks for a new Inpatient Per Diem charge to determine if this charge should be passed over to AR.
+2 ; Input: IBN = Pointer to Inpatient Per Diem charge currently being reviewed in the INTEGRATED BILLING ACTION (#350) file
+3 ; IBEVDT = Event Date for the charge currently being reviewed in the INTEGRATED BILLING ACTION (#350) file
+4 ; IBACTION = Passed by reference. Passed in as 0:Pass to AR
+5 ; IBINTACT = Optional - Flag to indicate when the call is being made from an interactive option.
+6 ; 1:Interactive
+7 ; 0:Non-Interactive
+8 ; For more info see COPAYCHK above
+9 ;
+10 ; Output: IBACTION = 0 if the current charge being reviewed should be passed over to AR
+11 ; # The IEN of the existing Copay charge for the Patient/Date of interest.
+12 ; The charge being reviewed should NOT be passed over to AR.
+13 ;
+14 ; Verify incoming value of IBACTION and default to 0 if not defined
+15 SET IBACTION=$SELECT(IBACTION'="":IBACTION,1:0)
+16 ; Quit if necessary data was not passed in
+17 IF +IBN<=0!(+IBEVDT'?7N)
QUIT IBACTION
+18 ; If IBINTACT was not passed in, default it to 0:Non-Interactive
+19 SET IBINTACT=$SELECT(IBINTACT'="":IBINTACT,1:0)
+20 NEW IBBFI,IBBFO,IBBFOB,IBLTC,IBBPD,IBDFN,IBRSN,IBCTOT,IBETOT,IBAT1,IBAT2
+21 ; Load Patient IEN from IBN passed in
+22 SET IBDFN=+$PIECE($GET(^IB(IBN,0)),U,2)
+23 ; Quit if no IEN in record
+24 IF IBDFN<1
QUIT IBACTION
+25 ; Determine if the Patient has already been charged an Inpatient Copay for the Event Date
+26 SET IBBFI=$$BFI^IBAUTL8C(IBDFN,IBEVDT,IBN)
+27 ; Take actions based on there being an existing Inpatient Copay
+28 IF IBBFI
Begin DoDot:1
+29 ; Set IBACTION = IEN of existing Inpatient Copay
+30 SET IBACTION=IBBFI
+31 ; Check for legal pairings
+32 ; Load Action Types of the two charges
+33 SET IBAT1=$PIECE($GET(^IB(IBN,0)),U,3)
SET IBAT2=$PIECE($GET(^IB(IBBFI,0)),U,3)
+34 ; If 2 copays for a single day are a legal pairing, set IBACTION =0
+35 ; If the Action Type is CC INPATIENT (133) and the Per Diem is CC PER DIEM (#130)
+36 IF IBAT1=133
IF IBAT2=130
SET IBACTION=0
+37 ; If the Action Type is one of the copays in Billing Group #2 and the Per Diem
+38 ; copay is INPATIENT PER DIEM (#45) set IBACTION =0
+39 IF IBAT1=45
IF ("^16^17^18^19^20^21^22^23^"[("^"_IBAT2_"^"))
SET IBACTION=0
+40 ; If the Action Type is NHCU COPAY (#24) and the Per Diem is NHCU PER DIEM (#48) set IBACTION =0
+41 IF IBAT1=48
IF IBAT2=24
SET IBACTION=0
+42 ; Quit if interactive
+43 if IBINTACT
QUIT
+44 ; Record related info into ^XTMP for MailMan message
+45 SET IBRSN="AN INPATIENT COPAY CHARGE BILLED AT HIGHER PRECEDENCE"
+46 DO STORE1^IBAUTL9(IBN,IBBFI,IBRSN)
End DoDot:1
if IBACTION
QUIT
+47 ;
+48 ; Determine if the Patient has already been charged an Inpatient Per Diem charge for the Event Date
+49 SET IBBPD=$$BFPD^IBAUTL8A(IBDFN,IBEVDT,IBN)
+50 ; If the Patient has already been charged an Inpatient Per Diem charge for the Event Date
+51 IF IBBPD
Begin DoDot:1
+52 ; Set return value to NOT pass the charge over to AR
+53 SET IBACTION=IBBPD
+54 ; Quit if interactive
+55 if IBINTACT
QUIT
+56 ; Load dollar amounts from the 2 charges
+57 SET IBCTOT=+$PIECE($GET(^IB(IBN,0)),U,7)
SET IBETOT=+$PIECE($GET(^IB(+IBBPD,0)),U,7)
+58 ; If the current charge being processed is <= to the existing Inpatient Per Diem charge
+59 IF IBCTOT<=IBETOT
Begin DoDot:2
+60 ; Cancel current charge with CANCELLATION REASON = 4 - ENTERED IN ERROR
+61 ; ### Uncomment for Phase 2 D CNCLCHRG^IBAUTL8A(IBN,4)
+62 ; Record related info into ^XTMP for MailMan message
+63 SET IBRSN="EXISTING INPATIENT PER DIEM CHARGE AT SAME OR HIGHER TIER RATE"
+64 DO STORE1^IBAUTL9(IBN,IBBPD,IBRSN)
+65 QUIT
End DoDot:2
QUIT
+66 ; If the current charge being processed is > than the existing Inpatient Per Diem charge
+67 IF IBCTOT>IBETOT
Begin DoDot:2
+68 ; IBND has to be set to 0 node for call to CANC^IBECEAU4
+69 ; ### N IBND S IBND=$G(^IB(IBN,0))
+70 ; IBFAC and IBSITE needed by Cancel operation below
+71 ; ### N IBFAC,IBSITE
+72 ; Calculate site from site parameters
+73 ; ### D SITE^IBAUTL
+74 ; Cancel existing charge with Reason = 42 - BILLED AT HIGHER TIER RATE
+75 ; UNCOMMENT THIS AND TEST MORE ON WHAT HAPPENS IN THE CANCELLATION PROCESS
+76 ; ### I 'IBINTACT D CANC^IBECEAU4(IBBPD,42,1)
+77 ; Record related info into ^XTMP for MailMan message
+78 SET IBRSN="ANOTHER INPATIENT PER DIEM CHARGE BILLED AT HIGHER TIER RATE"
+79 DO STORE2^IBAUTL9(IBN,IBBPD,IBRSN)
+80 QUIT
End DoDot:2
QUIT
+81 QUIT
End DoDot:1
QUIT
+82 ;
+83 ; Determine if the Patient has an Outpatient Observation Copay for the Event Date
+84 SET IBBFOB=$$BFOB^IBAUTL8A(IBDFN,IBEVDT,IBN)
+85 ; if there is an existing Outpatient Observation Copay, Do the following
+86 IF +IBBFOB
Begin DoDot:1
+87 ; Set IBACTION = IEN of Outpatient Observation Copay
+88 SET IBACTION=IBBFOB
+89 ; Quit if interactive
+90 if IBINTACT
QUIT
+91 ; ###Uncomment for Phase 2
+92 ; IBND has to be set to 0 node for call to CANC^IBECEAU4
+93 ; ### N IBND S IBND=$G(^IB(IBN,0))
+94 ; IBFAC and IBSITE needed by Cancel operation below
+95 ; ### N IBFAC,IBSITE
+96 ; Calculate site from site parameters
+97 ; ### D SITE^IBAUTL
+98 ; Cancel the existing Outpatient Observation Copay charge with
+99 ; CANCELLATION REASON = 42 - BILLED AT HIGHER TIER RATE
+100 ; ### I 'IBINTACT D CANC^IBECEAU4(IBBFI,42,1)
+101 ; Record related info into ^XTMP for MailMan message
+102 SET IBRSN="AN INPATIENT PER DIEM CHARGE BILLED AT HIGHER PRECEDENCE"
+103 DO STORE2^IBAUTL9(IBN,IBBFOB,IBRSN)
+104 QUIT
End DoDot:1
QUIT
+105 ;
+106 ; Determine if the Patient has an Outpatient Copay for the Event Date
+107 SET IBBFO=$$BFO^IBAUTL8A(IBDFN,IBEVDT,IBN)
+108 ; If the Patient has already been charged an Outpatient Copay for the Event Date, set IBACTION and quit
+109 IF IBBFO
Begin DoDot:1
+110 ; Set IBACTION = IEN of Outpatient Copay
+111 SET IBACTION=IBBFO
+112 ; Quit if interactive
+113 if IBINTACT
QUIT
+114 ; ###Uncomment for Phase 2
+115 ; IBND has to be set to 0 node for call to CANC^IBECEAU4
+116 ; ### N IBND S IBND=$G(^IB(IBN,0))
+117 ; IBFAC and IBSITE needed by Cancel operation below
+118 ; ### N IBFAC,IBSITE
+119 ; Calculate site from site parameters
+120 ; ### D SITE^IBAUTL
+121 ; Cancel the existing Outpatient Observation Copay charge with
+122 ; CANCELLATION REASON = 42 - BILLED AT HIGHER TIER RATE
+123 ; ### I 'IBINTACT D CANC^IBECEAU4(IBBFI,42,1)
+124 ; Record related info into ^XTMP for MailMan message
+125 SET IBRSN="AN INPATIENT PER DIEM CHARGE BILLED AT HIGHER PRECEDENCE"
+126 DO STORE2^IBAUTL9(IBN,IBBFO,IBRSN)
+127 QUIT
End DoDot:1
QUIT
+128 ;
+129 ; Determine if the Patient has an Long Term Care Copay for the Event Date
+130 SET IBLTC=$$LTC^IBAUTL8B(IBDFN,IBEVDT,IBN)
+131 ; If the patient has been charged a Long Term Care Copay for the Event Date, set IBACTION and quit
+132 IF IBLTC
Begin DoDot:1
+133 ; Set IBACTION = IEN of Outpatient Copay
+134 SET IBACTION=IBLTC
+135 ; Quit if interactive
+136 if IBINTACT
QUIT
+137 ; ###Uncomment for Phase 2
+138 ; IBND has to be set to 0 node for call to CANC^IBECEAU4
+139 ; ### N IBND S IBND=$G(^IB(IBN,0))
+140 ; IBFAC and IBSITE needed by Cancel operation below
+141 ; ### N IBFAC,IBSITE
+142 ; Calculate site from site parameters
+143 ; ### D SITE^IBAUTL
+144 ; Cancel the existing Outpatient Observation Copay charge with
+145 ; CANCELLATION REASON = 42 - BILLED AT HIGHER TIER RATE
+146 ; ### I 'IBINTACT D CANC^IBECEAU4(IBBFI,42,1)
+147 ; Record related info into ^XTMP for MailMan message
+148 SET IBRSN="AN INPATIENT PER DIEM CHARGE BILLED AT HIGHER PRECEDENCE"
+149 DO STORE2^IBAUTL9(IBN,IBLTC,IBRSN)
End DoDot:1
QUIT
+150 QUIT
+151 ;
BFO(DFN,IBDATE,IBNEW) ; Patient Billed For Outpatient Copay on a specified date?
+1 ; Input: DFN - Pointer to the patient in file #2
+2 ; IBDATE - Date of the Inpatient Visit
+3 ; IBNEW - IEN of new charge in File #350
+4 ; Output: 0 - Not billed the OPT copay on the visit date
+5 ; >0 - Pointer to charge in file #350 that was billed
+6 ;
+7 ; Outpatient Copays charges will be in Billing Group 4 and have Action Types:
+8 ; Action Types = 51 - DG OPT COPAY NEW 136 - CC (OPT) NEW
+9 ; 203 - CC URGENT CARE (OPT) NEW
+10 ;
+11 NEW IBAMT,IBATYP,IBATYPN,IBCHRG,IBDATA0,IBN,IBSTOPDT
+12 SET (IBATYP,IBATYPN)=""
SET IBAMT=0
+13 ; Initialize the return variable to 0 - Not billed the Outpatient copay on the visit date
+14 SET IBCHRG=0
+15 IF '$GET(DFN)!('$GET(IBDATE))
QUIT +$GET(IBCHRG)
+16 ; Set stop date for loop
+17 SET IBSTOPDT=$PIECE(IBDATE,".",1)
+18 ; Strip off time portion of DATA and reset IBDATE for looping by subtracting .000001
+19 SET IBDATE=$PIECE(IBDATE,".",1)-.000001
+20 ; Loop through Date/Time entries (earliest to latest) for the single date being checked
+21 FOR
SET IBDATE=$ORDER(^IB("ACHDT",DFN,IBDATE))
if 'IBDATE!($PIECE(IBDATE,".",1)>IBSTOPDT)
QUIT
Begin DoDot:1
+22 ; Loop through the individual charges
+23 SET IBN=0
+24 FOR
SET IBN=$ORDER(^IB("ACHDT",DFN,IBDATE,IBN))
if 'IBN
QUIT
Begin DoDot:2
+25 ; Quit if entry found in ACHDT is the entry we are currently processing
+26 if IBN=IBNEW
QUIT
+27 ; Load 0 node in File #350 for this record
+28 SET IBDATA0=$GET(^IB(IBN,0))
+29 ; Quit if ACTION TYPE is not an Outpatient Copay
+30 if "^51^136^203^"'[("^"_$PIECE(IBDATA0,U,3)_"^")
QUIT
+31 ; using the ACTION TYPE (#.03) field of the INTEGRATED BILLING ACTION file (#350) set IBATYP = 0 Node of the IB ACTION TYPE file (#350.1)
+32 SET IBATYP=$GET(^IBE(350.1,+$PIECE(IBDATA0,"^",3),0))
+33 ; Using IBATYP set IBATYPN = NEW ACTION TYPE (#.09)
+34 SET IBATYPN=$GET(^IBE(350.1,+$PIECE(IBATYP,"^",9),0))
+35 ; Quit if any of the key data for the checks is missing
+36 IF IBDATA0=""!(IBATYP="")!(IBATYPN="")
QUIT
+37 ; Check if the BILLING GROUP field (#.11) and the ACTION TYPE (#.03) matches to the
+38 ; specific combinations provided by the SMEs.
+39 ; Check for Billing Group = 4:OPT COPAY & charge type = an OPT COPAY (51^136^203)
+40 IF $PIECE(IBATYPN,"^",11)=4
IF ("^51^136^203^"[("^"_$PIECE(IBDATA0,U,3)_"^"))
Begin DoDot:3
+41 ; IF 1:NEW or 3:UPDATE is contained in the SEQUENCE NUMBER field (#.05) in the IB ACTION TYPE file (#350.1)
+42 ; AND the STATUS field (#.05) in the INTEGRATED BILLING ACTION file (#350) is one of the following:
+43 ; 1:INCOMPLETE, 2:COMPLETE, 3:BILLED, 4:UPDATED, 8:ON HOLD, 20:HOLD - RATE
+44 ; THEN set IBCHRG = IEN of the duplicate Outpatient Copay
+45 IF "^1^3^"[("^"_$PIECE(IBATYP,"^",5)_"^")
IF "^1^2^3^4^8^20^"[("^"_+$PIECE(IBDATA0,"^",5)_"^")
Begin DoDot:4
+46 ; Compare the TOTAL CHARGE of this Outpatient Copay charge to any previously identified
+47 ; Outpatient Copay for the same date and save the IEN of the highest charge
+48 IF +$PIECE(IBDATA0,U,7)>IBAMT
SET IBAMT=+$PIECE(IBDATA0,U,7)
SET IBCHRG=IBN
+49 QUIT
End DoDot:4
+50 QUIT
End DoDot:3
+51 QUIT
End DoDot:2
+52 QUIT
End DoDot:1
+53 QUIT +$GET(IBCHRG)
+54 ;
BFOB(DFN,IBDATE,IBNEW) ; Patient Billed For Outpatient Observation Copay on a specified date?
+1 ; Input: DFN - Pointer to the patient in file #2
+2 ; IBDATE - Date of the Outpatient Visit
+3 ; IBNEW - IEN of new charge in File #350
+4 ; Output: 0 - Not billed the OPT copay on the visit date
+5 ; >0 - Pointer to charge in file #350 that was billed
+6 ;
+7 ; Outpatient Observation Copays charges will have the following Billing Group & Action Types:
+8 ; Billing Group = 4 - OPT COPAY
+9 ; 74 - DG OBSERVATION COPAY NEW
+10 ;
+11 NEW IBAMT,IBATYP,IBATYPN,IBCHRG,IBDATA0,IBN,Y,IBSTOPDT
+12 SET (IBATYP,IBATYPN)=""
SET IBAMT=0
+13 ; Initialize the return variable to 0 - Not billed the Outpatient Observation Copay on the visit date
+14 SET IBCHRG=0
+15 IF '$GET(DFN)!'$GET(IBDATE)
QUIT +$GET(IBCHRG)
+16 ; Set stop date for loop
+17 SET IBSTOPDT=$PIECE(IBDATE,".",1)
+18 ; Strip off time portion of DATA and reset IBDATE for looping by subtracting .000001
+19 SET IBDATE=$PIECE(IBDATE,".",1)-.000001
+20 ; Loop through Date/Time entries (earliest to latest) for the single date being checked
+21 FOR
SET IBDATE=$ORDER(^IB("ACHDT",DFN,IBDATE))
if 'IBDATE!($PIECE(IBDATE,".",1)>IBSTOPDT)
QUIT
Begin DoDot:1
+22 ; Loop through the individual charges
+23 SET IBN=0
+24 FOR
SET IBN=$ORDER(^IB("ACHDT",DFN,IBDATE,IBN))
if 'IBN
QUIT
Begin DoDot:2
+25 ; Quit it entry found in ACHDT is the entry we are currently processing
+26 if IBN=IBNEW
QUIT
+27 ; Load 0 node in File #350 for this record
+28 SET IBDATA0=$GET(^IB(IBN,0))
+29 ; Quit if ACTION TYPE is not an Outpatient Observation Copay
+30 if $PIECE(IBDATA0,U,3)'=74
QUIT
+31 ; using the ACTION TYPE (#.03) field of the INTEGRATED BILLING ACTION file (#350) set IBATYP = 0 Node of the IB ACTION TYPE file (#350.1)
+32 SET IBATYP=$GET(^IBE(350.1,+$PIECE(IBDATA0,"^",3),0))
+33 ; Using IBATYP set IBATYPN = NEW ACTION TYPE (#.09)
+34 SET IBATYPN=$GET(^IBE(350.1,+$PIECE(IBATYP,"^",9),0))
+35 ; Quit if any of the key data for the checks is missing
+36 IF IBDATA0=""!(IBATYP="")!(IBATYPN="")
QUIT
+37 ; IF the BILLING GROUP field (#.11) in the IB ACTION TYPE file (#350.1) is OPT COPAY (#4)
+38 ; AND the SEQUENCE NUMBER (#.05) in the IB ACTION TYPE file (#350.1) is
+39 ; 1:INCOMPLETE OR 3:BILLED
+40 ; AND the STATUS field (#.05) in the INTEGRATED BILLING ACTION file (#350) is one of the following:
+41 ; 1:INCOMPLETE, 2:COMPLETE, 3:BILLED, 4:UPDATED, 8:ON HOLD, 20:HOLD - RATE
+42 ; THEN set IBCHRG = IEN of the Outpatient Observation Copay
+43 IF $PIECE(IBATYPN,"^",11)=4
IF "^1^3^"[("^"_$PIECE(IBATYP,"^",5)_"^")
IF "^1^2^3^4^8^20^"[("^"_+$PIECE(IBDATA0,"^",5)_"^")
Begin DoDot:3
+44 ; Compare the TOTAL CHARGE of this Outpatient Observation Copay charge to any previously identified
+45 ; Outpatient Observation Copay and save the IEN of the highest charge
+46 IF +$PIECE(IBDATA0,U,7)>IBAMT
SET IBAMT=+$PIECE(IBDATA0,U,7)
SET IBCHRG=IBN
End DoDot:3
+47 QUIT
End DoDot:2
+48 QUIT
End DoDot:1
+49 QUIT +$GET(IBCHRG)
+50 ;
BFPD(DFN,IBDATE,IBNEW) ; Patient Billed For Per Diem Copay on a specified date?
+1 ; Input: DFN - Pointer to the patient in file #2
+2 ; IBDATE - Date of the Outpatient Visit
+3 ; IBNEW - IEN of charge in File #350
+4 ; Output: 0 - Not billed the OPT copay on the visit date
+5 ; >0 - Pointer to charge in file #350 that was billed
+6 ;
+7 ; Valid Per Diem charges have the following Billing Group & Action Types:
+8 ; Billing Group = 3 - INPT/NHCU PER DIEM
+9 ; 45 DG INPT PER DIEM NEW 48 DG NHCU PER DIEM NEW
+10 ; 133 CC (PER DIEM) NEW
+11 ;
+12 NEW IBAMT,IBATYP,IBATYPN,IBCHRG,IBDATA0,IBN,IBSTOPDT
+13 SET (IBATYP,IBATYPN)=""
SET IBAMT=0
+14 ; Initialize the IBCHRG to 0 - Not billed a Per Diem on the visit date
+15 SET IBCHRG=0
+16 IF '$GET(DFN)!'$GET(IBDATE)
QUIT +$GET(IBCHRG)
+17 ; Set stop date for loop
+18 SET IBSTOPDT=$PIECE(IBDATE,".",1)
+19 ; Strip off time portion of DATA and reset IBDATE for looping by subtracting .000001
+20 SET IBDATE=$PIECE(IBDATE,".",1)-.000001
+21 ; Loop through Date/Time entries (earliest to latest) for the single date being checked
+22 FOR
SET IBDATE=$ORDER(^IB("ACHDT",DFN,IBDATE))
if 'IBDATE!($PIECE(IBDATE,".",1)>IBSTOPDT)
QUIT
Begin DoDot:1
+23 ; Loop through the individual charges
+24 SET IBN=0
+25 FOR
SET IBN=$ORDER(^IB("ACHDT",DFN,IBDATE,IBN))
if 'IBN
QUIT
Begin DoDot:2
+26 ; Quit it entry found in ACHDT is the entry we are currently processing
+27 if IBN=IBNEW
QUIT
+28 ; Load 0 node in File #350 for this record
+29 SET IBDATA0=$GET(^IB(IBN,0))
+30 ; Quit if ACTION TYPE is not an Per Diem Copay
+31 if "^45^48^133^"'[("^"_$PIECE(IBDATA0,U,3)_"^")
QUIT
+32 ; using the ACTION TYPE (#.03) field of the INTEGRATED BILLING ACTION file (#350) set IBATYP = 0 Node of the IB ACTION TYPE file (#350.1)
+33 SET IBATYP=$GET(^IBE(350.1,+$PIECE(IBDATA0,"^",3),0))
+34 ; Using IBATYP set IBATYPN = NEW ACTION TYPE (#.09)
+35 SET IBATYPN=$GET(^IBE(350.1,+$PIECE(IBATYP,"^",9),0))
+36 ; Quit if any of the key data for the checks is missing
+37 IF IBDATA0=""!(IBATYP="")!(IBATYPN="")
QUIT
+38 ; IF the BILLING GROUP field (#.11) in the IB ACTION TYPE file (#350.1) is INPT/NHCU PER DIEM (#3)
+39 ; AND the SEQUENCE NUMBER (#.05) in the IB ACTION TYPE file (#350.1) is
+40 ; 1:INCOMPLETE OR 3:BILLED
+41 ; AND the STATUS field (#.05) in the INTEGRATED BILLING ACTION file (#350) is one of the following:
+42 ; 1:INCOMPLETE, 2:COMPLETE, 3:BILLED, 4:UPDATED, 8:ON HOLD, 20:HOLD - RATE
+43 ; THEN set IBCHRG = IEN of the Per Diem copay
+44 IF $PIECE(IBATYPN,"^",11)=3
IF "^1^3^"[("^"_$PIECE(IBATYP,"^",5)_"^")
IF "^1^2^3^4^8^20^"[("^"_+$PIECE(IBDATA0,"^",5)_"^")
Begin DoDot:3
+45 ; Compare the TOTAL CHARGE of this Per Diem Copay charge to any previously identified
+46 ; Per Diem Copay and save the IEN of the highest charge
+47 IF +$PIECE(IBDATA0,U,7)>IBAMT
SET IBAMT=+$PIECE(IBDATA0,U,7)
SET IBCHRG=IBN
End DoDot:3
+48 QUIT
End DoDot:2
+49 QUIT
End DoDot:1
+50 QUIT +$GET(IBCHRG)
+51 ;
CNCLCHRG(IBN,IBCANRSN) ; Cancel a charge that will never be passed over to AR
+1 ; OR an existing charge in AR which is being replaced by a new charge at a higher Tier Rate.
+2 ; Input: IBN = IEN of record in the INTEGRATED BILLING ACTION (#350) file to edit
+3 ; IBCANRSN = the value to set into the CANCELLATION REASON (#.1) field in internal format
+4 ; Output: None
+5 ;
+6 ; The patch will initially be released as a info gathering patch so the set logic is currently
+7 ; commented out.
+8 ; ### remove to activate #630 functionality
QUIT
+9 NEW IBFDA
+10 ; Quit if no valid IBN
+11 if +IBN<=0
QUIT
+12 ; If the CANCELLATION REASON was not passed in, set it to 4 - ENTERED IN ERROR
+13 SET IBCANRSN=$SELECT(IBCANRSN'="":IBCANRSN,1:4)
+14 ; Set STATUS (#.05) to Cancelled (IEN=10)
+15 SET IBFDA(350,IBN,.05)=10
+16 ; Set CANCELLATION REASON (#.1) to value passed in
+17 SET IBFDA(350,IBN,.1)=IBCANRSN
+18 ; Cancel charge currently being reviewed
+19 DO FILE^DIE(,"IBFDA")
+20 QUIT