IVMPREC2 ;ALB/KCL - ROUTE INCOMING HL7 (ORU) MESSAGES BY EVENT TYPE ;5/17/02 1:43pm
;;2.0;INCOME VERIFICATION MATCH;**12,34,112,118,145**;21-OCT-94;Build 6
;;Per VHA Directive 2004-038, this routine should not be modified.
;
; This routine will process (ORU) HL7 messages received from the
; IVM center. Event type code indicating type of transmission is
; in the BHS segment. Routines based on type will be called to
; process these messages. For each batch an ACK will be sent to
; the IVM Center indicating errors found. If any errors are found
; a batch message with AE(indicating error(s)) is sent. If no errors
; only a MSH and MSA with AA(no errors) is sent. The following event
; type codes are processed in the following routines:
;
; EVENT CODE TRANSMISSION TYPE PROCESSING ROUTINE
; ==============================================================
; Z03 SSN TRANSMISSIONS IVMPREC5
; Z04 INSURANCE TRANSMISSIONS IVMPREC3
; Z05 DEMOGRAPHIC TRANSMISSIONS IVMPREC6
; Z06 MEANS TEST TRANSMISSIONS IVMPREC7
; Z08 CASE STATUS TRANSMISSIONS IVMPREC4
; Z10 INCOME TEST TRANSMISSIONS IVMCM
; Z11 ENROLLMENT/ELIGIBILTY ORUZ11^DGENUPL
;
;
ORU ; - Receive Observational Results Unsolicited Message
;
N DIC,%,%H,%I D NOW^%DTC S HLDT=%
K HLERR,IVMSEG1,IVMSEG2,IVMSEG3
S (HLEVN,IVMCT,IVMERROR,IVMCNTR)=0
; Make sure POSTMASTER DUZ instead of DUZ of Person who
; started Incoming Logical Link
S DUZ=.5
;
; - get incoming segment from HL7 (#772) file
N IVMRTN,SEGCNT,CNT,STATION,HLEID,HLEIDS
S IVMRTN="IVMPREC2" K ^TMP($J,IVMRTN),^TMP("HLA",$J),^TMP("HLS",$J)
F SEGCNT=1:1 X HLNEXT Q:HLQUIT'>0 D
. S CNT=0
. S ^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE
. F S CNT=$O(HLNODE(CNT)) Q:'CNT S ^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE(CNT)
;
S HLDA=HLMTIEN
S IVMSEG=$G(^TMP($J,IVMRTN,1,0)) I IVMSEG']"" G ORUQ
;
; - check for BHS
I $E(IVMSEG,1,3)'="BHS" G ORUQ
;
; - get batch control id
S HLFS=HL("FS")
S HLECH=HL("ECH")
S HLQ=$G(HL("HLQ")) S:HLQ="" HLQ=""""""
S IVMHLMID=$P(IVMSEG,HLFS,11)
S STATION=$P(IVMSEG,HLFS,6)
;
; - get event type code
S IVMETC=$P($P(IVMSEG,HLFS,9),$E(HLECH),3)
S IVMETC=$P(IVMETC,$E(HLECH,2),2)
S HLEID="VAMC "_STATION_" ORU-"_IVMETC_" SERVER"
I IVMETC="Z04" S HLEID=HLEID_" H" ;HEC TO VAMC
S HLEID=$O(^ORD(101,"B",HLEID,0)),HLEIDS=""
I HLEID]"" S HLEIDS=$O(^ORD(101,HLEID,775,"B",0))
;
; - process the message according to the event type code
S IVMDO=$S(IVMETC="Z03":"EN^IVMPREC5",IVMETC="Z04":"EN^IVMPREC3",IVMETC="Z05":"EN^IVMPREC6",IVMETC="Z06":"EN^IVMPREC7",IVMETC="Z08":"EN^IVMPREC4",IVMETC="Z10":"ORU^IVMCM",IVMETC="Z11":"ORUZ11^DGENUPL",1:"ORUQ")
I IVMETC="Z11" D
.D ORUZ11^DGENUPL(HLDA,.IVMERROR)
.S IVMCT=2*IVMERROR
.S HLEVN=IVMERROR
I IVMETC'="Z11" D
.D @IVMDO
Q:IVMDO="ORUQ"
;
; - if no error send ACK 'AA' message
S HLMTN="ACK"
K HLARYTYP,HLMTIENA,HLRESLTA,HLP
I 'IVMERROR S HLMID=IVMHLMID D ACK^IVMPREC S HLARYTYP="GM",HLMTIENA=""
I IVMERROR S HLARYTYP="GB",HLMTIENA=HLMTIEN ;HLMTIEN comes from ACK^IVMPREC
K ^TMP("HLA",$J) M ^TMP("HLA",$J)=^TMP("HLS",$J) K ^TMP("HLS",$J)
D GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,1,.HLRESLTA,HLMTIENA,.HLP)
;
ORUQ ;
K DFN,IVMCNTR,IVMCT,IVMDA,IVMERR,IVMERROR,IVMHLMID,IVMNDE,IVMPTID
K IVMSEG,IVMSEG1,IVMSEG2,IVMSEG3,IVMTEXT,XMSUB
K HLARYTYP,HLMTIENA,HLRESLTA,HLP
K ^TMP($J,IVMRTN),^TMP("HLA",$J),^TMP("HLS",$J)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIVMPREC2 3631 printed Oct 16, 2024@18:02:57 Page 2
IVMPREC2 ;ALB/KCL - ROUTE INCOMING HL7 (ORU) MESSAGES BY EVENT TYPE ;5/17/02 1:43pm
+1 ;;2.0;INCOME VERIFICATION MATCH;**12,34,112,118,145**;21-OCT-94;Build 6
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 ; This routine will process (ORU) HL7 messages received from the
+5 ; IVM center. Event type code indicating type of transmission is
+6 ; in the BHS segment. Routines based on type will be called to
+7 ; process these messages. For each batch an ACK will be sent to
+8 ; the IVM Center indicating errors found. If any errors are found
+9 ; a batch message with AE(indicating error(s)) is sent. If no errors
+10 ; only a MSH and MSA with AA(no errors) is sent. The following event
+11 ; type codes are processed in the following routines:
+12 ;
+13 ; EVENT CODE TRANSMISSION TYPE PROCESSING ROUTINE
+14 ; ==============================================================
+15 ; Z03 SSN TRANSMISSIONS IVMPREC5
+16 ; Z04 INSURANCE TRANSMISSIONS IVMPREC3
+17 ; Z05 DEMOGRAPHIC TRANSMISSIONS IVMPREC6
+18 ; Z06 MEANS TEST TRANSMISSIONS IVMPREC7
+19 ; Z08 CASE STATUS TRANSMISSIONS IVMPREC4
+20 ; Z10 INCOME TEST TRANSMISSIONS IVMCM
+21 ; Z11 ENROLLMENT/ELIGIBILTY ORUZ11^DGENUPL
+22 ;
+23 ;
ORU ; - Receive Observational Results Unsolicited Message
+1 ;
+2 NEW DIC,%,%H,%I
DO NOW^%DTC
SET HLDT=%
+3 KILL HLERR,IVMSEG1,IVMSEG2,IVMSEG3
+4 SET (HLEVN,IVMCT,IVMERROR,IVMCNTR)=0
+5 ; Make sure POSTMASTER DUZ instead of DUZ of Person who
+6 ; started Incoming Logical Link
+7 SET DUZ=.5
+8 ;
+9 ; - get incoming segment from HL7 (#772) file
+10 NEW IVMRTN,SEGCNT,CNT,STATION,HLEID,HLEIDS
+11 SET IVMRTN="IVMPREC2"
KILL ^TMP($JOB,IVMRTN),^TMP("HLA",$JOB),^TMP("HLS",$JOB)
+12 FOR SEGCNT=1:1
XECUTE HLNEXT
if HLQUIT'>0
QUIT
Begin DoDot:1
+13 SET CNT=0
+14 SET ^TMP($JOB,IVMRTN,SEGCNT,CNT)=HLNODE
+15 FOR
SET CNT=$ORDER(HLNODE(CNT))
if 'CNT
QUIT
SET ^TMP($JOB,IVMRTN,SEGCNT,CNT)=HLNODE(CNT)
End DoDot:1
+16 ;
+17 SET HLDA=HLMTIEN
+18 SET IVMSEG=$GET(^TMP($JOB,IVMRTN,1,0))
IF IVMSEG']""
GOTO ORUQ
+19 ;
+20 ; - check for BHS
+21 IF $EXTRACT(IVMSEG,1,3)'="BHS"
GOTO ORUQ
+22 ;
+23 ; - get batch control id
+24 SET HLFS=HL("FS")
+25 SET HLECH=HL("ECH")
+26 SET HLQ=$GET(HL("HLQ"))
if HLQ=""
SET HLQ=""""""
+27 SET IVMHLMID=$PIECE(IVMSEG,HLFS,11)
+28 SET STATION=$PIECE(IVMSEG,HLFS,6)
+29 ;
+30 ; - get event type code
+31 SET IVMETC=$PIECE($PIECE(IVMSEG,HLFS,9),$EXTRACT(HLECH),3)
+32 SET IVMETC=$PIECE(IVMETC,$EXTRACT(HLECH,2),2)
+33 SET HLEID="VAMC "_STATION_" ORU-"_IVMETC_" SERVER"
+34 ;HEC TO VAMC
IF IVMETC="Z04"
SET HLEID=HLEID_" H"
+35 SET HLEID=$ORDER(^ORD(101,"B",HLEID,0))
SET HLEIDS=""
+36 IF HLEID]""
SET HLEIDS=$ORDER(^ORD(101,HLEID,775,"B",0))
+37 ;
+38 ; - process the message according to the event type code
+39 SET IVMDO=$SELECT(IVMETC="Z03":"EN^IVMPREC5",IVMETC="Z04":"EN^IVMPREC3",IVMETC="Z05":"EN^IVMPREC6",IVMETC="Z06":"EN^IVMPREC7",IVMETC="Z08":"EN^IVMPREC4",IVMETC="Z10":"ORU^IVMCM",IVMETC="Z11":"ORUZ11^DGENUPL",1:"ORUQ")
+40 IF IVMETC="Z11"
Begin DoDot:1
+41 DO ORUZ11^DGENUPL(HLDA,.IVMERROR)
+42 SET IVMCT=2*IVMERROR
+43 SET HLEVN=IVMERROR
End DoDot:1
+44 IF IVMETC'="Z11"
Begin DoDot:1
+45 DO @IVMDO
End DoDot:1
+46 if IVMDO="ORUQ"
QUIT
+47 ;
+48 ; - if no error send ACK 'AA' message
+49 SET HLMTN="ACK"
+50 KILL HLARYTYP,HLMTIENA,HLRESLTA,HLP
+51 IF 'IVMERROR
SET HLMID=IVMHLMID
DO ACK^IVMPREC
SET HLARYTYP="GM"
SET HLMTIENA=""
+52 ;HLMTIEN comes from ACK^IVMPREC
IF IVMERROR
SET HLARYTYP="GB"
SET HLMTIENA=HLMTIEN
+53 KILL ^TMP("HLA",$JOB)
MERGE ^TMP("HLA",$JOB)=^TMP("HLS",$JOB)
KILL ^TMP("HLS",$JOB)
+54 DO GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,1,.HLRESLTA,HLMTIENA,.HLP)
+55 ;
ORUQ ;
+1 KILL DFN,IVMCNTR,IVMCT,IVMDA,IVMERR,IVMERROR,IVMHLMID,IVMNDE,IVMPTID
+2 KILL IVMSEG,IVMSEG1,IVMSEG2,IVMSEG3,IVMTEXT,XMSUB
+3 KILL HLARYTYP,HLMTIENA,HLRESLTA,HLP
+4 KILL ^TMP($JOB,IVMRTN),^TMP("HLA",$JOB),^TMP("HLS",$JOB)
+5 QUIT