/// <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); } }
private void HistoryEmrBatchInInner(EmrNode node, string deptChangeID) { try { SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@noofinpat", SqlDbType.VarChar), new SqlParameter("@templateid", SqlDbType.VarChar), new SqlParameter("@name", SqlDbType.VarChar), new SqlParameter("@content", SqlDbType.VarChar), new SqlParameter("@sortid", SqlDbType.VarChar), new SqlParameter("@owner", SqlDbType.VarChar), new SqlParameter("@createtime", SqlDbType.VarChar), new SqlParameter("@captiondatetime", SqlDbType.VarChar), new SqlParameter("@firstdailyflag", SqlDbType.VarChar), new SqlParameter("@isyihuangougong", SqlDbType.VarChar), new SqlParameter("@ip", SqlDbType.VarChar), new SqlParameter("@isconfigpagesize", SqlDbType.VarChar), new SqlParameter("@departcode", SqlDbType.VarChar), new SqlParameter("@wardcode", SqlDbType.VarChar), new SqlParameter("@changeid", SqlDbType.VarChar) }; parms[0].Value = m_Inpatient.NoOfFirstPage; parms[1].Value = node.DataRowItem["templateid"].ToString(); if (node.DataRowItem["sortid"].ToString() == "AC") { parms[2].Value = node.DataRowItem["mr_name"].ToString() + " " + node.DataRowItem["captiondatetime"].ToString() + " " + m_Host.User.Name; } else { parms[2].Value = node.DataRowItem["mr_name"].ToString() + " " + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + m_Host.User.Name; } string emrContent = node.DataRowItem["content"].ToString(); emrContent = Util.ProcessEmrContent(emrContent);//处理病历中的SaveLog节点和creator、deleter属性的值 parms[3].Value = emrContent; parms[4].Value = node.DataRowItem["sortid"].ToString(); parms[5].Value = m_Host.User.Id; parms[6].Value = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); parms[7].Value = node.DataRowItem["captiondatetime"].ToString(); parms[8].Value = node.DataRowItem["isfirstdaily"].ToString(); parms[9].Value = node.DataRowItem["isyihuangoutong"].ToString(); parms[10].Value = DS_Common.GetIPHost(); parms[11].Value = node.DataRowItem["isconfigpagesize"].ToString(); parms[12].Value = m_Host.User.CurrentDeptId; parms[13].Value = m_Host.User.CurrentWardId; parms[14].Value = null == deptChangeID ? string.Empty : deptChangeID; string sqlInsert = @"INSERT INTO recorddetail(id, noofinpat, templateid, name, content, sortid, owner, createtime, valid, hassubmit, hasprint, hassign, captiondatetime, islock, firstdailyflag, isyihuangoutong, ip, isconfigpagesize, departcode, wardcode, changeid) VALUES(seq_recorddetail_id.nextval, @noofinpat, @templateid, @name, @content, @sortid, @owner, @createtime, '1', '4600', '3600', '0', @captiondatetime, '4700', @firstdailyflag, @isyihuangougong, @ip, @isconfigpagesize, @departcode, @wardcode, @changeid)"; DS_SqlHelper.ExecuteNonQuery(sqlInsert, parms, CommandType.Text); } catch (Exception ex) { throw ex; } }