Esempio n. 1
0
        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;
        }
Esempio n. 2
0
 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;
 }