Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DGQEHL72

DGQEHL72.m

Go to the documentation of this file.
  1. DGQEHL72 ;ALB/JFP - VIC HL7 Batch Message Builder;09/01/96
  1. ;;V5.3;REGISTRATION;**73,1015**;DEC 11,1996;Build 21
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. EVENT(DGQEEVN,DFNARR) ;
  1. ; -- This option is the main entry point for the ID card driver.
  1. ;
  1. ;Input : DGQEEVN - HL7 event type
  1. ; DFNARRY - Array of DFNs to process
  1. ;
  1. ;Output : None
  1. ;
  1. ; -- Check input variables
  1. Q:'$D(DGQEEVN) "-1^required parameter not passed - event type"
  1. Q:'$D(DFNARR) "-1^ required parameter not passed - DFN array"
  1. ;
  1. ; -- Declare variables
  1. N HL7XMIT,XMITERR,MAXBATCH,MAXLINE,BATCHCNT,ERRCNT,DFN,MSGID,INCREM
  1. N ERRCNT,LINECNT,STATUS,ERRFLG
  1. N HLECH,HLEID,HLFS,HLMTIEN,HLRESLT,HLSAN
  1. N CLERK,OPT,SAPPL,RAPPL,MID
  1. ;
  1. EVNA08 ; -- A08 Update patient information for VIC
  1. I DGQEEVN="A08" D A08
  1. I ERRFLG=1 Q "-1^see mail message for details"
  1. Q 0
  1. ;
  1. A08 ; -- Builds update patient record
  1. ;
  1. ; -- Initialize global locations
  1. S HL7XMIT="^TMP(""HLS"","_$J_")"
  1. S XMITERR="^TMP(""DGQE"","_$J_",""ERROR"")"
  1. K @XMITERR,@HL7XMIT
  1. ; -- Set limits for batch message
  1. S MAXBATCH=30
  1. S MAXLINE=500
  1. ; -- Set up HL7 variables
  1. S BATCHCNT=0
  1. S ERRCNT=0
  1. D INIT
  1. ; -- Check for error in init section and quit
  1. I ERRFLG=1 D FATAL Q
  1. ; -- Loop through list of transactions
  1. S DFN=""
  1. F S DFN=$O(@DFNARR@(DFN)) Q:('DFN) D
  1. .; -- Calculate message control ID
  1. .S MSGID=HLMID_"-"_((BATCHCNT#MAXBATCH)+1)
  1. .;W !,"MSGID = ",MSGID
  1. .; -- Build HL7 message
  1. .S INCREM=$$BLDA08^DGQEHL73(DFN,.HL,MSGID,HL7XMIT,LINECNT)
  1. .; -- Check for error, increment less than 1
  1. .I (INCREM<0) D Q
  1. ..S ERRCNT=ERRCNT+1
  1. ..S @XMITERR@(DFN)=$P(INCREM,"^",2)
  1. .; -- Increment counts
  1. .S LINECNT=LINECNT+INCREM
  1. .S BATCHCNT=BATCHCNT+1
  1. .; -- Create tracking entry in ADT/HL7 transmission file (#39.4)
  1. .S FILE=$$FILE^DGQEHL74(MSGID,DFN,CLERK,OPT,SAPPL)
  1. .I FILE=-1 D ERRBULL^DGQEHL70($P(FILE,"^",2)) Q
  1. .; -- Check max size of batch, Send on max, Reset HL7 variables
  1. .I '(BATCHCNT#MAXBATCH)!(LINECNT>MAXLINE) D
  1. ..D SNDBTCH
  1. ..D INIT
  1. ;
  1. ; -- Check for unsent batch
  1. I ($O(@HL7XMIT@(0))) D
  1. .D SNDBTCH
  1. ; -- Send Completion bulletin
  1. D CMPLBULL^DGQEHL70(BATCHCNT,XMITERR)
  1. FATAL ; -- Fatal error or clean up variables, exit code
  1. K @XMITERR,@HL7XMIT
  1. Q
  1. ;
  1. INIT ; -- Initialize variables
  1. S ERRFLG=0
  1. S LINECNT=1
  1. K @HL7XMIT
  1. ; -- Get pointer to sending event
  1. S HLEID=+$O(^ORD(101,"B","DGQE HL7 A08 VIC SERVER",0))
  1. ; -- Check existance of event, send error bulletin, done
  1. I ('HLEID) D Q
  1. .D ERRBULL^DGQEHL70("-1^Unable to initialize HL7 variables - protocol not found")
  1. .S ERRFLG=1
  1. ; -- Get variables from HL7 package
  1. D INIT^HLFNC2(HLEID,.HL)
  1. ; -- Check existance of HL variables, send error bulletin, done
  1. I ($O(HL(""))="") D Q
  1. .D ERRBULL^DGQEHL70("-1^"_$P(HL,"^",2))
  1. .S ERRFLG=1
  1. ; -- Set variables for transmission file
  1. S SAPPL=$S($D(HL("SAN")):$G(HL("SAN")),1:"")
  1. S CLERK=$S(DUZ'="":$P($G(^VA(200,DUZ,0)),"^",1),1:"")
  1. S OPT=$S($D(XQY0):$P($G(XQY0),"^",2),1:"")
  1. ; -- Create batch message
  1. D CREATE^HLTF(.HLMID,.HLMTIEN,.HLDT,.HLDT1)
  1. ; -- Check to see if batch message created, send error, done
  1. I ('HLMTIEN) D Q
  1. .D ERRBULL^DGQEHL70("-1^Unable to create batch HL7 message")
  1. .S ERRFLG=1
  1. Q
  1. ;
  1. SNDBTCH ; -- Sends batch message
  1. S HLP("PRIORITY")="I"
  1. D GENERATE^HLMA(HLEID,"GB",1,.HLRESLT,HLMTIEN,.HLP)
  1. ; -- Check for error
  1. I ($P(HLRESLT,"^",2)'="") D Q
  1. .S STATUS=$P(HLRESLT,"^",2)_"^"_$P(HLRESLT,"^",3)
  1. .D ERRBULL^DGQEHL70(STATUS)
  1. .S ERRFLG=1
  1. ; -- Successful call, message ID returned
  1. S STATUS=$P(HLRESLT,"^",1)
  1. I $D(JPTEST) W !,"Message ID = ",STATUS
  1. Q
  1. ;
  1. END ; -- End of code
  1. Q
  1. ;