IBAUTL8B ;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.                       *
 ; ****************************************************************************
 ;
LTCNEW(IBN,IBEVDT,IBACTION,IBINTACT) ;
 ; Perform checks for a new Long Term Care Copay charge to determine if this charge should be passed over to AR.
 ;   Input:     
 ;          IBN = Pointer to Long Term Care Copay 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^IBAUTL8
 ;                    
 ; 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
 ; If IBINTACT was not passed in, default it to 0:Non-Interactive
 S IBINTACT=$S(IBINTACT'="":IBINTACT,1:0)
 N IBBFI,IBBFO,IBDFN,IBIEN,IBBOB,IBBPD,IBLTC,IBRSN
 ; 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
 ; Determine if the Patient has an Inpatient Copay for the Event Date
 S IBBFI=$$BFI^IBAUTL8C(IBDFN,IBEVDT,IBN)
 ; Determine if the Patient has an Per Diem Copay for the Event Date
 S IBBPD=$$BFPD^IBAUTL8A(IBDFN,IBEVDT,IBN)
 ; Determine if the Patient has an Observation Copay for the Event Date
 S IBBOB=$$BFOB^IBAUTL8A(IBDFN,IBEVDT,IBN)
 ; If the Patient has already been charged an Inpatient Copay charge OR an Inpatient Per Diem charge OR
 ; an Outpatient Observation Copay charge for the Event Date, Don't pass Outpatient Copay to AR
 I IBBFI!IBBPD!IBBOB D  Q
 . ; Set return value to NOT pass the charge over to AR
 . S IBACTION=$S(IBBFI:IBBFI,IBBPD:IBBPD,IBBOB:IBBOB,1:0)
 . ; Quit if interactive
 . Q:IBINTACT
 . ; Cancel the Outpatient Copay charge being reviewed with CANCELLATION REASON = 42 - BILLED AT HIGHER TIER RATE
 . ; ### Uncomment for Phase 2 D CNCLCHRG^IBAUTL8A(IBN,42)
 . ; Determine which Cancellation Reason to include in MailMan message
 . I IBBFI>0 S IBIEN=IBBFI,IBRSN="EXISTING INPATIENT COPAY CHARGE WHICH HAS HIGHER PRECEDENCE"
 . I IBBPD>0 S IBIEN=IBBPD,IBRSN="EXISTING INPATIENT PER DIEM CHARGE WHICH HAS HIGHER PRECEDENCE"
 . I IBBOB>0 S IBIEN=IBBOB,IBRSN="EXISTING OBSERVATION COPAY CHARGE WHICH HAS HIGHER PRECEDENCE"
 . ; Record related info into ^XTMP for MailMan message
 . I 'IBINTACT D STORE1^IBAUTL9(IBN,IBIEN,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, compare current charge being
 ; reviewed to the existing Outpatient Copay charge and determine what action to take.
 I IBBFO D  Q
 . ; Set IBACTION = IEN of Outpatient Copay
 . S IBACTION=IBBFO
 . ; Quit if interactive
 . Q:IBINTACT
 . ; Record related info into ^XTMP for MailMan message 
 . S IBRSN="EXISTING OUTPATIENT COPAY CHARGE WHICH HAS HIGHER PRECEDENCE"
 . D STORE1^IBAUTL9(IBN,IBBFO,IBRSN)
 ;
 ; 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
 . N IBCTOT,IBETOT
 . ; Load dollar amounts from the 2 charges. IBCTOT = Current Charge Being Reviewed Total, IBETOT = Existing Total
 . S IBCTOT=+$P($G(^IB(IBN,0)),U,7),IBETOT=+$P($G(^IB(+IBLTC,0)),U,7)
 . ; If the current charge being processed is <= to the existing LTC Copay charge
 . I IBCTOT<=IBETOT D  Q
 . . ; Cancel current charge being reviewed 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 LTC COPAY CHARGE AT SAME OR HIGHER TIER RATE"
 . . D STORE1^IBAUTL9(IBN,IBLTC,IBRSN)
 . ; If the current charge being processed is > than the existing LTC Copay charge
 . I IBCTOT>IBETOT D  Q
 . . ; ### 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
 . . ; If not interactive 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(IBBFO,42,1)
 . . ; Record related info into ^XTMP for MailMan message
 . . S IBRSN="ANOTHER LTC COPAY CHARGE BILLED AT HIGHER TIER RATE"
 . . D STORE2^IBAUTL9(IBN,IBLTC,IBRSN)
 . . Q
 . Q
 Q
 ;
LTC(DFN,IBDATE,IBNEW) ; Patient Billed For Long Term Care 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 LTC copay on the visit date
 ;            >0 - Pointer to charge in file #350 that was billed
 ;
 ; Long Term Care Copays charges will be in Billing Group 8 and have Action Types:
 ; Action Types =  89 - DG LTC OPT ADHC NEW          92 - DG LTC OPT GEM NEW
 ;                 95 - DG LTC OPT RESPITE NEW      105 - DG LTC FEE OPT ADHC NEW
 ;                108 - DG LTC FEE OPT RESPITE 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 a Long Term Care Copay
 . . Q:"^89^92^95^105^108^"'[("^"_$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 = 8:LTC OPT & charge type = a LTC Copay (89^92^95^105^108)
 . . I $P(IBATYPN,"^",11)=8,("^89^92^95^105^108^"[("^"_$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 LTC Copay charge to any previously identified
 . . . . ; LTC 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)
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBAUTL8B   9272     printed  Sep 23, 2025@19:44:27                                                                                                                                                                                                    Page 2
IBAUTL8B  ;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      ;
LTCNEW(IBN,IBEVDT,IBACTION,IBINTACT) ;
 +1       ; Perform checks for a new Long Term Care Copay charge to determine if this charge should be passed over to AR.
 +2       ;   Input:     
 +3       ;          IBN = Pointer to Long Term Care Copay charge currently being reviewed in the INTEGRATED BILLING ACTION (#350) file
 +4       ;       IBEVDT = Event Date for the charge currently being reviewed in the INTEGRATED BILLING ACTION (#350) file
 +5       ;     IBACTION = Passed by reference. Passed in as 0:Pass to AR
 +6       ;     IBINTACT = Optional - Flag to indicate when the call is being made from an interactive option.
 +7       ;                1:Interactive        
 +8       ;                0:Non-Interactive
 +9       ;                For more info see COPAYCHK^IBAUTL8
 +10      ;                    
 +11      ; Output: IBACTION = 0 if the current charge being reviewed should be passed over to AR
 +12      ;                    # The IEN of the existing Copay charge for the Patient/Date of interest.
 +13      ;                      The charge being reviewed should NOT be passed over to AR.
 +14      ;
 +15      ; Verify incoming value of IBACTION and default to 0 if not defined
 +16       SET IBACTION=$SELECT(IBACTION'="":IBACTION,1:0)
 +17      ; Quit if necessary data was not passed in
 +18       IF +IBN<=0!(+IBEVDT'?7N)
               QUIT 
 +19      ; If IBINTACT was not passed in, default it to 0:Non-Interactive
 +20       SET IBINTACT=$SELECT(IBINTACT'="":IBINTACT,1:0)
 +21       NEW IBBFI,IBBFO,IBDFN,IBIEN,IBBOB,IBBPD,IBLTC,IBRSN
 +22      ; Load Patient IEN from IBN passed in
 +23       SET IBDFN=+$PIECE($GET(^IB(IBN,0)),U,2)
 +24      ; Quit if no IEN in record
 +25       IF IBDFN<1
               QUIT 
 +26      ; Determine if the Patient has an Inpatient Copay for the Event Date
 +27       SET IBBFI=$$BFI^IBAUTL8C(IBDFN,IBEVDT,IBN)
 +28      ; Determine if the Patient has an Per Diem Copay for the Event Date
 +29       SET IBBPD=$$BFPD^IBAUTL8A(IBDFN,IBEVDT,IBN)
 +30      ; Determine if the Patient has an Observation Copay for the Event Date
 +31       SET IBBOB=$$BFOB^IBAUTL8A(IBDFN,IBEVDT,IBN)
 +32      ; If the Patient has already been charged an Inpatient Copay charge OR an Inpatient Per Diem charge OR
 +33      ; an Outpatient Observation Copay charge for the Event Date, Don't pass Outpatient Copay to AR
 +34       IF IBBFI!IBBPD!IBBOB
               Begin DoDot:1
 +35      ; Set return value to NOT pass the charge over to AR
 +36               SET IBACTION=$SELECT(IBBFI:IBBFI,IBBPD:IBBPD,IBBOB:IBBOB,1:0)
 +37      ; Quit if interactive
 +38               if IBINTACT
                       QUIT 
 +39      ; Cancel the Outpatient Copay charge being reviewed with CANCELLATION REASON = 42 - BILLED AT HIGHER TIER RATE
 +40      ; ### Uncomment for Phase 2 D CNCLCHRG^IBAUTL8A(IBN,42)
 +41      ; Determine which Cancellation Reason to include in MailMan message
 +42               IF IBBFI>0
                       SET IBIEN=IBBFI
                       SET IBRSN="EXISTING INPATIENT COPAY CHARGE WHICH HAS HIGHER PRECEDENCE"
 +43               IF IBBPD>0
                       SET IBIEN=IBBPD
                       SET IBRSN="EXISTING INPATIENT PER DIEM CHARGE WHICH HAS HIGHER PRECEDENCE"
 +44               IF IBBOB>0
                       SET IBIEN=IBBOB
                       SET IBRSN="EXISTING OBSERVATION COPAY CHARGE WHICH HAS HIGHER PRECEDENCE"
 +45      ; Record related info into ^XTMP for MailMan message
 +46               IF 'IBINTACT
                       DO STORE1^IBAUTL9(IBN,IBIEN,IBRSN)
 +47               QUIT 
               End DoDot:1
               QUIT 
 +48      ;
 +49      ; Determine if the Patient has an Outpatient Copay for the Event Date
 +50       SET IBBFO=$$BFO^IBAUTL8A(IBDFN,IBEVDT,IBN)
 +51      ; If the Patient has already been charged an Outpatient Copay for the Event Date, compare current charge being
 +52      ; reviewed to the existing Outpatient Copay charge and determine what action to take.
 +53       IF IBBFO
               Begin DoDot:1
 +54      ; Set IBACTION = IEN of Outpatient Copay
 +55               SET IBACTION=IBBFO
 +56      ; Quit if interactive
 +57               if IBINTACT
                       QUIT 
 +58      ; Record related info into ^XTMP for MailMan message 
 +59               SET IBRSN="EXISTING OUTPATIENT COPAY CHARGE WHICH HAS HIGHER PRECEDENCE"
 +60               DO STORE1^IBAUTL9(IBN,IBBFO,IBRSN)
               End DoDot:1
               QUIT 
 +61      ;
 +62      ; Determine if the Patient has an Long Term Care Copay for the Event Date
 +63       SET IBLTC=$$LTC^IBAUTL8B(IBDFN,IBEVDT,IBN)
 +64      ; If the patient has been charged a Long Term Care Copay for the Event Date, set IBACTION and quit
 +65       IF IBLTC
               Begin DoDot:1
 +66      ; Set IBACTION = IEN of Outpatient Copay
 +67               SET IBACTION=IBLTC
 +68      ; Quit if interactive
 +69               if IBINTACT
                       QUIT 
 +70               NEW IBCTOT,IBETOT
 +71      ; Load dollar amounts from the 2 charges. IBCTOT = Current Charge Being Reviewed Total, IBETOT = Existing Total
 +72               SET IBCTOT=+$PIECE($GET(^IB(IBN,0)),U,7)
                   SET IBETOT=+$PIECE($GET(^IB(+IBLTC,0)),U,7)
 +73      ; If the current charge being processed is <= to the existing LTC Copay charge
 +74               IF IBCTOT<=IBETOT
                       Begin DoDot:2
 +75      ; Cancel current charge being reviewed with CANCELLATION REASON = 4 - ENTERED IN ERROR
 +76      ; ### Uncomment for Phase 2 D CNCLCHRG^IBAUTL8A(IBN,4)
 +77      ; Record related info into ^XTMP for MailMan message
 +78                       SET IBRSN="EXISTING LTC COPAY CHARGE AT SAME OR HIGHER TIER RATE"
 +79                       DO STORE1^IBAUTL9(IBN,IBLTC,IBRSN)
                       End DoDot:2
                       QUIT 
 +80      ; If the current charge being processed is > than the existing LTC Copay charge
 +81               IF IBCTOT>IBETOT
                       Begin DoDot:2
 +82      ; ### Uncomment for Phase 2
 +83      ; IBND has to be set to 0 node for call to CANC^IBECEAU4
 +84      ; ### N IBND S IBND=$G(^IB(IBN,0))
 +85      ; IBFAC and IBSITE needed by Cancel operation below
 +86      ; ### N IBFAC,IBSITE
 +87      ; Calculate site from site parameters
 +88      ; ### D SITE^IBAUTL
 +89      ; If not interactive Cancel existing charge with Reason = 42 - BILLED AT HIGHER TIER RATE
 +90      ; UNCOMMENT THIS AND TEST MORE ON WHAT HAPPENS IN THE CANCELLATION PROCESS
 +91      ; ### I 'IBINTACT D CANC^IBECEAU4(IBBFO,42,1)
 +92      ; Record related info into ^XTMP for MailMan message
 +93                       SET IBRSN="ANOTHER LTC COPAY CHARGE BILLED AT HIGHER TIER RATE"
 +94                       DO STORE2^IBAUTL9(IBN,IBLTC,IBRSN)
 +95                       QUIT 
                       End DoDot:2
                       QUIT 
 +96               QUIT 
               End DoDot:1
               QUIT 
 +97       QUIT 
 +98      ;
LTC(DFN,IBDATE,IBNEW) ; Patient Billed For Long Term Care 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 LTC copay on the visit date
 +5       ;            >0 - Pointer to charge in file #350 that was billed
 +6       ;
 +7       ; Long Term Care Copays charges will be in Billing Group 8 and have Action Types:
 +8       ; Action Types =  89 - DG LTC OPT ADHC NEW          92 - DG LTC OPT GEM NEW
 +9       ;                 95 - DG LTC OPT RESPITE NEW      105 - DG LTC FEE OPT ADHC NEW
 +10      ;                108 - DG LTC FEE OPT RESPITE NEW
 +11      ;
 +12       NEW IBAMT,IBATYP,IBATYPN,IBCHRG,IBDATA0,IBN,IBSTOPDT
 +13       SET (IBATYP,IBATYPN)=""
           SET IBAMT=0
 +14      ; Initialize the return variable to 0 - Not billed the Outpatient copay 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 if 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 a Long Term Care Copay
 +31                       if "^89^92^95^105^108^"'[("^"_$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      ; Check if the BILLING GROUP field (#.11) and the ACTION TYPE (#.03) matches to the
 +39      ; specific combinations provided by the SMEs.
 +40      ; Check for Billing Group = 8:LTC OPT & charge type = a LTC Copay (89^92^95^105^108)
 +41                       IF $PIECE(IBATYPN,"^",11)=8
                               IF ("^89^92^95^105^108^"[("^"_$PIECE(IBDATA0,U,3)_"^"))
                                   Begin DoDot:3
 +42      ; IF 1:NEW or 3:UPDATE is contained in the SEQUENCE NUMBER field (#.05) in the IB ACTION TYPE file (#350.1)
 +43      ; AND the STATUS field (#.05) in the INTEGRATED BILLING ACTION file (#350) is one of the following:
 +44      ;    1:INCOMPLETE, 2:COMPLETE, 3:BILLED, 4:UPDATED, 8:ON HOLD, 20:HOLD - RATE 
 +45      ; THEN set IBCHRG = IEN of the duplicate Outpatient Copay
 +46                                   IF "^1^3^"[("^"_$PIECE(IBATYP,"^",5)_"^")
                                           IF "^1^2^3^4^8^20^"[("^"_+$PIECE(IBDATA0,"^",5)_"^")
                                               Begin DoDot:4
 +47      ; Compare the TOTAL CHARGE of this LTC Copay charge to any previously identified
 +48      ; LTC Copay for the same date and save the IEN of the highest charge
 +49                                               IF +$PIECE(IBDATA0,U,7)>IBAMT
                                                       SET IBAMT=+$PIECE(IBDATA0,U,7)
                                                       SET IBCHRG=IBN
 +50                                               QUIT 
                                               End DoDot:4
 +51                                   QUIT 
                                   End DoDot:3
 +52                       QUIT 
                       End DoDot:2
 +53               QUIT 
               End DoDot:1
 +54       QUIT +$GET(IBCHRG)