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

RGHLLOG1.m

Go to the documentation of this file.
  1. RGHLLOG1 ;ALB/CJM-SEND EXCEPTION TO MPI EXCEPTION HANDLER ;11/25/2000
  1. ;;1.0;CLINICAL INFO RESOURCE NETWORK;**13,18**;30 Apr 99
  1. ;
  1. ;Reference to file 870 supported by IA #3335
  1. ;Reference to file 391.72 supported by IA #3037
  1. ;References to file 773 supported by IA #3244 and 3273
  1. ;
  1. SENDMPI(RGEXC,RGERR,RGDFN,MSGID,STATNUM) ;
  1. ;Description: Sends the exception to the MPI Exception Handler.
  1. ;Input: Required
  1. ; RGEXC - Exception type in File #991.11
  1. ; RGERR - Supplemental text
  1. ; Optional
  1. ; RGDFN - IEN in the PATIENT file (#2)
  1. ; MSGID - message id of message being processed when the exception occurred (optional), uses RGLOG(3) or HL("MID") if not defined
  1. ; STATNUM - station # of site that encountered the error (optional)
  1. ; If not defined then local site is assumed, using $$SITE^VASITE
  1. ;Output: none
  1. ;
  1. ;Variables:
  1. ; @RGMSG is the location for the message text
  1. ;
  1. N RGMSG
  1. S RGMSG="^TMP($J,""RG MPI SERVER EXCEPTION"")"
  1. K @RGMSG
  1. ;
  1. D ADDLINE("**MPI/PD EXCEPTION**")
  1. D ADDDATA("EXCEPTION TYPE",$G(RGEXC))
  1. D ADDDATA("OPTIONAL TEXT",$G(RGERR))
  1. D ADDDATA("SITE OF OCCURRENCE",$S($D(STATNUM):STATNUM,1:$P($$SITE^VASITE(),"^",3)))
  1. D ADDDATA("SITE REPORTING",$P($$SITE^VASITE(),"^",3))
  1. D ADDDATA("DATE/TIME REPORTED",$$NOW^XLFDT)
  1. I $G(RGDFN) D
  1. .N OUT,SITE
  1. .D GETALL^RGFIU(RGDFN,.OUT)
  1. .D ADDLINE("**PATIENT DATA**")
  1. .D ADDDATA("ICN",OUT("ICN"))
  1. .D ADDDATA("NAME",$$NAME^RGFIU(RGDFN))
  1. .D ADDDATA("SSN",$$SSN^RGFIU(RGDFN))
  1. .D ADDDATA("CMOR",OUT("CMOR"))
  1. .S SITE=""
  1. .F S SITE=$O(OUT("TF",SITE)) Q:(SITE="") D ADDLINE("**"),ADDDATA("TREATING FACILITY",SITE),ADDDATA("DATE LAST TREATED",OUT("TF",SITE,"LASTDATE")),ADDDATA("EVENT REASON",$$GETFIELD^RGFIU(391.72,.01,OUT("TF",SITE,"EVENT")))
  1. K OUT
  1. I $$GETMSG($G(MSGID),.OUT) D
  1. .N SUB
  1. .D ADDLINE("**HL7 MESSAGE**")
  1. .S SUB=""
  1. .F S SUB=$O(OUT(SUB)) Q:(SUB="") D ADDDATA(SUB,OUT(SUB))
  1. D ADDLINE("**END**")
  1. I $$MAIL
  1. K @RGMSG
  1. ;
  1. Q
  1. ;
  1. SERVER() ;
  1. ;Description: Returns the <server name>@<server domain>. This entry
  1. ;returns the Servers location either at the test MPI or Production MPI.
  1. ;If a null is returned the MAIL subroutine will default to the MPIF
  1. ;EXCEPTIONS mail group
  1. ;
  1. ;Input: none
  1. ;Output: Where to send the exception.Returns the <server name>@<server domain> or Null
  1. ;
  1. N TO,IEN
  1. S TO=""
  1. ; get MPI logical link
  1. D LINK^HLUTIL3("200M",.HLL,"I")
  1. ; get MPI domain DBIA 3335
  1. S IEN=$O(HLL(0)) I +IEN>0 S TO=$$GET1^DIQ(870,+IEN_",",.03) I TO'="" S TO="S.MPI EXCEPTION SERVER@"_TO
  1. Q TO
  1. ;
  1. ADDDATA(LABEL,DATA) ;
  1. ;Description: Adds one formated line to the message text containing the label and data value
  1. ;Input:
  1. ; LABEL - text label that identifies the type of data
  1. ; DATA - data value
  1. ;Output:none
  1. ;
  1. D ADDLINE(LABEL_":"_DATA)
  1. Q
  1. ADDLINE(LINE) ;
  1. ;Description: adds one one to the message text
  1. ;Inputs:
  1. ; LINE - the line of text to be added
  1. ; RGMSG - @RGMSG is the location for the message text
  1. ;Output: none
  1. S @RGMSG@(($O(@RGMSG@(9999),-1)+1))=LINE
  1. Q
  1. MAIL() ;
  1. ;Description: Sends the message located at @RGMSG to the MPI Exception Handler
  1. ;Input: message at @RGMSG
  1. ;Output: If succssful, the function returns the mailman message number, otherwise, "" is returned
  1. ;
  1. N XMY,XMSUB,XMDUZ,XMTEXT,XMZ,XMDUN,DIFROM,SERVER
  1. Q:'$D(@RGMSG) ""
  1. S SERVER=$$SERVER
  1. ;if the MPI server isn't returned default to the old MPIF EXCEPTIONS mail group
  1. I SERVER="" S SERVER="MPIF EXCEPTIONS"
  1. S XMDUZ="MPI/PD at "_$P($$SITE^VASITE(),"^",2)
  1. S XMY(.5)=""
  1. S XMY(SERVER)=""
  1. S XMTEXT=$P(RGMSG,")")_","
  1. S XMSUB="MPI/PD EXCEPTION"
  1. D ^XMD
  1. Q $G(XMZ)
  1. ;
  1. GETMSG(MSGID,MSGARRAY) ;
  1. ;Description: Retrieves data from the HL7 Message Administration file (#773) related to the message
  1. ;Input:
  1. ; MSGID - the message id (optional)
  1. ; RGLOG(3) - if MSGID is not passed then RGLOG(3) is used to determine the message
  1. ; HL("MID") - if MSGID and RGLOG(3) are not defined then HL("MID") is used to determine the message
  1. ;
  1. ;Output:
  1. ; Function Value - 1 on success, 0 on failure
  1. ; MSGARRAY() - (pass by reference) - returns the data
  1. ; ("MESSAGE ID") - the HL7 message id
  1. ; ("MESSAGE TYPE") - the HL7 message type
  1. ; ("EVENT TYPE") - the HL7 event type
  1. ; ("SENDING APPLICATION") - the name of the sending application
  1. ; ("LOGICAL LINK") - the name of the HL Logical Link overwhich the message was received
  1. ;
  1. N MSGIEN
  1. K MSGARRAY
  1. I '$G(MSGID) D
  1. .I $G(RGLOG(3)) S MSGID=$$GETFIELD^RGFIU(773,2,RGLOG(3)) Q:MSGID
  1. .S MSGID=$G(HL("MID"))
  1. Q:'MSGID 0
  1. ;
  1. S MSGIEN=$$IEN773^RGHLLOG(MSGID)
  1. ;
  1. S MSGARRAY("MESSAGE ID")=MSGID
  1. S MSGARRAY("LOGICAL LINK")=$$GETFIELD^RGFIU(773,7,MSGIEN,,1)
  1. S MSGARRAY("SENDING APPLICATION")=$$GETFIELD^RGFIU(773,13,MSGIEN,,1)
  1. S MSGARRAY("MESSAGE TYPE")=$$GETFIELD^RGFIU(773,15,MSGIEN,,1)
  1. S MSGARRAY("EVENT TYPE")=$$GETFIELD^RGFIU(773,16,MSGIEN,,1)
  1. ;
  1. ;this compensates for a bug in the HL7 package - the external form rather than the pointer values are being stored in file 773
  1. I MSGID,'$L(MSGARRAY("MESSAGE TYPE")) S MSGARRAY("MESSAGE TYPE")=$$GETFIELD^RGFIU(773,15,MSGIEN)
  1. I MSGID,'$L(MSGARRAY("EVENT TYPE")) S MSGARRAY("EVENT TYPE")=$$GETFIELD^RGFIU(773,16,MSGIEN)
  1. ;
  1. Q 1