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

DGENEGT2.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. ;
  1. MFN ; Description: This entry point is the handler for incoming MFN type
  1. ; HL7 messages. This entry point is called from the PROCESSING ROUTINE
  1. ; field of the HL7 MESSAGE (multiple) field of the #771 file entry.
  1. ;
  1. ; Input:
  1. ; The following HL7 variables are set when the DHCP Application
  1. ; processing routine is invoked:
  1. ; HLDA - the internal entry number for the entry created in
  1. ; file #772.
  1. ; HLDAN - the name of the receiving application from the HL7 DHCP
  1. ; APPLICATION #771 file
  1. ; HLDAP - ien of the receiving application from the HL7 DHCP
  1. ; APPLICATION #771 file
  1. ; HLDT - date/time message was received in internal fileman format
  1. ; HLDT1 - date/time message was received in HL7 format
  1. ; HLECH - HL7 Encoding Characters from the 'EC' node of file #771
  1. ; HLFS - HL7 Field Separator from the 'FS' node of file #771
  1. ; HLMID - HL7 message control ID of the message received
  1. ; HLMTN - 3-7 character message type of the message received
  1. ; HLNDAP - Non-DHCP Application Pointer from file #770
  1. ; HLNDAP0 - Zero node from file #770 corresponding to HLNDAP
  1. ; HLQ - Double quotes ("") for use in building HL7 segments
  1. ; HLVER - HL7 version number of the HL7 protocol that was used to
  1. ; build the message received
  1. ;
  1. ; other HL7 variables used:
  1. ; HLEVN - number of HL7 events included in the HL7 message
  1. ; HLSDT - a flag that indicates that the data to be sent is
  1. ; stored in the ^TMP("HLS") global array.
  1. ; HLTRANS - existence of this variable indicates that the incoming
  1. ; HL7 message is being processed by the HLSERV routine and
  1. ; VA MailMan is the lowere level protocol being used.
  1. ;
  1. ;
  1. N EVENT,MSGID,SEG
  1. N CNT,HL,IVMRTN,SEGCNT
  1. ;
  1. ; SET UP WORK GLOBAL WITH INCOMING MESSAGE
  1. S IVMRTN="DGENEGT2"
  1. K ^TMP($J,IVMRTN)
  1. F SEGCNT=1:1 X HLNEXT Q:HLQUIT'>0 D
  1. .S CNT=0
  1. .S ^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE
  1. .F S CNT=$O(HLNODE(CNT)) Q:'CNT D
  1. ..S ^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE(CNT)
  1. S HLDA=HLMTIEN
  1. ;
  1. ; INITIALIZE HL7 VARIABLES
  1. S HLEID="VAMC "_$P($$SITE^VASITE,"^",3)_" MFN-ZEG SERVER"
  1. S HLEID=$O(^ORD(101,"B",HLEID,0))
  1. D INIT^HLFNC2(HLEID,.HL)
  1. S HLEIDS=$O(^ORD(101,HLEID,775,"B",0))
  1. ;
  1. D NXTSEG^DGENUPL(HLDA,0,.SEG)
  1. Q:(SEG("TYPE")'="MSH")
  1. S EVENT=$P(SEG(9),$E(HLECH),2)
  1. ;
  1. I EVENT="ZEG" D
  1. .S MSGID=SEG(10)
  1. .D EGT(HLDA,MSGID)
  1. ;
  1. K ^TMP($J,IVMRTN)
  1. Q
  1. ;
  1. ;
  1. EGT(MSGIEN,MSGID) ;
  1. ; Description: This procedure is used to process an MFN~ZEG message.
  1. ; It uploads the enrollment group threshold (EGT) data. An HL7
  1. ; Master File Acknowledgement (MFK) will be returned.
  1. ;
  1. ; Input:
  1. ; MSGIEN - the internal entry number of the HL7 message in the
  1. ; HL7 MESSAGE TEXT (#772) file
  1. ; MSGID - the message control id from the MSH segment
  1. ;
  1. ; Output: None
  1. ;
  1. N CURLINE,ERRCOUNT,SEG
  1. ;
  1. ; initialize HL7 variables
  1. S HLSDT="IVMQ" ; subscript in ^TMP( global for MFK message
  1. K ^TMP("HLA",$J)
  1. ;
  1. ; init variables
  1. S ERRCOUNT=0 ; used to indicate error
  1. S CURLINE=1
  1. ;
  1. ; process master file notification msg
  1. D MFNZEG(MSGIEN,MSGID,.CURLINE,.ERRCOUNT)
  1. ;
  1. ; transmit master file application acknowledgment (MFK)
  1. S HLEVN=$S(+$G(ERRCOUNT):+$G(ERRCOUNT),1:1)
  1. S HLARYTYP="GM",HLFORMAT=1
  1. D GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,HLFORMAT,.HLRESLTA)
  1. ;
  1. Q
  1. ;
  1. ;
  1. MFNZEG(MSGIEN,MSGID,CURLINE,ERRCOUNT) ;
  1. ; Description: This procedure is used to process a MFN~ZEG msg.
  1. ;
  1. ; Input:
  1. ; MSGIEN - the internal entry number of the HL7 message in the
  1. ; HL7 MESSAGE TEXT (#772) file
  1. ; MSGID - message control id of HL7 msg in the MSH segment
  1. ; CURLINE - the subscript of the MSH segment of the current message
  1. ; (pass by reference)
  1. ;
  1. ; Output:
  1. ; CURLINE - upon leaving the procedure this parameter should be set to
  1. ; the end of the current message. (pass by reference)
  1. ; ERRCOUNT - set if error encountered (pass by reference)
  1. ;
  1. N DGEGT,DGMFI,DGMFE,ERRMSG,OLDEGT
  1. ;
  1. ; drops out of DO block on error
  1. D
  1. .; parse the message
  1. .Q:'$$PARSE(MSGIEN,MSGID,.CURLINE,.ERRCOUNT,.DGEGT,.DGMFI,.DGMFE)
  1. .;
  1. .; get the current EGT record if it exists
  1. .I $$GET^DGENEGT($$FINDCUR^DGENEGT(),.OLDEGT)
  1. .;
  1. .; add assumed values to the EGT record containing the update
  1. .S DGEGT("ENTDATE")=$$NOW^XLFDT ; set to currnet date/time
  1. .S DGEGT("SOURCE")=1 ; set source of EGT to 'HEC'
  1. .;
  1. .; perform field validation checks on the EGT record
  1. .I '$$VALID^DGENEGT(.DGEGT,.ERRMSG) D Q
  1. ..D ADDERROR(MSGID,ERRMSG,.ERRCOUNT,.DGMFI,.DGMFE)
  1. .;
  1. .; store enrollment group threshold (EGT) record
  1. .D UPLDEGT^DGENEGT3(.DGEGT)
  1. .;
  1. .; if no error encountered, create an 'AA' MFK
  1. .D ACCEPT(MSGID,.DGMFI,.DGMFE)
  1. .;
  1. .; send local EGT notification msg
  1. .D NOTIFY^DGENEGT1(.DGEGT,.OLDEGT)
  1. ;
  1. Q
  1. ;
  1. ;
  1. PARSE(MSGIEN,MSGID,CURLINE,ERRCOUNT,DGEGT,DGMFI,DGMFE) ;
  1. ; Description: This function is used to parse the HL7 segments of the message.
  1. ;
  1. ; Input:
  1. ; MSGIEN - the internal entry number of the HL7 message in the
  1. ; HL7 MESSAGE TEXT (#772) file
  1. ; MSGID - message control id of HL7 msg in the MSH segment
  1. ; CURLINE - the subscript of the MSH segment of the current message
  1. ; (pass by reference)
  1. ;
  1. ; Output:
  1. ; Function Value: Returns 1 on success, 0 on failure
  1. ; DGEGT - array containing the EGT record (pass by reference)
  1. ; DGMFI - array containing fields of MFI segment needed for
  1. ; MFK (pass by reference)
  1. ; DGMFE - array containing fields of MFE segment needed for
  1. ; MFK (pass by reference)
  1. ; ERRCOUNT - set if error encountered (pass by reference)
  1. ;
  1. N ERROR,SEG
  1. S ERROR=0
  1. ;
  1. K DGEGT,DGMFI,DGMFE
  1. S (DGMFI,DGMFE)=""
  1. ;
  1. F SEG="MFI","MFE","ZEG" D Q:ERROR
  1. .D NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
  1. .I SEG("TYPE")=SEG D
  1. ..D @SEG^DGENEGT3
  1. .E D
  1. ..D ADDERROR(MSGID,SEG_" SEGMENT MISSING",.ERRCOUNT,.DGMFI,.DGMFE)
  1. ..S ERROR=1
  1. ;
  1. Q $S(ERROR:0,1:1)
  1. ;
  1. ;
  1. ADDERROR(MSGID,ERRMSG,ERRCOUNT,DGMFI,DGMFE) ;
  1. ; Description - This procedure writes an MFK - Application Error (AE)
  1. ; to the global that is used in the transmission of the 'MFK' msg.
  1. ;
  1. ; Inputs:
  1. ; MSGID - message control id of HL7 msg in the MSH segment
  1. ; ERRMSG - the error msg text
  1. ; ERRCOUNT - count of errors written (pass by reference)
  1. ; DGMFI - array containing fields of MFI segment received, needed
  1. ; for MFK (pass by reference)
  1. ; DGMFE - array containing fields of MFI segment received, needed
  1. ; for MFK (pass by reference)
  1. ;
  1. ; Outputs:
  1. ; ^TMP("HLS",$J,I) - global array containing all segments of
  1. ; the HL7 message that the receiving application wishes to send
  1. ; as response. The HLSDT variable is a flag that indicates that
  1. ; the data to be sent is stored in in the ^TMP("HLS") global
  1. ; array. The variable (I) is sequential number.
  1. ;
  1. S ERRCOUNT=+$G(ERRCOUNT)
  1. ;
  1. ; MSA segment
  1. S ^TMP("HLA",$J,(ERRCOUNT*2)+1)="MSA"_HLFS_"AE"_HLFS_MSGID_HLFS_ERRMSG
  1. ;
  1. ; MFI segment
  1. S ^TMP("HLA",$J,(ERRCOUNT*2)+2)="MFI"_HLFS_$G(DGMFI("MASTERID"))_HLFS_HLFS_$G(DGMFI("EVENT"))
  1. ;
  1. ; MFA segment
  1. S ^TMP("HLA",$J,(ERRCOUNT*2)+3)="MFA"_HLFS_$G(DGMFE("RECEVNT"))_HLFS_$G(DGMFE("CNTRLNUM"))_HLFS_HLFS_"U"_HLFS_$G(DGMFE("PRIMKEY"))
  1. S ERRCOUNT=ERRCOUNT+1
  1. Q
  1. ;
  1. ;
  1. ACCEPT(MSGID,DGMFI,DGMFE) ;
  1. ; Description - This procedure writes an MFK - Application Accept (AA)
  1. ; to the global that is used in the transmission of the 'MFK' msg.
  1. ;
  1. ; Inputs:
  1. ; MSGID - message control id of HL7 msg in the MSH segment
  1. ; DGMFI - array containing fields of MFI segment received, needed
  1. ; for MFK (pass by reference)
  1. ; DGMFE - array containing fields of MFI segment received, needed
  1. ; for MFK (pass by reference)
  1. ;
  1. ; Outputs:
  1. ; ^TMP("HLS",$J,HLSDT,I) - global array containing all segments of
  1. ; the HL7 message that the receiving application wishes to send
  1. ; as response. The HLSDT variable is a flag that indicates that
  1. ; the data to be sent is stored in in the ^TMP("HLS") global
  1. ; array. The variable (I) is sequential number.
  1. ;
  1. N DGCOUNT
  1. S DGCOUNT=1 ; sequential number used as array subscript
  1. ;
  1. ; MSA segment
  1. S DGCOUNT=DGCOUNT+1
  1. S ^TMP("HLA",$J,DGCOUNT)="MSA"_HLFS_"AA"_HLFS_MSGID
  1. ;
  1. ; MFI segment
  1. S DGCOUNT=DGCOUNT+1
  1. S ^TMP("HLA",$J,DGCOUNT)="MFI"_HLFS_$G(DGMFI("MASTERID"))_HLFS_HLFS_$G(DGMFI("EVENT"))
  1. ;
  1. ; MFA segment
  1. S DGCOUNT=DGCOUNT+1
  1. S ^TMP("HLA",$J,DGCOUNT)="MFA"_HLFS_$G(DGMFE("RECEVNT"))_HLFS_$G(DGMFE("CNTRLNUM"))_HLFS_HLFS_"S"_HLFS_$G(DGMFE("PRIMKEY"))
  1. Q