Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBConn dbcon       = new DBConn();
            String myHL7string = txtOutput.Text;

            string[] list = myHL7string.Split('\n');

            if (myHL7string.Contains(ConfigurationManager.AppSettings["AcceptTitleConfig"]))
            {
                paibanModel paiban    = HL7ToXmlConverter.toDataBae(myHL7string);
                string      tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"];
                if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 1)
                {
                    int i = dbcon.UpdatePaibanAll(paiban, tableName);
                    if (i > 0)
                    {
                        MessageBox.Show("修改手术成功");
                    }
                }
            }
            if (myHL7string.Contains(ConfigurationManager.AppSettings["AcceptTitle"]))
            {
                paibanModel paiban    = HL7ToXmlConverter.toDataBae(myHL7string);
                string      tableName = ConfigurationManager.AppSettings["PaibanTableName"];
                if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 0)
                {
                    int i = dbcon.InsertPaiban(paiban, tableName);
                    if (i > 0)
                    {
                        MessageBox.Show("新加手术成功");
                    }
                }
                else
                {
                    MessageBox.Show("病人已经存在!");
                }
            }
            if (myHL7string.Contains(ConfigurationManager.AppSettings["AcceptTitleCancel"]))
            {
                string PatID = "";
                myHL7string = myHL7string.Replace("ARQ", "\nARQ");
                string[] sList = myHL7string.Split('\n');
                foreach (string str in sList)
                {
                    if (str.Contains("ARQ|"))
                    {
                        PatID = str.Split('|')[1].Replace("^", "");
                    }
                }
                string tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"];
                int    i         = dbcon.UpdatePaiban(tableName, PatID);
                if (i > 0)
                {
                    MessageBox.Show("取消手术成功");
                }
            }
        }
        public HL7RequestInfo ParseRequestInfo(string message, string protocol)
        {
            HL7RequestInfo result = new HL7RequestInfo();
            PipeParser     parser = new PipeParser();

            try
            {
                ConfigurableContext configContext = new ConfigurableContext(parser.ValidationContext);
                parser.ValidationContext = configContext;
            }
            catch (Exception ex)
            {
                // Ignore any error, since the config is probably missing
            }

            try
            {
                IMessage hl7Message = parser.Parse(message);
                result = new HL7RequestInfo();
                if (HandleEachMessageAsEvent)
                {
                    result.Key = "V" + hl7Message.Version.Replace(".", "") + "." + hl7Message.GetStructureName();
                }
                else
                {
                    result.Key = "V" + hl7Message.Version.Replace(".", "") + ".MessageFactory";
                }

                if (!string.IsNullOrEmpty(protocol))
                {
                    result.Key += protocol;
                }

                result.Message = hl7Message;
            }
            catch (Exception ex)
            {
                XmlDocument xml     = HL7ToXmlConverter.ConvertToXml(message);
                var         version = xml.GetElementsByTagName("MSH.11").Item(0);
                result.versionname        = Convert.ToString(version.InnerText);
                result.feild10            = Convert.ToString(xml.GetElementsByTagName("MSH.9").Item(0).InnerText);
                result.sendingapp         = Convert.ToString(xml.GetElementsByTagName("MSH.2").Item(0).InnerText);
                result.sendingEnvironment = Convert.ToString(xml.GetElementsByTagName("MSH.3").Item(0).InnerText);
                result.feild11            = Convert.ToString(xml.GetElementsByTagName("MSH.10").Item(0).InnerText);
                result.feild15            = Convert.ToString(xml.GetElementsByTagName("MSH.14").Item(0).InnerText);
                result.feild16            = Convert.ToString(xml.GetElementsByTagName("MSH.15").Item(0).InnerText);
            }

            // Parse the message
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 消息达到后交个Biz处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void SocketHelper_MessageReviced(object sender, MessageRevicedEventArgs e)
        {
            string sendingApp = AppSettingString.SendingApp;
            string recvApp    = AppSettingString.RecvApp; //System.Configuration.ConfigurationManager.AppSettings["recvApp"];

            try
            {
                DBConn     dbcon  = new DBConn();
                PipeParser parser = new PipeParser();
                //解析出消息类型,创建对应的Biz进行处理
                string message = System.Text.Encoding.UTF8.GetString(e.Contents);
                message = MediII.Common.MLLPHelper.TrimMLLP(message, true, false);
                LogHelp.WriteLog(message);

                ////手术字典
                //if (message.Contains(_AcceptTitleOperDic))
                //{
                //    OperDicModel dic = HL7ToXmlConverter.ToOperDic(message);
                //    dbcon.InsertOperDic(dic);
                //}


                if (message.Contains(_NewOperApply))
                {
                    OTypesetting paiban = null;
                    paiban = HL7ToXmlConverter.toDataBae(message, paiban);
                    if (dbcon.GetPaiban(paiban.PatZhuYuanID) == null)
                    {
                        dbcon.InsertPaiban(paiban);
                    }
                }

                //修改
                else if (message.Contains(_UpdateOperApply))
                {
                    string       zhuyuanid = HL7ToXmlConverter.GetZhuyuanId(message);
                    OTypesetting paiban    = dbcon.GetPaiban(zhuyuanid);
                    paiban = HL7ToXmlConverter.toDataBae(message, paiban);

                    if (paiban != null)
                    {
                        if (paiban.Ostate == 0)
                        {
                            dbcon.UpdatePaiban(paiban);
                        }
                    }
                }

                else if (message.Contains(_CancelOperApply))
                {
                    string zhuyuanid = "";
                    message = message.Replace("ARQ", "\nARQ");
                    string[] sList = message.Split('\n');
                    foreach (string str in sList)
                    {
                        if (str.Contains("ARQ|"))
                        {
                            zhuyuanid = str.Split('|')[1].Replace("^", "");
                        }
                    }
                    dbcon.UpdatePaibanOstate(zhuyuanid, -1);
                }

                //string mesStruct = parser.GetMessageStructure(message).Substring(0, 3);
                string ackMsg = MediII.Common.MessageHelper.SetACK("ACK", "", "", recvApp, recvApp, sendingApp, sendingApp,
                                                                   Guid.NewGuid().ToString("N"));
                LogHelp.WriteLog(ackMsg);
                SocketHelper.SendAck(MediII.Common.MLLPHelper.AddMLLP(ackMsg), e.SocketHandler);
            }
            catch (Exception ex)
            {
                //出现异常需要返回,避免队列堵塞
                string ackMsg = MediII.Common.MessageHelper.SetACK("ACK", "", "", recvApp, recvApp, sendingApp, sendingApp,
                                                                   Guid.NewGuid().ToString("N"), ex.Message);
                LogHelp.WriteErrorLog(ackMsg);
                SocketHelper.SendAck(MediII.Common.MLLPHelper.AddMLLP(ackMsg), e.SocketHandler);
                MediII.Common.LogHelper.LogError(ex, Common.LogCatagories.AdapterBiz);
            }
        }
Esempio n. 4
0
        public void DoCompare(string file1, string file2)
        {
            try
            {
                MainProBar.Visible = true;
                MainProBar.Minimum = 1;
                MainProBar.Maximum = 18;
                MainProBar.Value   = 6;
                MainProBar.Step    = 1;
                MainProBar.PerformStep();

                //Convert HL7 to XML
                System.IO.StreamReader InputFile = new System.IO.StreamReader(file1);
                string InputHL7 = InputFile.ReadToEnd();
                InputFile.Close();
                InputHL7 = InputHL7.Replace((Char)127, (Char)13);

                String InputHL7asXml         = HL7ToXmlConverter.ConvertToXml(InputHL7, "");
                string myTempFile1           = Path.Combine(Path.GetTempPath(), "Input.xml");
                System.IO.StreamWriter fileI = new System.IO.StreamWriter(myTempFile1);
                fileI.WriteLine(InputHL7asXml);
                fileI.Close();
                file1 = myTempFile1;

                MainProBar.PerformStep();

                System.IO.StreamReader OutputFile = new System.IO.StreamReader(file2);
                string OutputHL7 = OutputFile.ReadToEnd();
                OutputFile.Close();
                OutputHL7 = OutputHL7.Replace((Char)127, (Char)13);

                String OutputHL7asXml        = HL7ToXmlConverter.ConvertToXml(OutputHL7, "");
                string myTempFile2           = Path.Combine(Path.GetTempPath(), "Output.xml");
                System.IO.StreamWriter fileO = new System.IO.StreamWriter(myTempFile2);
                fileO.WriteLine(OutputHL7asXml);
                fileO.Close();
                file2 = myTempFile2;

                MainProBar.PerformStep();

                string startupPath = Application.StartupPath;
                //output diff file.

                diffFile = startupPath + Path.DirectorySeparatorChar + "vxd.out";
                XmlTextWriter tw = new XmlTextWriter(new StreamWriter(diffFile));
                tw.Formatting = Formatting.Indented;

                MainProBar.PerformStep();

                //This method sets the diff.Options property.
                SetDiffOptions();

                bool isEqual = false;

                //Now compare the two files.
                try
                {
                    isEqual = diff.Compare(file1, file2, compareFragments, tw);
                }
                catch (XmlException xe)
                {
                    xe.StackTrace.ToString();
                    //MessageBox.Show("An exception occured while comparing\n" + xe.StackTrace);
                }
                finally
                {
                    tw.Close();
                }

                MainProBar.PerformStep();

                if (isEqual)
                {
                    //This means the files were identical for given options.
                    MessageBox.Show("Files Identical for the given options");
                    MainProBar.Value = 1;
                    return; //dont need to show the differences.
                }

                MainProBar.PerformStep();
                //Files were not equal, so construct XmlDiffView.
                XmlDiffView dv = new XmlDiffView();

                //Load the original file again and the diff file.
                XmlTextReader orig     = new XmlTextReader(file1);
                XmlTextReader diffGram = new XmlTextReader(diffFile);
                dv.Load(orig,
                        diffGram);

                MainProBar.PerformStep();

                //Wrap the HTML file with necessary html and
                //body tags and prepare it before passing it to the GetHtml method.

                string       tempFile = startupPath + Path.DirectorySeparatorChar + "Compare_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".htm";
                StreamWriter sw1      = new StreamWriter(tempFile);

                MainProBar.PerformStep();

                sw1.Write("<html><body><table width='100%'>");
                //Write Legend.
                sw1.Write("<tr><td colspan='2' align='center'><b>Legend:</b> <font style='background-color: yellow'" +
                          " color='black'>added</font>&nbsp;&nbsp;<font style='background-color: red'" +
                          " color='black'>removed</font>&nbsp;&nbsp;<font style='background-color: " +
                          "lightgreen' color='black'>changed</font>&nbsp;&nbsp;" +
                          "<font style='background-color: red' color='blue'>moved from</font>" +
                          "&nbsp;&nbsp;<font style='background-color: yellow' color='blue'>moved to" +
                          "</font>&nbsp;&nbsp;<font style='background-color: white' color='#AAAAAA'>" +
                          "ignored</font></td></tr>");


                sw1.Write("<tr><td><b> File Name : ");
                sw1.Write(OriginalPath.Text);
                sw1.Write("</b></td><td><b> File Name : ");
                sw1.Write(ComparePath.Text);
                sw1.Write("</b></td></tr>");

                MainProBar.PerformStep();
                //This gets the differences but just has the
                //rows and columns of an HTML table
                dv.GetHtml(sw1);

                MainProBar.PerformStep();
                //Finish wrapping up the generated HTML and complete the file.
                sw1.Write("</table></body></html>");

                //Open the IE Control window and pass it the HTML file we created.
                ReportWindow.Navigate(new Uri(tempFile));
                MainProBar.PerformStep();

                //HouseKeeping...close everything we dont want to lock.
                dv    = null;
                file1 = null;
                file2 = null;
                sw1.Close();
                orig.Close();
                diffGram.Close();
                orig.Dispose();
                diffGram.Dispose();
                tw.Dispose();
                sw1.Dispose();
                fileI.Dispose();
                fileO.Dispose();
                File.Delete(diffFile);
                GC.Collect();
                MainProBar.PerformStep();
                MainProBar.PerformStep();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                MainProBar.Value = 1;
            }
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string sendingApp = AppSettingString.SendingApp;
            string recvApp    = AppSettingString.RecvApp; //System.Configuration.ConfigurationManager.AppSettings["recvApp"];

            String message = txtOutput.Text;


            ////手术字典
            //if (message.Contains(Program._AcceptTitleOperDic))
            //{
            //    OperDicModel dic = HL7ToXmlConverter.ToOperDic(message);
            //    int res = dbcon.InsertOperDic(dic);
            //    if (res > 0)
            //    {
            //        MessageBox.Show("插入字典成功");
            //    }
            //}


            if (message.Contains(Program._NewOperApply))
            {
                OTypesetting paiban = null;
                paiban = HL7ToXmlConverter.toDataBae(message, paiban);
                if (dbcon.GetPaiban(paiban.PatZhuYuanID) == null)
                {
                    int i = dbcon.InsertPaiban(paiban);
                    if (i > 0)
                    {
                        MessageBox.Show("新加手术成功");
                    }
                }
                else
                {
                    MessageBox.Show("病人已经存在!");
                }
            }

            else if (message.Contains(Program._UpdateOperApply))
            {
                string       zhuyuanid = HL7ToXmlConverter.GetZhuyuanId(message);
                OTypesetting paiban    = dbcon.GetPaiban(zhuyuanid);
                paiban = HL7ToXmlConverter.toDataBae(message, paiban);

                if (paiban != null)
                {
                    if (paiban.Ostate == 0)
                    {
                        dbcon.UpdatePaiban(paiban);
                    }
                }
            }
            else if (message.Contains(Program._CancelOperApply))
            {
                string zhuyuanid = "";
                message = message.Replace("ARQ", "\nARQ");
                string[] sList = message.Split('\n');
                foreach (string str in sList)
                {
                    if (str.Contains("ARQ|"))
                    {
                        zhuyuanid = str.Split('|')[1].Replace("^", "");
                    }
                }
                int i = dbcon.UpdatePaibanOstate(zhuyuanid, -1);
                if (i > 0)
                {
                    MessageBox.Show("取消手术成功");
                }
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 消息达到后交个Biz处理
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void SocketHelper_MessageReviced(object sender, MessageRevicedEventArgs e)
 {
     try
     {
         DBConn     dbcon  = new DBConn();
         PipeParser parser = new PipeParser();
         //解析出消息类型,创建对应的Biz进行处理
         string message = System.Text.Encoding.UTF8.GetString(e.Contents);
         message = MediII.Common.MLLPHelper.TrimMLLP(message, true, false);
         LogTxt.WriteError("接收到信息:", message, EventLogEntryType.Information);
         if (message.Contains(ConfigurationManager.AppSettings["AcceptTitle"]))
         {
             paibanModel paiban    = HL7ToXmlConverter.toDataBae(message);
             string      tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"];
             if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 0)
             {
                 dbcon.InsertPaiban(paiban, tableName);
             }
         }
         if (message.Contains(ConfigurationManager.AppSettings["AcceptTitleConfig"]))
         {
             paibanModel paiban    = HL7ToXmlConverter.toDataBae(message);
             string      tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"];
             if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 1)
             {
                 dbcon.UpdatePaibanAll(paiban, tableName);
             }
         }
         if (message.Contains(ConfigurationManager.AppSettings["AcceptTitleCancel"]))
         {
             string PatID = "";
             message = message.Replace("ARQ", "\nARQ");
             string[] sList = message.Split('\n');
             foreach (string str in sList)
             {
                 if (str.Contains("ARQ|"))
                 {
                     PatID = str.Split('|')[1].Replace("^", "");
                 }
             }
             string tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"];
             dbcon.UpdatePaiban(tableName, PatID);
         }
         string mesStruct  = parser.GetMessageStructure(message).Substring(0, 3);
         string sendingApp = System.Configuration.ConfigurationManager.AppSettings["sendingApp"];
         string recvApp    = System.Configuration.ConfigurationManager.AppSettings["recvApp"];
         string ackMsg     = MediII.Common.MessageHelper.SetACK("ACK", "", "", sendingApp, sendingApp,
                                                                recvApp, recvApp, "123456789");
         DBConn.SaveLog(ackMsg);
         SocketHelper.SendAck(MediII.Common.MLLPHelper.AddMLLP(ackMsg), e.SocketHandler);
     }
     catch (Exception ex)
     {
         //出现异常需要返回,避免队列堵塞
         string sendingApp = System.Configuration.ConfigurationManager.AppSettings["SedingApplication"];
         string recvApp    = "SSMZ";
         string ackMsg     = MediII.Common.MessageHelper.SetACK("ACK", "", "", sendingApp, sendingApp,
                                                                recvApp, recvApp, "123456789", ex.Message);
         SocketHelper.SendAck(MediII.Common.MLLPHelper.AddMLLP(ackMsg), e.SocketHandler);
         MediII.Common.LogHelper.LogError(ex, Common.LogCatagories.AdapterBiz);
     }
 }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            string sendingApp = AppSettingString.SendingApp;
            string recvApp    = AppSettingString.RecvApp; //System.Configuration.ConfigurationManager.AppSettings["recvApp"];
            DBConn dbcon      = new DBConn();
            String message    = txtOutput.Text;


            //手术字典
            if (message.Contains(Program._AcceptTitleOperDic))
            {
                OperDicModel dic = HL7ToXmlConverter.ToOperDic(message);
                int          res = dbcon.InsertOperDic(dic);
                if (res > 0)
                {
                    MessageBox.Show("插入字典成功");
                }
            }

            if (message.Contains(Program._UpdateOperApply))
            {
                paibanModel paiban = HL7ToXmlConverter.toDataBae(message);
                if (dbcon.GetPaiban(paiban, Program._PaibanTable).Rows.Count == 1)
                {
                    int i = dbcon.UpdatePaibanAll(paiban, Program._PaibanTable);
                    if (i > 0)
                    {
                        MessageBox.Show("修改手术成功");
                    }
                }
            }
            if (message.Contains(Program._NewOperApply))
            {
                paibanModel paiban = HL7ToXmlConverter.toDataBae(message);
                if (dbcon.GetPaiban(paiban, Program._PaibanTable).Rows.Count == 0)
                {
                    int i = dbcon.InsertPaiban(paiban, Program._PaibanTable);
                    if (i > 0)
                    {
                        MessageBox.Show("新加手术成功");
                    }
                }
                else
                {
                    MessageBox.Show("病人已经存在!");
                }
            }
            if (message.Contains(Program._CancelOperApply))
            {
                string PatID = "";
                message = message.Replace("ARQ", "\nARQ");
                string[] sList = message.Split('\n');
                foreach (string str in sList)
                {
                    if (str.Contains("ARQ|"))
                    {
                        PatID = str.Split('|')[1].Replace("^", "");
                    }
                }
                int i = dbcon.UpdatePaibanOstate(Program._PaibanTable, PatID);
                if (i > 0)
                {
                    MessageBox.Show("取消手术成功");
                }
            }
        }