Example #1
0
        public static List <CardDataSourceUsage> GetUsage()
        {
            if (PrescripttionDbHelper != null)
            {
                return(PrescripttionDbHelper.GetUsage());
            }
            else
            {
                //DataTable dt = EMRCommon.GetOutChannel;

                string    strsql = @"SELECT ID,ChannelName,CName,EName,PYCode,WBCode,InputCode,EnumRange
		                            FROM emrdb..BASE_Channel 
		                            WHERE HospitalID = 33  AND DeleteFlag=0 AND OutUsed='Y'
		                            ORDER BY OrderNum"        ;
                DataTable dt     = MidDbHelper.ExecuteDataTable(MidDbHelper.EmrHandle, strsql);

                List <CardDataSourceUsage> list_Usage = new List <CardDataSourceUsage>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    CardDataSourceUsage mUsage = new CardDataSourceUsage();

                    mUsage.UsageId   = ConvertDataExtend.ToInt32(dt.Rows[i]["ID"], 0);
                    mUsage.UsageName = dt.Rows[i]["ChannelName"].ToString();
                    mUsage.Pym       = dt.Rows[i]["PYCode"].ToString();
                    mUsage.Wbm       = dt.Rows[i]["WBCode"].ToString();
                    //mUsage.Szm = dt.Rows[i]["ID"].ToString();
                    list_Usage.Add(mUsage);
                }
                return(list_Usage);
            }
        }
        void txtAge_TextChanged(object sender, EventArgs e)
        {
            this.birth.ValueChanged -= new EventHandler(birth_TextChanged);
            //if (sender.Equals(txtYear) == false)
            this.txtYear.TextChanged -= new EventHandler(txtAge_TextChanged);
            //if (sender.Equals(txtMonth) == false)
            this.txtMonth.TextChanged -= new EventHandler(txtAge_TextChanged);
            //if (sender.Equals(txtDay) == false)
            this.txtDay.TextChanged -= new EventHandler(txtAge_TextChanged);
            //if (sender.Equals(txtHour) == false)
            this.txtHour.TextChanged -= new EventHandler(txtAge_TextChanged);

            if (sender.Equals(txtYear))
            {
                this.txtMonth.Text = "0";
                this.txtDay.Text   = "0";
                this.txtHour.Text  = "0";
            }
            if (sender.Equals(txtMonth))
            {
                this.txtYear.Text = "0";
                this.txtDay.Text  = "0";
                this.txtHour.Text = "0";
            }
            if (sender.Equals(txtDay))
            {
                this.txtMonth.Text = "0";
                this.txtYear.Text  = "0";
                this.txtHour.Text  = "0";
            }
            if (sender.Equals(txtHour))
            {
                this.txtMonth.Text = "0";
                this.txtDay.Text   = "0";
                this.txtYear.Text  = "0";
            }


            AgeValue value = new AgeValue();

            value.Y_num = ConvertDataExtend.ToInt32(txtYear.Text, 0);
            value.M_num = ConvertDataExtend.ToInt32(txtMonth.Text, 0);
            value.D_num = ConvertDataExtend.ToInt32(txtDay.Text, 0);
            value.H_num = ConvertDataExtend.ToInt32(txtHour.Text, 0);

            //this.birth.Text = AgeExtend.GetDateTime(value).ToString("yyyyMMddHHmm");
            this.birth.Value = AgeExtend.GetDateTime(value);

            //if (sender.Equals(txtYear)==false)
            this.txtYear.TextChanged += new EventHandler(txtAge_TextChanged);
            //if (sender.Equals(txtMonth) == false)
            this.txtMonth.TextChanged += new EventHandler(txtAge_TextChanged);
            //if (sender.Equals(txtDay) == false)
            this.txtDay.TextChanged += new EventHandler(txtAge_TextChanged);
            //if (sender.Equals(txtHour) == false)
            this.txtHour.TextChanged += new EventHandler(txtAge_TextChanged);
            this.birth.ValueChanged  += new EventHandler(birth_TextChanged);
        }
        /// <summary>
        /// 获取药品信息
        /// </summary>
        /// <param name="itemId">药品Id</param>
        /// <returns>药品实体模型</returns>
        public CardDataSourceDrugItem  GetDrugItem(int itemId)
        {
            Action <ClientRequestData> requestAction = ((ClientRequestData request) =>
            {
                request.AddData(itemId);
            });
            ServiceResponseData           retData       = InvokeWcfService("OPProject.Service", "PresManageController", "GetDrugItemTpl", requestAction);
            DataTable                     dt            = retData.GetData <DataTable>(0);
            List <CardDataSourceDrugItem> list_DrugItem = new List <CardDataSourceDrugItem>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CardDataSourceDrugItem mDrugItem = new CardDataSourceDrugItem();
                mDrugItem.ItemId         = ConvertDataExtend.ToInt32(dt.Rows[i]["ItemID"], 0);
                mDrugItem.ItemName       = dt.Rows[i]["ItemName"].ToString();
                mDrugItem.ItemName_Print = dt.Rows[i]["ItemName"].ToString();
                mDrugItem.Standard       = dt.Rows[i]["Standard"].ToString();

                mDrugItem.Scale        = string.Empty;                                              //补偿比例
                mDrugItem.StoreNum     = ConvertDataExtend.ToDecimal(dt.Rows[i]["StoreAmount"], 0); //库存量
                mDrugItem.UnPickUnit   = dt.Rows[i]["UnPickUnit"].ToString();                       //包装单位(销售单位)
                mDrugItem.SellPrice    = ConvertDataExtend.ToDecimal(dt.Rows[i]["UnitPrice"], 0);   //销售价格?
                mDrugItem.BuyPrice     = ConvertDataExtend.ToDecimal(dt.Rows[i]["InPrice"], 0);     //进价
                mDrugItem.ExecDeptName = dt.Rows[i]["ExecDeptName"].ToString();                     //执行科室?
                mDrugItem.Pym          = dt.Rows[i]["Pym"].ToString();
                mDrugItem.Wbm          = dt.Rows[i]["Wbm"].ToString();
                mDrugItem.Address      = dt.Rows[i]["Address"].ToString();//生产厂家
                //mDrugItem.DoseUnitId = dt.Rows[i][""].ToString();//剂量单位
                mDrugItem.DoseUnitName   = dt.Rows[i]["DoseUnitName"].ToString();
                mDrugItem.DoseConvertNum = ConvertDataExtend.ToDecimal(dt.Rows[i]["DoseConvertNum"], 0);//剂量对应包装单位系数
                int statID      = ConvertDataExtend.ToInt32(dt.Rows[i]["StatID"], 0);
                int itemClass   = ConvertDataExtend.ToInt32(dt.Rows[i]["ItemClass"], 0);
                int itemClassId = GetItemType(itemClass, statID);
                mDrugItem.ItemType     = itemClassId;                                                        //项目类型 0-所有 1-西药 2-中药  3-处方可开的物品 4-收费项目
                mDrugItem.StatItemCode = statID.ToString();                                                  //大项目代码
                //mDrugItem.UnPickUnitId = dt.Rows[i][""].ToString();//包装单位ID
                mDrugItem.ExecDeptId             = ConvertDataExtend.ToInt32(dt.Rows[i]["ExecDeptId"], 0);   //执行科室ID?
                mDrugItem.FloatFlag              = ConvertDataExtend.ToInt32(dt.Rows[i]["FloatFlag"], 0);    // dt.Rows[i][""].ToString();//按含量取整1 按剂量取整0
                mDrugItem.VirulentFlag           = ConvertDataExtend.ToInt32(dt.Rows[i]["VirulentFlag"], 0); //剧毒标识
                mDrugItem.NarcoticFlag           = ConvertDataExtend.ToInt32(dt.Rows[i]["NarcoticFlag"], 0); //麻醉标识
                mDrugItem.SkinTestFlag           = ConvertDataExtend.ToInt32(dt.Rows[i]["SkinTestFlag"], 0); //皮试标识
                mDrugItem.RecipeFlag             = ConvertDataExtend.ToInt32(dt.Rows[i]["RecipeFlag"], 0);   //处方标识
                mDrugItem.LunacyFlag             = ConvertDataExtend.ToInt32(dt.Rows[i]["LunacyFlag"], 0);   //精神药品标识
                mDrugItem.CostlyFlag             = ConvertDataExtend.ToInt32(dt.Rows[i]["CostlyFlag"], 0);   //贵重药品标识
                mDrugItem.default_Usage_Amount   = 0;                                                        //默认用量
                mDrugItem.default_Usage_Id       = 0;                                                        //默认用法
                mDrugItem.default_Usage_Name     = string.Empty;
                mDrugItem.default_Frequency_Id   = 0;                                                        //默认频次
                mDrugItem.default_Frequency_Name = string.Empty;
                list_DrugItem.Add(mDrugItem);
            }

            return(list_DrugItem.Count > 0 ? list_DrugItem[0] : null);
        }
        public CardDataSourceDrugItem GetDrugItem(int ItemId)
        {
            string strsql = @"SELECT TOP 1* FROM ViewBaseData_Med T
                                        WHERE StockID={0}";

            strsql = string.Format(strsql, ItemId);

            DataTable dt = oleDb.GetDataTable(strsql);
            List <CardDataSourceDrugItem> list_DrugItem = new List <CardDataSourceDrugItem>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CardDataSourceDrugItem mDrugItem = new CardDataSourceDrugItem();
                mDrugItem.ItemId         = ConvertDataExtend.ToInt32(dt.Rows[i]["StockID"], 0);
                mDrugItem.ItemName       = dt.Rows[i]["CName"].ToString();
                mDrugItem.ItemName_Print = dt.Rows[i]["TName"].ToString();
                mDrugItem.Standard       = dt.Rows[i]["Spec"].ToString();

                mDrugItem.Scale      = "";                                                      //补偿比例
                mDrugItem.StoreNum   = ConvertDataExtend.ToDecimal(dt.Rows[i]["ActualQty"], 0); //库存量
                mDrugItem.UnPickUnit = dt.Rows[i]["MiniUnit"].ToString();                       //包装单位(销售单位)
                mDrugItem.SellPrice  = ConvertDataExtend.ToDecimal(dt.Rows[i]["ClinPrice"], 0); //销售价格?
                mDrugItem.BuyPrice   = ConvertDataExtend.ToDecimal(dt.Rows[i]["WardPrice"], 0); //进价
                //mDrugItem.ExecDeptName = dt.Rows[i][""].ToString();//执行科室?
                mDrugItem.Pym     = dt.Rows[i]["PyCode"].ToString();
                mDrugItem.Wbm     = dt.Rows[i]["WbCode"].ToString();
                mDrugItem.Address = dt.Rows[i]["FacName"].ToString();//生产厂家
                //mDrugItem.DoseUnitId = dt.Rows[i][""].ToString();//剂量单位
                mDrugItem.DoseUnitName   = dt.Rows[i]["DosUnit"].ToString();
                mDrugItem.DoseConvertNum = ConvertDataExtend.ToDecimal(dt.Rows[i]["Dosage"], 0); //剂量对应包装单位系数
                mDrugItem.ItemType       = ConvertDataExtend.ToInt32(dt.Rows[i]["MatClass"], 0); //项目类型 0-所有 1-西药 2-中药  3-处方可开的物品 4-收费项目
                //mDrugItem.StatItemCode = dt.Rows[i][""].ToString();//大项目代码
                //mDrugItem.UnPickUnitId = dt.Rows[i][""].ToString();//包装单位ID
                mDrugItem.ExecDeptId = ConvertDataExtend.ToInt32(dt.Rows[i]["DeptID"], 0);       //执行科室ID?
                mDrugItem.FloatFlag  = ConvertDataExtend.ToInt32(dt.Rows[i]["RoundingMode"], 0); // dt.Rows[i][""].ToString();//按含量取整1 按剂量取整0
                //mDrugItem.VirulentFlag = dt.Rows[i][""].ToString();//剧毒标识
                //mDrugItem.NarcoticFlag = dt.Rows[i][""].ToString();//麻醉标识
                mDrugItem.SkinTestFlag = ConvertDataExtend.ToInt32(dt.Rows[i]["SkinMethod"], 0);//皮试标识
                //mDrugItem.RecipeFlag = dt.Rows[i][""].ToString();//处方标识
                //mDrugItem.LunacyFlag = dt.Rows[i][""].ToString();//精神药品标识
                //mDrugItem.CostlyFlag = dt.Rows[i][""].ToString();//贵重药品标识
                mDrugItem.default_Usage_Amount   = 0; //默认用量
                mDrugItem.default_Usage_Id       = 0; //默认用法
                mDrugItem.default_Usage_Name     = "";
                mDrugItem.default_Frequency_Id   = 0; //默认频次
                mDrugItem.default_Frequency_Name = "";

                list_DrugItem.Add(mDrugItem);
            }
            return(list_DrugItem.Count > 0 ? list_DrugItem[0] : null);
        }
        /// <summary>
        /// 保存处方信息
        /// </summary>
        /// <param name="patListId">处方头id</param>
        /// <param name="list">处方数据</param>
        /// <param name="presType">处方类型</param>
        /// <returns>true成功</returns>
        public bool SavePrescriptionData(int patListId, List <Prescription> list, int presType)
        {
            //List<CardDataSourceFrequency> FrequencyList = GetFrequency();
            List <OPD_PresMouldDetail> detailList = new List <OPD_PresMouldDetail>();

            //构造处方明细表
            foreach (Prescription pres in list)
            {
                OPD_PresMouldDetail detailModel = new OPD_PresMouldDetail();
                detailModel.PresMouldDetailID = pres.PresListId; //?
                detailModel.PresMouldHeadID   = patListId;       //?  //处方头ID
                detailModel.PresNO            = pres.PresNo;
                detailModel.GroupID           = pres.Group_Id;
                detailModel.GroupSortNO       = pres.GroupSortNO;//?
                detailModel.ItemID            = pres.Item_Id;
                detailModel.ItemName          = pres.Item_Name;
                detailModel.StatID            = ConvertDataExtend.ToInt32(pres.StatItem_Code, 0);//?
                detailModel.Spec         = pres.Standard;
                detailModel.Dosage       = pres.Usage_Amount;
                detailModel.DosageUnit   = pres.Usage_Unit;
                detailModel.Factor       = pres.Usage_Rate;
                detailModel.ChannelID    = pres.Usage_Id;
                detailModel.FrequencyID  = pres.Frequency_Id;
                detailModel.Entrust      = pres.Entrust;
                detailModel.DoseNum      = pres.Dosage;
                detailModel.ChargeAmount = pres.Amount;
                detailModel.ChargeUnit   = pres.Unit;
                detailModel.Price        = pres.Sell_Price;
                detailModel.Days         = pres.Days;

                detailModel.PresAmount     = pres.Item_Amount;
                detailModel.PresAmountUnit = pres.Item_Unit;
                detailModel.PresFactor     = pres.Item_Rate;

                detailModel.ExecDeptID = pres.Dept_Id;

                detailList.Add(detailModel);
            }

            Action <ClientRequestData> requestAction = ((ClientRequestData request) =>
            {
                request.AddData(detailList);
            });
            ServiceResponseData retData = InvokeWcfService("OPProject.Service", "PresTemplateController", "SavePresTemplateData", requestAction);
            bool bRtn = retData.GetData <bool>(0);

            return(bRtn);
        }
        public void AsSavePresTemplate(int level, string mName, int presType, int deptId, int doctorId, List <Prescription.Controls.Entity.Prescription> data)
        {
            string strsql  = @"SELECT top 1 ID FROM Clinic_SetMealList WHERE ParentID=0 and LevelValue=" + level;
            int    LevelId = ConvertDataExtend.ToInt32(oleDb.GetDataResult(strsql), 0);

            strsql = @"INSERT INTO Clinic_SetMealList(ParentID,LevelValue,NodeName,DeptCode,StaffID,PYCode,WBCode)
                                Values({0},{1},'{2}','{3}',{4},'','')";
            strsql = string.Format(strsql, LevelId, level, mName, deptId, doctorId);

            int listId = oleDb.InsertSql(strsql);

            List <string> listSql = new List <string>();

            for (int i = 0; i < data.Count; i++)
            {
                strsql = @"INSERT INTO Clinic_SetMealDetail(ListID,ListNo,GroupID,OrderNum,FeeID,FeeName,FeeClass,Dosage,DosageUnit,Amount,Unit,FrequencyID,ChannelID,Days,Memo)
			                        VALUES({0},1,{1},{2},{3},'{4}',{5},{6},'{7}',{8},'{9}',{10},{11},{12},'{13}')"            ;
                strsql = string.Format(strsql, listId, data[i].Group_Id, i, data[i].Item_Id, data[i].Item_Name, data[i].Item_Type, data[i].Usage_Amount, data[i].Usage_Unit, data[i].Amount, data[i].Unit, data[i].Frequency_Id, data[i].Usage_Id, data[i].Days, data[i].Entrust);
                //MidDbHelper.ExecuteNonQuery(MidDbHelper.EmrHandle, strsql);
                listSql.Add(strsql);
            }
            oleDb.ExecuteSqls(listSql.ToArray());
        }
        public List <CardDataSourceUsage> GetUsage()
        {
            string    strsql = @"SELECT ID,ChannelName,CName,EName,PYCode,WBCode,InputCode
		                            FROM Clinic_Channel 
		                            WHERE  DeleteFlag=0 
		                            ORDER BY OrderNum"        ;
            DataTable dt     = oleDb.GetDataTable(strsql);

            List <CardDataSourceUsage> list_Usage = new List <CardDataSourceUsage>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CardDataSourceUsage mUsage = new CardDataSourceUsage();

                mUsage.UsageId   = ConvertDataExtend.ToInt32(dt.Rows[i]["ID"], 0);
                mUsage.UsageName = dt.Rows[i]["ChannelName"].ToString();
                mUsage.Pym       = dt.Rows[i]["PYCode"].ToString();
                mUsage.Wbm       = dt.Rows[i]["WBCode"].ToString();
                //mUsage.Szm = dt.Rows[i]["ID"].ToString();
                list_Usage.Add(mUsage);
            }
            return(list_Usage);
        }
        /// <summary>
        /// 获取药品信息
        /// </summary>
        /// <param name="type">处方类型</param>
        /// <param name="pageNo">页号</param>
        /// <param name="pageSize">页面大小</param>
        /// <param name="filter">过滤条件</param>
        /// <returns>药品列表</returns>
        public List <CardDataSourceDrugItem> GetDrugItem(int type, int pageNo, int pageSize, string filter)
        {
            // 全部 = 0, 西药与中成药 = 1, 中草药 = 2, 收费项目 = 3
            int statId = 100;

            if (type == 1)
            {
                statId = 100;
            }
            else if (type == 2)
            {
                statId = 102;
            }
            else if (type == 3)
            {
                statId = 0;
            }

            List <CardDataSourceDrugItem> list_DrugItem = new List <CardDataSourceDrugItem>();

            if (dtDrugItems == null || dtDrugItems.Rows.Count == 0)
            {
                Action <ClientRequestData> requestAction = ((ClientRequestData request) =>
                {
                    request.AddData(type);
                    request.AddData(statId);
                    request.AddData(SelectedDrugRoomID);
                });
                ServiceResponseData retdata = InvokeWcfService("OPProject.Service", "PresManageController", "GetShowCardData", requestAction);
                dtDrugItems = retdata.GetData <DataTable>(0);
            }

            //过滤处方数据
            DataTable dt = FilterPresData(type, statId);

            DataView dv = dt.DefaultView;

            dv.RowFilter = "Pym like '%" + filter + "%' or Wbm like '%" + filter + "%' or ItemName like '%" + filter + "%'";
            dt           = dv.ToTable();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CardDataSourceDrugItem mDrugItem = new CardDataSourceDrugItem();
                mDrugItem.ItemId         = ConvertDataExtend.ToInt32(dt.Rows[i]["ItemID"], 0);
                mDrugItem.ItemName       = dt.Rows[i]["ItemName"].ToString();
                mDrugItem.ItemName_Print = dt.Rows[i]["ItemName"].ToString();
                mDrugItem.Standard       = dt.Rows[i]["Standard"].ToString();
                mDrugItem.PresFactor     = ConvertDataExtend.ToInt32(dt.Rows[i]["MiniConvertNum"], 1);
                mDrugItem.Scale          = string.Empty;                                              //补偿比例
                mDrugItem.StoreNum       = ConvertDataExtend.ToDecimal(dt.Rows[i]["StoreAmount"], 0); //库存量
                mDrugItem.UnPickUnit     = dt.Rows[i]["UnPickUnit"].ToString();                       //包装单位(销售单位)
                mDrugItem.PresFactor     = ConvertDataExtend.ToInt32(dt.Rows[i]["MiniConvertNum"], 1);
                mDrugItem.MiniUnit       = dt.Rows[i]["MiniUnitName"].ToString();
                mDrugItem.SellPrice      = ConvertDataExtend.ToDecimal(dt.Rows[i]["UnitPrice"], 0); //基本单位价格?
                mDrugItem.BuyPrice       = ConvertDataExtend.ToDecimal(dt.Rows[i]["InPrice"], 0);   //进价
                mDrugItem.ExecDeptName   = dt.Rows[i]["ExecDeptName"].ToString();                   //执行科室?
                mDrugItem.ExecDeptId     = ConvertDataExtend.ToInt32(dt.Rows[i]["ExecDeptId"], 0);
                mDrugItem.StatItemCode   = dt.Rows[i]["StatID"].ToString();
                mDrugItem.Pym            = dt.Rows[i]["Pym"].ToString();
                mDrugItem.Wbm            = dt.Rows[i]["Wbm"].ToString();
                mDrugItem.Address        = dt.Rows[i]["Address"].ToString();//生产厂家
                //mDrugItem.DoseUnitId = dt.Rows[i][""].ToString();//剂量单位
                mDrugItem.DoseUnitName   = dt.Rows[i]["DoseUnitName"].ToString();
                mDrugItem.DoseConvertNum = ConvertDataExtend.ToDecimal(dt.Rows[i]["DoseConvertNum"], 0);//剂量对应包装单位系数
                int statID      = ConvertDataExtend.ToInt32(dt.Rows[i]["StatID"], 0);
                int itemClass   = ConvertDataExtend.ToInt32(dt.Rows[i]["ItemClass"], 0);
                int itemClassId = GetItemType(itemClass, statID);
                mDrugItem.ItemType     = itemClassId;                                                        //项目类型 0-所有 1-西药 2-中药  3-处方可开的物品 4-收费项目
                mDrugItem.StatItemCode = statID.ToString();                                                  //大项目代码
                //mDrugItem.UnPickUnitId = dt.Rows[i][""].ToString();//包装单位ID
                mDrugItem.ExecDeptId             = ConvertDataExtend.ToInt32(dt.Rows[i]["ExecDeptId"], 0);   //执行科室ID?
                mDrugItem.FloatFlag              = ConvertDataExtend.ToInt32(dt.Rows[i]["FloatFlag"], 0);    // dt.Rows[i][""].ToString();//按含量取整1 按剂量取整0
                mDrugItem.VirulentFlag           = ConvertDataExtend.ToInt32(dt.Rows[i]["VirulentFlag"], 0); //剧毒标识
                mDrugItem.NarcoticFlag           = ConvertDataExtend.ToInt32(dt.Rows[i]["NarcoticFlag"], 0); //麻醉标识
                mDrugItem.SkinTestFlag           = ConvertDataExtend.ToInt32(dt.Rows[i]["SkinTestFlag"], 0); //皮试标识
                mDrugItem.RecipeFlag             = ConvertDataExtend.ToInt32(dt.Rows[i]["RecipeFlag"], 0);   //处方标识
                mDrugItem.LunacyFlag             = ConvertDataExtend.ToInt32(dt.Rows[i]["LunacyFlag"], 0);   //精神药品标识
                mDrugItem.CostlyFlag             = ConvertDataExtend.ToInt32(dt.Rows[i]["CostlyFlag"], 0);   //贵重药品标识
                mDrugItem.default_Usage_Amount   = 0;                                                        //默认用量
                mDrugItem.default_Usage_Id       = 0;                                                        //默认用法
                mDrugItem.default_Usage_Name     = string.Empty;
                mDrugItem.default_Frequency_Id   = 0;                                                        //默认频次
                mDrugItem.default_Frequency_Name = string.Empty;
                mDrugItem.ResolveFlag            = ConvertDataExtend.ToInt32(dt.Rows[i]["ResolveFlag"], 0);
                list_DrugItem.Add(mDrugItem);
            }

            return(list_DrugItem);
        }
Example #9
0
        //0-所有 1-西药 2-中药  3-处方可开的物品 4-收费项目
        public static List <CardDataSourceDrugItem> GetDrugItem(int type, int pageNo, int pageSize, string filter)
        {
            if (PrescripttionDbHelper != null)
            {
                return(PrescripttionDbHelper.GetDrugItem(type, pageNo, pageSize, filter));
            }
            else
            {
                PageInfo page = new PageInfo(pageSize, pageNo);
                page.KeyName = "StockID";


                string strsql = @"SELECT * FROM hisdb..View_DrugAndFeeList WHERE MatClass={1} and (PyCode LIKE '%{0}%' OR PyCodeT LIKE '%{0}%' OR WbCode LIKE '%{0}%' OR WbCodeT LIKE '%{0}%' OR CName LIKE '%{0}%')";
                strsql = string.Format(strsql, filter, type);
                DataTable dt = MidDbHelper.ExecuteDataTable(MidDbHelper.HisHandle, strsql, page);

                //DataTable dt = HIS_FeeList.GetDrugAndFeeListFromMid(0, filter);

                List <CardDataSourceDrugItem> list_DrugItem = new List <CardDataSourceDrugItem>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    CardDataSourceDrugItem mDrugItem = new CardDataSourceDrugItem();
                    mDrugItem.ItemId         = ConvertDataExtend.ToInt32(dt.Rows[i]["StockID"], 0);
                    mDrugItem.ItemName       = dt.Rows[i]["CName"].ToString();
                    mDrugItem.ItemName_Print = dt.Rows[i]["TName"].ToString();
                    mDrugItem.Standard       = dt.Rows[i]["Spec"].ToString();

                    mDrugItem.Scale      = dt.Rows[i]["Competence"].ToString();                     //补偿比例
                    mDrugItem.StoreNum   = ConvertDataExtend.ToDecimal(dt.Rows[i]["ActualQty"], 0); //库存量
                    mDrugItem.UnPickUnit = dt.Rows[i]["MiniUnit"].ToString();                       //包装单位(销售单位)
                    mDrugItem.SellPrice  = ConvertDataExtend.ToDecimal(dt.Rows[i]["ClinPrice"], 0); //销售价格?
                    mDrugItem.BuyPrice   = ConvertDataExtend.ToDecimal(dt.Rows[i]["WardPrice"], 0); //进价
                    //mDrugItem.ExecDeptName = dt.Rows[i][""].ToString();//执行科室?
                    mDrugItem.Pym     = dt.Rows[i]["PyCode"].ToString();
                    mDrugItem.Wbm     = dt.Rows[i]["WbCode"].ToString();
                    mDrugItem.Address = dt.Rows[i]["FacName"].ToString();//生产厂家
                    //mDrugItem.DoseUnitId = dt.Rows[i][""].ToString();//剂量单位
                    mDrugItem.DoseUnitName   = dt.Rows[i]["DosUnit"].ToString();
                    mDrugItem.DoseConvertNum = ConvertDataExtend.ToDecimal(dt.Rows[i]["Dosage"], 0); //剂量对应包装单位系数
                    mDrugItem.ItemType       = ConvertDataExtend.ToInt32(dt.Rows[i]["MatClass"], 0); //项目类型 0-所有 1-西药 2-中药  3-处方可开的物品 4-收费项目
                    //mDrugItem.StatItemCode = dt.Rows[i][""].ToString();//大项目代码
                    //mDrugItem.UnPickUnitId = dt.Rows[i][""].ToString();//包装单位ID
                    mDrugItem.ExecDeptId = ConvertDataExtend.ToInt32(dt.Rows[i]["DeptID"], 0); //执行科室ID?
                    mDrugItem.FloatFlag  = 1;                                                  // dt.Rows[i][""].ToString();//按含量取整1 按剂量取整0
                    //mDrugItem.VirulentFlag = dt.Rows[i][""].ToString();//剧毒标识
                    //mDrugItem.NarcoticFlag = dt.Rows[i][""].ToString();//麻醉标识
                    mDrugItem.SkinTestFlag = ConvertDataExtend.ToInt32(dt.Rows[i]["SkinMethod"], 0);//皮试标识
                    //mDrugItem.RecipeFlag = dt.Rows[i][""].ToString();//处方标识
                    //mDrugItem.LunacyFlag = dt.Rows[i][""].ToString();//精神药品标识
                    //mDrugItem.CostlyFlag = dt.Rows[i][""].ToString();//贵重药品标识
                    mDrugItem.default_Usage_Amount   = ConvertDataExtend.ToDecimal(dt.Rows[i]["BASEDos"], 0); //默认用量
                    mDrugItem.default_Usage_Id       = ConvertDataExtend.ToInt32(dt.Rows[i]["UsgID"], 0);     //默认用法
                    mDrugItem.default_Usage_Name     = dt.Rows[i]["ChannelName"].ToString();
                    mDrugItem.default_Frequency_Id   = ConvertDataExtend.ToInt32(dt.Rows[i]["FcyID"], 0);     //默认频次
                    mDrugItem.default_Frequency_Name = dt.Rows[i]["FrequencyName"].ToString();

                    list_DrugItem.Add(mDrugItem);
                }
                return(list_DrugItem);
            }
        }
        public List <Prescription.Controls.Entity.Prescription> GetPresTemplateRow(int type, int[] tpldetailIds)
        {
            if (tpldetailIds.Length == 0)
            {
                return(new List <Prescription.Controls.Entity.Prescription>());
            }

            string strsql = "";

            strsql = @"SELECT TOP 100 A.GroupID,
	                                A.FeeID,A.FeeName,A.FeeClass, 
	                                A.Dosage,A.DosageUnit,
	                                A.Amount,A.Unit,
	                                A.FrequencyID,C.FrequencyName AS FrequencyName,C.ExecuteCode,
	                                A.ChannelID,B.CName AS ChannelName,
	                                A.Days Num, A.Days,A.Memo
	                                ,D.ClinPrice,D.Spec,D.Dosage DoseConvertNum,D.MatClass,D.SkinMethod IsAst
	                                FROM Clinic_SetMealDetail A
		                                LEFT JOIN Clinic_Channel B ON A.ChannelID = B.ID
		                                LEFT JOIN Clinic_Frequency C ON A.FrequencyID = C.ID 
		                                LEFT JOIN ViewBaseData_Med D ON A.FeeID=D.StockID 
	                                 WHERE A.ID in ({0})
	                                 ORDER BY A.GroupID,A.OrderNum"    ;
            strsql = string.Format(strsql,
                                   string.Join(",", Array.ConvertAll <int, string>(tpldetailIds, delegate(int v)
            {
                return(v.ToString());
            })));


            DataTable dt = oleDb.GetDataTable(strsql);
            List <Prescription.Controls.Entity.Prescription> list_Prescription = new List <Prescription.Controls.Entity.Prescription>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Prescription.Controls.Entity.Prescription mPres = new Prescription.Controls.Entity.Prescription();

                mPres.PresListId = 0;
                mPres.PresHeadId = 0;
                //mPres.OrderNo = i + 1;//行号
                mPres.Item_Id       = Convert.ToInt32(dt.Rows[i]["FeeID"]);
                mPres.Item_Name     = dt.Rows[i]["FeeName"].ToString();
                mPres.Item_Type     = type;//1西药 2中药 3项目材料
                mPres.StatItem_Code = "";
                mPres.Sell_Price    = ConvertDataExtend.ToDecimal(dt.Rows[i]["ClinPrice"], 0);
                mPres.Buy_Price     = ConvertDataExtend.ToDecimal(dt.Rows[i]["ClinPrice"], 0);
                mPres.Item_Price    = ConvertDataExtend.ToDecimal(dt.Rows[i]["ClinPrice"], 0);
                mPres.Standard      = dt.Rows[i]["Spec"].ToString();
                mPres.Usage_Amount  = Convert.ToDecimal(dt.Rows[i]["Dosage"]);                      //剂量
                mPres.Usage_Unit    = dt.Rows[i]["DosageUnit"].ToString();                          //剂量单位
                mPres.Usage_Rate    = ConvertDataExtend.ToDecimal(dt.Rows[i]["DoseConvertNum"], 1); //剂量系数
                mPres.Dosage        = Convert.ToInt32(dt.Rows[i]["Num"]);                           //付数
                mPres.Usage_Id      = Convert.ToInt32(dt.Rows[i]["ChannelID"]);
                mPres.Frequency_Id  = Convert.ToInt32(dt.Rows[i]["FrequencyID"]);
                mPres.Days          = Convert.ToInt32(dt.Rows[i]["Days"]);

                mPres.Amount = Convert.ToDecimal(dt.Rows[i]["Amount"].ToString());            //发药数量
                mPres.Unit   = dt.Rows[i]["Unit"].ToString();                                 //发药单位

                mPres.Item_Amount = Convert.ToInt32(Convert.ToDecimal(dt.Rows[i]["Amount"])); //开药数量
                mPres.Item_Unit   = dt.Rows[i]["Unit"].ToString();                            //开药单位
                mPres.Item_Rate   = 1;                                                        //系数

                mPres.Group_Id      = Convert.ToInt32(dt.Rows[i]["GroupID"]);                 //分组组号
                mPres.SkinTest_Flag = ConvertDataExtend.ToInt32(dt.Rows[i]["IsAst"], 0);      //皮试
                mPres.SelfDrug_Flag = 0;                                                      //自备
                mPres.Entrust       = dt.Rows[i]["Memo"].ToString();                          //嘱托

                mPres.FootNote = "";
                mPres.Tc_Flag  = 0;                                               //套餐

                mPres.Usage_Name        = dt.Rows[i]["ChannelName"].ToString();   //用法名称
                mPres.Frequency_Name    = dt.Rows[i]["FrequencyName"].ToString(); //频次名称
                mPres.Frequency_Caption = dt.Rows[i]["ExecuteCode"].ToString();   //频次名称

                int _execNum, _cycleDay;
                CardDataSourceFrequency.Calculate(dt.Rows[i]["ExecuteCode"].ToString(), out _execNum, out _cycleDay);
                mPres.Frequency_ExecNum  = _execNum;  //执行次数
                mPres.Frequency_CycleDay = _cycleDay; //执行周期


                mPres.CalculateAmount(null);

                list_Prescription.Add(mPres);
            }

            return(list_Prescription);
            //throw new NotImplementedException();
        }
        public Prescription.Controls.Entity.Prescription GetPresTemplateRow(int type, int itemId)
        {
            CardDataSourceDrugItem durgItem = GetDrugItem(itemId);

            if (durgItem == null)
            {
                throw new Exception("该项目已停用,不能开出!");
            }
            Prescription.Controls.Entity.Prescription mPres = new Prescription.Controls.Entity.Prescription();
            mPres.Item_Id       = ConvertDataExtend.ToInt32(durgItem.ItemId, -1);
            mPres.Item_Name     = ConvertDataExtend.ToString(durgItem.ItemName, "");
            mPres.Item_Type     = type;//Convert.ToInt32(durgItem.ItemType);//1西药 2中药 3项目材料
            mPres.StatItem_Code = ConvertDataExtend.ToString(durgItem.StatItemCode, "");;
            mPres.Sell_Price    = durgItem.SellPrice;
            mPres.Buy_Price     = durgItem.BuyPrice;
            mPres.Item_Price    = durgItem.SellPrice;
            mPres.Standard      = durgItem.Standard;
            mPres.Usage_Amount  = durgItem.default_Usage_Id; //剂量
            mPres.Usage_Unit    = durgItem.DoseUnitName;     //剂量单位
            mPres.Usage_Rate    = durgItem.DoseConvertNum;   //剂量系数
            if (mPres.IsHerb)
            {
                mPres.Dosage = 1;//付数
            }
            else
            {
                mPres.Dosage = 0;
            }
            mPres.Usage_Id     = durgItem.default_Usage_Id;
            mPres.Frequency_Id = durgItem.default_Frequency_Id;
            mPres.Days         = Convert.ToInt32(1);

            //mPres.Amount = 0;//发药数量
            mPres.Unit = durgItem.UnPickUnit;            //发药单位

            mPres.Item_Amount = Convert.ToInt32(1);      //开药数量
            mPres.Item_Unit   = durgItem.UnPickUnit;     //开药单位
            mPres.Item_Rate   = Convert.ToInt32(1);      //系数

            mPres.SkinTest_Flag = durgItem.SkinTestFlag; //皮试
            mPres.SelfDrug_Flag = Convert.ToInt32(0);    //自备
            mPres.Entrust       = "";                    //嘱托

            mPres.FootNote = "";
            mPres.Tc_Flag  = 0;//套餐

            mPres.Pres_Date = Convert.ToDateTime(DateTime.Now);

            mPres.Usage_Name     = durgItem.default_Usage_Name;     //用法名称
            mPres.Frequency_Name = durgItem.default_Frequency_Name; //频次名称

            string _caption = "";
            CardDataSourceFrequency freq = GetFrequency().Find(x => x.FrequencyId == mPres.Usage_Id);

            if (freq != null)
            {
                _caption = freq.Caption;
            }

            //string _caption = CardDataSource.Tables["frequencydic"].Select("FrequencyId=" + mPres.Usage_Id)[0]["Caption"].ToString();
            mPres.Frequency_Caption = _caption;//频次名称

            int _execNum, _cycleDay;

            CardDataSourceFrequency.Calculate(_caption, out _execNum, out _cycleDay);
            mPres.Frequency_ExecNum  = _execNum;  //执行次数
            mPres.Frequency_CycleDay = _cycleDay; //执行周期

            mPres.IsFloat = true;                 //row["RoundingMode"]

            mPres.Usage_Amount = mPres.Usage_Amount <= 0 ? 1 : mPres.Usage_Amount;
            mPres.CalculateAmount(durgItem.UnPickUnit);//计算数量 和 金额

            return(mPres);
            //throw new NotImplementedException();
        }
        private List <CardDataSourceDrugItem> GetDrugItemToDatabase(int type, int pageNo, int pageSize, string filter)
        {
            PageInfo page = new PageInfo(pageSize, pageNo);

            page.KeyName = "StockID";

            string strsql = "";

            strsql = @"SELECT * FROM ViewBaseData_Med T WHERE  (PyCode LIKE '%{0}%' OR PyCodeT LIKE '%{0}%' OR WbCode LIKE '%{0}%' OR WbCodeT LIKE '%{0}%' OR CName LIKE '%{0}%' OR TName LIKE '%{0}%')";
            strsql = string.Format(strsql, filter);
            strsql = SqlPage.FormatSql(strsql, page, delegate(string sql)
            {
                int toltal        = 0;
                SqlDataReader sdr = oleDb.GetSqlDataReader(sql);
                if (sdr.Read())
                {
                    toltal = (int)sdr.GetValue(0);
                }
                sdr.Close();
                return(toltal);
            });
            DataTable dt = oleDb.GetDataTable(strsql);

            List <CardDataSourceDrugItem> list_DrugItem = new List <CardDataSourceDrugItem>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CardDataSourceDrugItem mDrugItem = new CardDataSourceDrugItem();
                mDrugItem.ItemId         = ConvertDataExtend.ToInt32(dt.Rows[i]["StockID"], 0);
                mDrugItem.ItemName       = dt.Rows[i]["CName"].ToString();
                mDrugItem.ItemName_Print = dt.Rows[i]["TName"].ToString();
                mDrugItem.Standard       = dt.Rows[i]["Spec"].ToString();

                mDrugItem.Scale      = "";                                                      //补偿比例
                mDrugItem.StoreNum   = ConvertDataExtend.ToDecimal(dt.Rows[i]["ActualQty"], 0); //库存量
                mDrugItem.UnPickUnit = dt.Rows[i]["MiniUnit"].ToString();                       //包装单位(销售单位)
                mDrugItem.SellPrice  = ConvertDataExtend.ToDecimal(dt.Rows[i]["ClinPrice"], 0); //销售价格?
                mDrugItem.BuyPrice   = ConvertDataExtend.ToDecimal(dt.Rows[i]["WardPrice"], 0); //进价
                //mDrugItem.ExecDeptName = dt.Rows[i][""].ToString();//执行科室?
                mDrugItem.Pym     = dt.Rows[i]["PyCode"].ToString();
                mDrugItem.Wbm     = dt.Rows[i]["WbCode"].ToString();
                mDrugItem.Address = dt.Rows[i]["FacName"].ToString();//生产厂家
                //mDrugItem.DoseUnitId = dt.Rows[i][""].ToString();//剂量单位
                mDrugItem.DoseUnitName   = dt.Rows[i]["DosUnit"].ToString();
                mDrugItem.DoseConvertNum = ConvertDataExtend.ToDecimal(dt.Rows[i]["Dosage"], 0); //剂量对应包装单位系数
                mDrugItem.ItemType       = ConvertDataExtend.ToInt32(dt.Rows[i]["MatClass"], 0); //项目类型 0-所有 1-西药 2-中药  3-处方可开的物品 4-收费项目
                //mDrugItem.StatItemCode = dt.Rows[i][""].ToString();//大项目代码
                //mDrugItem.UnPickUnitId = dt.Rows[i][""].ToString();//包装单位ID
                mDrugItem.ExecDeptId = ConvertDataExtend.ToInt32(dt.Rows[i]["DeptID"], 0);       //执行科室ID?
                mDrugItem.FloatFlag  = ConvertDataExtend.ToInt32(dt.Rows[i]["RoundingMode"], 0); // dt.Rows[i][""].ToString();//按含量取整1 按剂量取整0
                //mDrugItem.VirulentFlag = dt.Rows[i][""].ToString();//剧毒标识
                //mDrugItem.NarcoticFlag = dt.Rows[i][""].ToString();//麻醉标识
                mDrugItem.SkinTestFlag = ConvertDataExtend.ToInt32(dt.Rows[i]["SkinMethod"], 0);//皮试标识
                //mDrugItem.RecipeFlag = dt.Rows[i][""].ToString();//处方标识
                //mDrugItem.LunacyFlag = dt.Rows[i][""].ToString();//精神药品标识
                //mDrugItem.CostlyFlag = dt.Rows[i][""].ToString();//贵重药品标识
                mDrugItem.default_Usage_Amount   = 0; //默认用量
                mDrugItem.default_Usage_Id       = 0; //默认用法
                mDrugItem.default_Usage_Name     = "";
                mDrugItem.default_Frequency_Id   = 0; //默认频次
                mDrugItem.default_Frequency_Name = "";

                list_DrugItem.Add(mDrugItem);
            }
            return(list_DrugItem);
        }