Beispiel #1
0
 /// <summary>
 /// 设置command对象的参数
 /// </summary>
 /// <param name="cfmx"></param>
 /// <param name="command">add by wangzhi 2014-08-26</param>
 private static void SetCommandParameter(ts_mz_class.classes.hjcfmx cfmx, IDbCommand command)
 {
     command.Parameters.Add(Fun.NewCommandParameter(command, "@PYM", cfmx.pym));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@BM", cfmx.bm));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@PM", cfmx.pm));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@SPM", cfmx.spm));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@GG", cfmx.gg));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@CJ", cfmx.cj));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@DJ", cfmx.dj));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@SL", cfmx.sl));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@DW", cfmx.dw));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@YDWBL", cfmx.ydwbl));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@JS", cfmx.js));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@JE", cfmx.je));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@TJDXMDM", cfmx.tjdxmdm));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@XMID", cfmx.xmid));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@BZBY", cfmx.bzby));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@BPSBZ", cfmx.bpsbz));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@PSHJMXID", cfmx.pshjmxid));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@YL", cfmx.yl));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@YLDW", cfmx.yldw));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@YLDWID", cfmx.yldwid));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@DWLX", cfmx.dwlx));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@YFID", cfmx.yfid));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@YFMC", cfmx.yfmc));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@PCID", cfmx.pcid));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@PCMC", cfmx.pcmc));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@TS", cfmx.ts));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@ZT", cfmx.zt));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@FZXH", cfmx.fzxh));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@PXXH", cfmx.pxxh));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@pfj", cfmx.pfj));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@TCID", cfmx.tcid));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@yzid", cfmx.yzid));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@yzmc", cfmx.yzmc));
     command.Parameters.Add(Fun.NewCommandParameter(command, "@memo", cfmx.memo));
 }
Beispiel #2
0
        /// <summary>
        /// 新增或更新处方明细
        /// </summary>
        /// <param name="cfmx"></param>
        /// <param name="_Database">add by wangzhi 2014-08-26</param>
        public static void SaveCfmx(ts_mz_class.classes.hjcfmx cfmx, RelationalDatabase _Database)
        {
            Guid   _NewHjmxid = Guid.Empty;
            int    err_code   = 0;
            string err_text   = "";

            SaveCfmx(cfmx.hjmxid.ToString(), cfmx.hjid.ToString(), cfmx.pym, cfmx.bm, cfmx.pm, cfmx.spm, cfmx.gg, cfmx.cj, cfmx.dj, cfmx.sl, cfmx.dw, cfmx.ydwbl, cfmx.js, cfmx.je, cfmx.tjdxmdm,
                     cfmx.xmid, cfmx.bzby, cfmx.bpsbz, cfmx.pshjmxid.ToString(), cfmx.yl, cfmx.yldw, cfmx.yldwid, cfmx.dwlx, cfmx.yfid, cfmx.yfmc, cfmx.pcid, cfmx.pcmc, cfmx.ts, cfmx.zt, cfmx.fzxh,
                     cfmx.pxxh, cfmx.pfj, cfmx.pfje, cfmx.tcid, cfmx.yzid, cfmx.yzmc, out _NewHjmxid, out err_code, out err_text, cfmx.yblx, cfmx.memo, _Database);
            cfmx.NewHjmxid = _NewHjmxid;
            cfmx.err_text  = err_text;
            cfmx.err_code  = err_code;
            return;

            #region ....
            //            string yptjdmxdm = "01,02,03";
            //            cfmx.err_code = -1;
            //            #region 医保匹配验证
            //            SystemCfg cfg1101 = new SystemCfg( 1101 , _Database );
            //            if ( cfg1101.Config == "1" && cfmx.yblx > 0 )
            //            {
            //                long xmid = cfmx.xmid;
            //                int xmly = 2;
            //                if ( yptjdmxdm.IndexOf( cfmx.tjdxmdm ) != -1 )
            //                {
            //                    xmid = cfmx.yzid;
            //                    xmly = 1;
            //                }
            //                string sql = string.Format( "select * from jc_yb_bl where xmid={0} and xmly={1} and yblx={2}" , xmid , xmly , cfmx.yblx );
            //                DataRow row = _Database.GetDataRow( sql );
            //                if ( row == null )
            //                {
            //                    cfmx.err_text = string.Format( "[{0}] {1} 医保没有匹配,请重新选择.医保编号:** {3} " , cfmx.pm , cfmx.gg , xmid );
            //                    return;
            //                }
            //            }
            //            #endregion
            //            #region 金额验证
            //            if ( yptjdmxdm.IndexOf( cfmx.tjdxmdm ) != -1 )
            //            {
            //                cfmx.pfj = Convert.ToDecimal( Convertor.IsNull( _Database.GetDataResult( string.Format( "select pfj/{1} from yp_ypcjd where cjid={0}" , cfmx.xmid , cfmx.ydwbl ) ) , "0" ) );
            //                cfmx.pfje = Decimal.Round( cfmx.pfj * cfmx.sl * cfmx.js , 3 );
            //            }
            //            if ( cfmx.hjmxid == Guid.Empty )
            //            {
            //                decimal num1 = Math.Abs( cfmx.dj * cfmx.sl * cfmx.js );
            //                decimal num2 = Math.Abs( cfmx.je );
            //                if ( ( num1 - num2 ) > 0.1M )
            //                {
            //                    cfmx.err_text = string.Format( "单价*数量*剂数<>金额,请您核实  {0}" , num1 );
            //                    return;
            //                }
            //            }
            //            #endregion
            //            #region 药品大项目与头表项目来源对应验证
            //            if ( yptjdmxdm.IndexOf( cfmx.tjdxmdm ) != -1 )
            //            {
            //                string sql = "select xmly from mz_hjb where hjid = '" + cfmx.hjid + "'";
            //                object obj = _Database.GetDataResult( sql );
            //                int xmly = Convert.ToInt32( Convertor.IsNull( obj , "0" ) );
            //                if ( xmly != 1 )
            //                    throw new Exception( "保存处方明细出错,药品明细对应的头表的项目来源不一致" );
            //            }
            //            #endregion
            //            #region 库存量判断
            //            if ( yptjdmxdm.IndexOf( cfmx.tjdxmdm ) != -1 )
            //            {
            //                SystemCfg cfg3004 = new SystemCfg( 3004 , _Database );
            //                if ( cfg3004.Config == "1" )
            //                {
            //                    string sql = string.Format( "select KCL/DWBL from YF_KCMX a inner join ( select ZXKS from MZ_HJB where HJID='{0}' ) b on a.DEPTID=b.ZXKS where a.CJID={1}" ,
            //                        cfmx.hjid , cfmx.xmid );
            //                    object obj = _Database.GetDataResult( sql );
            //                    decimal yfkcl = Convert.ToDecimal( Convertor.IsNull( obj , "0" ) );
            //                    decimal yl = cfmx.sl * cfmx.js / cfmx.ydwbl;
            //                    if ( yfkcl < yl )
            //                        throw new Exception( "药品[ " + cfmx.spm + " ] 库存量不足,可用库存量:" + yfkcl.ToString() );
            //                }
            //            }
            //            #endregion
            //            try
            //            {
            //                using ( IDbCommand command = _Database.GetCommand() )
            //                {
            //                    command.CommandType = CommandType.Text;
            //                    if ( _Database.IsInTransaction )
            //                        command.Transaction = _Database.GetTransaction();
            //                    if ( cfmx.hjmxid == Guid.Empty )
            //                    {
            //                        command.CommandText = @"INSERT INTO MZ_HJB_MX(HJMXID,HJID,PYM,BM,PM,SPM,GG,CJ,DJ,SL,DW,YDWBL,JS,JE,TJDXMDM,XMID,BZBY,BPSBZ,PSHJMXID,YL,YLDW,YLDWID,DWLX,YFID,YFMC,PCID,PCMC,TS,ZT,FZXH,PXXH,PFJ,PFJE,TCID,YZID,YZMC,MEMO)
            //                                                       VALUES(@NEWHJMXID,@HJID,@PYM,@BM,@PM,@SPM,@GG,@CJ,@DJ,@SL,@DW,@YDWBL,@JS,ROUND(@JE,2),@TJDXMDM,@XMID,@BZBY,@BPSBZ,@PSHJMXID,@YL,@YLDW,@YLDWID,@DWLX,@YFID,@YFMC,@PCID,@PCMC,@TS,@ZT,@FZXH,@PXXH,@PFJ,ROUND(@PFJ*@SL*@JS,2),@TCID,@YZID,@YZMC,@MEMO)";
            //                        Guid NewHjmxid = new Guid( _Database.GetDataResult( "select dbo.FUN_GETGUID(newid(),getdate())" ).ToString() );
            //                        command.Parameters.Add( Fun.NewCommandParameter( command , "@NewHjmxid" , NewHjmxid ) );
            //                        command.Parameters.Add( Fun.NewCommandParameter( command , "@HJID" , cfmx.hjid ) );
            //                        //设置其他参数
            //                        SetCommandParameter( cfmx , command );
            //                        int ret = command.ExecuteNonQuery();
            //                        if ( ret != 0 )
            //                        {
            //                            cfmx.NewHjmxid = NewHjmxid;
            //                        }
            //                        else
            //                        {
            //                            cfmx.err_text = "插入处方明细失败";
            //                            return;
            //                        }
            //                    }
            //                    else
            //                    {
            //                        command.CommandText = @"UPDATE MZ_HJB_MX SET PYM=@PYM,BM=@BM,PM=@PM,SPM=@SPM,GG=@GG,CJ=@CJ,DJ=@DJ,SL=@SL,DW=@DW,YDWBL=@YDWBL,JS=@JS,JE=ROUND(@JE,2),TJDXMDM=@TJDXMDM,XMID=@XMID,BZBY=@BZBY,BPSBZ=@BPSBZ,PSHJMXID=@PSHJMXID,YL=@YL,YLDW=@YLDW,
            //                                                            YLDWID=@YLDWID,DWLX=@DWLX,YFID=@YFID,YFMC=@YFMC,PCID=@PCID,PCMC=@PCMC,TS=@TS,ZT=@ZT,FZXH=@FZXH,
            //                                                            PXXH=@PXXH,PFJ=@PFJ,PFJE=ROUND(@PFJ*@SL*@JS,2),TCID=@TCID,YZID=@YZID,YZMC=@YZMC WHERE HJMXID=@HJMXID";
            //                        //设置其他参数
            //                        SetCommandParameter( cfmx , command );
            //                        //设置更新条件参数
            //                        command.Parameters.Add( Fun.NewCommandParameter( command , "@hjmxid" , cfmx.hjmxid ) );
            //                        int ret = command.ExecuteNonQuery();
            //                        if ( ret != 0 )
            //                        {
            //                            cfmx.NewHjmxid = cfmx.hjmxid;
            //                        }
            //                        else
            //                        {
            //                            cfmx.err_text = "更新处方明细失败";
            //                            return;
            //                        }
            //                    }
            //                }
            //                cfmx.err_code = 0;
            //                cfmx.err_text = "保存成功";
            //            }
            //            catch ( Exception error )
            //            {
            //                cfmx.err_text = "保存处方明细失败: " + error.Message;
            //            }
            #endregion
        }
Beispiel #3
0
        /// <summary>
        /// 执行划价
        /// </summary>
        /// <param name="patient"></param>
        /// <returns></returns>
        public override bool ExecPricing(PhysicalExaminePatient patient)
        {
            SystemCfg cfg1146 = new SystemCfg(1146, this.Database);
            SystemCfg cfg1148 = new SystemCfg(1148, this.Database);

            if (string.IsNullOrEmpty(cfg1146.Config))
            {
                throw new Exception("进行体检收费发生错误,该体检收费需要设置参数1146");
            }
            if (!Convertor.IsNumeric(cfg1146.Config))
            {
                throw new Exception("参数1146设置错误,必须为整数");
            }

            if (string.IsNullOrEmpty(cfg1148.Config))
            {
                throw new Exception("进行体检收费发生错误,没有设置体检费的执行科室(参数1148)");
            }
            if (!Convertor.IsNumeric(cfg1148.Config))
            {
                throw new Exception("参数1148设置错误,必须为整数");
            }

            int     itemId        = Convert.ToInt32(cfg1146.Config);
            DataRow rowChargeItem = this.Database.GetDataRow(string.Format("select * from jc_hsitemdiction where jgbm={0} and item_id={1}", CurrentDept.Jgbm, itemId));
            DataRow rowOrdrItem   = this.Database.GetDataRow(string.Format("select * from JC_HOITEMDICTION where ORDER_ID in ( select HOITEM_ID from JC_HOI_HDI where TC_FLAG = 0 and TCID<=0 and HDITEM_ID = {0} )", itemId));

            int         tjksdm     = Convert.ToInt32(cfg1148.Config); //体检科室代码
            DateTime    serverDate = DateManager.ServerDateTimeByDBType(Database);
            Guid        brxxid     = Guid.Empty;
            Guid        ghxxid     = Guid.Empty;
            List <Guid> hjids      = new List <Guid>();
            string      mzh        = "";

            try
            {
                Database.BeginTransaction();
                //保存病人信息
                ts_mz_class.YY_BRXX brxx = base.SavePatientInfo(patient);
                //生成挂号记录
                ghxxid = base.SaveRegisterRecord(brxx, tjksdm, 0, 0, serverDate, out mzh);
                //生成划价数据
                classes.hjcf cf = new classes.hjcf();
                #region ...........
                cf.hjid   = Guid.Empty;
                cf.jgbm   = base.CurrentDept.Jgbm;
                cf.brxxid = brxx.Brxxid;
                cf.ghxxid = ghxxid;
                cf.blh    = mzh;
                cf.cfrq   = serverDate.ToString("yyyy-MM-dd HH:mm:ss");
                cf.hjy    = CurrentUser.EmployeeId;
                cf.hjck   = "";
                cf.ysdm   = 0;
                cf.ksdm   = tjksdm;
                cf.zyksdm = 0;
                cf.cfje   = patient.TotalCost;
                cf.zxks   = tjksdm;
                cf.xmly   = 2;
                cf.cfjs   = 1;
                cf.byscf  = 0;
                mz_hj.SaveCf(cf, Database);
                if (cf.err_code != 0 || cf.NewHjid == Guid.Empty)
                {
                    throw new Exception("保存划价数据失败:" + cf.err_text);
                }
                hjids.Add(cf.NewHjid);
                #endregion
                //生成划价明细
                classes.hjcfmx cfmx = new ts_mz_class.classes.hjcfmx();
                #region .................
                cfmx.hjmxid  = Guid.Empty;
                cfmx.hjid    = cf.NewHjid;
                cfmx.pym     = "";
                cfmx.bm      = "";
                cfmx.pm      = Convertor.IsNull(rowChargeItem["item_name"], "");
                cfmx.spm     = Convertor.IsNull(rowChargeItem["item_name"], "");
                cfmx.gg      = "";
                cfmx.cj      = "";
                cfmx.dj      = patient.TotalCost;
                cfmx.sl      = 1;
                cfmx.dw      = Convertor.IsNull(rowChargeItem["item_unit"], "");
                cfmx.ydwbl   = 1;
                cfmx.js      = 1;
                cfmx.je      = patient.TotalCost;
                cfmx.tjdxmdm = Convertor.IsNull(rowChargeItem["statitem_code"], "");
                cfmx.xmid    = itemId;
                cfmx.yl      = 1;
                cfmx.yldw    = Convertor.IsNull(rowChargeItem["item_unit"], "");
                cfmx.pcmc    = "";
                cfmx.ts      = 1;
                cfmx.zt      = "";
                cfmx.pxxh    = 1;
                cfmx.tcid    = 0;
                cfmx.yzid    = Convert.ToInt32(rowOrdrItem["order_id"]);
                cfmx.yzmc    = Convertor.IsNull(rowOrdrItem["order_name"], "");
                mz_hj.SaveCfmx(cfmx, Database);
                if (cfmx.err_code != 0 || cfmx.NewHjmxid == Guid.Empty)
                {
                    throw new Exception("保存划价明细失败");
                }
                #endregion
                Database.CommitTransaction();
            }
            catch (Exception error)
            {
                Database.RollbackTransaction();
                throw error;
            }

            string sql = string.Format("Update Pat_Info set His_RegNo = '{0}' where  ChargeFlag=0 and PTFlag='P' and PatID = '{1}'", mzh, patient.ExamineNo);
            pesDb.DoCommand(sql);

            InvokeEvent(brxxid, ghxxid, hjids);

            return(true);
        }