/// <summary>
        /// 导入处理过的病历---优化(转科)
        /// </summary>
        /// <auth>Yanqiao.Cai</auth>
        /// <date>2013-02-20</date>
        /// <param name="dt"></param>
        private void ProcEMRNew(DataTable dt)
        {
            try
            {
                DS_Common.SetWaitDialogCaption(m_WaitDialog, "正在处理历史病历...");
                string userID   = m_App.User.Id;
                string userName = m_App.User.Name;
                int    day      = 0;

                List <DataRow> allRecords = new List <DataRow>();
                //【1】初始化病例信息
                dt.Columns.Add("captiondatetimeTemp");
                foreach (DataRow dr in dt.Rows)
                {
                    dr["noofinpat"]  = m_CurrentInpatient.NoOfFirstPage.ToString();
                    dr["owner"]      = userID;
                    dr["createtime"] = CurrentDateTime;
                    dr["auditor"]    = "";
                    dr["audittime"]  = null;
                    dr["hassubmit"]  = "4600";
                    dr["hasprint"]   = "3600";
                    dr["hassign"]    = "0";
                    dr["islock"]     = "4700";
                    dr["ip"]         = DS_Common.GetIPHost();
                    dr["departcode"] = DS_Common.currentUser.CurrentDeptId;
                    dr["wardcode"]   = DS_Common.currentUser.CurrentWardId;

                    if (dr["sortid"].ToString() == ContainerCatalog.BingChengJiLu)//针对病程需要特殊处理,每份病例的时间间距是1天
                    {
                        string bingChenDateTime = Convert.ToDateTime(CurrentDateTime).AddDays(day).ToString("yyyy-MM-dd HH:mm:ss");
                        day++;
                        dr["name"] = dr["name"].ToString().Split(' ')[0] + ' ' + bingChenDateTime + ' ' + userName;
                        dr["captiondatetimeTemp"] = bingChenDateTime;
                    }
                    else
                    {
                        dr["name"]            = dr["name"].ToString().Split(' ')[0] + ' ' + CurrentDateTime + ' ' + userName;
                        dr["captiondatetime"] = CurrentDateTime;
                    }
                    allRecords.Add(dr);
                }
                //【2】处理病历记录和首程内容
                ///获取病例中所有首次病程
                var firstRecords = allRecords.Where(p => p["sortid"].ToString() == ContainerCatalog.BingChengJiLu && p["FIRSTDAILYFLAG"].ToString() == "1");
                ///获取所有病历内容集合(包含header和footer,包含所有首次病程中的病历)
                List <string[]> allRecordContents = new List <string[]>();
                if (null != firstRecords && firstRecords.Count() > 0)
                {
                    for (int i = 0; i < firstRecords.Count(); i++)
                    {
                        DataRow     firstRecord = firstRecords.ElementAt(i);
                        XmlDocument xmlRecord   = NewXmlDocument(firstRecord["content"].ToString());
                        if (null != allRecordContents && allRecordContents.Count() > 0)
                        {
                            List <string[]> thisRecordContents = DS_BaseService.GetRecoedsByXML(xmlRecord);
                            if (null != thisRecordContents && thisRecordContents.Count() > 0)
                            {
                                var onlyRecordContents = thisRecordContents.Where(p => p[0] != "header" && p[0] != "footer");
                                allRecordContents = allRecordContents.AsEnumerable().Union(onlyRecordContents).ToList();
                            }
                        }
                        else
                        {
                            allRecordContents = DS_BaseService.GetRecoedsByXML(xmlRecord);
                        }
                    }
                    ///将首次病程设为普通病历(非首次病程)
                    firstRecords = SetFirstDailyToDaily(firstRecords);
                }
                ///获取所有病历内容对应的时间集合
                List <string> xmlRecordTimes = allRecordContents.Select(p => p[0]).ToList();
                ///去除病例中无内容的节点
                allRecords = allRecords.Where(p => (p["sortid"].ToString() != ContainerCatalog.BingChengJiLu && !string.IsNullOrEmpty(p["content"].ToString())) || (p["sortid"].ToString() == ContainerCatalog.BingChengJiLu && xmlRecordTimes.Contains(p["captiondatetime"].ToString()))).OrderBy(q => DateTime.Parse(q["captiondatetime"].ToString())).ToList();
                ///首次病程内容
                string newEMRContent = string.Empty;
                ///获取过滤后的病程记录
                var emrRecords = allRecords.Where(p => p["sortid"].ToString() == ContainerCatalog.BingChengJiLu).OrderBy(q => DateTime.Parse(q["captiondatetime"].ToString()));
                ///需要过滤(去除)的病历时间
                List <string> toDeleteTime = new List <string>();
                foreach (DataRow emr in emrRecords)
                {
                    string[] contentArray = allRecordContents.FirstOrDefault(p => p[0] == emr["captiondatetime"].ToString());
                    if (null == contentArray || string.IsNullOrEmpty(contentArray[1].Trim()))
                    {
                        toDeleteTime.Add(emr["captiondatetime"].ToString());
                        continue;
                    }
                    string newContent = SetCaptionTime(emr["captiondatetime"].ToString(), emr["captiondatetimeTemp"].ToString(), contentArray[1]);
                    if (!string.IsNullOrEmpty(newContent.Trim()))
                    {
                        newEMRContent         += newContent;
                        emr["captiondatetime"] = emr["captiondatetimeTemp"];
                    }
                    else
                    {
                        toDeleteTime.Add(emr["captiondatetime"].ToString());
                    }
                }
                if (null != toDeleteTime && toDeleteTime.Count > 0)
                {
                    allRecords = allRecords.Where(p => !toDeleteTime.Contains(p["captiondatetime"].ToString())).OrderBy(q => DateTime.Parse(q["captiondatetime"].ToString())).ToList();
                }
                if (null != allRecordContents && allRecordContents.Count() > 0)
                {
                    string[] header = allRecordContents.FirstOrDefault(p => p[0] == "header");
                    if (null != header && !string.IsNullOrEmpty(header[1]))
                    {
                        newEMRContent = header[1] + newEMRContent;
                    }
                    string[] footer = allRecordContents.FirstOrDefault(p => p[0] == "footer");
                    if (null != footer && !string.IsNullOrEmpty(footer[1]))
                    {
                        newEMRContent += footer[1];
                    }
                }
                if (null != emrRecords && emrRecords.Count() > 0)
                {
                    DataRow firstEmr = emrRecords.FirstOrDefault();
                    if (null != firstEmr)
                    {
                        firstEmr["FIRSTDAILYFLAG"] = "1";
                        firstEmr["content"]        = newEMRContent;
                    }
                }

                //【3】保存到数据库
                DS_Common.SetWaitDialogCaption(m_WaitDialog, "正在保存病历...");
                SaveRecordsInTran(allRecords);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }