示例#1
0
        /// <summary>
        /// 检查是否存在病历记录 --- 事务专用
        /// </summary>
        /// <auth>Yanqiao.Cai</auth>
        /// <date>2012-12-10</date>
        /// <param name="id">首次病程ID</param>
        /// <param name="theTime">病历时间</param>
        /// <returns></returns>
        public static bool CheckExistRecordDetailInTran(int id, string theTime)
        {
            try
            {
                bool boo = false;
                if (string.IsNullOrEmpty(theTime))
                {
                    return(boo);
                }
                theTime = DateTime.Parse(theTime).ToString("yyyy-MM-dd HH:mm:ss");
                //string content = DS_SqlService.GetRecordContentsByID(id);
                string content = DS_SqlService.GetRecordContentsByIDInTran(id);

                if (!string.IsNullOrEmpty(content))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(content);
                    List <string> list       = GetEditEmrContentTimes(doc);
                    string        theTitle   = GetEmrRecordTitle(doc, theTime);
                    string        nextTime   = list.Where(p => DateTime.Parse(p) > DateTime.Parse(theTime)).OrderBy(q => DateTime.Parse(q)).FirstOrDefault();
                    string        nextTitle  = !string.IsNullOrEmpty(nextTime) ? GetEmrRecordTitle(doc, nextTime) : "</body></document>";
                    int           startIndex = doc.InnerXml.IndexOf(theTitle);
                    int           endIndex   = doc.InnerXml.IndexOf(nextTitle);
                    if (startIndex < 0 || endIndex < 0 || startIndex > endIndex)
                    {
                        return(boo);
                    }
                    if (!string.IsNullOrEmpty(doc.InnerXml.Substring(startIndex, endIndex - startIndex)))
                    {
                        boo = true;
                    }
                }
                return(boo);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }