//接诊时调用医保的共享数据 缓存在客户端
        public String getMedicalsharingData(Ent4BannerDTO ent4Banner, BaseContext context, out string errMessage, string str)
        {
            ClincHistoryTradeInfo historyInfo = null;
            EachCommDTO           eachCommDTO = new EachCommDTO();

            eachCommDTO.Code_hp = ent4Banner.No_hp;
            eachCommDTO.Id_grp  = context.Group.Id_grp;
            eachCommDTO.Id_org  = context.Org.Id_org;
            eachCommDTO.Id_pat  = ent4Banner.Id_pat;
            historyInfo         = MedicalSharingCache.getMedicalData(ent4Banner.No_hp);
            if (historyInfo != null && historyInfo.SysInfo != null && historyInfo.SysInfo.ServerDateTime != null)
            {
                DateTime        systemDateTime  = LogicEx.GetInstance().GetSystemDateTime();
                DateTime        serverDateTime2 = (DateTime)historyInfo.SysInfo.ServerDateTime;
                System.TimeSpan timespan        = systemDateTime.Subtract(serverDateTime2);
                if (timespan != null && timespan.TotalMinutes > 10)
                {
                    historyInfo = service.GetClincHistoryInfo(eachCommDTO, out errMessage, str);
                    //historyInfo = service.GetClincHistoryInfoByTest();
                }
            }
            else
            {
                //historyInfo = service.GetClincHistoryInfoByTest();
                // historyInfo = service.GetClincHistoryInfo(icno, out errMessage, str);

                historyInfo = service.GetClincHistoryInfo(eachCommDTO, out errMessage, str);
            }
            // ClincHistoryTradeInfo historyInfo = service.GetClincHistoryInfo(icno, out errMessage, str);
            // ClincHistoryTradeInfo historyInfo =  service.GetClincHistoryInfoByTest();//测试数据
            errMessage = "";
            MedicalSharingCache.setMedicalSharingData(ent4Banner.No_hp, historyInfo, errMessage);
            return("");
        }
        /// <summary>
        /// 药品的唯一编码
        /// </summary>
        /// <param name="icno">医保卡号</param>
        /// <returns></returns>
        public static List <MedicalSharingDTO> MedicalSharingValidate(BaseContext context, MedicalSharingDTO[] medicalSharingDto, Ent4BannerDTO ent4BannerDto)
        {
            ciOrderQryService = XapServiceMgr.find <ICiOrdQryService>();
            string errMsg = "";
            //当前时间
            DateTime systemDateTime = LogicEx.GetInstance().GetSystemDateTime();

            infoMedicalSharingDto = new List <MedicalSharingDTO>();

            //本院数据 签署未交费的验证
            // LocalValiDate(context, medicalSharingDto, ent4BannerDto, systemDateTime); // -- 2017-1--16 Bug:0109210, 废弃不用 (费用负责)

            //医保中心的50天的数据
            //判断时间是否超出 10分钟
            //医保中心的数据
            ClincHistoryTradeInfo historyTradeInfo = MedicalSharingCache.getMedicalData(ent4BannerDto.No_hp);

            if (historyTradeInfo == null)
            {
                return(infoMedicalSharingDto);
            }
            DateTime?serverDateTime  = historyTradeInfo.SysInfo.ServerDateTime;
            DateTime serverDateTime2 = new DateTime();

            if (serverDateTime != null)
            {
                serverDateTime2 = (DateTime)serverDateTime;
            }
            System.TimeSpan timespan = systemDateTime.Subtract(serverDateTime2);
            if (timespan != null && timespan.TotalMinutes > 10)
            {
                GetMedicalsharingData.Instance.getMedicalsharingData(ent4BannerDto, context, out errMsg, "");
            }
            //判断排斥有的药品
            //不限制药品
            //中草药,葡萄糖及氯化钠相关注射液。溶媒类

            //重复开药(同一天)
            //医嘱不可重复:在医保共享数据中若已存在某医嘱,本次开立的医嘱中,不能有保内的同样的医嘱。再确认一下。
            //若出现重复,提示信息【医嘱共享数据中已存在该药品,不可重复开立】,按钮【放弃开立】【自费开立】

            // 【医嘱共享数据中已存在该药品,不可重复开立】,按钮【放弃开立】【自费开立】";
            //天数是否超出
            //遍历医保共享数据,若(交易日期 + 药品开立天数)- 当前日期  > 5时,该医嘱不可开立
            OutValiDate(context, medicalSharingDto, historyTradeInfo, ent4BannerDto, systemDateTime);



            //return dict;
            return(infoMedicalSharingDto);
        }
        /// <summary>
        /// 天数是否超出
        /// 遍历医保共享数据,若(交易日期 + 药品开立天数)- 当前日期  > 5时,该医嘱不可开立
        /// </summary>
        /// <param name="historyTradeInfo"></param>
        /// <param name="Itemcode"></param>
        /// <returns></returns>
        public static String Daysexceeding(ClincHistoryTradeInfo historyTradeInfo, MedicalSharingDTO medicalSharingDto, DateTime systemDateTime, string code)
        {
            String info = null;
            List <TradeInfoEach> list = historyTradeInfo.TradeInfoEachs;

            if (list != null && list.Count > 0)
            {
                foreach (TradeInfoEach tradeInfo in list)
                {
                    List <FeeItemEach> FeeList    = tradeInfo.FeeItemEaches;
                    string             tradMicode = tradeInfo.TradeMiCode;
                    if (tradMicode != null && tradMicode == code)
                    {
                        Hospital_code = tradeInfo.TradeMiName;
                    }
                    if (FeeList != null && FeeList.Count > 0)
                    {
                        foreach (FeeItemEach feeItem in FeeList)
                        {
                            if (feeItem.ItemCode != null && feeItem.ItemCode.Equals(medicalSharingDto.Code) && tradeInfo.TradeFundType != null && tradeInfo.TradeFundType.Equals(MedicalSharingCache.getcodeHpKind()))
                            {
                                int num = sumDys(tradeInfo.TradeDate, feeItem.Days, systemDateTime);
                                if (num > 5)
                                {
                                    medicalSharingDto.Name14 = feeItem.ItemName;
                                    info = "该病人在" + tradeInfo.TradeDate + "在" + tradeInfo.TradeMiName + " 开过" +
                                           medicalSharingDto.Name_srv + "药 ,\n 用药" + feeItem.Days +
                                           "天,按领量未服用完,按医保要求,今天不能再开";
                                }
                            }
                        }
                    }
                }
            }
            return(info);
        }
 public static Boolean excludeDrug(MedicalSharingDTO medicalSharingDto)
 {
     return(MedicalSharingCache.getBdHpUnlimitDrugDO(medicalSharingDto.Code));
 }