Пример #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\":\"无数据导入\"}\"";

            //if (isP)
            //{
            //    dicList = GetClinicalInfoDgDicList_Q(dataStr);
            //}
            //else
            //{
            dicList = GetClinicalInfoDgDicList(dataStr);
            //}
            if (dicList != null && dicList.Count > 0)
            {
                List <Model.PatientDiagnose> list = new List <Model.PatientDiagnose>();
                for (int i = 0; i < dicList.Count; i++)
                {
                    //把数据添加到数据库
                    Model.PatientDiagnose model = new Model.PatientDiagnose();
                    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);
                // new Dictionary<string, string>() { {"Sample Source", code  } }
                //newDicList[0].Add("Sample Source", code);
                foreach (var item in newDicList)
                {
                    item.Add("Sample Source", code);
                    if (item.Keys.Contains("诊断类型"))
                    {
                        switch (item["诊断类型"])
                        {
                        case "1":
                            item["诊断类型"] = "中医疾病";
                            break;

                        case "2":
                            item["诊断类型"] = "中医症候";
                            break;

                        case "3":
                            item["诊断类型"] = "西医主诊断";
                            break;

                        case "4":
                            item["诊断类型"] = "西医其他诊断";
                            break;

                        default:
                            break;
                        }
                    }
                    if (item.Keys.Contains("诊断类别"))
                    {
                        switch (item["诊断类别"])
                        {
                        case "1":
                            item["诊断类别"] = "西医诊断";
                            break;

                        case "2":
                            item["诊断类别"] = "中医诊断";
                            break;

                        default:
                            break;
                        }
                    }
                }
                string strList = JsonConvert.SerializeObject(newDicList);
                mes = PostData(strList);
                if (mes.Contains("{\"success\":true,"))
                {
                    foreach (var item in list)
                    {
                        PatientDiagnose n = new PatientDiagnose();
                        try
                        {
                            n.Add(item);
                        }
                        catch (Exception ex)
                        {
                            Common.LogHelper.WriteError(ex);
                            continue;
                        }
                    }
                }
            }
            return(mes);
        }
Пример #2
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\":\"无数据导入\"}\"";
            //if (isP)
            //{
            //    dicList = GetClinicalInfoDgDicList_Q(dataStr);
            //}
            //else
            //{
            dicList = GetClinicalInfoDgDicList(dataStr);
            //}
            if (dicList != null && dicList.Count > 0)
            {
                List<Model.PatientDiagnose> list = new List<Model.PatientDiagnose>();
                for (int i = 0; i < dicList.Count; i++)
                {
                    //把数据添加到数据库
                    Model.PatientDiagnose model = new Model.PatientDiagnose();
                    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);
               // new Dictionary<string, string>() { {"Sample Source", code  } }
                //newDicList[0].Add("Sample Source", code);
                foreach (var item in newDicList)
                {
                    item.Add("Sample Source", code);
                    if (item.Keys.Contains("诊断类型"))
                    {
                        switch (item["诊断类型"])
                        {
                            case "1":
                                item["诊断类型"] = "中医疾病";
                                break;

                            case "2":
                                item["诊断类型"] = "中医症候";
                                break;

                            case "3":
                                item["诊断类型"] = "西医主诊断";
                                break;

                            case "4":
                                item["诊断类型"] = "西医其他诊断";
                                break;

                            default:
                                break;
                        }
                    }
                    if (item.Keys.Contains("诊断类别"))
                    {
                        switch (item["诊断类别"])
                        {
                            case "1":
                                item["诊断类别"] = "西医诊断";
                                break;

                            case "2":
                                item["诊断类别"] = "中医诊断";
                                break;

                            default:
                                break;
                        }
                    }
                }
                string strList = JsonConvert.SerializeObject(newDicList);
                mes = PostData(strList);
                if (mes.Contains("{\"success\":true,"))
                {
                    foreach (var item in list)
                    {
                        PatientDiagnose n = new PatientDiagnose();
                        try
                        {
                            n.Add(item);
                        }
                        catch (Exception ex)
                        {
                            Common.LogHelper.WriteError(ex);
                            continue;
                        }
                    }
                }
            }
            return mes;
        }