示例#1
0
        /// <summary>
        /// 下载农合药品目录到本地数据库
        /// </summary>
        public static void DownLoadAndSaveNcmsDrug()
        {
            try
            {
                //药品列表容器
                List <Drug> drugList = new List <Drug>();
                //定义入口参数
                DownLoadItem hisData  = new DownLoadItem();
                JoinArea     joinArea = new JoinArea();
                joinArea.code = CURRENT_JOINAREA_CODE;
                joinArea.name = CURRENT_JOINAREA_NAME;

                DataType dataType = new DataType();
                dataType.dataTypeName  = NcmsDataType.门诊数据.ToString();
                dataType.dataTypeValue = ((int)NcmsDataType.门诊数据).ToString();

                //项目类型 [1(所有目录)[2(药品目录),3(诊疗项目目录)]
                Condition condition = new Condition();
                condition.condition_name  = "CONTENT_TYPE";
                condition.condition_value = ((int)DownLoadItemType.DRUG).ToString();
                //要下载的页码 整数
                int       current_page = 1;
                Condition condition1   = new Condition();
                condition1.condition_name  = "CURRENT_PAGE";
                condition1.condition_value = current_page.ToString();
                //要下载的每页大小
                Condition condition2 = new Condition();
                condition2.condition_name  = "PAGE_SIZE";
                condition2.condition_value = "100";

                hisData.uploadorg = "23423";
                hisData.dataType  = dataType;
                hisData.joinArea  = joinArea;

                Condition[] conditions = new Condition[3];
                conditions[0]      = condition;
                conditions[1]      = condition1;
                conditions[2]      = condition2;
                hisData.conditions = conditions;
                //下载第一页并取得页面相关信息
                DownLoadCenterItemResult result = NccmInterfaces.DownLoadDrugListInfo(hisData);
                if (result.resultId)
                {
                    drugList = result.drug.ToList <Drug>();

                    int totalPage = result.drugPageInfo.totalPageNo;

                    current_page = 2;

                    while (current_page <= totalPage)
                    {
                        //重新指定要下载的页
                        hisData.conditions[1].condition_value = current_page.ToString();

                        result = NccmInterfaces.DownLoadDrugListInfo(hisData);

                        if (result.resultId)
                        {
                            //追加到List
                            for (int i = 0; i < result.drug.Length; i++)
                            {
                                drugList.Add(result.drug[i]);
                            }
                        }
                        else
                        {
                            throw new Exception(result.resultString);
                        }
                        current_page++;
                    }
                    //将药品信息保存到数据库
                    try
                    {
                        oleDb.BeginTransaction();
                        HIS.SYSTEM.Core.BindEntity <Model.NCMS_DRUG_CATALOG> .CreateInstanceDAL(oleDb).Delete("");

                        foreach (Drug drug in drugList)
                        {
                            Model.NCMS_DRUG_CATALOG model = new HIS.Model.NCMS_DRUG_CATALOG();
                            #region .......
                            model.DRUG_ALIAS            = drug.drug_alias;
                            model.DRUG_CODE             = drug.drug_code;
                            model.DRUG_CODE2            = drug.drug_code2;
                            model.DRUG_FORM             = drug.drug_form;
                            model.DRUG_NAME             = drug.drug_name;
                            model.DRUG_TYPE             = drug.drug_type;
                            model.DRUGCLASS_CODE        = drug.drugclass_code;
                            model.LIMIT_DEPT            = drug.limit_dept;
                            model.LIMIT_DESC            = drug.limit_desc;
                            model.LIMIT_DISEASE         = drug.limit_disease;
                            model.LIMIT_DOCTOR          = drug.limit_doctor;
                            model.LIMIT_FORM            = drug.limit_form;
                            model.LIMIT_HOSPITAL        = drug.limit_hospital;
                            model.LIMIT_LINE            = drug.limit_line;
                            model.LIMIT_MAKER           = drug.limit_maker;
                            model.LIMIT_PRICE           = drug.limit_price.ToString();
                            model.LIMIT_PRICEFIELDSPECI = drug.limit_priceSpecified.ToString();
                            model.LIMIT_UNIT_NAME       = drug.limit_unit_name;
                            model.LIMIT_UNIT_NUM        = drug.limit_unit_num;
                            model.MARK      = drug.mark;
                            model.USE_LEVEL = drug.use_level;
                            #endregion

                            HIS.SYSTEM.Core.BindEntity <Model.NCMS_DRUG_CATALOG> .CreateInstanceDAL(oleDb).Add(model);
                        }
                        oleDb.CommitTransaction();
                    }
                    catch (Exception err)
                    {
                        oleDb.RollbackTransaction();
                        throw err;
                    }
                }
                else
                {
                    throw new Exception(result.resultString);
                }
            }
            catch (Exception err)
            {
                throw err;
            }
        }
示例#2
0
        /// <summary>
        /// 下载诊疗服务项目
        /// </summary>
        public static void DownLoadAndSavNcmsTherapy()
        {
            try
            {
                //药品列表容器
                List <Therapy> theraypList = new List <Therapy>();
                //定义入口参数
                DownLoadItem hisData  = new DownLoadItem();
                JoinArea     joinArea = new JoinArea();
                joinArea.code = CURRENT_JOINAREA_CODE;
                joinArea.name = CURRENT_JOINAREA_NAME;

                DataType dataType = new DataType();
                dataType.dataTypeName  = NcmsDataType.门诊数据.ToString();
                dataType.dataTypeValue = ((int)NcmsDataType.门诊数据).ToString();

                //项目类型 [1(所有目录)[2(药品目录),3(诊疗项目目录)]
                Condition condition = new Condition();
                condition.condition_name  = "CONTENT_TYPE";
                condition.condition_value = ((int)DownLoadItemType.THERAPY).ToString();
                //要下载的页码 整数
                int       current_page = 1;
                Condition condition1   = new Condition();
                condition1.condition_name  = "CURRENT_PAGE";
                condition1.condition_value = current_page.ToString();
                //要下载的每页大小
                Condition condition2 = new Condition();
                condition2.condition_name  = "PAGE_SIZE";
                condition2.condition_value = "100";

                hisData.uploadorg = "23423";
                hisData.dataType  = dataType;
                hisData.joinArea  = joinArea;

                Condition[] conditions = new Condition[3];
                conditions[0]      = condition;
                conditions[1]      = condition1;
                conditions[2]      = condition2;
                hisData.conditions = conditions;
                //下载第一页并取得页面相关信息
                DownLoadCenterItemResult result = NccmInterfaces.DownLoadDrugListInfo(hisData);
                if (result.resultId)
                {
                    theraypList = result.therapy.ToList <Therapy>();

                    int totalPage = result.therapyPageInfo.totalPageNo;

                    current_page = 2;

                    while (current_page <= totalPage)
                    {
                        //重新指定要下载的页
                        hisData.conditions[1].condition_value = current_page.ToString();

                        result = NccmInterfaces.DownLoadTherapyListInfo(hisData);

                        if (result.resultId)
                        {
                            //追加到List
                            for (int i = 0; i < result.therapy.Length; i++)
                            {
                                theraypList.Add(result.therapy[i]);
                            }
                        }
                        else
                        {
                            throw new Exception(result.resultString);
                        }
                        current_page++;
                    }
                    //将药品信息保存到数据库
                    try
                    {
                        oleDb.BeginTransaction();
                        HIS.SYSTEM.Core.BindEntity <Model.NCMS_THERAPY_CATALOG> .CreateInstanceDAL(oleDb).Delete("");

                        foreach (Therapy therapy in theraypList)
                        {
                            Model.NCMS_THERAPY_CATALOG model = new HIS.Model.NCMS_THERAPY_CATALOG();
                            #region .......
                            model.EXCLUDE_CONTENT = therapy.exclude_content;
                            model.FINANCE_TYPE    = therapy.finance_type;
                            model.ITEM_CODE       = therapy.item_code;
                            model.ITEM_CONTENT    = therapy.item_content;
                            model.ITEM_NAME       = ConvertSpeciString(therapy.item_name);
                            model.MARK            = therapy.mark;
                            model.MEDCLASS_CODE   = therapy.medclass_code;
                            model.PRICE1          = therapy.price1;
                            model.PRICE2          = therapy.price2;
                            model.PRICE3          = therapy.price3;
                            model.SPECS           = therapy.specs;
                            model.UNIT            = therapy.unit;
                            #endregion

                            HIS.SYSTEM.Core.BindEntity <Model.NCMS_THERAPY_CATALOG> .CreateInstanceDAL(oleDb).Add(model);
                        }
                        oleDb.CommitTransaction();
                    }
                    catch (Exception err)
                    {
                        oleDb.RollbackTransaction();
                        throw err;
                    }
                }
                else
                {
                    throw new Exception(result.resultString);
                }
            }
            catch (Exception err)
            {
                throw err;
            }
        }