DGENEGT2 ;ALB/KCL - PROCESS INCOMING MFN TYPE HL7 MSGS; 04-MAY-1999 ; 3/7/01 9:14am
;;5.3;Registration;**232,417,363**;Aug 13, 1993
;
;
MFN ; Description: This entry point is the handler for incoming MFN type
; HL7 messages. This entry point is called from the PROCESSING ROUTINE
; field of the HL7 MESSAGE (multiple) field of the #771 file entry.
;
; Input:
; The following HL7 variables are set when the DHCP Application
; processing routine is invoked:
; HLDA - the internal entry number for the entry created in
; file #772.
; HLDAN - the name of the receiving application from the HL7 DHCP
; APPLICATION #771 file
; HLDAP - ien of the receiving application from the HL7 DHCP
; APPLICATION #771 file
; HLDT - date/time message was received in internal fileman format
; HLDT1 - date/time message was received in HL7 format
; HLECH - HL7 Encoding Characters from the 'EC' node of file #771
; HLFS - HL7 Field Separator from the 'FS' node of file #771
; HLMID - HL7 message control ID of the message received
; HLMTN - 3-7 character message type of the message received
; HLNDAP - Non-DHCP Application Pointer from file #770
; HLNDAP0 - Zero node from file #770 corresponding to HLNDAP
; HLQ - Double quotes ("") for use in building HL7 segments
; HLVER - HL7 version number of the HL7 protocol that was used to
; build the message received
;
; other HL7 variables used:
; HLEVN - number of HL7 events included in the HL7 message
; HLSDT - a flag that indicates that the data to be sent is
; stored in the ^TMP("HLS") global array.
; HLTRANS - existence of this variable indicates that the incoming
; HL7 message is being processed by the HLSERV routine and
; VA MailMan is the lowere level protocol being used.
;
;
N EVENT,MSGID,SEG
N CNT,HL,IVMRTN,SEGCNT
;
; SET UP WORK GLOBAL WITH INCOMING MESSAGE
S IVMRTN="DGENEGT2"
K ^TMP($J,IVMRTN)
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 D
..S ^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE(CNT)
S HLDA=HLMTIEN
;
; INITIALIZE HL7 VARIABLES
S HLEID="VAMC "_$P($$SITE^VASITE,"^",3)_" MFN-ZEG SERVER"
S HLEID=$O(^ORD(101,"B",HLEID,0))
D INIT^HLFNC2(HLEID,.HL)
S HLEIDS=$O(^ORD(101,HLEID,775,"B",0))
;
D NXTSEG^DGENUPL(HLDA,0,.SEG)
Q:(SEG("TYPE")'="MSH")
S EVENT=$P(SEG(9),$E(HLECH),2)
;
I EVENT="ZEG" D
.S MSGID=SEG(10)
.D EGT(HLDA,MSGID)
;
K ^TMP($J,IVMRTN)
Q
;
;
EGT(MSGIEN,MSGID) ;
; Description: This procedure is used to process an MFN~ZEG message.
; It uploads the enrollment group threshold (EGT) data. An HL7
; Master File Acknowledgement (MFK) will be returned.
;
; Input:
; MSGIEN - the internal entry number of the HL7 message in the
; HL7 MESSAGE TEXT (#772) file
; MSGID - the message control id from the MSH segment
;
; Output: None
;
N CURLINE,ERRCOUNT,SEG
;
; initialize HL7 variables
S HLSDT="IVMQ" ; subscript in ^TMP( global for MFK message
K ^TMP("HLA",$J)
;
; init variables
S ERRCOUNT=0 ; used to indicate error
S CURLINE=1
;
; process master file notification msg
D MFNZEG(MSGIEN,MSGID,.CURLINE,.ERRCOUNT)
;
; transmit master file application acknowledgment (MFK)
S HLEVN=$S(+$G(ERRCOUNT):+$G(ERRCOUNT),1:1)
S HLARYTYP="GM",HLFORMAT=1
D GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,HLFORMAT,.HLRESLTA)
;
Q
;
;
MFNZEG(MSGIEN,MSGID,CURLINE,ERRCOUNT) ;
; Description: This procedure is used to process a MFN~ZEG msg.
;
; Input:
; MSGIEN - the internal entry number of the HL7 message in the
; HL7 MESSAGE TEXT (#772) file
; MSGID - message control id of HL7 msg in the MSH segment
; CURLINE - the subscript of the MSH segment of the current message
; (pass by reference)
;
; Output:
; CURLINE - upon leaving the procedure this parameter should be set to
; the end of the current message. (pass by reference)
; ERRCOUNT - set if error encountered (pass by reference)
;
N DGEGT,DGMFI,DGMFE,ERRMSG,OLDEGT
;
; drops out of DO block on error
D
.; parse the message
.Q:'$$PARSE(MSGIEN,MSGID,.CURLINE,.ERRCOUNT,.DGEGT,.DGMFI,.DGMFE)
.;
.; get the current EGT record if it exists
.I $$GET^DGENEGT($$FINDCUR^DGENEGT(),.OLDEGT)
.;
.; add assumed values to the EGT record containing the update
.S DGEGT("ENTDATE")=$$NOW^XLFDT ; set to currnet date/time
.S DGEGT("SOURCE")=1 ; set source of EGT to 'HEC'
.;
.; perform field validation checks on the EGT record
.I '$$VALID^DGENEGT(.DGEGT,.ERRMSG) D Q
..D ADDERROR(MSGID,ERRMSG,.ERRCOUNT,.DGMFI,.DGMFE)
.;
.; store enrollment group threshold (EGT) record
.D UPLDEGT^DGENEGT3(.DGEGT)
.;
.; if no error encountered, create an 'AA' MFK
.D ACCEPT(MSGID,.DGMFI,.DGMFE)
.;
.; send local EGT notification msg
.D NOTIFY^DGENEGT1(.DGEGT,.OLDEGT)
;
Q
;
;
PARSE(MSGIEN,MSGID,CURLINE,ERRCOUNT,DGEGT,DGMFI,DGMFE) ;
; Description: This function is used to parse the HL7 segments of the message.
;
; Input:
; MSGIEN - the internal entry number of the HL7 message in the
; HL7 MESSAGE TEXT (#772) file
; MSGID - message control id of HL7 msg in the MSH segment
; CURLINE - the subscript of the MSH segment of the current message
; (pass by reference)
;
; Output:
; Function Value: Returns 1 on success, 0 on failure
; DGEGT - array containing the EGT record (pass by reference)
; DGMFI - array containing fields of MFI segment needed for
; MFK (pass by reference)
; DGMFE - array containing fields of MFE segment needed for
; MFK (pass by reference)
; ERRCOUNT - set if error encountered (pass by reference)
;
N ERROR,SEG
S ERROR=0
;
K DGEGT,DGMFI,DGMFE
S (DGMFI,DGMFE)=""
;
F SEG="MFI","MFE","ZEG" D Q:ERROR
.D NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
.I SEG("TYPE")=SEG D
..D @SEG^DGENEGT3
.E D
..D ADDERROR(MSGID,SEG_" SEGMENT MISSING",.ERRCOUNT,.DGMFI,.DGMFE)
..S ERROR=1
;
Q $S(ERROR:0,1:1)
;
;
ADDERROR(MSGID,ERRMSG,ERRCOUNT,DGMFI,DGMFE) ;
; Description - This procedure writes an MFK - Application Error (AE)
; to the global that is used in the transmission of the 'MFK' msg.
;
; Inputs:
; MSGID - message control id of HL7 msg in the MSH segment
; ERRMSG - the error msg text
; ERRCOUNT - count of errors written (pass by reference)
; DGMFI - array containing fields of MFI segment received, needed
; for MFK (pass by reference)
; DGMFE - array containing fields of MFI segment received, needed
; for MFK (pass by reference)
;
; Outputs:
; ^TMP("HLS",$J,I) - global array containing all segments of
; the HL7 message that the receiving application wishes to send
; as response. The HLSDT variable is a flag that indicates that
; the data to be sent is stored in in the ^TMP("HLS") global
; array. The variable (I) is sequential number.
;
S ERRCOUNT=+$G(ERRCOUNT)
;
; MSA segment
S ^TMP("HLA",$J,(ERRCOUNT*2)+1)="MSA"_HLFS_"AE"_HLFS_MSGID_HLFS_ERRMSG
;
; MFI segment
S ^TMP("HLA",$J,(ERRCOUNT*2)+2)="MFI"_HLFS_$G(DGMFI("MASTERID"))_HLFS_HLFS_$G(DGMFI("EVENT"))
;
; MFA segment
S ^TMP("HLA",$J,(ERRCOUNT*2)+3)="MFA"_HLFS_$G(DGMFE("RECEVNT"))_HLFS_$G(DGMFE("CNTRLNUM"))_HLFS_HLFS_"U"_HLFS_$G(DGMFE("PRIMKEY"))
S ERRCOUNT=ERRCOUNT+1
Q
;
;
ACCEPT(MSGID,DGMFI,DGMFE) ;
; Description - This procedure writes an MFK - Application Accept (AA)
; to the global that is used in the transmission of the 'MFK' msg.
;
; Inputs:
; MSGID - message control id of HL7 msg in the MSH segment
; DGMFI - array containing fields of MFI segment received, needed
; for MFK (pass by reference)
; DGMFE - array containing fields of MFI segment received, needed
; for MFK (pass by reference)
;
; Outputs:
; ^TMP("HLS",$J,HLSDT,I) - global array containing all segments of
; the HL7 message that the receiving application wishes to send
; as response. The HLSDT variable is a flag that indicates that
; the data to be sent is stored in in the ^TMP("HLS") global
; array. The variable (I) is sequential number.
;
N DGCOUNT
S DGCOUNT=1 ; sequential number used as array subscript
;
; MSA segment
S DGCOUNT=DGCOUNT+1
S ^TMP("HLA",$J,DGCOUNT)="MSA"_HLFS_"AA"_HLFS_MSGID
;
; MFI segment
S DGCOUNT=DGCOUNT+1
S ^TMP("HLA",$J,DGCOUNT)="MFI"_HLFS_$G(DGMFI("MASTERID"))_HLFS_HLFS_$G(DGMFI("EVENT"))
;
; MFA segment
S DGCOUNT=DGCOUNT+1
S ^TMP("HLA",$J,DGCOUNT)="MFA"_HLFS_$G(DGMFE("RECEVNT"))_HLFS_$G(DGMFE("CNTRLNUM"))_HLFS_HLFS_"S"_HLFS_$G(DGMFE("PRIMKEY"))
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGENEGT2 9015 printed Sep 15, 2024@22:06:42 Page 2
DGENEGT2 ;ALB/KCL - PROCESS INCOMING MFN TYPE HL7 MSGS; 04-MAY-1999 ; 3/7/01 9:14am
+1 ;;5.3;Registration;**232,417,363**;Aug 13, 1993
+2 ;
+3 ;
MFN ; Description: This entry point is the handler for incoming MFN type
+1 ; HL7 messages. This entry point is called from the PROCESSING ROUTINE
+2 ; field of the HL7 MESSAGE (multiple) field of the #771 file entry.
+3 ;
+4 ; Input:
+5 ; The following HL7 variables are set when the DHCP Application
+6 ; processing routine is invoked:
+7 ; HLDA - the internal entry number for the entry created in
+8 ; file #772.
+9 ; HLDAN - the name of the receiving application from the HL7 DHCP
+10 ; APPLICATION #771 file
+11 ; HLDAP - ien of the receiving application from the HL7 DHCP
+12 ; APPLICATION #771 file
+13 ; HLDT - date/time message was received in internal fileman format
+14 ; HLDT1 - date/time message was received in HL7 format
+15 ; HLECH - HL7 Encoding Characters from the 'EC' node of file #771
+16 ; HLFS - HL7 Field Separator from the 'FS' node of file #771
+17 ; HLMID - HL7 message control ID of the message received
+18 ; HLMTN - 3-7 character message type of the message received
+19 ; HLNDAP - Non-DHCP Application Pointer from file #770
+20 ; HLNDAP0 - Zero node from file #770 corresponding to HLNDAP
+21 ; HLQ - Double quotes ("") for use in building HL7 segments
+22 ; HLVER - HL7 version number of the HL7 protocol that was used to
+23 ; build the message received
+24 ;
+25 ; other HL7 variables used:
+26 ; HLEVN - number of HL7 events included in the HL7 message
+27 ; HLSDT - a flag that indicates that the data to be sent is
+28 ; stored in the ^TMP("HLS") global array.
+29 ; HLTRANS - existence of this variable indicates that the incoming
+30 ; HL7 message is being processed by the HLSERV routine and
+31 ; VA MailMan is the lowere level protocol being used.
+32 ;
+33 ;
+34 NEW EVENT,MSGID,SEG
+35 NEW CNT,HL,IVMRTN,SEGCNT
+36 ;
+37 ; SET UP WORK GLOBAL WITH INCOMING MESSAGE
+38 SET IVMRTN="DGENEGT2"
+39 KILL ^TMP($JOB,IVMRTN)
+40 FOR SEGCNT=1:1
XECUTE HLNEXT
if HLQUIT'>0
QUIT
Begin DoDot:1
+41 SET CNT=0
+42 SET ^TMP($JOB,IVMRTN,SEGCNT,CNT)=HLNODE
+43 FOR
SET CNT=$ORDER(HLNODE(CNT))
if 'CNT
QUIT
Begin DoDot:2
+44 SET ^TMP($JOB,IVMRTN,SEGCNT,CNT)=HLNODE(CNT)
End DoDot:2
End DoDot:1
+45 SET HLDA=HLMTIEN
+46 ;
+47 ; INITIALIZE HL7 VARIABLES
+48 SET HLEID="VAMC "_$PIECE($$SITE^VASITE,"^",3)_" MFN-ZEG SERVER"
+49 SET HLEID=$ORDER(^ORD(101,"B",HLEID,0))
+50 DO INIT^HLFNC2(HLEID,.HL)
+51 SET HLEIDS=$ORDER(^ORD(101,HLEID,775,"B",0))
+52 ;
+53 DO NXTSEG^DGENUPL(HLDA,0,.SEG)
+54 if (SEG("TYPE")'="MSH")
QUIT
+55 SET EVENT=$PIECE(SEG(9),$EXTRACT(HLECH),2)
+56 ;
+57 IF EVENT="ZEG"
Begin DoDot:1
+58 SET MSGID=SEG(10)
+59 DO EGT(HLDA,MSGID)
End DoDot:1
+60 ;
+61 KILL ^TMP($JOB,IVMRTN)
+62 QUIT
+63 ;
+64 ;
EGT(MSGIEN,MSGID) ;
+1 ; Description: This procedure is used to process an MFN~ZEG message.
+2 ; It uploads the enrollment group threshold (EGT) data. An HL7
+3 ; Master File Acknowledgement (MFK) will be returned.
+4 ;
+5 ; Input:
+6 ; MSGIEN - the internal entry number of the HL7 message in the
+7 ; HL7 MESSAGE TEXT (#772) file
+8 ; MSGID - the message control id from the MSH segment
+9 ;
+10 ; Output: None
+11 ;
+12 NEW CURLINE,ERRCOUNT,SEG
+13 ;
+14 ; initialize HL7 variables
+15 ; subscript in ^TMP( global for MFK message
SET HLSDT="IVMQ"
+16 KILL ^TMP("HLA",$JOB)
+17 ;
+18 ; init variables
+19 ; used to indicate error
SET ERRCOUNT=0
+20 SET CURLINE=1
+21 ;
+22 ; process master file notification msg
+23 DO MFNZEG(MSGIEN,MSGID,.CURLINE,.ERRCOUNT)
+24 ;
+25 ; transmit master file application acknowledgment (MFK)
+26 SET HLEVN=$SELECT(+$GET(ERRCOUNT):+$GET(ERRCOUNT),1:1)
+27 SET HLARYTYP="GM"
SET HLFORMAT=1
+28 DO GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,HLFORMAT,.HLRESLTA)
+29 ;
+30 QUIT
+31 ;
+32 ;
MFNZEG(MSGIEN,MSGID,CURLINE,ERRCOUNT) ;
+1 ; Description: This procedure is used to process a MFN~ZEG msg.
+2 ;
+3 ; Input:
+4 ; MSGIEN - the internal entry number of the HL7 message in the
+5 ; HL7 MESSAGE TEXT (#772) file
+6 ; MSGID - message control id of HL7 msg in the MSH segment
+7 ; CURLINE - the subscript of the MSH segment of the current message
+8 ; (pass by reference)
+9 ;
+10 ; Output:
+11 ; CURLINE - upon leaving the procedure this parameter should be set to
+12 ; the end of the current message. (pass by reference)
+13 ; ERRCOUNT - set if error encountered (pass by reference)
+14 ;
+15 NEW DGEGT,DGMFI,DGMFE,ERRMSG,OLDEGT
+16 ;
+17 ; drops out of DO block on error
+18 Begin DoDot:1
+19 ; parse the message
+20 if '$$PARSE(MSGIEN,MSGID,.CURLINE,.ERRCOUNT,.DGEGT,.DGMFI,.DGMFE)
QUIT
+21 ;
+22 ; get the current EGT record if it exists
+23 IF $$GET^DGENEGT($$FINDCUR^DGENEGT(),.OLDEGT)
+24 ;
+25 ; add assumed values to the EGT record containing the update
+26 ; set to currnet date/time
SET DGEGT("ENTDATE")=$$NOW^XLFDT
+27 ; set source of EGT to 'HEC'
SET DGEGT("SOURCE")=1
+28 ;
+29 ; perform field validation checks on the EGT record
+30 IF '$$VALID^DGENEGT(.DGEGT,.ERRMSG)
Begin DoDot:2
+31 DO ADDERROR(MSGID,ERRMSG,.ERRCOUNT,.DGMFI,.DGMFE)
End DoDot:2
QUIT
+32 ;
+33 ; store enrollment group threshold (EGT) record
+34 DO UPLDEGT^DGENEGT3(.DGEGT)
+35 ;
+36 ; if no error encountered, create an 'AA' MFK
+37 DO ACCEPT(MSGID,.DGMFI,.DGMFE)
+38 ;
+39 ; send local EGT notification msg
+40 DO NOTIFY^DGENEGT1(.DGEGT,.OLDEGT)
End DoDot:1
+41 ;
+42 QUIT
+43 ;
+44 ;
PARSE(MSGIEN,MSGID,CURLINE,ERRCOUNT,DGEGT,DGMFI,DGMFE) ;
+1 ; Description: This function is used to parse the HL7 segments of the message.
+2 ;
+3 ; Input:
+4 ; MSGIEN - the internal entry number of the HL7 message in the
+5 ; HL7 MESSAGE TEXT (#772) file
+6 ; MSGID - message control id of HL7 msg in the MSH segment
+7 ; CURLINE - the subscript of the MSH segment of the current message
+8 ; (pass by reference)
+9 ;
+10 ; Output:
+11 ; Function Value: Returns 1 on success, 0 on failure
+12 ; DGEGT - array containing the EGT record (pass by reference)
+13 ; DGMFI - array containing fields of MFI segment needed for
+14 ; MFK (pass by reference)
+15 ; DGMFE - array containing fields of MFE segment needed for
+16 ; MFK (pass by reference)
+17 ; ERRCOUNT - set if error encountered (pass by reference)
+18 ;
+19 NEW ERROR,SEG
+20 SET ERROR=0
+21 ;
+22 KILL DGEGT,DGMFI,DGMFE
+23 SET (DGMFI,DGMFE)=""
+24 ;
+25 FOR SEG="MFI","MFE","ZEG"
Begin DoDot:1
+26 DO NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
+27 IF SEG("TYPE")=SEG
Begin DoDot:2
+28 DO @SEG^DGENEGT3
End DoDot:2
+29 IF '$TEST
Begin DoDot:2
+30 DO ADDERROR(MSGID,SEG_" SEGMENT MISSING",.ERRCOUNT,.DGMFI,.DGMFE)
+31 SET ERROR=1
End DoDot:2
End DoDot:1
if ERROR
QUIT
+32 ;
+33 QUIT $SELECT(ERROR:0,1:1)
+34 ;
+35 ;
ADDERROR(MSGID,ERRMSG,ERRCOUNT,DGMFI,DGMFE) ;
+1 ; Description - This procedure writes an MFK - Application Error (AE)
+2 ; to the global that is used in the transmission of the 'MFK' msg.
+3 ;
+4 ; Inputs:
+5 ; MSGID - message control id of HL7 msg in the MSH segment
+6 ; ERRMSG - the error msg text
+7 ; ERRCOUNT - count of errors written (pass by reference)
+8 ; DGMFI - array containing fields of MFI segment received, needed
+9 ; for MFK (pass by reference)
+10 ; DGMFE - array containing fields of MFI segment received, needed
+11 ; for MFK (pass by reference)
+12 ;
+13 ; Outputs:
+14 ; ^TMP("HLS",$J,I) - global array containing all segments of
+15 ; the HL7 message that the receiving application wishes to send
+16 ; as response. The HLSDT variable is a flag that indicates that
+17 ; the data to be sent is stored in in the ^TMP("HLS") global
+18 ; array. The variable (I) is sequential number.
+19 ;
+20 SET ERRCOUNT=+$GET(ERRCOUNT)
+21 ;
+22 ; MSA segment
+23 SET ^TMP("HLA",$JOB,(ERRCOUNT*2)+1)="MSA"_HLFS_"AE"_HLFS_MSGID_HLFS_ERRMSG
+24 ;
+25 ; MFI segment
+26 SET ^TMP("HLA",$JOB,(ERRCOUNT*2)+2)="MFI"_HLFS_$GET(DGMFI("MASTERID"))_HLFS_HLFS_$GET(DGMFI("EVENT"))
+27 ;
+28 ; MFA segment
+29 SET ^TMP("HLA",$JOB,(ERRCOUNT*2)+3)="MFA"_HLFS_$GET(DGMFE("RECEVNT"))_HLFS_$GET(DGMFE("CNTRLNUM"))_HLFS_HLFS_"U"_HLFS_$GET(DGMFE("PRIMKEY"))
+30 SET ERRCOUNT=ERRCOUNT+1
+31 QUIT
+32 ;
+33 ;
ACCEPT(MSGID,DGMFI,DGMFE) ;
+1 ; Description - This procedure writes an MFK - Application Accept (AA)
+2 ; to the global that is used in the transmission of the 'MFK' msg.
+3 ;
+4 ; Inputs:
+5 ; MSGID - message control id of HL7 msg in the MSH segment
+6 ; DGMFI - array containing fields of MFI segment received, needed
+7 ; for MFK (pass by reference)
+8 ; DGMFE - array containing fields of MFI segment received, needed
+9 ; for MFK (pass by reference)
+10 ;
+11 ; Outputs:
+12 ; ^TMP("HLS",$J,HLSDT,I) - global array containing all segments of
+13 ; the HL7 message that the receiving application wishes to send
+14 ; as response. The HLSDT variable is a flag that indicates that
+15 ; the data to be sent is stored in in the ^TMP("HLS") global
+16 ; array. The variable (I) is sequential number.
+17 ;
+18 NEW DGCOUNT
+19 ; sequential number used as array subscript
SET DGCOUNT=1
+20 ;
+21 ; MSA segment
+22 SET DGCOUNT=DGCOUNT+1
+23 SET ^TMP("HLA",$JOB,DGCOUNT)="MSA"_HLFS_"AA"_HLFS_MSGID
+24 ;
+25 ; MFI segment
+26 SET DGCOUNT=DGCOUNT+1
+27 SET ^TMP("HLA",$JOB,DGCOUNT)="MFI"_HLFS_$GET(DGMFI("MASTERID"))_HLFS_HLFS_$GET(DGMFI("EVENT"))
+28 ;
+29 ; MFA segment
+30 SET DGCOUNT=DGCOUNT+1
+31 SET ^TMP("HLA",$JOB,DGCOUNT)="MFA"_HLFS_$GET(DGMFE("RECEVNT"))_HLFS_$GET(DGMFE("CNTRLNUM"))_HLFS_HLFS_"S"_HLFS_$GET(DGMFE("PRIMKEY"))
+32 QUIT