/// <summary>
 /// 根据id值查找组件AggDO数据
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public CiPresDO findById(String id)
 {
     #region "缓存处理"
     if (ch.IsCached("findById"))
     {
         return(ch.findById(id));
     }
     #endregion
     List <object> param = new List <object>();
     param.Add(id);
     si.url = url_r;
     CiPresDO rtn = si.invoke <CiPresDO>("findById", param.ToArray());
     return(rtn);
 }
        public void CreatPres(string id_pat)
        {
            //TODO:执行之前 只针对未设置处方的,只生成新的处方,不进行修改,暂时只是按照 分类进行分方,并没有对每个方子里的条数 进行限制
            OrdSrvDO[] orderSrvs = modelSrv.GetSrvs(id_pat);//代表已经获取该患者的所有医嘱服务 参数 患者id
            //分组 医嘱服务

            var v = from c in orderSrvs
                    group c by new
            {
                SD_SRVTP = c.Sd_srvtp
            } into s
                select new
            {
                SD_SRVTP    = s.Select(p => p.Sd_srvtp).First(),
                ordSrvCount = s.Select(p => p.Sd_srvtp).Count()
            };

            v.ToList().ForEach(p =>
            {
                OrdSrvDO srvtem = orderSrvs.First(t => t.Sd_srvtp == p.SD_SRVTP);
                string ci_code  = "PRES" + CommonExtentions.NowTime(this).Year + CommonExtentions.NowTime(this).Month + CommonExtentions.NowTime(this).Day + CommonExtentions.NowTime(this).Hour + CommonExtentions.NowTime(this).Minute + CommonExtentions.NowTime(this).Second + CommonExtentions.NowTime(this).Millisecond + ran.Next(0, 100);//code 生成机制
                CiPresDO ci     = new CiPresDO()
                {
                    //-此为处方所有字段,用到那个 解开注释加哪个
                    Id_pati   = srvtem.Id_pat,
                    Id_entp   = srvtem.Id_entp,   // "0001AA10000000004O80",//TODO: 临时数据,
                    Code_entp = srvtem.Code_entp, // "01",
                    Id_en     = srvtem.Id_en,     //"0001AA1000000001OM3N",//TODO: 临时数据,
                    Id_di     = "患者的诊断",          //患者诊断,
                    //Id_diitm,
                    //Str_id_di,
                    //Str_name_di,
                    Id_srvtp  = srvtem.Id_srvtp,
                    Sd_srvtp  = p.SD_SRVTP, //服务类型编码,
                    Id_prestp = "01",       //TODO:处方类型 后面改正
                    Sd_prestp = p.SD_SRVTP,
                    Code      = ci_code,
                    Name      = srvtem.Id_pat + "处方",
                    Id_dep_or = UserManager.getInstance().CurrentDept.Id_dep,  //开立科室
                    Id_emp_or = UserManager.getInstance().CurrentUser.Id_user, //开立医生
                    Dt_entry  = CommonExtentions.NowTime(this),                //开立日期
                    //Fg_bb,
                    //No_bb,
                    //Id_bb,
                    Id_route    = srvtem.Id_route,//用法,
                    Id_routedes = srvtem.Id_routedes,
                    //Id_boil,
                    //Id_boildes,
                    //Fg_charge,
                    Fg_dispense = false,//发药标识,
                    //Id_backtp,
                    //Sd_backtp,
                    //Fg_back,
                    //Id_emp,
                    //Fg_prn,
                    //Fg_prn_add,
                    //Id_pres_rel_add,
                    Id_su_bl = "1", //TODO:记账状态 先假数据
                    Sd_su_bl = "1", //记账状态,
                    //Fg_makeup,
                    Createdby    = UserManager.getInstance().CurrentUser.Createdby,
                    Createdtime  = UserManager.getInstance().CurrentUser.Createdtime,
                    Modifiedby   = UserManager.getInstance().CurrentUser.Modifiedby,
                    Modifiedtime = UserManager.getInstance().CurrentUser.Modifiedtime,
                    //Ds,
                    //Sv
                };
                string id_pres = Save(ci)[0].Id_pres;
                orderSrvs.ToList().ForEach(x =>
                {
                    if (x.Sd_srvtp == p.SD_SRVTP)
                    {
                        x.Id_pres = id_pres;
                        x.Status  = DOStatus.UPDATED;
                    }
                });
            });

            //所有的医嘱单已经生成完毕 更新srv

            modelSrv.Save(orderSrvs);
        }
 //新增处方 时候  患者的一些信息 要获取
 public CiPresDO[] Save(CiPresDO presDO)
 {
     return(service.save(new CiPresDO[] { presDO }));
 }