private bool CheckData(Model.NormalLisReport data) { BLL.NormalLisReport normalLisReport = new BLL.NormalLisReport(); bool result = false; if (data != null) { string whereStr = string.Format("chinese ='{0}' and hospnum ='{1}' and check_date ='{2}' and patname='{3}'", data.chinese, data.hospnum, data.check_date, data.patname); List <Model.NormalLisReport> list = normalLisReport.GetModelList(whereStr); if (list != null && list.Count > 0) { result = true; } } return(result); }
public string PostData(string code, string codeType, string dataStr, string username, bool isP) { List<Dictionary<string, string>> dicList = new List<Dictionary<string, string>>(); List<Dictionary<string, string>> newDicList = new List<Dictionary<string, string>>(); string mes = "\"{\"success\":false,\"error\":true,\"message\":\"无数据导入\"}\""; dicList = GetClinicalInfoDgDicList(dataStr); if (dicList != null && dicList.Count > 0) { List<Model.NormalLisReport> list = new List<Model.NormalLisReport>(); for (int i = 0; i < dicList.Count; i++) { //把数据添加到数据库 Model.NormalLisReport model = new Model.NormalLisReport(); model = DicToNormalLisReportModel(dicList[i]); try { if (this.CheckData(model)) { dicList.Remove(dicList[i]); } else { list.Add(model); } } catch (Exception ex) { Common.LogHelper.WriteError(ex); continue; } } newDicList = MatchClinicalDic(dicList, codeType); foreach (var item in newDicList) { item.Add("Sample Source", code); if (item.Keys.Contains("性别")) { switch (item["性别"]) { case "M": item["性别"] = "男"; break; case "F": item["性别"] = "女"; break; default: item.Remove("性别"); break; } } } string strList = JsonConvert.SerializeObject(newDicList); mes = PostData(strList); if (mes.Contains("{\"success\":true,")) { foreach (var item in list) { NormalLisReport n = new NormalLisReport(); try { n.Add(item); } catch (Exception ex) { Common.LogHelper.WriteError(ex); continue; } } } } return mes; }
private List<Dictionary<string, string>> GetClinicalInfoDgDicList(string dataStr) { List<Model.NormalLisReport> pageClinicalInfoList = new List<Model.NormalLisReport>(); Model.NormalLisReport cl = new Model.NormalLisReport(); List<Dictionary<string, string>> ClinicalInfoDgDicList = new List<Dictionary<string, string>>(); if (!string.IsNullOrEmpty(dataStr) && dataStr != "[]") { pageClinicalInfoList = FreezerProUtility.Fp_Common.FpJsonHelper.JsonStrToObject<List<Model.NormalLisReport>>(dataStr);//转换ok } foreach (Model.NormalLisReport item in pageClinicalInfoList) { //给对象拼接--临床数据中需要添加基本信息中的RegisterID,InPatientID ClinicalInfoDgDicList.Add(FormToDic.ConvertModelToDic(item)); } return ClinicalInfoDgDicList; }
private List <Model.NormalLisReport> GetList(string xmlStr, out string Msg) { List <Model.NormalLisReport> list = new List <Model.NormalLisReport>(); XmlDocument xd = HospitalXmlStrHelper.HospitalXmlStrToXmlDoc(xmlStr); Msg = "无数据"; if (xd == null) { } else { if (xd.HasChildNodes) { XmlNode xn = xd.SelectSingleNode("//ResultCode"); if (xn != null) { if (xn.InnerText == "0") { //有数据 XmlNodeList xnl = xd.SelectNodes("//reocrd"); if (xnl.Count > 0) { foreach (XmlNode item in xnl) { try { Model.NormalLisReport nn = this.XmlTomModel(item); // && Common.MatchDic.NeedRecordDic.Keys.Contains(nn.chinese) if (nn.chinese != null) { if (!string.IsNullOrEmpty(nn.ref_flag)) { if (!this.CheckData(nn)) { list.Add(nn); } } } } catch (Exception ex) { Common.LogHelper.WriteError(ex); continue; } } if (list.Count > 0) { Msg = ""; } } } else { //查询数据出错,联接无问题 Msg = xd.SelectSingleNode("//ErrorMsg").InnerText; } } else { //查询数据出错,联接无问题 Msg = xd.InnerText; //保存查询记录 } } } return(list); }