- INHUACK ; FRW ; 2 Jul 96 11:32; Handle Incoming ACK messages
- ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
- ;COPYRIGHT 1991-2000 SAIC
- ;;
- ;
- ACK ;Deal with inbound ack messages
- ;INPUT:
- ; UIF - ien of ack message in Universal Interface file
- ;OUTPUT:
- ; INSTERR - if present indicates error occurred
- ; INHERR - if present indicates error message
- ;
- N LCT,LINE,ACKSTAT,ACKEDMES,ERRMSG,INERMSG
- ;Start reading lines from the beginning of the message
- S LCT=0
- ;Get message header
- D GET^INHOU(UIF,0)
- I '$D(LINE) S INHERR="No message header (MSH) segment" G ERR
- S INDELIM=$E(LINE,4),INSUBDEL=$E(LINE,5)
- ;Get MSA segment
- D GET^INHOU(UIF,0)
- ;Check for errors
- I $P($G(LINE),INDELIM,1)'="MSA" S INHERR="No message acknowledgement (MSA) segment" G ERR
- ;Parse out segment
- ;Ack code
- S ACKSTAT=$P(LINE,INDELIM,2),ACKSTAT="^AA^CA^"[(U_ACKSTAT_U)
- ;ID of Acknowldeged message
- S ACKEDMES=$P(LINE,INDELIM,3)
- I '$L(ACKEDMES) S INHERR="No message identified to acknowledge" G ERR
- I '$D(^INTHU("C",ACKEDMES)) S INHERR="Acknowledge for unknown message ID - "_ACKEDMES G ERR
- ;Save any @INV@("MSA6") Error Messages (HL7 V2.3 format)
- S INERMSG=$P(LINE,INDELIM,7)
- ;Get the first ERR segment
- D GET^INHOU(UIF,0)
- S ERRMSG=$P($G(LINE),INDELIM,2)
- ;Give priority to ERR Segment Error Messages
- S:'$L(ERRMSG) ERRMSG=INERMSG
- ;Log acknowledge
- D ACKLOG^INHU(UIF,ACKEDMES,ACKSTAT,ERRMSG)
- ;
- Q
- ;
- ERR ;Error module
- S INSTERR=2
- Q
- ;
- NOTES ;Description:
- ;This program is called as part of the INCOMING ACK script
- ;
- ;Issues:
- ;Repeating ERR segments are not recognized
- ;
- INHUACK ; FRW ; 2 Jul 96 11:32; Handle Incoming ACK messages
- +1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
- +2 ;COPYRIGHT 1991-2000 SAIC
- +3 ;;
- +4 ;
- ACK ;Deal with inbound ack messages
- +1 ;INPUT:
- +2 ; UIF - ien of ack message in Universal Interface file
- +3 ;OUTPUT:
- +4 ; INSTERR - if present indicates error occurred
- +5 ; INHERR - if present indicates error message
- +6 ;
- +7 NEW LCT,LINE,ACKSTAT,ACKEDMES,ERRMSG,INERMSG
- +8 ;Start reading lines from the beginning of the message
- +9 SET LCT=0
- +10 ;Get message header
- +11 DO GET^INHOU(UIF,0)
- +12 IF '$DATA(LINE)
- SET INHERR="No message header (MSH) segment"
- GOTO ERR
- +13 SET INDELIM=$EXTRACT(LINE,4)
- SET INSUBDEL=$EXTRACT(LINE,5)
- +14 ;Get MSA segment
- +15 DO GET^INHOU(UIF,0)
- +16 ;Check for errors
- +17 IF $PIECE($GET(LINE),INDELIM,1)'="MSA"
- SET INHERR="No message acknowledgement (MSA) segment"
- GOTO ERR
- +18 ;Parse out segment
- +19 ;Ack code
- +20 SET ACKSTAT=$PIECE(LINE,INDELIM,2)
- SET ACKSTAT="^AA^CA^"[(U_ACKSTAT_U)
- +21 ;ID of Acknowldeged message
- +22 SET ACKEDMES=$PIECE(LINE,INDELIM,3)
- +23 IF '$LENGTH(ACKEDMES)
- SET INHERR="No message identified to acknowledge"
- GOTO ERR
- +24 IF '$DATA(^INTHU("C",ACKEDMES))
- SET INHERR="Acknowledge for unknown message ID - "_ACKEDMES
- GOTO ERR
- +25 ;Save any @INV@("MSA6") Error Messages (HL7 V2.3 format)
- +26 SET INERMSG=$PIECE(LINE,INDELIM,7)
- +27 ;Get the first ERR segment
- +28 DO GET^INHOU(UIF,0)
- +29 SET ERRMSG=$PIECE($GET(LINE),INDELIM,2)
- +30 ;Give priority to ERR Segment Error Messages
- +31 IF '$LENGTH(ERRMSG)
- SET ERRMSG=INERMSG
- +32 ;Log acknowledge
- +33 DO ACKLOG^INHU(UIF,ACKEDMES,ACKSTAT,ERRMSG)
- +34 ;
- +35 QUIT
- +36 ;
- ERR ;Error module
- +1 SET INSTERR=2
- +2 QUIT
- +3 ;
- NOTES ;Description:
- +1 ;This program is called as part of the INCOMING ACK script
- +2 ;
- +3 ;Issues:
- +4 ;Repeating ERR segments are not recognized
- +5 ;