/// <summary>自动小结 /// 自动小结 /// </summary> /// <param name="strordernum">dictlab 分点对象,用于各地的参考范围不同时</param> public void AutoSummary(string strordernum, double?dictlabid) { #region ***********************科室小结*********************** #region 科室小结实现方法描述 //[1]汇总异常结果组成字符串,字符串组成方式: // 1、数值型结果组成方式 : 项目名称 +“:” + 结果 + 高低提示符 // 2、描述性结果组成方式 : 项目名称 +“:” + 结果 //[2]多个异常项目用分号隔开。如果结果全部是正常,则默认“未见异常”。 #endregion //1,获取体检号对应的结果 List <Ordertest> orderTestListAll = orderTestService.GetAllOrderLabdeptresultList(strordernum); //全部结果 List <Ordertest> orderTestList = orderTestListAll.Where(c => c.Testresult != null && c.Testresult != null).ToList <Ordertest>(); //去掉结果为null的 //2,获取无重复的不为空的科室ID var labdepidList = (from o in orderTestList select o.Dictlabdeptid).Distinct(); //3,组合科室小结内容 List <Orderlabdeptresult> editTemp = new List <Orderlabdeptresult>();//存放待编辑科室小结 foreach (Double?lab in labdepidList) { //过滤掉有结果为空的科室 if (orderTestListAll.Where(c => (c.Testresult == "" || c.Testresult == null) && c.Dictlabdeptid == lab).Count() > 0) { continue; } //获取科室所属检查项目 List <Ordertest> orderTestTemp = orderTestList.Where(test => test.Dictlabdeptid == lab.Value).ToList <Ordertest>(); //实例化科室小结对象 Orderlabdeptresult orderlabdeptresultTemp = new Orderlabdeptresult(); orderlabdeptresultTemp.Ordernum = strordernum; orderlabdeptresultTemp.Dictlabdeptid = lab.Value; orderlabdeptresultTemp.Appraiseby = 4;//系统自动小结,4为User帐号 //判断是否全部为正常,如正常则结果为未见异常,否则组合异常结果 if (orderTestTemp.Count <Ordertest>(c => c.Isexception == "1") == 0) { orderlabdeptresultTemp.Labdeptresult = "未见异常"; editTemp.Add(orderlabdeptresultTemp); continue;//继续下一循环 } //有异常,组合异常结果 StringBuilder sb = new StringBuilder(); foreach (Ordertest orderTest in orderTestTemp) { if (orderTest.Isexception == "0") { continue; //只记录异常的 } if (ValidateUtils.IsNumeric(orderTest.Testresult)) { //数值型 sb.AppendFormat("{0}:{1} {2};", orderTest.Testname, orderTest.Testresult, orderTest.Hlflag); } else { //描述性 sb.AppendFormat("{0}:{1};", orderTest.Testname, orderTest.Testresult); } } orderlabdeptresultTemp.Labdeptresult = sb.ToString(); editTemp.Add(orderlabdeptresultTemp); } #endregion #region ***********************诊断建议*********************** #region 诊断建议实现方法描述 //1,匹配符合条件的规则公式[规则公式中的项目清单是该体检检验项目的子集],年龄,性别判断等 //2,由传入参数判断规则公式[sourcecode],false则将该诊断建议存至临时List中保存,以待插入诊断建议表 //3,科室检查项目有多项异常,则逐条记录,如果全部没有,则记录"未见异常" #endregion List <Dictruleformular> ruleformularAll = loginservice.GetLoginDictruleformularresultList(); //从缓存读取规则公式 List <Dictdiagnosis> diagnosisAll = loginservice.GetLoginDictdiagnosisresultList(); //从缓存读取诊断建议 #region >>>获取体检项目ID集合和检查项目结果集合 string[] testIdArray = new string[orderTestList.Count]; object[] testResultArray = new object[orderTestList.Count]; int nIndex = 0; string tempTestResult = string.Empty; for (int i = 0; i < orderTestList.Count; i++) { testIdArray[i] = orderTestList[i].Dicttestitemid.ToString(); //结果中包含有><号时要去掉><号号,将原值加或减掉0.0000001 tempTestResult = orderTestList[i].Testresult.Replace('>', ' ').Replace('<', ' ').Trim(); //加上前面的判断是为了区分有些结果为阴性的不是传文字类型而是直接传一个-过来的情况 //tempTestResult != "-" && tempTestResult!="+"&& if (ValidateUtils.IsNumeric(tempTestResult))//数字类型 { if (orderTestList[i].Testresult.Contains(">")) { testResultArray[nIndex++] = double.Parse(tempTestResult) + 0.0000001; } else if (orderTestList[i].Testresult.Contains("<")) { testResultArray[nIndex++] = double.Parse(tempTestResult) - 0.0000001; } else { testResultArray[nIndex++] = double.Parse(orderTestList[i].Testresult); } } else { //HPV 人乳头瘤 结果有科学计数法,要转成普通的 if (tempTestResult.Contains("E+")) { try { testResultArray[nIndex++] = double.Parse(tempTestResult); } catch { testResultArray[nIndex++] = orderTestList[i].Testresult; } } else { testResultArray[nIndex++] = orderTestList[i].Testresult; } } } #endregion #region >>>获取匹配的自动诊断建议 //获取用户的基本信息 Dictmember member = new DictmemberService().SelectDictmemberByOrderNum(strordernum); //通用公式 List <Dictruleformular> isUserRuleformularLstTemp = ruleformularAll.Where(r => (r.Sex == member.Sex || r.Sex == "B" || r.Sex == "U") && (r.Ismarry == member.Ismarried || r.Ismarry == "2") && r.Dictlabid == 0 && (member.Caculatedage > r.Caculatedagelow && member.Caculatedage < r.Caculatedagehigh)).ToList <Dictruleformular>(); //先根据年龄,性别,婚否及分点第一次筛选 if (dictlabid != 0) { //分点公式 List <Dictruleformular> labRuleformularLst = ruleformularAll.Where(r => (r.Sex == member.Sex || r.Sex == "B" || r.Sex == "U") && (r.Ismarry == member.Ismarried || r.Ismarry == "2") && r.Dictlabid == dictlabid && (member.Caculatedage > r.Caculatedagelow && member.Caculatedage < r.Caculatedagehigh)).ToList <Dictruleformular>(); //分点中有和通用相同的规则代码,则取分点中的规则公式 if (labRuleformularLst.Count > 0) { foreach (Dictruleformular ruleItem in labRuleformularLst) { Dictruleformular tempRule = isUserRuleformularLstTemp.FirstOrDefault <Dictruleformular>(c => c.Dictrulecode == ruleItem.Dictrulecode); if (tempRule != null) { isUserRuleformularLstTemp.Remove(tempRule); isUserRuleformularLstTemp.Add(ruleItem); } else { isUserRuleformularLstTemp.Add(ruleItem); } } } } //保存该体检项目集合的子集 List <Dictruleformular> isUserRuleformularLst = new List <Dictruleformular>(); //规则公式是否是该体检项目集合的子集,不是子集,移除 foreach (Dictruleformular ruleformular in isUserRuleformularLstTemp) { if (isSubSet(testIdArray, ruleformular.Formulartests.Split(','))) { isUserRuleformularLst.Add(ruleformular); } } #endregion #region 计算规则公式[false],匹配诊断建议 //临时存储计算后的诊断建议 List <Dictdiagnosis> tempDiagnosisLst = new List <Dictdiagnosis>(); //规则公式返回false,则生成评价 ArrayList lstHealthCheck = new ArrayList(); //循环该次体检包含的科室 foreach (Double?lab in labdepidList) { //遍历该科室的规则公式 foreach (Dictruleformular ruleitem in isUserRuleformularLst.Where(r => r.Dictlabdeptid == lab)) { //计算公式项目清单集合 string[] ruleTest = ruleitem.Formulartests.Split(new char[] { ',' }); //组装计算公示用到的参数 ArrayList results = new ArrayList(); for (int w = 0; w < ruleTest.Length - 1; w++) //遍历规则公式中的项目清单 { for (int k = 0; k < testIdArray.Length; k++) //遍历该体检项目集合 { if (testIdArray[k] == ruleTest[w]) { results.Add(testResultArray[k]); continue; } } } if (DictRuleFormularService.GetRuleFormularResult(ruleitem.Sourcecode, results.ToArray())) { Dictdiagnosis tempDiagnosis = diagnosisAll.Find(c => c.Dictdiagnosisid == ruleitem.Dictdiagnosisid); //将科室ID添加到诊断实体中 tempDiagnosis.Dictlabdeptid = lab; tempDiagnosisLst.Add(tempDiagnosis); } } } #endregion #endregion //#region add by lee 20121218 过滤掉重复的或者相冲突的异常建议,如HPV分型的一些建议 //List<Dictdiagnosis> diagnosisLst = tempDiagnosisLst; //List<Dictdiagnosesmutex> mutexLst = loginservice.GetLoginDictdiagnosesmutexList(); //foreach (Dictdiagnosis diagnosisitem in tempDiagnosisLst) //{ // List<Dictdiagnosesmutex> mutexLstTemp = mutexLst.Where<Dictdiagnosesmutex>(c => c.Dictdiagnosisid == diagnosisitem.Dictdiagnosisid).ToList<Dictdiagnosesmutex>(); // if (mutexLstTemp.Count > 0) // { // foreach (Dictdiagnosesmutex mutexItem in mutexLstTemp) // { // if (isUserRuleformularLst.Count<Dictruleformular>(d => d.Dictdiagnosisid == mutexItem.Dictmutexdiagnosisid) > 0) // { // //move // diagnosisLst.Remove(diagnosisitem); // } // } // } //} //#endregion #region ***********************保存自动小结与诊断建议内容,并做审核操作*********************** SaveOrderlabdeptresult(editTemp, tempDiagnosisLst, true); #endregion ********************************************** //写日志 new BaseService().AddOperationLog(strordernum, "", "检查结果录入", "对[" + strordernum + "]执行自动小结", "修改留痕", ""); }