IBTRHLI ;ALB/JWS - Receive and store 278 Response message ;05-JUN-2014
 ;;2.0;INTEGRATED BILLING;**517**;21-MAR-94;Build 240
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 Q
 ;
EN ; This is the entry point for receiving a 278 Response Message
 ; Starting point - put message into a TMP global
 N EVENT,HLFS,IBPRTCL,SEGMT,TAG,CNT,SEGCNT,HLNODE
 ; EXPECTS HLMTIEN=entry in file 772 ^HL(772) HL7 MESSAGE TEXT
 ; ALSO HLNEXT = "D HLNEXT^HLCSUTL"
 ; ALSO HLQUIT = "" OR 0
 ; ALSO HLNODE is = data string of HL7 segment, set in HLNEXT^HLCSUTL
 K ^TMP($J,"IBTRHLI")
 F SEGCNT=1:1 X HLNEXT Q:'HLQUIT  D
 . S CNT=0
 . S ^TMP($J,"IBTRHLI",SEGCNT,CNT)=HLNODE
 . I SEGCNT=1 S SEGMT=HLNODE
 . F  S CNT=$O(HLNODE(CNT)) Q:'CNT  D
 .. S ^TMP($J,"IBTRHLI",SEGCNT,CNT)=HLNODE(CNT)
 .. I SEGCNT=1 S SEGMT=$G(SEGMT)_HLNODE(CNT)
 . Q 
 S HLFS=$E(SEGMT,4)
 S EVENT=$P(SEGMT,HLFS,9),IBPRTCL=""
 ;  Determine which protocol to use
 ;  The event type determines protocol
 I EVENT="RPA^I08" S TAG="RSP",IBPRTCL="IBTR HCSR IN"
 I IBPRTCL="" G XIT
 ;  Initialize the HL7 variables
 D INIT^HLFNC2(IBPRTCL,.HL)
 ;  Call the event tag
 D @TAG
 ;
XIT ;
 K ^TMP($J,"IBTRHLI"),HL,HLNEXT,HLNODE,HLQUIT
 Q
 ;
RSP ;  Response Processing
 D EN^IBTRHLI1
 K ^TMP($J,"IBTRHLI"),HL,HLNEXT,HLNODE,HLQUIT
 Q
 ;
TEST ;
 S $ET="D ^%ZTER"
 R !,"HLMTIEN= ",HLMTIEN:120 Q:HLMTIEN=""
 S HLQUIT=0
 S HLNEXT="D HLNEXT^HLCSUTL"
 G EN
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBTRHLI   1449     printed  Sep 23, 2025@20:04:46                                                                                                                                                                                                     Page 2
IBTRHLI   ;ALB/JWS - Receive and store 278 Response message ;05-JUN-2014
 +1       ;;2.0;INTEGRATED BILLING;**517**;21-MAR-94;Build 240
 +2       ;;Per VA Directive 6402, this routine should not be modified.
 +3       ;
 +4        QUIT 
 +5       ;
EN        ; This is the entry point for receiving a 278 Response Message
 +1       ; Starting point - put message into a TMP global
 +2        NEW EVENT,HLFS,IBPRTCL,SEGMT,TAG,CNT,SEGCNT,HLNODE
 +3       ; EXPECTS HLMTIEN=entry in file 772 ^HL(772) HL7 MESSAGE TEXT
 +4       ; ALSO HLNEXT = "D HLNEXT^HLCSUTL"
 +5       ; ALSO HLQUIT = "" OR 0
 +6       ; ALSO HLNODE is = data string of HL7 segment, set in HLNEXT^HLCSUTL
 +7        KILL ^TMP($JOB,"IBTRHLI")
 +8        FOR SEGCNT=1:1
               XECUTE HLNEXT
               if 'HLQUIT
                   QUIT 
               Begin DoDot:1
 +9                SET CNT=0
 +10               SET ^TMP($JOB,"IBTRHLI",SEGCNT,CNT)=HLNODE
 +11               IF SEGCNT=1
                       SET SEGMT=HLNODE
 +12               FOR 
                       SET CNT=$ORDER(HLNODE(CNT))
                       if 'CNT
                           QUIT 
                       Begin DoDot:2
 +13                       SET ^TMP($JOB,"IBTRHLI",SEGCNT,CNT)=HLNODE(CNT)
 +14                       IF SEGCNT=1
                               SET SEGMT=$GET(SEGMT)_HLNODE(CNT)
                       End DoDot:2
 +15               QUIT 
               End DoDot:1
 +16       SET HLFS=$EXTRACT(SEGMT,4)
 +17       SET EVENT=$PIECE(SEGMT,HLFS,9)
           SET IBPRTCL=""
 +18      ;  Determine which protocol to use
 +19      ;  The event type determines protocol
 +20       IF EVENT="RPA^I08"
               SET TAG="RSP"
               SET IBPRTCL="IBTR HCSR IN"
 +21       IF IBPRTCL=""
               GOTO XIT
 +22      ;  Initialize the HL7 variables
 +23       DO INIT^HLFNC2(IBPRTCL,.HL)
 +24      ;  Call the event tag
 +25       DO @TAG
 +26      ;
XIT       ;
 +1        KILL ^TMP($JOB,"IBTRHLI"),HL,HLNEXT,HLNODE,HLQUIT
 +2        QUIT 
 +3       ;
RSP       ;  Response Processing
 +1        DO EN^IBTRHLI1
 +2        KILL ^TMP($JOB,"IBTRHLI"),HL,HLNEXT,HLNODE,HLQUIT
 +3        QUIT 
 +4       ;
TEST      ;
 +1        SET $ETRAP="D ^%ZTER"
 +2        READ !,"HLMTIEN= ",HLMTIEN:120
           if HLMTIEN=""
               QUIT 
 +3        SET HLQUIT=0
 +4        SET HLNEXT="D HLNEXT^HLCSUTL"
 +5        GOTO EN