示例#1
0
        private static bool sendPowerscribe(DocumentTemplate dt, int interfaceId, string interfaceType, string ip, string port, string hl7SegmentList)
        {
            bool returnValue = false;

            if ((!String.IsNullOrEmpty(ip)) && (!String.IsNullOrEmpty(port)))
            {
                string    str         = null;
                string    hl7Response = "";
                TcpClient client;
                Stream    stream = null;

                try
                {
                    client                = new TcpClient(ip, Int32.Parse(port));
                    client.SendTimeout    = 5000; // milliseconds
                    client.ReceiveTimeout = 30000;
                    stream                = client.GetStream();
                } catch (Exception e) {
                    Logger.Instance.WriteToLog("Failed to establish HL7 MLLP listener with Powerscribe at location " + ip + ":" + port + ", underlying error message is: " + e.ToString());
                }

                // Extract the outbound message from the html document...
                str = extractHL7(dt, hl7SegmentList);   // enter the segmentList in lkpInterfaceDefinitions.stringParam1 if you don't want to use the default segment list

                if (stream == null)
                {
                    Logger.Instance.WriteToLog("No HL7 MLLP connection with Powerscribe at location " + ip + ":" + port + ".");
                    return(false);
                }
                // Transmit the HL7 message, and await the response.
                try
                {
                    MLLP mllp = new MLLP(stream, false);
                    mllp.Send(str);
                    hl7Response = mllp.Receive();
                    returnValue = true;     // got a response...
                    Logger.Instance.WriteToLog("MLLP Message Received: " + hl7Response);
                }
                catch (Exception e)
                {
                    // TODO:  Do something, you know, retry perhaps?
                    Logger.Instance.WriteToLog("Failed to send ORU to Powerscribe.  HL7 message is: " + str + ", underlying error message is: " + e.ToString());
                }
                finally
                {
                    stream.Close();
                }
                return(returnValue);
            }
            else
            {
                Logger.Instance.WriteToLog("Failed to send ORU to Powerscribe. Currently configured is interface id " + interfaceId + ", port " + port + ", IP " + ip + ", and segment list " + hl7SegmentList + ".  Relevant tables are lkpAutomationDocuments, lkpInterfaceDefinitions, and lkpDocumentTemplates. ");
            }

            return(false);
        }
示例#2
0
        private static bool sendPowerscribe(DocumentTemplate dt, int interfaceId, string interfaceType, string ip, string port, string hl7SegmentList)
        {
            bool returnValue = false;

            if ((!String.IsNullOrEmpty(ip)) && (!String.IsNullOrEmpty(port)))
            {
                string str = null;
                string hl7Response = "";
                TcpClient client;
                Stream stream = null;

                try
                {
                    client = new TcpClient(ip, Int32.Parse(port));
                    client.SendTimeout = 5000;  // milliseconds
                    client.ReceiveTimeout = 30000;
                    stream = client.GetStream();
                }
                catch (Exception e)
                {
                    Logger.Instance.WriteToLog("Failed to establish HL7 MLLP listener with Powerscribe at location " + ip + ":" + port + ", underlying error message is: " + e.ToString());
                }

                // Extract the outbound message from the html document...
                str = extractHL7(dt, hl7SegmentList);   // enter the segmentList in lkpInterfaceDefinitions.stringParam1 if you don't want to use the default segment list

                if (stream == null)
                {
                    Logger.Instance.WriteToLog("No HL7 MLLP connection with Powerscribe at location " + ip + ":" + port + ".");
                    return false;
                }
                // Transmit the HL7 message, and await the response.
                try
                {
                    MLLP mllp = new MLLP(stream, false);
                    mllp.Send(str);
                    hl7Response = mllp.Receive();
                    returnValue = true;     // got a response...
                    Logger.Instance.WriteToLog("MLLP Message Received: " + hl7Response);
                }
                catch (Exception e)
                {
                    // TODO:  Do something, you know, retry perhaps?
                    Logger.Instance.WriteToLog("Failed to send ORU to Powerscribe.  HL7 message is: " + str + ", underlying error message is: " + e.ToString());
                }
                finally
                {
                    stream.Close();
                }
                return returnValue;
            }
            else
            {
                Logger.Instance.WriteToLog("Failed to send ORU to Powerscribe. Currently configured is interface id " + interfaceId + ", port " + port + ", IP " + ip + ", and segment list " + hl7SegmentList + ".  Relevant tables are lkpAutomationDocuments, lkpInterfaceDefinitions, and lkpDocumentTemplates. ");
            }

            return false;
        }