public string GetTplDetail(string id)
        {
            string strJson = string.Empty;
            try
            {
                var token = Session["token"] == null ? "XXXXXXX" : Session["token"].ToString();
                TplDetailResponse tpldetail = new TplDetailResponse();
                tpldetail = tplRequest.TplDetail(token, id);
                if (tpldetail.code == 0)
                {
                    tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.termid) - Convert.ToInt32(right.termid)));
                    tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.sharpid2) - Convert.ToInt32(right.sharpid2)));
                    tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.sharpid) - Convert.ToInt32(right.sharpid)));

                    strJson = JsonHelper.SerializeObject(tpldetail);
                }
            }
            catch (Exception ex)
            {
                AppLog.Instance.Write("GetTplDetail", AppLog.LogMessageType.Error, ex);
            }
            return strJson;
        }
        public string GetTplDetai()
        {
            string jsonDetailTpl = string.Empty;
            try
            {
                var token = Session["token"] == null ? "XXXXXXX" : Session["token"].ToString();
                TplRequest tr = new TplRequest();
                //TplDetailResponse tpl10 = new TplDetailResponse();
                //TplDetailResponse tpl11 = new TplDetailResponse();
                TplDetailResponse tpldetail = new TplDetailResponse();
                List<TplDetailResponse> listTplDetail = new List<TplDetailResponse>();
                TplListResponse tpllist = tr.TplList(token, "", "");
                foreach (var tpl in tpllist.data.data)
                {
                    tpldetail = tr.TplDetail(token, tpl.id);
                    if (tpldetail.code == 0)
                    {
                        //if (tpldetail.data.id == "10" || tpldetail.data.id == "11" || tpldetail.data.id == "12")
                        //{
                        //tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.sharpid) - Convert.ToInt32(right.sharpid)));
                        //tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.sharpid2) - Convert.ToInt32(right.sharpid2)));
                        ////tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.termid) - Convert.ToInt32(right.termid)));



                        tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.termid) - Convert.ToInt32(right.termid)));
                        tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.sharpid2) - Convert.ToInt32(right.sharpid2)));
                        tpldetail.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.sharpid) - Convert.ToInt32(right.sharpid)));

                        listTplDetail.Add(tpldetail);
                        //}


                    }
                }


                //tpl10 = tr.TplDetail(token, "10");
                //tpl11 = tr.TplDetail(token, "11");
                //if (tpl10.code == 0)
                //{
                //    tpl10.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.sharpid) + Convert.ToInt32(left.sharpid2)) - (Convert.ToInt32(right.sharpid) + Convert.ToInt32(right.sharpid2)));
                //    listTplDetail.Add(tpl10);
                //}
                //if (tpl11.code == 0)
                //{
                //    tpl11.data.tpl_detail.Sort((left, right) => (Convert.ToInt32(left.sharpid) + Convert.ToInt32(left.sharpid2)) - (Convert.ToInt32(right.sharpid) + Convert.ToInt32(right.sharpid2)));
                //    listTplDetail.Add(tpl11);
                //}

                jsonDetailTpl = JsonHelper.SerializeObject(listTplDetail);
                ViewBag.listTplDetail = jsonDetailTpl;

            }
            catch (Exception ex)
            {

                AppLog.Instance.Write("GetTplDetai", AppLog.LogMessageType.Error, ex);
            }

            return jsonDetailTpl;
        }
        /// <summary>
        /// 18、	获取模板详情
        /// </summary>
        /// <param name="token">token</param>
        /// <param name="id">要查询的模板id</param>
        /// <returns></returns>
        public TplDetailResponse TplDetail(string token, string id)
        {
            try
            {
                string ApiResponse = string.Empty;
                TplDetailResponse tplDetailResponse = new TplDetailResponse();
                Dictionary<string, string> sPara = new Dictionary<string, string>();

                sPara.Add("id", id);

                ApiResponse = F8YLSubmit.BuildGetRequest(sPara, "tpl/detail?token=" + token);

                tplDetailResponse = JsonHelper.DeserializeJsonToObject<TplDetailResponse>(ApiResponse);
                //tplDetailResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<TplDetailResponse>(ApiResponse);

                return tplDetailResponse;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 18、	get方式获取模板详情
        /// </summary>
        /// <param name="token">token</param>
        /// <param name="id">要查询的模板id</param>
        /// <returns></returns>
        public string getTplDetail(string token, string id)
        {
            try
            {
                string ApiResponse = string.Empty;
                TplDetailResponse tplDetailResponse = new TplDetailResponse();
                Dictionary<string, string> sPara = new Dictionary<string, string>();

                sPara.Add("id", id);

                ApiResponse = F8YLSubmit.BuildGetRequest(sPara, "tpl/detail?token=" + token);


                //ApiResponse = "{\"code\": \"0\", \"message\": null, \"data\": {\"id\": \"11\", \"userid\": \"12\", \"hospitalid\": \"9951480\", \"name\": \"检查\", \"period\": \"0\", \"freqs\": \"1\", \"kindid\": \"20\", \"editbypat\": \"0\", \"remark\": \"随访模板\", \"ctime\": \"2015-11-17 17:11:44\", \"utime\": \"2015-11-18 10:45:18\", \"tpl_detail\": [{\"id\": \"32\", \"tplid\": \"11\", \"sharpid\": \"7\", \"sharpid2\": \"9\", \"termid\": \"20\", \"sorter\": \"0\", \"term\": {\"id\": \"20\", \"cateid\": \"0\", \"hospitalid\": \"0\", \"userid\": \"0\", \"name\": \"癌胚抗原\", \"itype\": \"10\", \"vtype\": \"2\", \"unit\": \"\", \"editbypat\": \"0\", \"term_val\": [{\"id\": \"52\", \"termid\": \"20\", \"val\": \"1000000\", \"desc\": \"\", \"sorter\": \"126\"}, {\"id\": \"51\", \"termid\": \"20\", \"val\": \"0\", \"desc\": \"\", \"sorter\": \"127\"}]}}, {\"id\": \"35\", \"tplid\": \"11\", \"sharpid\": \"7\", \"sharpid2\": \"10\", \"termid\": \"20\", \"sorter\": \"0\", \"term\": {\"id\": \"20\", \"cateid\": \"0\", \"hospitalid\": \"0\", \"userid\": \"0\", \"name\": \"癌胚抗原\", \"itype\": \"10\", \"vtype\": \"2\", \"unit\": \"\", \"editbypat\": \"0\", \"term_val\": [{\"id\": \"52\", \"termid\": \"20\", \"val\": \"1000000\", \"desc\": \"\", \"sorter\": \"126\"}, {\"id\": \"51\", \"termid\": \"20\", \"val\": \"0\", \"desc\": \"\", \"sorter\": \"127\"}]}}, {\"id\": \"36\", \"tplid\": \"11\", \"sharpid\": \"7\", \"sharpid2\": \"10\", \"termid\": \"15\", \"sorter\": \"127\", \"term\": {\"id\": \"15\", \"cateid\": \"0\", \"hospitalid\": \"0\", \"userid\": \"0\", \"name\": \"CA125\", \"itype\": \"10\", \"vtype\": \"2\", \"unit\": \"U/ml\", \"editbypat\": \"0\", \"term_val\": [{\"id\": \"31\", \"termid\": \"15\", \"val\": \"0\", \"desc\": \"\", \"sorter\": \"127\"}, {\"id\": \"32\", \"termid\": \"15\", \"val\": \"1000000\", \"desc\": \"\", \"sorter\": \"126\"}]}}, {\"id\": \"43\", \"tplid\": \"11\", \"sharpid\": \"8\", \"sharpid2\": \"12\", \"termid\": \"16\", \"sorter\": \"127\", \"term\": {\"id\": \"16\", \"cateid\": \"0\", \"hospitalid\": \"0\", \"userid\": \"0\", \"name\": \"白细胞计数\", \"itype\": \"10\", \"vtype\": \"2\", \"unit\": \"109/L\", \"editbypat\": \"0\", \"term_val\": [{\"id\": \"33\", \"termid\": \"16\", \"val\": \"0\", \"desc\": \"\", \"sorter\": \"127\"}, {\"id\": \"34\", \"termid\": \"16\", \"val\": \"1000000\", \"desc\": \"\", \"sorter\": \"126\"}]}}, {\"id\": \"44\", \"tplid\": \"11\", \"sharpid\": \"8\", \"sharpid2\": \"12\", \"termid\": \"24\", \"sorter\": \"125\", \"term\": {\"id\": \"24\", \"cateid\": \"0\", \"hospitalid\": \"0\", \"userid\": \"0\", \"name\": \"淋巴细胞绝对值\", \"itype\": \"10\", \"vtype\": \"2\", \"unit\": \"109/L\", \"editbypat\": \"0\", \"term_val\": [{\"id\": \"59\", \"termid\": \"24\", \"val\": \"0\", \"desc\": \"\", \"sorter\": \"127\"}, {\"id\": \"60\", \"termid\": \"24\", \"val\": \"100000\", \"desc\": \"\", \"sorter\": \"126\"}]}}], \"sharp\": {\"7\": {\"id\": \"7\", \"name\": \"肿瘤标记物\", \"parentid\": \"0\"}, \"8\": {\"id\": \"8\", \"name\": \"血生化\", \"parentid\": \"0\"}, \"9\": {\"id\": \"9\", \"name\": \"术前肿瘤标志物\", \"parentid\": \"7\"}, \"10\": {\"id\": \"10\", \"name\": \"术后、随访肿瘤标志物\", \"parentid\": \"7\"}, \"11\": {\"id\": \"11\", \"name\": \"入院时、术前一天血生化\", \"parentid\": \"8\"}, \"12\": {\"id\": \"12\", \"name\": \"术后一天、术后七天血生化\", \"parentid\": \"8\"}}}}";

                //ApiResponse = "1234";
                return ApiResponse;
            }
            catch (Exception)
            {
                throw;
            }
        }
        //ProjectDetail
        public ActionResult ProjectDetail(string id)
        {
            var token = Session["token"] == null ? "XXXXXXX" : Session["token"].ToString();

            ViewBag.role = Session["role"] == null ? "XXXXXXX" : Session["role"].ToString();
            ViewBag.username = Session["username"] == null ? "XXXXXXX" : Session["username"].ToString();

            ViewBag.sessionHospitalid= Session["hospitalid"] == null ? "XXXXXXX" : Session["hospitalid"].ToString();


            //实体
            ProjectDetailResponse projectDetailResponse = new ProjectDetailResponse();

            HospitalRequest hospitalrequest = new HospitalRequest();

            HospitalSearchResponse response = new HospitalSearchResponse();//医院列表

            HospitalUserProfileResponse hospitalprofile = new HospitalUserProfileResponse();//医院pi

            ProjectTplListResponse tplListResponse = new ProjectTplListResponse();//模板列表

            TplDetailResponse tpldetailresponse = new TplDetailResponse();//模板详情

            //方法
            UserRequest userrequest = new UserRequest();
            ViewBag.UserFile = userrequest.profile(token, "").data;

            ProjectRequest projecttplrequest = new ProjectRequest();

            //TplRequest tplrequest = new TplRequest();

            List<HospitalUserProfileResponse> listhospitalfrofile = new List<HospitalUserProfileResponse>();

            string apiResponse = string.Empty;
            try
            {
                projectDetailResponse = projectRequest.detail(token, id);

                if (projectDetailResponse.data != null)
                {
                    if (projectDetailResponse.data.tpl == null)
                    {
                        projectDetailResponse.data.tpl = new List<ProjectDetailTplInfo>();
                    }

                    //模板列表
                    tplListResponse = projecttplrequest.ProjectTplList(token, projectDetailResponse.data.id, "", 1);

                    if (tplListResponse.data != null)
                    {
                        //列表detail
                        tpldetailresponse = tplrequest.TplDetail(token, tplListResponse.data.data[0].tplid);
                    }

                    //医院列表
                    response = hospitalrequest.Search(token, 1, "");

                    //医院pi
                    if (response.data != null)
                    {
                        foreach (HospitalEntity hs in response.data.data)
                        {
                            hospitalprofile = userrequest.SearchHospitalPi(token, hs.id, "");
                            if (hospitalprofile.data != null)
                            {
                                listhospitalfrofile.Add(hospitalprofile);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            ViewBag.TplList = tplListResponse;//tpllist
            ViewBag.hospitalSearch = response;//hospitallist
            ViewBag.hopital = listhospitalfrofile;//pi
            ViewBag.TplDetail = tpldetailresponse;//tpldetail
            ViewBag.Token = token;
            return View(projectDetailResponse);
        }