Example #1
0
        public override void ProcessMessage()
        {
            string jiuZhenKH = InObject.patientid;

            if (string.IsNullOrEmpty(jiuZhenKH))
            {
                throw new Exception("患者编号不能为空");
            }

            string sqlBingRenID = "select bingrenid from gy_bingrenxx where jiuzhenkh ='{0}'";
            string bingRenID    = (string)DBVisitor.ExecuteScalar(string.Format(sqlBingRenID, jiuZhenKH));

            string errChuFang = string.Empty;

            foreach (var item in InObject.orderinfo)
            {
                string orderno = item.orderno;
                if (string.IsNullOrEmpty(orderno))
                {
                    errChuFang += "," + jiuZhenKH;
                    continue;
                }
                string sqlPYWC = "update mz_chufang1 set peiyaobz = 1 where chufangid = '{0}' and bingrenid = '{1}'";
                DBVisitor.ExecuteNonQuery(string.Format(sqlPYWC, orderno, jiuZhenKH));
            }
            if (!string.IsNullOrEmpty(errChuFang))
            {
                errChuFang = errChuFang.Trim(',');
                throw new Exception("以下病人的处方id获取失败请检查数据:" + errChuFang);
            }
        }
Example #2
0
        public static void sendRYSJ()
        {
            var Brxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00001, " and brzt in (3,4) and ryfszt = 0 "));

            if (Brxx == null || Brxx.Count == 0)
            {
            }
            else
            {
                foreach (var mxxx in Brxx)
                {
                    var str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                              "<request action= \"sendInHospitalFlag\" client=\"市二:192.168.1.10\" >" +
                              "<head><patient><mpiId></mpiId>" +
                              "<personName>" + mxxx.Get("brxm") + "</personName>" +
                              "<sexCode>" + mxxx.Get("brxb") + "</sexCode>" +
                              "<birthday>" + mxxx.Get("brcsrq") + "</birthday>" +
                              "<idCard>" + mxxx.Get("sfzh") + "</idCard>" +
                              "<idType>01</idType>" +
                              "<cardNo>" + mxxx.Get("jzkh") + "</cardNo>" +
                              "<cardType>" + mxxx.Get("jzklx") + "</cardType>" +
                              "</patient></head>" +
                              "<body>" +
                              "<hospitalCode>47011662233010511A1001</hospitalCode>" +
                              "<wardAreaCode>" + mxxx.Get("bqdm") + "</wardAreaCode>" +
                              "<wardArea>" + mxxx.Get("bqmc") + "</wardArea>" +
                              "<departmentCode>" + mxxx.Get("ksdm") + "</departmentCode>" +
                              "<department>" + mxxx.Get("ksmc") + "</department>" +
                              "<bedNo>" + mxxx.Get("curr_bed") + "</bedNo>" +
                              "<inHospitalTime>" + mxxx.Get("admiss_date") + "</inHospitalTime>" +
                              "<inHospitalReason></inHospitalReason>" +
                              "<doctorName>" + mxxx.Get("zzys") + "</doctorName>" +
                              "<doctorPhone>" + mxxx.Get("zzyslxdh") + "</doctorPhone>" +
                              "<reserveNo>" + mxxx.Get("zzsqdh") + "</reserveNo>" +
                              "<submitor>自动转发</submitor>" +
                              "<submitTime>" + System.DateTime.Now.ToString() + "</submitTime>" +
                              "<submitAgency>杭州市二医院</submitAgency></body></request>";

                    var rtnstr = sendJK(str);
                    var xmldom = new XmlDocument();
                    var xmlOut = "";
                    xmlOut = rtnstr;
                    xmldom.LoadXml(xmlOut);
                    var errno = xmldom.GetElementsByTagName("code").Item(0).FirstChild.InnerText;
                    if (errno == "200")
                    {
                        var tran = DBVisitor.Connection.BeginTransaction();
                        try
                        {
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.AUTO00007, mxxx.Get("zzsqdh")), tran);
                            tran.Commit();
                        }
                        catch (Exception ex)
                        {
                            tran.Rollback();
                        }
                    }
                }
            }
        }
Example #3
0
        public override void ProcessMessage()
        {
            if (string.IsNullOrEmpty(InObject.LEIXING))
            {
                throw new Exception("日志类型不能为空!");
            }
            if (string.IsNullOrEmpty(InObject.CONTEXT))
            {
                throw new Exception("日志内容不能为空!");
            }
            string RiZId = "";
            var    maxid = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.HIS00026, " seq_GY_RIZHI_ZZJ.nextval "));

            if (maxid == null)
            {
                throw new Exception(string.Format("获取日志ID失败!"));
            }
            else
            {
                RiZId = maxid.Items["MAXID"].ToString();
            }
            string StrTct = InObject.CONTEXT.Replace("'", "").Trim();

            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00027, RiZId, InObject.JIUZHENKH, StrTct, InObject.BASEINFO.CAOZUOYDM,
                                                        InObject.IP, InObject.LEIXING, InObject.ERRBZ));
            OutObject = new CAOZUORIJL_OUT();
        }
Example #4
0
        public override void ProcessMessage()
        {
            if (string.IsNullOrEmpty(InObject.pharmacyid) || !InObject.pharmacyid.Contains('*'))
            {
                throw new Exception("传入参数格式错误");
            }
            string chuFangHM = InObject.pharmacyid.Split('*')[1]; //处方id 多个时使用#分割
            string bingRenID = InObject.pharmacyid.Split('*')[0]; //病人id

            string pharmacyid = string.Empty;                     //药房id
            string winno      = string.Empty;                     //窗口id

            #region 入参判断
            if (string.IsNullOrEmpty(chuFangHM))
            {
                throw new Exception("处方号码不能为空");
            }
            if (string.IsNullOrEmpty(bingRenID))
            {
                throw new Exception("病人id不能为空");
            }
            #endregion

            string sqlCKXX = "select a.chufangid, a.chuangkouid chuangkouid,b.yingyongid yaofangid from mz_chufang1 a ,my_chuangkou b where a.chuangkouid = b.chuangkouid and a.chufangid in(select max(chufangid) from mz_chufang1 where chufanghm in('{0}') group by chufanghm)  and a.bingrenid = '{1}' ";

            DataTable dtCKXX = DBVisitor.ExecuteTable(string.Format(sqlCKXX, chuFangHM, bingRenID));

            if (dtCKXX.Rows.Count > 0)
            {
                pharmacyid          = dtCKXX.Rows[0]["yaofangid"].ToString();
                winno               = dtCKXX.Rows[0]["chuangkouid"].ToString();
                InObject.pharmacyid = pharmacyid;
                InObject.winno      = winno;
                InObject.orderno    = dtCKXX.Rows[0]["chufangid"].ToString();
                string sqlJiuZhenKH = "select jiuzhenkh from gy_bingrenxx where bingrenid ='{0}'";
                InObject.patientid = (string)DBVisitor.ExecuteScalar(string.Format(sqlJiuZhenKH, bingRenID));
                //InObject.patientid = bingRenID;
                OutObject = Unity.runService <DISP_PREPARE_IN, DISP_PREPARE_OUT>(InObject);
                if (OutObject.ResultCode == "0")
                {
                    if (OutObject.Result.state == "2")
                    {
                        OutObject.ResultContent = "已配药完成";
                        string sqlPYBZ = "update mz_chufang1 set peiyaobz = 1 where chufangid = '{0}'";
                        DBVisitor.ExecuteNonQuery(string.Format(sqlPYBZ, InObject.orderno));
                    }
                    else
                    {
                        //OutObject.ResultContent = "正在配药中,请稍后!";
                    }
                }
            }
            else
            {
                throw new Exception("未找到相应的处方信息");
            }
        }
Example #5
0
        public static void sendCFTZ()
        {
            var Brxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00001, " and cftz in = 1 and cftzfszt = 0 "));

            if (Brxx == null || Brxx.Count == 0)
            {
            }
            else
            {
                foreach (var mxxx in Brxx)
                {
                    var str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                              "<request action= \"sendInhospitalVisitNotice\" client=\"市二:192.168.1.10\" >" +
                              "<head><patient><mpiId></mpiId>" +
                              "<personName>" + mxxx.Get("brxm") + "</personName>" +
                              "<sexCode>" + mxxx.Get("brxb") + "</sexCode>" +
                              "<birthday>" + mxxx.Get("brcsrq") + "</birthday>" +
                              "<idCard>" + mxxx.Get("sfzh") + "</idCard>" +
                              "<idType>01</idType>" +
                              "<cardNo>" + mxxx.Get("jzkh") + "</cardNo>" +
                              "<cardType>" + mxxx.Get("jzklx") + "</cardType>" +
                              "</patient></head>" +
                              "<body>" +
                              "<reserveNo>" + mxxx.Get("zzsqdh") + "</reserveNo>" +
                              "<visitDate>" + mxxx.Get("ywlx") + "</visitDate>" +
                              "<submitor>自动转发</submitor>" +
                              "<submitTime>" + System.DateTime.Now.ToString() + "</submitTime>" +
                              "<submitAgency>杭州市二医院</submitAgency></body></request>";

                    var rtnstr = sendJK(str);
                    var xmldom = new XmlDocument();
                    var xmlOut = "";
                    xmlOut = rtnstr;
                    xmldom.LoadXml(xmlOut);
                    var errno = xmldom.GetElementsByTagName("code").Item(0).FirstChild.InnerText;
                    if (errno == "200")
                    {
                        var tran = DBVisitor.Connection.BeginTransaction();
                        try
                        {
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.AUTO00007, mxxx.Get("zzsqdh")), tran);
                            tran.Commit();
                        }
                        catch (Exception ex)
                        {
                            tran.Rollback();
                        }
                    }
                }
            }
        }
Example #6
0
        public static void sendDRYSJ()
        {
            var Brxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00001, " and brzt in (1,3,4) and dryfszt = 0 "));

            if (Brxx == null || Brxx.Count == 0)
            {
            }
            else
            {
                foreach (var mxxx in Brxx)
                {
                    var str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                              "<request action= \"sendInHospitalAcceptFlag\" client=\"市二:192.168.1.10\" >" +
                              "<head><patient><mpiId></mpiId>" +
                              "<personName>" + mxxx.Get("brxm") + "</personName>" +
                              "<sexCode>" + mxxx.Get("brxb") + "</sexCode>" +
                              "<birthday>" + mxxx.Get("brcsrq") + "</birthday>" +
                              "<idCard>" + mxxx.Get("sfzh") + "</idCard>" +
                              "<idType>01</idType>" +
                              "<cardNo>" + mxxx.Get("jzkh") + "</cardNo>" +
                              "<cardType>" + mxxx.Get("jzklx") + "</cardType>" +
                              "</patient></head>" +
                              "<body>" +
                              "<reserveNo>" + mxxx.Get("zzsqdh") + "</reserveNo>" +
                              "<departmentNo>" + mxxx.Get("ksdm") + "</departmentNo>" +
                              "<department>" + mxxx.Get("ksmc") + "</department>" +
                              "</body></request>";

                    var rtnstr = sendJK(str);
                    var xmldom = new XmlDocument();
                    var xmlOut = "";
                    xmlOut = rtnstr;
                    xmldom.LoadXml(xmlOut);
                    var errno = xmldom.GetElementsByTagName("code").Item(0).FirstChild.InnerText;
                    if (errno == "200")
                    {
                        var tran = DBVisitor.Connection.BeginTransaction();
                        try
                        {
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.AUTO00007, mxxx.Get("zzsqdh")), tran);
                            tran.Commit();
                        }
                        catch (Exception ex)
                        {
                            tran.Rollback();
                        }
                    }
                }
            }
        }
Example #7
0
        /// <summary>
        /// 注册获取交易安全校验码
        /// </summary>
        /// <param name="MAC"></param>
        /// <param name="key"></param>
        public int Signature(string MAC, ref string key, ref string Erro)
        {
            DataTable dt = DBVisitor.ExecuteTable($"select * from GY_REGISTERED where mac='{MAC}'");
            int       i  = 0;

            key = GetRandomString(12);
            if (dt.Rows.Count > 0)
            {
                i = DBVisitor.ExecuteNonQuery($"update GY_REGISTERED set KEY='{key}' where MAC='{MAC}'");
            }
            else
            {
                i = DBVisitor.ExecuteNonQuery($"insert into GY_REGISTERED(MAC,KEY) values('{MAC}','{key}')");
            }
            if (i > 0)
            {
                return(0);
            }
            else
            {
                Erro = "注册失败!";
                return(-1);
            }
        }
Example #8
0
        public override void ProcessMessage()
        {
            #region 手机网页退费
            if (InObject.TUIFEILX == "1")
            {
                ////////////////////////////////////////////请求参数////////////////////////////////////////////


                //服务器异步通知页面路径
                string notify_url = InObject.NOTIFYURL;
                //需http://格式的完整路径,不允许加?id=123这类自定义参数

                //卖家支付宝帐户
                string seller_email = Common.Alipay.Config.Seller_email;
                //必填

                if (string.IsNullOrEmpty(InObject.REFUNDDATA))
                {
                    throw new Exception("退款请求时间不能为空!");
                }

                try
                {
                    string dt = DateTime.Parse(InObject.REFUNDDATA).ToString("yyyy-MM-dd HH:mm:ss");
                }
                catch
                {
                    throw new Exception("退款时间格式不正确!");
                }
                //退款当天日期
                string refund_date = InObject.REFUNDDATA;
                //必填,格式:年[4位]-月[2位]-日[2位] 小时[2位 24小时制]:分[2位]:秒[2位],如:2007-10-01 13:13:13

                if (string.IsNullOrEmpty(InObject.BATCHNO))
                {
                    throw new Exception("批次号不能为空!");
                }
                //批次号
                string batch_no = InObject.BATCHNO;// WIDbatch_no.Text.Trim();
                //必填,格式:当天日期[8位]+序列号[3至24位],如:201008010000001

                if (string.IsNullOrEmpty(InObject.BATCHNUM))
                {
                    throw new Exception("退款笔数不能为空!");
                }
                //退款笔数
                string batch_num = InObject.BATCHNUM;
                //必填,参数detail_data的值中,“#”字符出现的数量加1,最大支持1000笔(即“#”字符出现的数量999个)

                //退款用trade_no 异步通知回调的时候你们可以拿到
                if (string.IsNullOrEmpty(InObject.DETAILDATA))
                {
                    throw new Exception("退款详细数据不能为空!");
                }
                //退款详细数据  结算时的trade_no
                string detail_data = InObject.DETAILDATA;// WIDdetail_data.Text.Trim();
                //必填,具体格式请参见接口技术文档


                ////////////////////////////////////////////////////////////////////////////////////////////////

                //把请求参数打包成数组
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "refund_fastpay_by_platform_pwd");
                sParaTemp.Add("notify_url", notify_url);
                sParaTemp.Add("seller_email", seller_email);
                sParaTemp.Add("refund_date", refund_date);
                sParaTemp.Add("batch_no", batch_no);
                sParaTemp.Add("batch_num", batch_num);
                sParaTemp.Add("detail_data", detail_data);

                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                OutObject           = new ZHIFUBAOTF_OUT();
                OutObject.TUIFEIURL = sHtmlText;
            }
            #endregion
            #region 商户代扣、二维码支付退费,两个方式一样
            else if (InObject.TUIFEILX == "2" || InObject.TUIFEILX == "3")
            {
                var listpbxx = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00002, InObject.WIDOUTTRADENO));
                if (listpbxx.Rows.Count <= 0)
                {
                    //if(string.IsNullOrEmpty(InObject.WIDTOTALFEE)&&)
                    throw new Exception("订单号为【" + InObject.WIDOUTTRADENO + "】的结算信息不存在!");
                }
                if (listpbxx.Rows[0]["JIESUANZT"].ToString() == "0")
                {
                    throw new Exception("订单【" + InObject.WIDOUTTRADENO + "】未支付!");
                }
                //-1支付失败 2未入账 3 退费成功 4 退费中 5 退费失败
                if (listpbxx.Rows[0]["JIESUANZT"].ToString() == "-1")
                {
                    throw new Exception("订单【" + InObject.WIDOUTTRADENO + "】支付未成功!");
                }
                //正记录的冲销标志=1代表 已经退费
                if (listpbxx.Rows[0]["CXBZ"].ToString() == "1")
                {
                    throw new Exception("订单【" + InObject.WIDOUTTRADENO + "】已退费!");
                }
                if (double.Parse(InObject.WIDTOTALFEE) != double.Parse(listpbxx.Rows[0]["ITOTALFEE"].ToString()))
                {
                    throw new Exception("传入的金额与结算的金额不一致!");
                }

                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "alipay.acquire.refund");
                sParaTemp.Add("out_trade_no", InObject.WIDOUTTRADENO);                    //out_trade_no	商户网站唯一订单号	String(64)	支付宝合作商户网站唯一订单号。	不可空	HZ0120131127001
                sParaTemp.Add("refund_amount", listpbxx.Rows[0]["ITOTALFEE"].ToString()); //refund_amount	退款金额	number(9,2)	退款金额不能大于订单金额,全额退款必须与订单金额一致。	不可空	200.00
                sParaTemp.Add("trade_no", listpbxx.Rows[0]["TRADENO"].ToString());        //trade_no	支付宝交易号	String(64)	该交易在支付宝系统中的交易流水号。最短16位,最长64位。如果同时传了out_trade_no和trade_no,则以trade_no为准。	可空	2013112611001004680073956707
                sParaTemp.Add("out_request_no", InObject.WIDOUTREQUESTNO);                //out_request_no	商户退款请求单号	String(64)	商户退款请求单号,用以标识本次交易的退款请求。如果不传入本参数,则以out_trade_no填充本参数的值。同时,认为本次请求为全额退款,要求退款金额和交易支付金额一致。	可空	HZ01RF001
                sParaTemp.Add("operator_id", InObject.BASEINFO.CAOZUOYDM);                //operator_id	操作员号	String(28)	卖家的操作员ID。	可空	OP001
                sParaTemp.Add("refund_reason", InObject.REFUNDREASON);                    //refund_reason	退款原因	String(128)	退款原因说明。	可空	正常退款
                sParaTemp.Add("key", "rfk3sw6dlq28k2tijjj54le6lfhw73s4");                 //取余杭卫生局的key
                //sParaTemp.Add("it_b_pay", InObject.OUTTIME);
                //ref_ids	业务关联ID集合	String(256)	业务关联ID集合,用于放置商户的退款单号、退款流水号等信息,json格式,具体请参见“4.3  业务关联ID集合说明”。	可空	[{"id_type":"orig_out_request_no","id":"HZ0001"},{"id_type":"orig_out_order_no","id":"HZ0001"}]



                string sHtmlText = Submit.BuildRequest(sParaTemp);
                OutObject = new ZHIFUBAOTF_OUT();
                XmlDocument xmlDoc = new XmlDocument();
                try
                {
                    xmlDoc.LoadXml(sHtmlText);
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode("alipay").ChildNodes;
                    foreach (XmlNode xn in nodeList)
                    {
                        //判断是否异常,如果返回异常 则抛出
                        //if (xn.Name == "is_success" && xn.InnerText == "F")
                        //{

                        //    throw new Exception("支付宝商户代扣失败!");
                        //}
                        if (xn.Name == "error")
                        {
                            throw new Exception(xn.InnerText);
                        }
                        if (xn.Name == "response")
                        {
                            XmlElement  xe      = (XmlElement)xn;
                            XmlNodeList subList = xe.ChildNodes;
                            foreach (XmlNode xmlNode in subList)
                            {
                                if (xmlNode.Name == "alipay")
                                {
                                    XmlElement  xemx      = (XmlElement)xmlNode;
                                    XmlNodeList submxList = xemx.ChildNodes;

                                    foreach (XmlNode mxnode in submxList)
                                    {
                                        if (mxnode.Name == "detail_error_code")
                                        {
                                            OutObject.ERRORCODE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "detail_error_des")
                                        {
                                            OutObject.ERRORDES = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "result_code")
                                        {
                                            OutObject.RESULTCODE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "trade_no")
                                        {
                                            OutObject.TRADENO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "out_trade_no")
                                        {
                                            OutObject.WIDOUTREQUESTNO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "buyer_user_id")
                                        {
                                            OutObject.BUYERUSERID = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "buyer_logon_id")
                                        {
                                            OutObject.BUYEREMAIL = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "fund_change")
                                        {
                                            OutObject.FUNDCHANGE = mxnode.InnerText;
                                        }

                                        if (mxnode.Name == "refund_fee")
                                        {
                                            OutObject.REFUNDFEE = mxnode.InnerText;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (OutObject.RESULTCODE.ToUpper() == "SUCCESS")
                    {
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00015, "T" + InObject.WIDOUTTRADENO, "3",
                                                                    InObject.BASEINFO.CAOZUOYXM, InObject.BASEINFO.CAOZUOYDM, InObject.WIDOUTTRADENO));
                        //更新付记录状态 退费成功
                        // DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set JIESUANZT='3' where IOUTTRADENO='{0}' ", InObject.WIDOUTREQUESTNO));
                        //更新正记录 冲销标志
                        DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set CXBZ='1' where IOUTTRADENO='{0}' ", InObject.WIDOUTTRADENO));
                    }
                }
                catch (Exception exp)
                {
                    throw new Exception(exp.Message.ToString());
                }
            }
            #endregion
            #region 支付宝中心多了结算数据,冲正
            else if (InObject.TUIFEILX == "4")
            {
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "alipay.acquire.refund");
                sParaTemp.Add("out_trade_no", InObject.WIDOUTTRADENO);     //out_trade_no	商户网站唯一订单号	String(64)	支付宝合作商户网站唯一订单号。	不可空	HZ0120131127001
                sParaTemp.Add("refund_amount", InObject.WIDTOTALFEE);      //refund_amount	退款金额	number(9,2)	退款金额不能大于订单金额,全额退款必须与订单金额一致。	不可空	200.00
                sParaTemp.Add("trade_no", InObject.TRADENO);               //trade_no	支付宝交易号	String(64)	该交易在支付宝系统中的交易流水号。最短16位,最长64位。如果同时传了out_trade_no和trade_no,则以trade_no为准。	可空	2013112611001004680073956707
                sParaTemp.Add("out_request_no", InObject.WIDOUTREQUESTNO); //out_request_no	商户退款请求单号	String(64)	商户退款请求单号,用以标识本次交易的退款请求。如果不传入本参数,则以out_trade_no填充本参数的值。同时,认为本次请求为全额退款,要求退款金额和交易支付金额一致。	可空	HZ01RF001
                sParaTemp.Add("operator_id", InObject.BASEINFO.CAOZUOYDM); //operator_id	操作员号	String(28)	卖家的操作员ID。	可空	OP001
                sParaTemp.Add("refund_reason", InObject.REFUNDREASON);     //refund_reason	退款原因	String(128)	退款原因说明。	可空	正常退款
                sParaTemp.Add("key", "rfk3sw6dlq28k2tijjj54le6lfhw73s4");  //取余杭卫生局的key

                string sHtmlText = Submit.BuildRequest(sParaTemp);
                OutObject = new ZHIFUBAOTF_OUT();
                XmlDocument xmlDoc = new XmlDocument();
                try
                {
                    xmlDoc.LoadXml(sHtmlText);
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode("alipay").ChildNodes;
                    foreach (XmlNode xn in nodeList)
                    {
                        if (xn.Name == "error")
                        {
                            throw new Exception(xn.InnerText);
                        }
                        if (xn.Name == "response")
                        {
                            XmlElement  xe      = (XmlElement)xn;
                            XmlNodeList subList = xe.ChildNodes;
                            foreach (XmlNode xmlNode in subList)
                            {
                                if (xmlNode.Name == "alipay")
                                {
                                    XmlElement  xemx      = (XmlElement)xmlNode;
                                    XmlNodeList submxList = xemx.ChildNodes;

                                    foreach (XmlNode mxnode in submxList)
                                    {
                                        if (mxnode.Name == "detail_error_code")
                                        {
                                            OutObject.ERRORCODE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "detail_error_des")
                                        {
                                            OutObject.ERRORDES = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "result_code")
                                        {
                                            OutObject.RESULTCODE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "trade_no")
                                        {
                                            OutObject.TRADENO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "out_trade_no")
                                        {
                                            OutObject.WIDOUTREQUESTNO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "buyer_user_id")
                                        {
                                            OutObject.BUYERUSERID = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "buyer_logon_id")
                                        {
                                            OutObject.BUYEREMAIL = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "fund_change")
                                        {
                                            OutObject.FUNDCHANGE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "refund_fee")
                                        {
                                            OutObject.REFUNDFEE = mxnode.InnerText;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //if (OutObject.RESULTCODE.ToUpper() == "SUCCESS")
                    //{
                    //    DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00015, InObject.WIDOUTREQUESTNO, "3",
                    //               InObject.BASEINFO.CAOZUOYXM, InObject.BASEINFO.CAOZUOYDM, InObject.WIDOUTTRADENO));
                    //    //更新付记录状态 退费成功
                    //    // DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set JIESUANZT='3' where IOUTTRADENO='{0}' ", InObject.WIDOUTREQUESTNO));
                    //    //更新正记录 冲销标志
                    //    DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set CXBZ='1' where IOUTTRADENO='{0}' ", InObject.WIDOUTTRADENO));

                    //}
                }
                catch (Exception exp)
                {
                    throw new Exception(exp.Message.ToString());
                }
            }
            #endregion
            else
            {
                throw new Exception("退费类型不正确!");
            }
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                Notify aliNotify = new Notify();
                HIS4.Biz.LogUnit.Write("notify_id:" + Request.Form["notify_id"], "NotifyUrl");
                HIS4.Biz.LogUnit.Write("sign" + Request.Form["sign"], "NotifyUrl");

                bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);
                // if (verifyResult)//验证成功
                if (true)
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码

                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                    //商户订单号
                    string out_trade_no = Request.Form["out_trade_no"];
                    HIS4.Biz.LogUnit.Write("out_trade_no:" + Request.Form["out_trade_no"], "NotifyUrl");

                    //支付宝交易号
                    string trade_no = Request.Form["trade_no"];
                    HIS4.Biz.LogUnit.Write("trade_no:" + Request.Form["trade_no"], "NotifyUrl");

                    //交易状态
                    string trade_status = Request.Form["trade_status"];
                    HIS4.Biz.LogUnit.Write("trade_status:" + Request.Form["trade_status"], "NotifyUrl");
                    //WAIT_BUYER_PAY	交易创建,等待买家付款。
                    //TRADE_CLOSED	在指定时间段内未支付时关闭的交易;
                    //在交易完成全额退款成功时关闭的交易。
                    //TRADE_SUCCESS	交易成功,且可对该交易做操作,如:多级分润、退款等。
                    //TRADE_PENDING	等待卖家收款(买家付款后,如果卖家账号被冻结)。
                    //TRADE_FINISHED	交易成功且结束,即不可再做任何操作

                    if (trade_status == "TRADE_SUCCESS")
                    {
                        //更新状态 未入账
                        DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set JIESUANZT='2',IBUYERID='{1}',IBUYEREMAIL='{2}' where IOUTTRADENO='{0}' ", out_trade_no, sPara["buyer_id"], sPara["buyer_email"]));
                    }
                    else
                    {
                        //更新状态 结算失败
                        DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set FAILERR='{0}',JIESUANZT='-1' ,IBUYERID='{1}',IBUYEREMAIL='{2}' where IOUTTRADENO='{3}' ", trade_status, sPara["buyer_id"], sPara["buyer_email"], Request.Form["trade_no"]));
                    }

                    //如果没有数据 修改返回状态
                    var listpbxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.HIS00002, out_trade_no));
                    if (listpbxx.Count <= 0)
                    {
                        trade_status = "NODATA";
                        return;
                    }
                    string HttpIndata = "notify_id=" + Request.Form["notify_id"] + "&" +
                                        "sign=" + Request.Form["sign"] + "&" +
                                        "out_trade_no=" + out_trade_no + "&" +
                                        "trade_no=" + trade_no + "&" +
                                        "trade_status=" + trade_status + "&" +
                                        "total_fee=" + Request.Form["total_fee"];
                    HIS4.Biz.LogUnit.Write("POSE入参:" + HttpIndata, "NotifyUrl");
                    //POST提交给请求断
                    string ret = PostWebRequest(listpbxx[0]["INOTIFYURL"].ToString(), HttpIndata);
                    HIS4.Biz.LogUnit.Write("POSE出参:" + ret, "NotifyUrl");
                    if (ret.ToLower() == "success") //处理成功
                    {                               //结算成功
                        DateTime dt = string.IsNullOrEmpty(Request.Form["gmt_payment"]) ? DateTime.Now : DateTime.Parse(Request.Form["gmt_payment"]);
                        DBVisitor.ExecuteNonQuery(
                            "update JR_ZHIFUBAOJSXX set JIESUANSJ=To_Date('{dt}','yyyy-mm-dd hh24:mi:ss'),JIESUANZT='1',TRADENO='{trade_no}' where IOUTTRADENO='{out_trade_no}' ");
                        Response.Write("success");  //请不要修改或删除
                    }
                    else
                    {
                        //更新状态 结算失败
                        DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set FAILERR='{0}' where IOUTTRADENO='{1}' ", ret, out_trade_no));
                        Response.Write("success");//处理失败
                    }
                }
                else//验证失败
                {
                    DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set FAILERR='{0}',JIESUANZT='-1' where IOUTTRADENO='{1}' ", "验证失败", Request.Form["out_trade_no"]));
                    Response.Write("success");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
Example #10
0
        public override void ProcessMessage()
        {
            //取得预约信息
            OutObject = new SHEBEIYYQX_OUT();
            if (InObject.YUYUESQDBH == null || InObject.YUYUESQDBH == "")
            {
                throw new Exception(string.Format("预约申请单编号为空!"));
            }
            var listyyxx = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00004, InObject.YUYUESQDBH.ToString()));

            if (listyyxx == null)
            {
                OutObject.OUTMSG.ERRNO  = "-2";
                OutObject.OUTMSG.ERRMSG = string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString());
                return;
                //throw new Exception(string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString()));
            }
            if (listyyxx.Items.Count == 0)
            {
                OutObject.OUTMSG.ERRNO  = "-2";
                OutObject.OUTMSG.ERRMSG = string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString());
                return;
                //throw new Exception(string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString()));
            }

            if (System.Configuration.ConfigurationManager.AppSettings["JianChaJKMS"] == "1")
            {
                var resource = new HISYY_Cancel();
                resource.RequestNo = listyyxx.Items["YYH"].ToString();
                resource.YYH       = "";
                resource.JCH       = "";
                string url = System.Configuration.ConfigurationManager.AppSettings["LAIDAURL"];
                string xml = XMLHandle.EntitytoXML <HISYY_Cancel>(resource);
                HISYY_Cancel_Result result = XMLHandle.XMLtoEntity <HISYY_Cancel_Result>(WSServer.Call <HISYY_GetResource>(url, xml).ToString());
                if (result.Success == "False")
                {
                    throw new Exception("取消预约失败,错误原因:" + result.Message);
                }
                var tran = DBVisitor.Connection.BeginTransaction();
                try
                {
                    DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00005, InObject.YUYUESQDBH.ToString(), 9), tran);
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
            }
            else
            {
                var listyyhxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.FSD00014, listyyxx.Items["JCSBDM"].ToString(), listyyxx.Items["JCRQ"].ToString(), listyyxx.Items["JCSJ"].ToString()));
                foreach (var item in listyyhxx)
                {
                    var listyyh = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00010, item.Get("yyhxx").ToString(), listyyxx.Items["YYH"].ToString()));
                    var zyyyys  = int.Parse(item.Get("zyyyys"));
                    var mzyyys  = int.Parse(item.Get("mzyyys"));
                    var sqyyys  = int.Parse(item.Get("sqyyys"));
                    var yyys    = int.Parse(item.Get("yyys"));
                    var yyly    = listyyxx.Items["YYLY"].ToString();
                    if (yyly == "3")
                    {
                        --sqyyys;
                    }
                    else if (yyly == "2")
                    {
                        --zyyyys;
                    }
                    else if (yyly == "1")
                    {
                        --mzyyys;
                    }
                    else
                    {
                        if (listyyxx.Items["BRLX"].ToString() == "2")
                        {
                            --zyyyys;
                        }
                    }

                    //if (listyyxx.Items["BRLX"].ToString() == "2")
                    //{
                    //    --zyyyys;
                    //}
                    if (listyyh == null)
                    {
                        continue;
                    }
                    if (listyyh.Items.Count > 0)
                    {
                        var tran = DBVisitor.Connection.BeginTransaction();
                        try
                        {
                            //更新预约信息状态为取消
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00005, InObject.YUYUESQDBH.ToString(), 9), tran);
                            //更新预约号状态
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00009, item.Get("yyhxx").ToString(), listyyxx.Items["YYH"], 0), tran);
                            //更新预约排班表
                            if (yyly == "3")
                            {
                                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00021, item.Get("yyhxx").ToString(), int.Parse(item.Get("yyys")) - 1, sqyyys), tran);
                            }
                            else if (yyly == "2")
                            {
                                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00008, item.Get("yyhxx").ToString(), int.Parse(item.Get("yyys")) - 1, zyyyys), tran);
                            }
                            else if (yyly == "1")
                            {
                                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00020, item.Get("yyhxx").ToString(), int.Parse(item.Get("yyys")) - 1, mzyyys), tran);
                            }
                            else
                            {
                                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00008, item.Get("yyhxx").ToString(), int.Parse(item.Get("yyys")) - 1, zyyyys), tran);
                            }
                            tran.Commit();
                        }
                        catch (Exception ex)
                        {
                            tran.Rollback();
                            throw ex;
                        }
                    }
                }
            }
        }
Example #11
0
        public override void ProcessMessage()
        {
            if (InObject.YUYUERQ == null)
            {
                throw new Exception(string.Format("预约日期不能为空!"));
            }
            if (InObject.YUYUESJ == null)
            {
                throw new Exception(string.Format("预约时间不能为空!"));
            }
            //if (InObject.JIANCHAXMDM == null || InObject.JIANCHAXMDM == "")
            //{
            //    throw new Exception(string.Format("检查项目不能为空!"));
            //}
            if (InObject.BINGRENLX == null || InObject.BINGRENLX < 1 || InObject.BINGRENLX > 3)
            {
                throw new Exception(string.Format("病人类型代码不对!"));
            }
            if (InObject.YEWULY == null)
            {
                InObject.YEWULY = InObject.BINGRENLX.ToString();
            }
            var jcsbdm = InObject.JIANCHASBDM.ToString();
            var yyrq   = InObject.YUYUERQ.ToString();
            var yysj   = InObject.YUYUESJ.ToString();
            var yyh    = "";

            //不能预约以前的日期
            if (string.Compare(yyrq, DateTime.Now.ToString("yyyy-MM-dd")) < 0)
            {
                throw new Exception(string.Format("预约日期必须大于等于今天!"));
            }

            if (System.Configuration.ConfigurationManager.AppSettings["JianChaJKMS"] == "1")
            {
                HISYY_Submit resource = new HISYY_Submit();
                var          yysqdbh  = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00018)).Items["YYSQDBH"].ToString();
                //检查
                if (InObject.YEWULY == "1")
                {
                    #region 调用包,判断入参是否正确
                    var jyjcdxx = "";
                    var jyjcmx  = "";
                    var zdmx    = "";
                    var jcxmdm  = "";
                    int i       = 0;
                    if (InObject.JIANCHALB.Count < 1)
                    {
                        throw new Exception(string.Format("检查项目不能为空!"));
                    }
                    #region 检查单信息
                    jyjcdxx += InObject.JIUZHENKLX + "|";                       //	就诊卡类型
                    jyjcdxx += InObject.JIUZHENKH + "|";                        //	就诊卡号
                    jyjcdxx += InObject.SHENQINGYSGH + "|";                     //	送检医生
                    jyjcdxx += InObject.SHENQINGYYDM + "|";                     //	送检科室
                    jyjcdxx += InObject.YUYUESF + "|";                          //	收费识别
                    jyjcdxx += InObject.BINGQINGMS + "|";                       //	病情描述
                    jyjcdxx += InObject.ZHENDUAN + "|";                         //	诊断
                    jyjcdxx += InObject.BINGRENTZ + "|";                        //	病人体征
                    jyjcdxx += InObject.QITAJC + "|";                           //	其它检查
                    jyjcdxx += InObject.BINGRENZS + "|";                        //	病人主诉
                    jyjcdxx += InObject.YEWULY + "|";                           //	检查来源
                    jyjcdxx += InObject.BINGRENXM + "|";                        //	病人姓名
                    jyjcdxx += InObject.SHENFENZH + "|";                        //	病人身份证号
                    jyjcdxx += "0" + "|";                                       //	接收方式
                    jyjcdxx += "|";                                             //	检查申请单号
                    jyjcdxx += InObject.YUYUERQ + " " + InObject.YUYUESJ + "|"; //	检查日期
                    jyjcdxx += InObject.BINGRENXB + "|";                        //	病人性别
                    jyjcdxx += InObject.BINGRENNL;                              //	病人年龄
                    #endregion
                    #region 检验检查明细
                    foreach (var item in InObject.JIANCHALB)
                    {
                        if (i == 0)
                        {
                            jcxmdm = item.JIANCHAXMBH;
                        }
                        else
                        {
                            jcxmdm += "," + item.JIANCHAXMBH;
                        }
                        ++i;
                        jyjcmx += item.JIANCHAXMBH + "|"; //	检查项目编号
                        jyjcmx += item.JIANCHAXMMC + "|"; //	检查项目名称
                        jyjcmx += item.JIANCHAFLBM + "|"; //	检查分类编码
                        jyjcmx += item.JIANCHASTBW + "|"; //	检查身体部位
                        jyjcmx += item.JIANCHAFXDM + "|"; //	检查方向代码
                        jyjcmx += item.JIANCHAZYDM + "|"; //	检查肢位代码
                        jyjcmx += item.JIANCHATS + "^";   //	检查提示
                    }
                    #endregion
                    #region 疾病明细
                    foreach (var item in InObject.ZHENDUANLB)
                    {
                        zdmx += item.ICD10 + "|";      //	ICD10
                        zdmx += item.ZHENDUANMC + "^"; //	诊断名称
                    }
                    #endregion
                    #region 调用包
                    var jianchakd = SqlLoad.GetProcedure(SQ.P_FSD00030);
                    jianchakd["ywlx"]    = 1;
                    jianchakd["jyjcdxx"] = jyjcdxx;
                    jianchakd["jyjcmx"]  = jyjcmx;
                    jianchakd["zdmx"]    = zdmx;
                    jianchakd["jylx"]    = 1;
                    jianchakd["errno"]   = -1;
                    jianchakd["errmsg"]  = string.Empty.PadRight(1024);
                    jianchakd["outdata"] = string.Empty.PadRight(1024);
                    DBVisitor.ExecuteProcedure(jianchakd);

                    if (jianchakd["errno"].ToString() != "0")
                    {
                        throw new Exception("更新库存失败:" + jianchakd["errmsg"]);
                    }
                    #endregion
                    #endregion

                    if (InObject.YEWULX == "2")
                    {
                        resource.AdmissionSource = "10";
                    }
                    else
                    {
                        resource.AdmissionSource = "50";
                    }
                    resource.HospitalCode = InObject.BASEINFO.JIGOUDM;
                    resource.HospitalName = "余杭三院";
                    resource.PatientName  = InObject.BINGRENXM;
                    resource.IdNumber     = InObject.SHENFENZH;
                    resource.RequestNo    = yysqdbh;
                    if (InObject.YEWULY == "2")
                    {
                        resource.AdmissionID = InObject.BINGRENZYH;
                    }
                    else
                    {
                        resource.AdmissionID = InObject.BINGRENMZH;
                    }
                    resource.ExaminePartTime   = InObject.XIANGMUHS;
                    resource.PatientSex        = InObject.BINGRENXB.ToString();
                    resource.PatientBorn       = InObject.BINGRENCSRQ;
                    resource.PatientAge        = InObject.BINGRENNL;
                    resource.PatientTel        = InObject.BINGRENLXDH;
                    resource.PatientAddress    = InObject.BINGRENLXDZ;
                    resource.PatientCard       = InObject.BINGRENKH;
                    resource.InPatientAreaName = InObject.BINGRENBQMC;
                    resource.InPatientAreaCode = InObject.BINGRENBQDM;
                    resource.BedNum            = InObject.BINGRENCWH;
                    resource.DeviceCode        = InObject.JIANCHASBDM.ToString();
                    resource.DeviceName        = InObject.JIANCHASBMC;
                    var codes = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.FSD00027, jcxmdm));
                    foreach (var code in codes)
                    {
                        resource.StudiesExamine.Add(new StudiesExamine()
                        {
                            ExamineCode  = code["LBXH"].ToString(),
                            ExamineName  = Unity.encodeString(code["LBMC"].ToString()),
                            Numbers      = "1",
                            ExaminePrice = DBVisitor.ExecuteScalar(SqlLoad.GetFormat(SQ.FSD00029, code["LBXH"].ToString())).ToString()
                        });
                    }
                    resource.ExamineFY  = resource.StudiesExamine.Sum <StudiesExamine>(group => { return(Convert.ToDecimal(group.ExaminePrice)); }).ToString();
                    resource.ReceiptNum = InObject.BINGRENFPH;
                    codes = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.FSD00027, jcxmdm));
                    resource.ZxDepartmentId   = codes[0]["JCKS"].ToString();
                    resource.ZxDepartmentName = codes[0]["KSMC"].ToString();
                    resource.Sqrq             = InObject.BASEINFO.CAOZUORQ;
                    resource.BespeakDateTime  = InObject.YUYUERQ + " " + InObject.YUYUESJ;
                    resource.JZ = "0"; // InObject.JIZHEN;
                    resource.ZQ = "0"; //InObject.ZENGQIANG;
                    resource.LS = "0"; //InObject.LINSHI;
                    resource.PF = "1";

                    ///调用WEBSERVICE
                    string url = System.Configuration.ConfigurationManager.AppSettings["LAIDAURL"];
                    string xml = XMLHandle.EntitytoXML <HISYY_Submit>(resource);
                    HISYY_Submit_Result result = XMLHandle.XMLtoEntity <HISYY_Submit_Result>(WSServer.Call <HISYY_Submit>(url, xml).ToString());

                    if (result.Success == "False")
                    {
                        throw new Exception("预约失败,错误原因:" + result.Message);
                    }

                    var tran = DBVisitor.Connection.BeginTransaction();
                    try
                    {
                        #region 先插入到临时表
                        var ID     = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00024, " seq_sxzz_jianchad.nextval "));
                        var xh     = "";
                        var JCSQDH = result.JCH;
                        int k      = 0;
                        if (ID == null)
                        {
                            throw new Exception(string.Format("检查单序列获取失败!"));
                        }
                        else
                        {
                            xh = ID.Items["MAXID"].ToString();
                        }
                        //var SQDH = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00023, " SEQ_GY_YXSQD_SQDH.NEXTVAL "));
                        //if (SQDH == null)
                        //{
                        //    throw new Exception(string.Format("申请单号获取失败!"));
                        //}
                        //else
                        //{
                        //    JCSQDH = SQDH.Items["MAXID"].ToString();
                        //}
                        //插入检查单信息
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00022,
                                                                    xh, "", InObject.BINGRENMZH, InObject.BINGRENXM,
                                                                    InObject.SHENFENZH, InObject.SHENQINGYSGH, InObject.JIANCHAKSDM, 0,
                                                                    InObject.BINGQINGMS, InObject.ZHENDUAN, InObject.BINGRENTZ, InObject.QITAJC,
                                                                    InObject.BINGRENZS, InObject.YEWULX, 0, JCSQDH, InObject.YUYUERQ,
                                                                    InObject.BINGRENXB, InObject.BINGRENNL), tran);
                        //插入检查明细
                        foreach (var item in InObject.JIANCHALB)
                        {
                            ++k;
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00023,
                                                                        xh, k, item.JIANCHAXMBH,
                                                                        item.JIANCHAXMMC, item.JIANCHAFLBM, item.JIANCHASTBW,
                                                                        item.JIANCHAFXDM, item.JIANCHAZYDM, item.JIANCHATS), tran);
                        }
                        k = 0;
                        //插入诊断明细
                        foreach (var item in InObject.ZHENDUANLB)
                        {
                            ++k;
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00025,
                                                                        xh, k, item.ICD10, item.ZHENDUANMC), tran);
                        }


                        #endregion

                        var listyylsh = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00017));
                        var yysqlsh   = listyylsh.Items["YYSQLSH"].ToString();

                        //插入预约申请信息fdsyy_sq
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00011,
                                                                    "申请单",                 //预约申请单名称
                                                                    InObject.YUYUEZT,      //预约申请单状态(0未确认,1已确认,9作废)
                                                                    InObject.JIANCHAKSDM,  //检查科室代码
                                                                    InObject.JIANCHAKSMC,  //检查科室名称
                                                                    InObject.BINGRENFPH,   //病人发票号
                                                                    InObject.BINGRENLX,    //病人类型
                                                                    InObject.BINGRENLXMC,  //病人类型名称
                                                                    InObject.BINGRENKH,    //病人卡号
                                                                    InObject.BINGRENMZH,   //病人门诊号
                                                                    InObject.BINGRENZYH,   //病人住院号
                                                                    InObject.BINGRENBQDM,  //病人病区代码
                                                                    InObject.BINGRENBQMC,  //病人病区名称
                                                                    InObject.BINGRENCWH,   //病人床位号
                                                                    InObject.BINGRENXM,    //病人姓名
                                                                    InObject.BINGRENXB,    //病人性别
                                                                    InObject.BINGRENNL,    //病人年龄
                                                                    InObject.BINGRENCSRQ,  //病人出生日期
                                                                    InObject.BINGRENLXDZ,  //病人联系地址
                                                                    InObject.BINGRENLXDH,  //病人联系电话
                                                                    InObject.SHENQINGYSGH, //申请医生工号
                                                                    InObject.SHENQINGYSMC, //申请医生姓名
                                                                    "",                    //申请科室代码
                                                                    "",                    //申请科室名称
                                                                    InObject.SHENQINGYYDM, //申请医院代码
                                                                    InObject.SHENQINGYYMC, //申请医院名称
                                                                    result.JCH,            //检查号
                                                                    InObject.YUYUERQ,      //检查日期
                                                                    InObject.YUYUESJ,      //检查时间

                                                                    jcxmdm,                //InObject.JIANCHAXMDM,//检查项目代码
                                                                    InObject.JIANCHAXMMC,  //检查项目名称

                                                                    InObject.JIANCHAXMLX,  //检查项目类型
                                                                    InObject.JIANCHABWDM,  //检查部位代码
                                                                    InObject.JIANCHABWMC,  //检查部位名称
                                                                    InObject.JIANCHASBDM,  //检查设备代码
                                                                    InObject.JIANCHASBMC,  //检查设备名称
                                                                    InObject.JIANCHASBDD,  //检查设备地点
                                                                    result.YYH,            //预约号
                                                                    InObject.SHENFENZH,    //身份证号
                                                                    InObject.YUYUESF,      //预约收费(0未收费,1已收费)
                                                                    InObject.JIANCHASQDBH, //检查申请单编号
                                                                    InObject.YINGXIANGFX,
                                                                    "",                    //影像方向
                                                                    yysqlsh,               //预约申请流水号
                                                                    yysqdbh,               //预约申请单编号
                                                                    InObject.XIANGMUHS,    //详细安排时间
                                                                    InObject.YEWULY,
                                                                    InObject.YEWULX,
                                                                    InObject.ZENGQIANG,
                                                                    InObject.JIZHEN,
                                                                    InObject.LINSHI
                                                                    ), tran);//业务来源
                        tran.Commit();

                        OutObject            = new SHEBEIYY_OUT();
                        OutObject.YUYUERQ    = InObject.YUYUERQ;
                        OutObject.YUYUESJ    = InObject.YUYUESJ;
                        OutObject.YUYUEH     = result.YYH;
                        OutObject.JIANCHAH   = result.JCH;
                        OutObject.YUYUESQDBH = yysqdbh;
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        throw ex;
                    }
                }
                //检验
                else
                {
                }
            }
            else
            {
                #region 市二
                if (InObject.JIANCHAXMDM == null || InObject.JIANCHAXMDM == "")
                {
                    throw new Exception(string.Format("检查项目不能为空!"));
                }
                var listjcsb = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00007, jcsbdm));
                if (listjcsb == null)
                {
                    throw new Exception(string.Format("未找到预约设备:设备编号[{0}]", jcsbdm));
                }
                if (listjcsb.Items.Count == 0)//判断有无该设备
                {
                    throw new Exception(string.Format("未找到预约设备:设备编号[{0}]", jcsbdm));
                }
                else
                {
                    if (listjcsb.Items["JCSBZT"].ToString() != "0")//设备是否可用
                    {
                        throw new Exception(string.Format("预约设备故障或者已停用:设备编号[{0}]", jcsbdm));
                    }
                    else
                    {
                        if (listjcsb.Items["SBYYBZ"].ToString() != "0")//设备是否可预约
                        {
                            throw new Exception(string.Format("预约设备为不可预约状态:设备编号[{0}]", jcsbdm));
                        }
                        else
                        {
                            //获取设备某天预约排班信息
                            var listsbyyxx = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00002, jcsbdm, yyrq, yysj, 0));
                            if (listsbyyxx == null)
                            {
                                throw new Exception(string.Format("未找到预约号信息!"));
                            }
                            //取得预约类型,再去取预约号及状态
                            var jcyylx = int.Parse(listsbyyxx.Items["JCYYLX"].ToString());
                            var yyhxx  = int.Parse(listsbyyxx.Items["YYHXX"].ToString());
                            var yyzs   = int.Parse(listsbyyxx.Items["YYZS"].ToString());
                            var kyys   = int.Parse(listsbyyxx.Items["KYYS"].ToString());
                            var xcyls  = int.Parse(listsbyyxx.Items["XCYLS"].ToString());
                            var yyys   = int.Parse(listsbyyxx.Items["YYYS"].ToString());
                            int xcyy   = 0;//现场预约值为2,则检索所有数据
                            var zykyys = int.Parse(listsbyyxx.Items["ZYKYYS"].ToString());
                            var zyyyys = int.Parse(listsbyyxx.Items["ZYYYYS"].ToString());
                            var mzkyys = int.Parse(listsbyyxx.Items["MZKYYS"].ToString());
                            var mzyyys = int.Parse(listsbyyxx.Items["MZYYYS"].ToString());
                            var sqkyys = int.Parse(listsbyyxx.Items["SQKYYS"].ToString());
                            var sqyyys = int.Parse(listsbyyxx.Items["SQYYYS"].ToString());
                            var tran   = DBVisitor.Connection.BeginTransaction();
                            var yysjd  = listsbyyxx.Items["KSSJ"].ToString() + "-" + listsbyyxx.Items["JSSJ"].ToString();
                            if (string.Compare(listsbyyxx.Items["PBRQ"].ToString(), DateTime.Now.ToString("yyyy-MM-dd")) == 0)
                            {
                                xcyy = 2;
                            }
                            if (xcyy == 0)//非现场预约,则判断门诊住院预约的比例值
                            {
                                if (InObject.BINGRENLX == 2)
                                {
                                    if (InObject.YEWULY == "3")
                                    {
                                        if (sqkyys <= sqyyys)
                                        {
                                            throw new Exception(string.Format("当前社区可预约数已预约完,不能再预约!"));
                                        }
                                        ++sqyyys;
                                    }
                                    else
                                    {
                                        if (zykyys <= zyyyys)
                                        {
                                            throw new Exception(string.Format("当前住院可预约数已预约完,不能再预约!"));
                                        }
                                        ++zyyyys;
                                    }
                                }
                                else
                                {
                                    if (InObject.YEWULY == "3")
                                    {
                                        if (sqkyys <= sqyyys)
                                        {
                                            throw new Exception(string.Format("当前社区可预约数已预约完,不能再预约!"));
                                        }
                                        ++sqyyys;
                                    }
                                    else
                                    {
                                        if (mzkyys <= mzyyys)
                                        {
                                            throw new Exception(string.Format("当前门诊可预约数已预约完,不能再预约!"));
                                        }
                                        ++mzyyys;
                                    }
                                }
                            }
                            if (jcyylx == 1)//有预约号模式
                            {
                                if (InObject.YUYUEH == null || InObject.YUYUEH == "")
                                {
                                    throw new Exception(string.Format("预约号不能为空!"));
                                }
                                yyh = InObject.YUYUEH.ToString();
                                var listsbyyhxx = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00010, yyhxx, yyh));
                                if (listsbyyhxx == null)
                                {
                                    throw new Exception(string.Format("未找到预约号:预约号:[{0}]!", yyh));
                                }
                                if (listsbyyhxx.Items["YYZT"].ToString() == "1")
                                {
                                    throw new Exception(string.Format("该预约号已被预约:预约号:[{0}]!", yyh));
                                }
                                else
                                {
                                    try
                                    {
                                        if (InObject.YEWULY == "3")
                                        {
                                            //更新预约排班表 社区
                                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00021, yyhxx, yyys + 1, sqyyys), tran);
                                        }
                                        else if (InObject.BINGRENLX == 2)
                                        {
                                            //更新预约排班表 住院
                                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00008, yyhxx, yyys + 1, zyyyys), tran);
                                        }
                                        else
                                        {
                                            //更新预约排班表 门诊
                                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00020, yyhxx, yyys + 1, mzyyys), tran);
                                        }
                                        //更新预约排班表
                                        //DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00008, yyhxx, yyys + 1, zyyyys), tran);
                                        //更新预约号状态
                                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00009, yyhxx, yyh, 1), tran);
                                        //tran.Commit();
                                    }
                                    catch (Exception ex)
                                    {
                                        tran.Rollback();
                                        throw ex;
                                    }
                                }
                            }
                            else//无预约号模式
                            {
                                try
                                {
                                    //取得当前预约信息未预约的最小号码
                                    var listsbyyhxx = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00013, yyhxx, xcyy));
                                    if (listsbyyhxx == null)
                                    {
                                        throw new Exception(string.Format("预约已满!"));
                                    }
                                    yyh = listsbyyhxx.Items["YYH"].ToString();
                                    if (InObject.YEWULY == "3")
                                    {
                                        //更新预约排班表 社区
                                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00021, yyhxx, yyys + 1, sqyyys), tran);
                                    }
                                    else if (InObject.BINGRENLX == 2)
                                    {
                                        //更新预约排班表 住院
                                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00008, yyhxx, yyys + 1, zyyyys), tran);
                                    }
                                    else
                                    {
                                        //更新预约排班表 门诊
                                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00020, yyhxx, yyys + 1, mzyyys), tran);
                                    }
                                    //更新预约排班表
                                    //DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00008, yyhxx, yyys + 1, zyyyys), tran);
                                    //更新预约号状态
                                    DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00009, yyhxx, yyh, 1), tran);
                                    //tran.Commit();
                                }
                                catch (Exception ex)
                                {
                                    tran.Rollback();
                                    throw ex;
                                }
                            }
                            try
                            {
                                var listyylsh   = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00017));
                                var yysqlsh     = listyylsh.Items["YYSQLSH"].ToString();
                                var listyysqdbh = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00018));
                                var yysqdbh     = listyysqdbh.Items["YYSQDBH"].ToString();
                                //插入预约申请信息fdsyy_sq
                                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00011,
                                                                            "申请单",                 //预约申请单名称
                                                                            InObject.YUYUEZT,      //预约申请单状态(0未确认,1已确认,9作废)
                                                                            InObject.JIANCHAKSDM,  //检查科室代码
                                                                            InObject.JIANCHAKSMC,  //检查科室名称
                                                                            InObject.BINGRENFPH,   //病人发票号
                                                                            InObject.BINGRENLX,    //病人类型
                                                                            InObject.BINGRENLXMC,  //病人类型名称
                                                                            InObject.BINGRENKH,    //病人卡号
                                                                            InObject.BINGRENMZH,   //病人门诊号
                                                                            InObject.BINGRENZYH,   //病人住院号
                                                                            InObject.BINGRENBQDM,  //病人病区代码
                                                                            InObject.BINGRENBQMC,  //病人病区名称
                                                                            InObject.BINGRENCWH,   //病人床位号
                                                                            InObject.BINGRENXM,    //病人姓名
                                                                            InObject.BINGRENXB,    //病人性别
                                                                            InObject.BINGRENNL,    //病人年龄
                                                                            InObject.BINGRENCSRQ,  //病人出生日期
                                                                            InObject.BINGRENLXDZ,  //病人联系地址
                                                                            InObject.BINGRENLXDH,  //病人联系电话
                                                                            InObject.SHENQINGYSGH, //申请医生工号
                                                                            InObject.SHENQINGYSMC, //申请医生姓名
                                                                            "",                    //申请科室代码
                                                                            "",                    //申请科室名称
                                                                            InObject.SHENQINGYYDM, //申请医院代码
                                                                            InObject.SHENQINGYYMC, //申请医院名称
                                                                            "",                    //检查号
                                                                            InObject.YUYUERQ,      //检查日期
                                                                            InObject.YUYUESJ,      //检查时间
                                                                            InObject.JIANCHAXMDM,  //检查项目代码
                                                                            InObject.JIANCHAXMMC,  //检查项目名称
                                                                            InObject.JIANCHAXMLX,  //检查项目类型
                                                                            InObject.JIANCHABWDM,  //检查部位代码
                                                                            InObject.JIANCHABWMC,  //检查部位名称
                                                                            InObject.JIANCHASBDM,  //检查设备代码
                                                                            InObject.JIANCHASBMC,  //检查设备名称
                                                                            InObject.JIANCHASBDD,  //检查设备地点
                                                                            yyh,                   //预约号
                                                                            InObject.SHENFENZH,    //身份证号
                                                                            InObject.YUYUESF,      //预约收费(0未收费,1已收费)
                                                                            InObject.JIANCHASQDBH, //检查申请单编号
                                                                            InObject.YINGXIANGFX,
                                                                            yysjd,                 //影像方向
                                                                            yysqlsh,               //预约申请流水号
                                                                            yysqdbh,               //预约申请单编号
                                                                            InObject.XIANGXIAPSJ,  //详细安排时间
                                                                            InObject.YEWULY,
                                                                            1,
                                                                            0,
                                                                            0,
                                                                            0), tran);//业务来源
                                tran.Commit();
                                OutObject            = new SHEBEIYY_OUT();
                                OutObject.YUYUERQ    = yyrq;
                                OutObject.YUYUESJ    = yysj;
                                OutObject.YUYUEH     = yyh;
                                OutObject.YUYUESQDBH = yysqdbh;
                            }
                            catch (Exception ex)
                            {
                                tran.Rollback();
                                throw ex;
                            }
                        }
                    }
                }
                #endregion
            }
        }
Example #12
0
        public override void ProcessMessage()
        {
            string  jiuZhenKH    = InObject.JIUZHENKH;                     //就诊卡号
            string  bingAnHao    = InObject.BINGANHAO;                     //病案号
            string  caoZuoGH     = InObject.BASEINFO.CAOZUOYDM;            //操作员工号
            string  jiaoYiSJ     = InObject.BASEINFO.CAOZUORQ;             //交易时间
            string  jiaoYiFS     = InObject.JIAOYIFS;                      //交易方式
            string  jiaoYiLX     = InObject.JIAOYILX;                      //交易类型
            string  shangHuH     = InObject.SHANGHUH;                      //商户号
            string  zhongDuanH   = InObject.ZHONGDUANH;                    //终端号
            string  yinHangKH    = InObject.YINHANGKH;                     //银行卡号
            string  jiaoYiPCH    = InObject.JIAOYIPCH;                     //交易批次号
            string  jiaoYiLSH    = InObject.JIAOYILSH;                     //交易流水号
            string  jiaoYiCKH    = InObject.JIAOYICKH;                     //交易参考号
            string  dingDanH     = InObject.DINGDANH;                      //订单号
            string  jiaoYiJE     = InObject.JIAOYIJE;                      //交易金额
            decimal zhiBi100     = Convert.ToDecimal(InObject.ZHIBIZS100); //100元纸币张数
            decimal zhiBi50      = Convert.ToDecimal(InObject.ZHIBIZS50);  //50元纸币张数
            decimal zhiBi20      = Convert.ToDecimal(InObject.ZHIBIZS20);  //20元纸币张数
            decimal zhiBi10      = Convert.ToDecimal(InObject.ZHIBIZS10);  //10元纸币张数
            decimal zhiBi5       = Convert.ToDecimal(InObject.ZHIBIZS5);   //5元纸币张数
            decimal zhiBi1       = Convert.ToDecimal(InObject.ZHIBIZS1);   //1元纸币张数
            string  jiaoYiZT     = InObject.JIAOYIZT;                      //交易状态
            string  GUANLIANJYID = InObject.GUANLIANJYID;                  //关联交易ID

            OutObject = new JINRONGJYRZ_OUT();

            #region 基础入参判断
            if (string.IsNullOrEmpty(jiaoYiZT))
            {
                jiaoYiZT = "1";
            }

            if (string.IsNullOrEmpty(jiuZhenKH) && string.IsNullOrEmpty(bingAnHao))
            {
                throw new Exception("就诊卡号和病案号不能同时为空!");
            }

            if (string.IsNullOrEmpty(caoZuoGH))
            {
                throw new Exception("操作工号不能为空!");
            }

            if (string.IsNullOrEmpty(jiaoYiSJ))
            {
                throw new Exception("交易时间不能为空!");
            }

            if (string.IsNullOrEmpty(jiaoYiFS))
            {
                throw new Exception("交易方式不能为空!");
            }

            if (string.IsNullOrEmpty(jiaoYiLX))
            {
                throw new Exception("交易类型不能为空!");
            }
            else if (true)
            {//交易类型和法值判断
            }

            if (string.IsNullOrEmpty(jiaoYiJE))
            {
                throw new Exception("交易金额不能为空!");
            }


            switch (jiaoYiLX)
            {
            case "1":    //现金

                if (zhiBi100 == 0 && zhiBi50 == 0 && zhiBi20 == 0 && zhiBi10 == 0 && zhiBi5 == 0 && zhiBi1 == 0)
                {
                    throw new Exception("投币数量不能为0!");
                }
                break;

            case "10":
            case "4":    //银行卡
                if (string.IsNullOrEmpty(yinHangKH))
                {
                    throw new Exception("银行卡号不能为空!");
                }
                if (string.IsNullOrEmpty(jiaoYiLSH))
                {
                    throw new Exception("交易流水号不能为空!");
                }
                if (string.IsNullOrEmpty(jiaoYiCKH))
                {
                    throw new Exception("交易参考号不能为空!");
                }
                break;

            case "23":    //智慧医疗

                if (string.IsNullOrEmpty(jiaoYiLSH))
                {
                    throw new Exception("交易流水号不能为空!");
                }
                if (string.IsNullOrEmpty(jiaoYiCKH))
                {
                    throw new Exception("交易参考号不能为空!");
                }
                break;

            case "16":    //支付宝

                if (string.IsNullOrEmpty(shangHuH))
                {
                    throw new Exception("商户号不能为空!");
                }
                if (string.IsNullOrEmpty(dingDanH))
                {
                    throw new Exception("订单号不能为空!");
                }
                break;

            case "17":    //微信

                if (string.IsNullOrEmpty(shangHuH))
                {
                    throw new Exception("商户号不能为空!");
                }
                if (string.IsNullOrEmpty(dingDanH))
                {
                    throw new Exception("订单号不能为空!");
                }
                break;
            }
            #endregion


            #region sql语句准备,数据初始  sqi-291
            string jieSuanID = "";//结算id 取序列
            var    maxid     = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.HIS00023, " seq_gy_jinrongjy_zzj.nextval "));
            if (maxid == null)
            {
                throw new Exception(string.Format("结算ID获取失败!"));
            }
            else
            {
                jieSuanID = maxid.Items["MAXID"].ToString();
            }

            if (string.IsNullOrEmpty(GUANLIANJYID))
            {
                /* SQI-HIS00291 插入金融交易日志
                 * jiaoyiid,jiuzhenkh,jiaoyisj,caozuoygh,jiaoyilx,
                 * jiaoyifs,shanghuh,zhongduanh,yinhangkh,jiaoyipch,
                 * jiaoyilsh,jiaoyickh,dingdanh,jiaoyije,zhibizs100,
                 * zhibizs50,zhibizs20,zhibizs10,zhibizs5,zhibizs1,
                 * bingAnHao,jiaoYiZT
                 */
                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00024,
                                                            jieSuanID, jiuZhenKH, jiaoYiSJ, caoZuoGH, jiaoYiLX,
                                                            jiaoYiFS, shangHuH, zhongDuanH, yinHangKH, jiaoYiPCH,
                                                            jiaoYiLSH, jiaoYiCKH, dingDanH, jiaoYiJE, zhiBi100,
                                                            zhiBi50, zhiBi20, zhiBi10, zhiBi5, zhiBi1,
                                                            bingAnHao, jiaoYiZT));
            }
            else
            {
                /* SQI-HIS00291 插入金融交易日志 有关联记录
                 * jiaoyiid,jiuzhenkh,jiaoyisj,caozuoygh,jiaoyilx,
                 * jiaoyifs,shanghuh,zhongduanh,yinhangkh,jiaoyipch,
                 * jiaoyilsh,jiaoyickh,dingdanh,jiaoyije,zhibizs100,
                 * zhibizs50,zhibizs20,zhibizs10,zhibizs5,zhibizs1,
                 * bingAnHao,jiaoYiZT,guanlianjyid
                 */
                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00025,
                                                            jieSuanID, jiuZhenKH, jiaoYiSJ, caoZuoGH, jiaoYiLX,
                                                            jiaoYiFS, shangHuH, zhongDuanH, yinHangKH, jiaoYiPCH,
                                                            jiaoYiLSH, jiaoYiCKH, dingDanH, jiaoYiJE, zhiBi100,
                                                            zhiBi50, zhiBi20, zhiBi10, zhiBi5, zhiBi1,
                                                            bingAnHao, jiaoYiZT, GUANLIANJYID));
            }
            #endregion

            OutObject.JIAOYIID = jieSuanID;
        }
Example #13
0
        public override void ProcessMessage()
        {
            #region
            //本地下载
            if (InObject.XIAZAILX == "1")
            {
                if (string.IsNullOrEmpty(InObject.BASEINFO.FENYUANDM))
                {
                    throw new Exception("分院代码不能为空");
                }
                OutObject = new ZHIFUBAOJSMXXZ_OUT();
                //每页固定查询50条
                int star = 1 + (int.Parse(InObject.PAGENO) - 1) * 50;
                int end  = 50 + (int.Parse(InObject.PAGENO) - 1) * 50;
                //分页数据
                var Listxx = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00016, InObject.RIQI, end, star, InObject.BASEINFO.FENYUANDM));
                //数据总量
                var TotalTb = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00017, InObject.RIQI, InObject.BASEINFO.FENYUANDM));
                OutObject.PAGENO   = InObject.PAGENO;
                OutObject.PAGESIZE = "50";
                ///判断是否还有数据没下载
                if (TotalTb.Rows.Count <= (int.Parse(InObject.PAGENO) - 1) * 3 + Listxx.Rows.Count)
                {
                    OutObject.HASNEXTPAGE = "F";
                }
                else
                {
                    OutObject.HASNEXTPAGE = "T";
                }
                if (Listxx.Rows.Count > 0)
                {
                    foreach (DataRow dr in Listxx.Rows)
                    {
                        ZHIFUBAOMX zfbdzmx = new ZHIFUBAOMX();
                        zfbdzmx.MERCHANTOUTORDERNO = dr["IOUTTRADENO"].ToString();
                        zfbdzmx.TOTALFEE           = dr["ITOTALFEE"].ToString();
                        if (dr["JIESUANZT"].ToString() == "1")
                        {
                            zfbdzmx.TRANSCODEMSG = "收费";
                        }
                        else if (dr["JIESUANZT"].ToString() == "3")
                        {
                            zfbdzmx.TRANSCODEMSG = "退费";
                        }
                        zfbdzmx.TRANSDATE = dr["QINGQIUSJ"].ToString();
                        zfbdzmx.CZYDM     = dr["CAOZUOYDM"].ToString();
                        zfbdzmx.CZYXM     = dr["CAOZUOYXM"].ToString();

                        zfbdzmx.TRADENO = dr["TRADENO"].ToString();
                        OutObject.ZHIFUBAOXZMX.Add(zfbdzmx);
                    }
                }
            }
            #endregion
            #region  载支付宝
            //下载支付宝
            else if (InObject.XIAZAILX == "2")
            {
                if (string.IsNullOrEmpty(InObject.BASEINFO.FENYUANDM))
                {
                    throw new Exception("分院代码不能为空");
                }
                DataTable dt = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00006, InObject.BASEINFO.FENYUANDM));
                if (dt.Rows.Count <= 0)
                {
                    throw new Exception("查询不到医院代码为【" + InObject.BASEINFO.FENYUANDM + "】的医院信息");
                }
                //先删除这一天的下载记录
                DBVisitor.ExecuteBool(SqlLoad.GetFormat(SQ.HIS00020, InObject.RIQI));
                //页号
                string page_no = InObject.PAGENO;
                //必填,必须是正整数
                //账务查询开始时间
                string gmt_start_time = DateTime.Parse(InObject.RIQI).ToString("yyyy-MM-dd 00:00:00");// WIDgmt_start_time.Text.Trim();
                //格式为:yyyy-MM-ddHH:mm:ss
                //账务查询结束时间
                string gmt_end_time = DateTime.Parse(InObject.RIQI).ToString("yyyy-MM-dd 23:59:59");;
                //格式为:yyyy-MM-ddHH:mm:ss

                ////////////////////////////////////////////////////////////////////////////////////////////////

                //把请求参数打包成数组
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", dt.Rows[0]["PARTNER"].ToString());// Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "account.page.query");
                sParaTemp.Add("page_no", page_no);
                sParaTemp.Add("gmt_start_time", gmt_start_time);
                sParaTemp.Add("gmt_end_time", gmt_end_time);
                sParaTemp.Add("key", dt.Rows[0]["KEY"].ToString());
                //sParaTemp.Add("iw_account_log_id", InObject.IWACCOUNTLOGID);
                //sParaTemp.Add("trade_no", InObject.TRADENO);
                //sParaTemp.Add("merchant_out_order_no", InObject.MERCHANTOUTORDERNO);
                //sParaTemp.Add("deposit_bank_no", InObject.DEPOSITBANKNO);
                //sParaTemp.Add("page_size", InObject.PAGESIZE);

                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp);

                //请在这里加上商户的业务逻辑程序代码

                #region 支付宝错误码字典
                Dictionary <string, string> ErrDic = new Dictionary <string, string>();
                ErrDic.Add("REQUIRED_DATE", "起始和结束时间不能为空");
                ErrDic.Add("ILLEGAL_DATE_FORMAT", "起始和结束时间格式不正确");
                ErrDic.Add("ILLEGAL_DATE_TOO_LONG", "起始和结束时间间隔超过最大间隔");
                ErrDic.Add("START_DATE_AFTER_NOW", "起始时间大于当前时间");
                ErrDic.Add("START_DATE_AFTER_END_DATE", "起始时间大于结束时间");
                ErrDic.Add("ILLEGAL_PAGE_NO", "当前页码必须为数据且必须大于0");
                ErrDic.Add("START_DATE_OUT_OF_RANGE", "查询时间超出范围");
                ErrDic.Add("ILLEGAL_PAGE_SIZE", "分页大小必须为数字且大于0");
                ErrDic.Add("ILLEGAL_ACCOUNT_LOG_ID", "账务流水必须为数字且大于0");
                ErrDic.Add("TOO_MANY_QUERY", "当前查询量太多");
                ErrDic.Add("ACCOUNT_NOT_EXIST", "要查询的用户不存在");
                ErrDic.Add("ACCESS_ACCOUNT_DENIED", "无权查询该账户的账务明细");
                ErrDic.Add("SYSTEM_BUSY", "系统繁忙");
                ErrDic.Add("ILLEGAL_SIGN", "签名不正确");
                ErrDic.Add("ILLEGAL_ARGUMENT", "参数不正确");
                ErrDic.Add("ILLEGAL_SERVICE", "非法服务名称");
                ErrDic.Add("ILLEGAL_USER", "用户ID不正确");
                ErrDic.Add("ILLEGAL_PARTNER", "合作伙伴信息不正确");
                ErrDic.Add("ILLEGAL_EXTERFACE", "接口配置不正确");
                ErrDic.Add("ILLEGAL_PARTNER_EXTERFACE", "合作伙伴接口信息不正确");
                ErrDic.Add("ILLEGAL_SECURITY_PROFILE", "未找到匹配的密钥配置");
                ErrDic.Add("ILLEGAL_SIGN_TYPE", "签名类型不正确");
                ErrDic.Add("ILLEGAL_CHARSET", "字符集不合法");
                ErrDic.Add("ILLEGAL_CLIENT_IP", "客户端IP地址无权访问服务");
                ErrDic.Add("HAS_NO_PRIVILEGE", "未开通此接口权限");
                ErrDic.Add("USER_DATA_MIGRATE_ERROR", "用户的数据未迁移或者迁移状态未完成");
                //系统错误 ,联系支付宝技术支持处理
                ErrDic.Add("SYSTEM_ERROR", "支付宝系统错误");
                ErrDic.Add("SESSION_TIMEOUT", "session超时");
                ErrDic.Add("ILLEGAL_TARGET_SERVICE", "错误的target_service");
                ErrDic.Add("ILLEGAL_ACCESS_SWITCH_SYSTEM", "partner不允许访问该类型的系统");
                ErrDic.Add("ILLEGAL_SWITCH_SYSTEM", "切换系统异常");
                ErrDic.Add("ILLEGAL_ENCODING", "不支持该编码类型");
                ErrDic.Add("EXTERFACE_IS_CLOSED", "接口已关闭");
                #endregion

                #region 分析结算出差
                OutObject = new ZHIFUBAOJSMXXZ_OUT();
                XmlDocument xmlDoc = new XmlDocument();

                try
                {
                    xmlDoc.LoadXml(sHtmlText);
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode("alipay").ChildNodes;
                    foreach (XmlNode xn in nodeList)
                    {
                        //判断是否异常,如果返回异常 则抛出
                        if (xn.Name == "is_success" && xn.InnerText == "F")
                        {
                            foreach (XmlNode xnerr in nodeList)
                            {
                                if (xnerr.Name == "error")
                                {
                                    foreach (var errmsg in ErrDic)
                                    {
                                        if (errmsg.Key == xnerr.InnerText.ToUpper())
                                        {
                                            throw new Exception(errmsg.Key + "|" + errmsg.Value);
                                        }
                                    }
                                }
                            }
                        }


                        if (xn.Name == "response")
                        {
                            XmlElement  xe      = (XmlElement)xn;
                            XmlNodeList subList = xe.ChildNodes;
                            foreach (XmlNode xmlNode in subList)
                            {
                                if (xmlNode.Name == "account_page_query_result")
                                {
                                    XmlElement  xemx      = (XmlElement)xmlNode;
                                    XmlNodeList submxList = xemx.ChildNodes;
                                    string      text      = "";
                                    foreach (XmlNode mxnode in submxList)
                                    {
                                        if (mxnode.Name == "has_next_page")
                                        {
                                            OutObject.HASNEXTPAGE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "page_no")
                                        {
                                            OutObject.PAGENO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "page_size")
                                        {
                                            OutObject.PAGESIZE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "account_log_list")
                                        {
                                            XmlElement  mx     = (XmlElement)mxnode;
                                            XmlNodeList mxList = mx.ChildNodes;
                                            foreach (XmlNode nodemx in mxList)
                                            {
                                                XmlElement  mx1     = (XmlElement)nodemx;
                                                XmlNodeList mxList1 = mx1.ChildNodes;
                                                ZHIFUBAOMX  zfbdzmx = new ZHIFUBAOMX();

                                                //明细列表赋值
                                                foreach (XmlNode nodemx1 in mxList1)
                                                {
                                                    //BALANCE	余额
                                                    if (nodemx1.Name == "balance")
                                                    {
                                                        zfbdzmx.BALANCE = nodemx1.InnerText;
                                                    }
                                                    //INCOME	收入金额
                                                    if (nodemx1.Name == "income")
                                                    {
                                                        if (double.Parse(nodemx1.InnerText) != 0)
                                                        {
                                                            // zfbdzmx.INCOME = nodemx1.InnerText;
                                                            zfbdzmx.TOTALFEE = nodemx1.InnerText;
                                                        }
                                                    }
                                                    //OUTCOME	支出金额
                                                    if (nodemx1.Name == "outcome")
                                                    {
                                                        // zfbdzmx.OUTCOME = nodemx1.InnerText;
                                                        if (double.Parse(nodemx1.InnerText) != 0)
                                                        {
                                                            // zfbdzmx.INCOME = nodemx1.InnerText;
                                                            zfbdzmx.TOTALFEE = "-" + nodemx1.InnerText;
                                                        }
                                                    }
                                                    ////BANKACCOUNTNAME	银行帐号名称
                                                    //if (nodemx1.Name == "bank_account_name")
                                                    //    zfbdzmx.BANKACCOUNTNAME = nodemx1.InnerText;
                                                    ////BANKACCOUNTNO	银行帐号
                                                    //if (nodemx1.Name == "bank_account_no")
                                                    //    zfbdzmx.BANKACCOUNTNO = nodemx1.InnerText;
                                                    ////BANKNAME	银行名称
                                                    //if (nodemx1.Name == "bank_name")
                                                    //    zfbdzmx.BANKNAME = nodemx1.InnerText;
                                                    // //BUYERACCOUNT	买家支付宝人民币资金账户
                                                    if (nodemx1.Name == "buyer_account")
                                                    {
                                                        zfbdzmx.BUYERACCOUNT = nodemx1.InnerText;
                                                    }
                                                    ////CURRENCY	货币代码
                                                    //if (nodemx1.Name == "currency")
                                                    //    zfbdzmx.CURRENCY = nodemx1.InnerText;
                                                    ////GOODSTITLE	商品名称
                                                    //if (nodemx1.Name == "goods_title")
                                                    //    zfbdzmx.GOODSTITLE = nodemx1.InnerText;
                                                    ////IWACCOUNTLOGID	财务序列号
                                                    //if (nodemx1.Name == "iw_account_log_id")
                                                    //    zfbdzmx.IWACCOUNTLOGID = nodemx1.InnerText;
                                                    ////MEMO	备注
                                                    //if (nodemx1.Name == "memo")
                                                    //    zfbdzmx.MEMO = nodemx1.InnerText;
                                                    //MERCHANTOUTORDERNO	商户订单号
                                                    if (nodemx1.Name == "merchant_out_order_no")
                                                    {
                                                        zfbdzmx.MERCHANTOUTORDERNO = nodemx1.InnerText;
                                                    }
                                                    ////OUTHERACCOUNTEMAIL	财务对方邮箱
                                                    //if (nodemx1.Name == "other_account_email")
                                                    //    zfbdzmx.OTHERACCOUNTFULLNAME = nodemx1.InnerText;
                                                    ////OTHERACCOUNTFULLNAME	财务对方名称
                                                    //if (nodemx1.Name == "other_account_fullname")
                                                    //    zfbdzmx.OTHERACCOUNTFULLNAME = nodemx1.InnerText;
                                                    ////OTHERUSERID	财务对方支付宝用户号
                                                    //if (nodemx1.Name == "other_user_id")
                                                    //    zfbdzmx.OTHERUSERID = nodemx1.InnerText;
                                                    //PARTNERID	合作者身份ID
                                                    if (nodemx1.Name == "partner_id")
                                                    {
                                                        zfbdzmx.PARTNERID = nodemx1.InnerText;
                                                    }
                                                    ////SELLERACCOUNT 卖家支付宝人民币资金账户
                                                    //if (nodemx1.Name == "seller_account")
                                                    //    zfbdzmx.SELLERACCOUNT = nodemx1.InnerText;
                                                    //SELLERFULLNAME	卖家姓名
                                                    if (nodemx1.Name == "seller_fullname")
                                                    {
                                                        zfbdzmx.SELLERFULLNAME = nodemx1.InnerText;
                                                    }
                                                    ////SERVICFEE	交易服务费
                                                    //if (nodemx1.Name == "service_fee")
                                                    //    zfbdzmx.SERVICFEE = nodemx1.InnerText;
                                                    ////SERVICEFEERATIO	交易服务费率
                                                    //if (nodemx1.Name == "service_fee_ratio")
                                                    //    zfbdzmx.SERVICEFEERATIO = nodemx1.InnerText;
                                                    //TOTALFEE	交易总金额
                                                    //if (nodemx1.Name == "total_fee")
                                                    //    zfbdzmx.TOTALFEE = nodemx1.InnerText;
                                                    //TRADENO	支付宝交易号
                                                    if (nodemx1.Name == "trade_no")
                                                    {
                                                        zfbdzmx.TRADENO = nodemx1.InnerText;
                                                    }
                                                    ////TRANSACCOUNT	财务本方支付宝人民币资金账户
                                                    //if (nodemx1.Name == "trans_account")
                                                    //    zfbdzmx.TRANSACCOUNT = nodemx1.InnerText;
                                                    //TRANSCODEMSG	业务类型
                                                    if (nodemx1.Name == "trans_code_msg")
                                                    {
                                                        zfbdzmx.TRANSCODEMSG = nodemx1.InnerText;
                                                    }
                                                    //TRANSDATE	交易时间
                                                    if (nodemx1.Name == "trans_date")
                                                    {
                                                        zfbdzmx.TRANSDATE = nodemx1.InnerText;
                                                    }
                                                    ////TRANSOUTERORDERNO	订单号
                                                    //if (nodemx1.Name == "trans_out_order_no")
                                                    //    zfbdzmx.TRANSOUTERORDERNO = nodemx1.InnerText;
                                                    ////DEPOSITBANKNO	网银充值流水号
                                                    //if (nodemx1.Name == "deposit_bank_no")
                                                    //    zfbdzmx.DEPOSITBANKNO = nodemx1.InnerText;
                                                    ////TRADEREFUNDAMOUNT	累积退款金额
                                                    //if (nodemx1.Name == "trade_refund_amount")
                                                    //    zfbdzmx.TRADEREFUNDAMOUNT = nodemx1.InnerText;
                                                }
                                                if (string.IsNullOrEmpty(zfbdzmx.TOTALFEE))
                                                {
                                                    zfbdzmx.TOTALFEE = "0";
                                                }
                                                if (double.Parse(zfbdzmx.TOTALFEE) < 0)
                                                {
                                                    zfbdzmx.MERCHANTOUTORDERNO = "T" + zfbdzmx.MERCHANTOUTORDERNO;
                                                }
                                                //   OutObject.ZHIFUBAOMX.Add(zfbdzmx);
                                                string sfzh = "";
                                                if (string.IsNullOrEmpty(zfbdzmx.BUYERACCOUNT) && zfbdzmx.BUYERACCOUNT.Length > 4)
                                                {
                                                    DataTable dtqyxx = DBVisitor.ExecuteTable(string.Format("select * from gy_bangdinggx where BINRENSB='{0}'", zfbdzmx.BUYERACCOUNT.Substring(0, zfbdzmx.BUYERACCOUNT.Length - 4)));
                                                    if (dtqyxx.Rows.Count > 0)
                                                    {
                                                        sfzh = dtqyxx.Rows[0]["SHENFENZH"].ToString();
                                                    }
                                                }
                                                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00018,
                                                                                            zfbdzmx.MERCHANTOUTORDERNO,  //IOUTTRADENO	VARCHAR2(50)	N			商户订单号
                                                                                            zfbdzmx.TOTALFEE,            //ITOTALFEE	VARCHAR2(100)	N			总金额
                                                                                            "",                          //JIESUANZT	NUMBER(4)	Y			状态  0支付  1退费
                                                                                            zfbdzmx.TRANSDATE,           //JIESUANSJ	DATE	Y			结算时间
                                                                                            zfbdzmx.BUYERACCOUNT,        //IBUYERID	VARCHAR2(50)	Y			买家支付宝用户号
                                                                                            sfzh,                        //IBUYEREMAIL	VARCHAR2(50)	Y			买家支付宝帐号
                                                                                            "",                          //IAGREENNO	VARCHAR2(50)	Y			协议号
                                                                                            zfbdzmx.TRADENO,             //TRADENO	VARCHAR2(50)	Y			支付宝交易号
                                                                                            InObject.BASEINFO.FENYUANDM, //FENYUANDM	VARCHAR2(50)	Y			分院代码
                                                                                            ""                           //SHOUKUANZH	VARCHAR2(50)	Y			收款帐号
                                                                                            ));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception exp)
                {
                    throw new Exception(exp.Message.ToString());
                }
                #endregion
                #endregion
            }
            else
            {
                throw new Exception("下载类型不正确");
            }
        }
Example #14
0
        public static void sendXZSQSJ()
        {
            var Brxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00001, " and xzzt = 1 and xzsqfszt = 0 "));

            if (Brxx == null || Brxx.Count == 0)
            {
            }
            else
            {
                foreach (var mxxx in Brxx)
                {
                    var str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                              "<request action= \"sendExchangeReport\" client=\"市二:192.168.1.10\" >" +
                              "<head><patient><mpiId></mpiId>" +
                              "<personName>" + mxxx.Get("brxm") + "</personName>" +
                              "<sexCode>" + mxxx.Get("brxb") + "</sexCode>" +
                              "<birthday>" + mxxx.Get("brcsrq") + "</birthday>" +
                              "<idCard>" + mxxx.Get("sfzh") + "</idCard>" +
                              "<idType>01</idType>" +
                              "<cardNo>" + mxxx.Get("jzkh") + "</cardNo>" +
                              "<cardType>" + mxxx.Get("jzklx") + "</cardType>" +
                              "</patient></head>" +
                              "<body>" +
                              "<yybm>47011662233010511A1001</yybm>" +
                              "<zzdh>" + mxxx.Get("zzsqdh") + "</zzdh>" +
                              "<zzdh>" + mxxx.Get("zzsqdh") + "</zzdh>" +
                              "<zljg>" + mxxx.Get("cyzt") + "</zljg>" +
                              "<xzrq>" + mxxx.Get("xzsqrq") + "</xzrq>" +
                              "<kfnr>" + mxxx.Get("cyzt") + "</kfnr>" +
                              "<zzys>" + mxxx.Get("zzys") + "</zzys>" +
                              "<cyxj>" + mxxx.Get("xzzzyy") + "</cyxj>" +
                              "<tjys>自动转发</tjys>" +
                              "<tjsj>" + System.DateTime.Now.ToString() + "</tjsj>" +
                              "<tjjg>杭州市二医院</tjjg>";
                    var cfxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00014, mxxx.Get("jzxh")));
                    if (cfxx == null || cfxx.Count == 0)
                    {
                    }
                    else
                    {
                        foreach (var item in cfxx)
                        {
                            str += "<chufangxx>" +
                                   "<cfid>" + item.Get("cfid") + "</cfid>" +
                                   "<brxm>" + mxxx.Get("brxm") + "</brxm>" +
                                   "<cflx>" + item.Get("cflx") + "</cflx>" +
                                   "<cfks>" + item.Get("cfks") + "</cfks>" +
                                   "<cfys>" + item.Get("cfys") + "</cfys>" +
                                   "<cfrq>" + item.Get("cfrq") + "</cfrq>" +
                                   "<bzxx>" + item.Get("bzxx") + "</bzxx>";
                            var cfmxxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00015, item.Get("cfid")));
                            if (cfmxxx == null || cfmxxx.Count == 0)
                            {
                            }
                            else
                            {
                                foreach (var itemmx in cfmxxx)
                                {
                                    str += "<chufangxxxx>" +
                                           "<cfid>" + item.Get("cfid") + "</cfid>" +
                                           "<yplx>" + itemmx.Get("yplx") + "</yplx>" +
                                           "<ypmc>" + itemmx.Get("ypmc") + "</ypmc>" +
                                           "<ypgg>" + itemmx.Get("ypgg") + "</ypgg>" +
                                           "<ycjl>" + itemmx.Get("ycjl") + "</ycjl>" +
                                           "<jldw>" + itemmx.Get("jldw") + "</jldw>" +
                                           "<yyts>" + itemmx.Get("yyts") + "</yyts>" +
                                           "<yypl>" + itemmx.Get("yypl") + "</yypl>" +
                                           "<ypcd>" + itemmx.Get("ypcd") + "</ypcd>" +
                                           "<yysl>" + itemmx.Get("ypsl") + "</yysl>" +
                                           "<ypyf>" + itemmx.Get("ypyf") + "</ypyf>" +
                                           "<kssj>" + itemmx.Get("kssj") + "</kssj>" +
                                           "<tzsj>" + itemmx.Get("tzsj") + "</tzsj>" +
                                           "<psjg>" + itemmx.Get("psjg") + "</psjg>" +
                                           "<zyts>" + itemmx.Get("zyts") + "</zyts>" +
                                           "<fyrq>" + itemmx.Get("fyrq") + "</fyrq>" +
                                           "</chufangxxxx>";
                                }
                            }
                            str += "</chufangxx>";
                        }
                    }
                    var jyxx = DBVisitor1.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00016, mxxx.Get("jzxh")));
                    if (jyxx == null || jyxx.Count == 0)
                    {
                    }
                    else
                    {
                        foreach (var item in jyxx)
                        {
                            str += "<jianyanxx>" +
                                   "<jydh>" + item.Get("jydh") + "</jydh>" +
                                   "<jylb>" + item.Get("jylb") + "</jylb>" +
                                   "<jyxm>" + item.Get("jyxm") + "</jyxm>" +
                                   "<kdrq>" + item.Get("kdrq") + "</kdrq>" +
                                   "<kdys>" + item.Get("kdys") + "</kdys>" +
                                   "<kdks>" + item.Get("kdks") + "</kdks>" +
                                   "<jyff>" + item.Get("jyff") + "</jyff>" +
                                   "<jyjg>" + item.Get("jyjg") + "</jyjg>" +
                                   "<bzxx>" + item.Get("bzxx") + "</bzxx>";
                            var jymxxx = DBVisitor1.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00017, item.Get("jydh")));
                            if (jymxxx == null || jymxxx.Count == 0)
                            {
                            }
                            else
                            {
                                foreach (var itemmx in jymxxx)
                                {
                                    str += "<jianyanmxxx>" +
                                           "<jyxm>" + item.Get("jyxm") + "</jyxm>" +
                                           "<jyjgdx>" + item.Get("jyjgdx") + "</jyjgdx>" +
                                           "<jydh>" + item.Get("jydh") + "</jydh>" +
                                           "<jyjgsz>" + item.Get("jyjg") + "</jyjgsz>" +
                                           "<jldw>" + item.Get("jldw") + "</jldw>" +
                                           "<ckgz>" + item.Get("ckgz") + "</ckgz>" +
                                           "<ckdz>" + item.Get("ckdz") + "</ckdz>" +
                                           "<jyzb>" + item.Get("jyzb") + "</jyzb>" +
                                           "<bzxx>" + item.Get("bzxx") + "</bzxx>" +
                                           "</jianyanmxx>";
                                }
                            }
                            str += "</jianyanxx>";
                        }
                    }
                    var jcxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00020, mxxx.Get("jzxh")));
                    if (jcxx == null || jcxx.Count == 0)
                    {
                    }
                    else
                    {
                        foreach (var item in jcxx)
                        {
                            str += "<jianchaxx>" +
                                   "<jcdh>" + item.Get("jcdh") + "</jcdh>" +
                                   "<yxbh>" + item.Get("yxbh") + "</yxbh>" +
                                   "<jclb>" + item.Get("jclb") + "</jclb>" +
                                   "<jcxm>" + item.Get("jcxm") + "</jcxm>" +
                                   "<jcbw>" + item.Get("jcbw") + "</jcbw>" +
                                   "<jcsqd>" + item.Get("jcsqd") + "</jcsqd>" +
                                   "<jcbg>" + item.Get("jcbg") + "</jcbg>" +
                                   "<yxxx>" + item.Get("yxxx") + "</yxxx>" +
                                   "<jcjg>" + item.Get("jcjg") + "</jcjg>" +
                                   "<bzxx>" + item.Get("bzxx") + "</bzxx>" +
                                   "</jianchaxx>";
                        }
                    }
                    var zyyzxx = DBVisitor.ExecuteModels(SqlLoad.GetFormat(SQ.AUTO00019, mxxx.Get("jzxh")));
                    if (zyyzxx == null || zyyzxx.Count == 0)
                    {
                    }
                    else
                    {
                        str += "<zyyzjl>";
                        foreach (var item in zyyzxx)
                        {
                            str += "<zyyzmx>" +
                                   "<yzxm>" + item.Get("yzxh") + "</yzxm>" +
                                   "<zyh>" + mxxx.Get("bah") + "</zyh>" +
                                   "<ypmc>" + item.Get("ypmc") + "</ypmc>" +
                                   "<ypcd>" + item.Get("ypcd") + "</ypcd>" +
                                   "<yfgg>" + item.Get("yfgg") + "</yfgg>" +
                                   "<yfdw>" + item.Get("yfdw") + "</yfdw>" +
                                   "<kssj>" + item.Get("kssj") + "</kssj>" +
                                   "<ycsl>" + item.Get("ycsl") + "</ycsl>" +
                                   "<ytcs>" + item.Get("ytcs") + "</ytcs>" +
                                   "<fysl>" + item.Get("fysl") + "</fysl>" +
                                   "<sypc>" + item.Get("sypc") + "</sypc>" +
                                   "<yzlx>" + item.Get("yzlx") + "</yzlx>" +
                                   "<yyts>" + item.Get("yyts") + "</yyts>" +
                                   "</zyyzmx>";
                        }
                        str += "</zyyzjl>";
                    }
                    str += "</body></request>";

                    var rtnstr = sendJK(str);
                    var xmldom = new XmlDocument();
                    var xmlOut = "";
                    xmlOut = rtnstr;
                    xmldom.LoadXml(xmlOut);
                    var errno = xmldom.GetElementsByTagName("code").Item(0).FirstChild.InnerText;
                    if (errno == "200")
                    {
                        var tran = DBVisitor.Connection.BeginTransaction();
                        try
                        {
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.AUTO00007, mxxx.Get("zzsqdh")), tran);
                            tran.Commit();
                        }
                        catch (Exception ex)
                        {
                            tran.Rollback();
                        }
                    }
                }
            }
        }
Example #15
0
        public override void ProcessMessage()
        {
            string jiuzhenkLx    = InObject.JIUZHENKLX;         //就诊卡类型
            string jiuzhenKh     = InObject.JIUZHENKH;          //就诊卡号
            string bingrenLb     = InObject.BINGRENLB;          //病人类别
            string yibaokLx      = InObject.YIBAOKLX;           //医保卡类型
            string yibaokXx      = InObject.YIBAOKXX;           //医保卡信息
            string yibaokh       = InObject.YIBAOKH;            //医保卡号
            string gerenBh       = InObject.GERENBH;            //个人编号
            string bingliBh      = InObject.BINGLIBH;           //病历本号
            string xingMing      = InObject.XINGMING;           //姓名
            string xingBie       = InObject.XINGBIE;            //性别
            string minZu         = InObject.MINZU;              //民族
            string chushengRq    = InObject.CHUSHENGRQ;         //出生日期 YYYT-MM-DD
            string zhengjianLx   = InObject.ZHENGJIANLX;        //证件类型
            string zhengjianHm   = InObject.ZHENGJIANHM;        //证件号码
            string danweiLx      = InObject.DANWEILX;           //单位类型
            string danweiBh      = InObject.DANWEIBH;           //单位编号
            string danweiMc      = InObject.DANWEIMC;           //单位名称
            string jiatingZz     = InObject.JIATINGZZ;          //家庭住址
            string renyuanLb     = InObject.RENYUANLB;          //人员类别
            string lianxiDh      = InObject.LIANXIDH;           //联系电话
            string yinhangKh     = InObject.YINHANGKH;          //银行卡号
            string qianyueBz     = InObject.QIANYUEBZ;          //签约标识
            string yiliaoLb      = InObject.YILIAOLB;           //医疗类别
            string jiesuanLb     = InObject.JIESUANLB;          //结算类别
            string yibaokMm      = InObject.YIBAOKMM;           //医保卡密码
            string photo         = InObject.PHOTO;              //照片 二进制码流
            string shifouYk      = InObject.SHIFOUYK;           //是否有卡
            string bangdingYhk   = InObject.BANGDINGYHK;        //绑定银行卡
            string zhongduansbXx = InObject.ZHONGDUANSBXX;      //终端识别信息
            string bingrenXz     = InObject.BINGRENXZ;          //病人性质
            string chongzhiJe    = InObject.CHONGZHIJE;         //充值金额
            string zhifuFs       = InObject.ZHIFUFS;            //支付方式
            string jiandangRen   = InObject.BASEINFO.CAOZUOYDM; //建档人工号
            string caozuoRq      = InObject.BASEINFO.CAOZUORQ;  //操作日期
            string empiId        = InObject.EMPIID;             //实名制认证标识

            OutObject = new RENYUANZC_OUT();

            int  JIUZHENKCD   = Convert.ToInt32(ConfigurationManager.AppSettings["JIUZHENKCD"]);   //就诊卡默认长度
            char JIUZHENKTCZF = string.IsNullOrEmpty(ConfigurationManager.AppSettings["JIUZHENKTCZF"]) ? '0' :
                                ConfigurationManager.AppSettings["JIUZHENKTCZF"].ToCharArray()[0]; //就诊卡填充字符

            #region 基本入参判断
            if (string.IsNullOrEmpty(jiuzhenKh) && string.IsNullOrEmpty(yibaokh))
            {
                throw new Exception("就诊卡号和医保卡号不能同时为空!");
            }

            if (string.IsNullOrEmpty(jiuzhenKh))
            {
                jiuzhenKh = yibaokh;
            }

            if (string.IsNullOrEmpty(zhengjianHm))
            {
                throw new Exception("证件号码不能为空!");
            }

            if (string.IsNullOrEmpty(xingMing))
            {
                throw new Exception("病人姓名不能为空!");
            }
            if (string.IsNullOrEmpty(xingBie))
            {
                throw new Exception("病人性别不能为空!");
            }

            if (string.IsNullOrEmpty(chushengRq))
            {
                throw new Exception("出生日期不能为空!");
            }

            if (string.IsNullOrEmpty(jiatingZz))
            {
                throw new Exception("家庭住址不能为空!");
            }
            if (string.IsNullOrEmpty(lianxiDh))
            {
                throw new Exception("联系电话不能为空!");
            }
            #endregion

            #region 检查档案状态


            StringBuilder sbSql = new StringBuilder("select a.bingrenid,a.jiuzhenkh ,a.xingming ");
            sbSql.Append("from gy_v_bingrenxx a ,gy_zijinzh b where a.bingrenid = b.bingrenid(+) ");

            #region 就诊卡自动长度补全
            if (JIUZHENKCD > 0)
            {
                if (jiuzhenKh.Length < JIUZHENKCD)
                {
                    jiuzhenKh = jiuzhenKh.PadLeft(JIUZHENKCD, JIUZHENKTCZF);
                }
            }
            #endregion
            sbSql.Append(" and (a.jiuzhenkh='" + jiuzhenKh + "' or a.yibaokh='" + yibaokh + "' or nvl(a.shenfenzh,'*') = '" + zhengjianHm + "' ) ");
            sbSql.Append(" order by a.yibaokh asc, a.xiugaisj desc ");
            #endregion

            DataTable dtRenYuanXX = DBVisitor.ExecuteTable(sbSql.ToString());
            if (dtRenYuanXX == null || dtRenYuanXX.Rows.Count <= 0)
            {
                #region 建档

                string sqlStr     = "select FUN_GY_GETORDER('1', 'GY_BINGRENXX', 10) as bingrenid from dual ";
                string bingrenId  = DBVisitor.ExecuteScalar(sqlStr).ToString();
                string shoukuanRq = Convert.ToDateTime(caozuoRq).ToString("yyyy-MM-dd HH:mm:ss");
                string jiaoyanMa  = Unity.GetMD5(bingrenId + Convert.ToSingle(chongzhiJe).ToString("f4") + shoukuanRq + "1" + jiandangRen).ToLower();

                //医保卡信息特殊处理
                if (!string.IsNullOrEmpty(yibaokXx) && yibaokXx.Contains('$'))
                {
                    yibaokXx = yibaokXx.Replace('$', '&');
                }

                #region 医保病人需要转化获取所需的性质ID
                //联众医保yibaobrxz不填,要在包里取//add by renj
                //if (bingrenLb != "1")
                //{
                //    string sqlYb = string.Format("select xingzhiid from gy_feiyongxz where feiyonglb='{0}' and yibaobrxz='{1}'", bingrenLb, bingrenXz);
                //    bingrenXz = new DBServer().GetCurrData(sqlYb);
                //}
                #endregion
                #region 性别信息转换
                if (xingBie == "0")
                {
                    xingBie = "未知";
                }
                else if (xingBie == "1")
                {
                    xingBie = "男";
                }
                else if (xingBie == "2")
                {
                    xingBie = "女";
                }
                else
                {
                    xingBie = "其他";
                }
                #endregion

                #region 入参信息拼装
                //病人性质? 建档人?
                //数据库包中有建档自动开启电子账户功能 可通过注释包语句进行该功能的关闭
                string tradeMsgList = jiuzhenkLx + "|" + jiuzhenKh + "|" + bingrenLb + "|" + yibaokLx + "|" + yibaokXx + "|" + yibaokh + "|"
                                      + gerenBh + "|" + bingliBh + "|" + xingMing + "|" + xingBie + "|" + minZu + "|" + chushengRq + "|"
                                      + zhengjianLx + "|" + zhengjianHm + "|" + danweiLx + "|" + danweiBh + "|" + danweiMc + "|" + jiatingZz + "|"
                                      + renyuanLb + "|" + lianxiDh + "|" + yinhangKh + "|" + qianyueBz + "|" + yiliaoLb + "|" + jiesuanLb + "|"
                                      + yibaokMm + "|" + photo + "|" + shifouYk + "|" + bangdingYhk + "|" + zhongduansbXx + "|" + jiandangRen + "|"
                                      + chongzhiJe + "|" + bingrenId + "|" + zhifuFs + "|" + shoukuanRq + "|" + jiaoyanMa + "|" + bingrenXz + "|";

                //LogHelper.WriteLog(typeof(GG_JiaoYiBLL), "建档交易入参:" + tradeMsgList);//交易入参日志
                #endregion

                OracleParameter[] paramJiaoYi = new OracleParameter[3];
                paramJiaoYi[0]           = new OracleParameter("PRM_MSG", OracleType.VarChar);
                paramJiaoYi[0].Value     = tradeMsgList;
                paramJiaoYi[0].Direction = ParameterDirection.Input;
                paramJiaoYi[1]           = new OracleParameter("PRM_APPCODE", OracleType.Number);
                paramJiaoYi[1].Value     = null;
                paramJiaoYi[1].Direction = ParameterDirection.Output;
                paramJiaoYi[2]           = new OracleParameter("PRM_OUTBUFFER", OracleType.VarChar);
                paramJiaoYi[2].Value     = null;
                paramJiaoYi[2].Size      = 2000;
                paramJiaoYi[2].Direction = ParameterDirection.Output;

                string        returnValue = string.Empty;
                DbTransaction transaction = null;
                DbConnection  conn        = DBVisitor.Connection;
                try
                {
                    transaction = conn.BeginTransaction();
                    DBVisitor.ExecuteProcedure("PKG_GY_YINYIJK.PRC_BINGRENJD", paramJiaoYi, transaction);
                }
                catch (Exception ex)
                {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                        //transaction.Connection.Close();
                    }
                    throw new Exception(ex.Message);
                }
                returnValue = paramJiaoYi[1].Value.ToString();
                string returnMsg = paramJiaoYi[2].Value.ToString();
                string zhanghuId = string.Empty;
                if (returnValue == "1")//建档及生成虚拟账户成功
                {
                    transaction.Commit();
                    //transaction.Connection.Close();
                    //zhanghuId = returnMsg.Split('|')[1];//账户ID
                    //此处需要处理返回成功的xml
                    OutObject.JIUZHENKH = jiuzhenKh;
                    OutObject.BINGRENID = bingrenId;
                    //OutObject.XUNIZH = zhanghuId;
                }
                else
                {
                    transaction.Rollback();
                    //transaction.Connection.Close();
                    throw new Exception(returnMsg);
                }
                #endregion
            }
            else
            {
                if (InObject.XINGMING != dtRenYuanXX.Rows[0]["xingming"].ToString())
                {
                    throw new Exception("该卡号和病人姓名不匹配,请核查!");
                }

                OutObject.JIUZHENKH = dtRenYuanXX.Rows[0]["jiuzhenkh"].ToString();
                OutObject.BINGRENID = dtRenYuanXX.Rows[0]["bingrenid"].ToString();
            }

            if (!string.IsNullOrEmpty(OutObject.BINGRENID) && !string.IsNullOrEmpty(empiId))
            {
                DBVisitor.ExecuteNonQuery(string.Format(" update gy_bingrenxx set empiid ='{0}' where bingrenid = '{1}' ", empiId, OutObject.BINGRENID));
            }
        }
Example #16
0
        public override void ProcessMessage()
        {
            OutObject = new GUAHAOYY_OUT();
            string yuyueLx      = InObject.YUYUELX;
            string jiuzhenkLx   = InObject.JIUZHENKLX;                           //就诊卡类型
            string jiuzhenKh    = InObject.JIUZHENKH;                            //就诊卡号
            string zhengjianLx  = InObject.ZHENGJIANLX;                          //证件类型
            string zhengjianHm  = InObject.ZHENGJIANHM;                          //证件号码
            string xingMing     = InObject.XINGMING;                             //姓名
            string yizhoupbId   = InObject.YIZHOUPBID;                           //一周排班id;
            string dangtianpbId = InObject.DANGTIANPBID;                         //当天排班id
            string riQi         = InObject.RIQI;                                 //日期
            string guahaoBc     = InObject.GUAHAOBC;                             //挂号班次
            string guahaoLb     = InObject.GUAHAOLB;                             //挂号类别
            string keshiDm      = InObject.KESHIDM;                              //科室代码
            string yishengDm    = InObject.YISHENGDM;                            //医生代码
            string guahaoXh     = InObject.GUAHAOXH;                             //挂号序号
            string yuyueLy      = InObject.YUYUELY;                              //预约来源
            string lianxiDh     = InObject.LIANXIDH;                             //手机号码
            string bingrenId    = InObject.BINGRENID;                            //病人ID
            string xingBie      = InObject.XINGBIE;                              //性别
            string FenYuanDM    = InObject.BASEINFO.FENYUANDM;                   //分院代码
            string beiZhu       = InObject.BEIZHU;                               //备注

            string czygh     = ConfigurationManager.AppSettings["JRCaoZuoYGH"];  //接入操作员工号
            string yuYueCZFS = ConfigurationManager.AppSettings["GUAHAOYYCZFS"]; //挂号预约处理方式

            if (!string.IsNullOrEmpty(yuYueCZFS) && yuYueCZFS == "1")
            {
                #region  兴悦城业务处理
                #region 基本入参判断
                //if (string.IsNullOrEmpty(zhengjianHm)) {
                //    throw new Exception("证件号码不能为空!");
                //}
                if (string.IsNullOrEmpty(beiZhu))
                {
                    beiZhu = string.Empty;
                }

                if (string.IsNullOrEmpty(xingMing))
                {
                    throw new Exception("姓名不能为空!");
                }

                if (string.IsNullOrEmpty(xingBie))
                {
                    throw new Exception("性别不能为空!");
                }

                if (string.IsNullOrEmpty(lianxiDh))
                {
                    throw new Exception("联系电话不能为空!");
                }

                if (string.IsNullOrEmpty(guahaoBc))
                {
                    throw new Exception("挂号班次不能为空!请传入1 上午,2 下午!");
                }
                else if (guahaoBc != "1" && guahaoBc != "2")
                {
                    throw new Exception("挂号班次不能为空!请传入1 上午,2 下午!");
                }

                if (string.IsNullOrEmpty(xingBie))
                {
                    xingBie = "0";
                }

                if (string.IsNullOrEmpty(yuyueLx))
                {
                    yuyueLx = ConfigurationManager.AppSettings["GuaHaoYYLX"];//预约类型
                }
                #endregion

                string sXingBie = string.Empty;
                switch (xingBie)
                {
                case "0":
                    sXingBie = "未知";
                    break;

                case "1":
                    sXingBie = "男";
                    break;

                case "2":
                    sXingBie = "女";
                    break;

                default:
                    sXingBie = "其它";
                    break;
                }

                string chuShenRQ = "null";
                if (!string.IsNullOrEmpty(zhengjianHm))
                {
                    chuShenRQ = string.Format("to_date('{0}','yyyy-mm-dd')", zhengjianHm.Substring(6, 8).Insert(4, "-").Insert(7, "-"));
                }

                string    houzhensj   = "select kaishisj,jieshusj from v_mz_houzhensj where paibanid = '{0}' and (shangxiawbz = '{1}') and (qishighxh>= '{2}' and jieshughxh <= '{2}')";
                DataTable dtHouZhensj = DBVisitor.ExecuteTable(string.Format(houzhensj, dangtianpbId, guahaoBc == "1" ? "0" : "1", guahaoXh));
                string    kaishisj    = string.Empty;
                string    jieshusj    = string.Empty;
                if (dtHouZhensj != null && dtHouZhensj.Rows.Count > 0)
                {
                    kaishisj = dtHouZhensj.Rows[0]["kaishisj"].ToString();
                    jieshusj = dtHouZhensj.Rows[0]["jieshusj"].ToString();
                }

                string PaiBanHYXX = @"select * from v_mz_guahaoyyxh_qbhy where paibanid = '{0}' and guahaoyyxh = '{1}' and shangxiawbz = '{2}'and yuanquid = '{3}' ";

                DataTable dtPBHYXX = DBVisitor.ExecuteTable(string.Format(PaiBanHYXX, dangtianpbId, guahaoXh, guahaoBc == "1" ? "0" : "1", FenYuanDM));
                if (dtPBHYXX == null || dtPBHYXX.Rows.Count <= 0)
                {
                    throw new Exception("未找到有效的号源信息!");
                }

                //号源占用判断
                DataTable dtYYYXX = DBVisitor.ExecuteTable(string.Format("select * from v_mz_guahaoyyxh_yshyh where paibanid = '{0}' and guahaoyyxh = '{1}' and shangxiawbz = '{2}' and yuanquid = '{3}' ", dangtianpbId, guahaoXh, ((guahaoBc == "1") ? 0 : 1), FenYuanDM));
                if (dtYYYXX.Rows.Count > 0)
                {
                    throw new Exception("该时间段已被预约,请选择其它时间段!");
                }

                string quHaoMM = DBVisitor.ExecuteScalar("select LPAD(seq_gy_jiuzhenyy.nextval,10,'0') from dual").ToString();

                string bingrenid = DBVisitor.ExecuteScalar(string.Format("select nvl(bingrenid,'') from gy_bingrenxx where xingming = '{0}' and xingbie = '{1}' and  jiatingdh = '{2}' ", xingMing, sXingBie, lianxiDh)).ToString();

                string insertYYXX = @"insert into gy_jiuzhenyy (jiuzhenyyid,yuyuesj,yisehngid,keshiid,xingming,
                                            shuruma1,shuruma2,shuruma3,xingbie,chushengrq,dianhua,
                                            yuyuerq,jiuzhenbz,jiluren,jieshusj,zuofeibz,yuyuely,beizhu,bingrenid,chuzhenbz )
                                            values( '{0}','{1}','{2}','{3}','{4}',
                                            fun_gy_getshuruma1('{4}',50),fun_gy_getshuruma2('{4}',50),fun_gy_getshuruma3('{4}',50),'{5}',{6},'{7}',
                                            to_date('{8}','yyyy-mm-dd'),'0','{9}','{10}','0','{11}','{12}','{13}',{14} )";
                DBVisitor.ExecuteNonQuery(string.Format(insertYYXX, quHaoMM, kaishisj, yishengDm, keshiDm,
                                                        xingMing, sXingBie, chuShenRQ, lianxiDh, riQi, InObject.BASEINFO.CAOZUOYDM, jieshusj, yuyueLx, beiZhu,
                                                        bingrenid, string.IsNullOrEmpty(bingrenid)?1:0));
                OutObject.GUAHAOXH  = guahaoXh;
                OutObject.JIUZHENSJ = Unity.getJiuZhenSJD(yishengDm, keshiDm.ToString(), guahaoXh, yuyueLx, ((guahaoBc == "1") ? 0 : 1), guahaoLb, riQi);
                OutObject.QUHAOMM   = quHaoMM;
                #endregion
            }
            else
            {
                #region 标准his4业务处理

                #region 基本入参判断
                if (string.IsNullOrEmpty(InObject.BASEINFO.CAOZUOYDM))
                {
                    throw new Exception("非法操作员,无法进行预约操作!");
                }
                if (!string.IsNullOrEmpty(czygh) && !czygh.Contains("^" + InObject.BASEINFO.CAOZUOYDM + "^"))
                {
                    throw new Exception("非法操作员,无法进行预约操作!");
                }


                //预约类型
                if (string.IsNullOrEmpty(yuyueLx))
                {
                    yuyueLx = ConfigurationManager.AppSettings["GuaHaoYYLX"];//预约类型
                }

                //性别
                if (string.IsNullOrEmpty(xingBie))
                {
                    xingBie = "未知";
                }
                else if (xingBie == "1")
                {
                    xingBie = "男";
                }
                else if (xingBie == "2")
                {
                    xingBie = "女";
                }
                else if (xingBie == "9")
                {
                    xingBie = "其他";
                }
                else
                {
                    xingBie = "";
                }

                if (!string.IsNullOrEmpty(zhengjianHm))
                {
                    zhengjianHm = zhengjianHm.ToUpper();
                }

                //姓名
                if (string.IsNullOrEmpty(xingMing))
                {
                    throw new Exception("姓名不能为空!");
                }
                //就诊卡号
                if (string.IsNullOrEmpty(jiuzhenKh) && string.IsNullOrEmpty(zhengjianHm) && string.IsNullOrEmpty(bingrenId))
                {
                    throw new Exception("就诊卡号和证件号码不能同时为空!");
                }

                //排班id
                if (string.IsNullOrEmpty(dangtianpbId))
                {
                    throw new Exception("排班信息获取失败,请重新尝试挂号!");
                }
                //预约日期
                if (string.IsNullOrEmpty(riQi))
                {
                    throw new Exception("预约日期获取失败,请重新尝试挂号!");
                }
                //挂号班次
                if (string.IsNullOrEmpty(guahaoBc))
                {
                    throw new Exception("挂号班次获取失败,请重新尝试挂号!");
                }
                //挂号类别
                if (string.IsNullOrEmpty(guahaoLb))
                {
                    throw new Exception("挂号类别获取失败,请重新尝试挂号!");
                }
                //科室代码
                if (string.IsNullOrEmpty(keshiDm))
                {
                    throw new Exception("科室信息获取失败,请重新尝试挂号!");
                }
                //挂号序号
                if (string.IsNullOrEmpty(guahaoXh))
                {
                    throw new Exception("预约挂号序号获取失败,请重新尝试挂号!");
                }
                //联系电话
                if (string.IsNullOrEmpty(lianxiDh))
                {
                    throw new Exception("联系电话获取失败,请重新尝试挂号!");
                }

                if (string.IsNullOrEmpty(yishengDm))
                {
                    yishengDm = "*";
                }

                if (string.IsNullOrEmpty(yuyueLy))
                {
                    yuyueLy = ConfigurationManager.AppSettings["GuaHaoYYLY"];
                    if (string.IsNullOrEmpty(yuyueLy))
                    {
                        yuyueLy = "7";
                    }
                }
                #endregion



                string chushengrq  = "";
                string xuexing     = "";
                string hunyin      = "";
                string zhiye       = "";
                string guoji       = "";
                string minzu       = "";
                string jiwangshi   = "";
                string guominshi   = "";
                string jiatingdz   = "";
                string lianxirdh   = "";
                string lianxiren   = "";
                string dianhua     = "";
                string houzhenkssj = "";
                string houzhenjssj = "";
                if (!string.IsNullOrEmpty(jiuzhenKh) || !string.IsNullOrEmpty(zhengjianHm) || !string.IsNullOrEmpty(bingrenId))
                {
                    //获取病人个人信息
                    StringBuilder sbSql = new StringBuilder("select a.jiuzhenkh,a.shenfenzh,xingbie, to_char(a.chushengrq,'yyyy-mm-dd') chushengrq,a.bingrenid, a.xuexing,a.hunyin,");
                    sbSql.Append(" a.zhiye,a.guoji,a.minzu,a.jiwangshi,a.guominshi,a.jiatingdz,a.lianxirdh,a.lianxiren,a.dianhua,a.lianxidh ");
                    sbSql.Append("from gy_v_bingrenxx a where ((a.jiuzhenkh is not null and  a.jiuzhenkh = '" + jiuzhenKh + "') or (a.yibaokh is not null and   a.yibaokh = '" + jiuzhenKh + "') or  (a.bingrenid is not null and a.bingrenid ='" + bingrenId + "') or (a.shenfenzh is not null and a.shenfenzh = '" + zhengjianHm + "'))   order by a.yibaokh asc, a.xiugaisj desc ");
                    DataTable dt = DBVisitor.ExecuteTable(sbSql.ToString());
                    if (dt.Rows.Count > 0)
                    {
                        jiuzhenKh   = dt.Rows[0]["jiuzhenkh"].ToString();
                        bingrenId   = dt.Rows[0]["bingrenid"].ToString();
                        zhengjianHm = dt.Rows[0]["shenfenzh"].ToString();
                        chushengrq  = dt.Rows[0]["chushengrq"].ToString();
                        xuexing     = dt.Rows[0]["xuexing"].ToString();
                        hunyin      = dt.Rows[0]["hunyin"].ToString();
                        zhiye       = dt.Rows[0]["zhiye"].ToString();
                        guoji       = dt.Rows[0]["guoji"].ToString();
                        minzu       = dt.Rows[0]["minzu"].ToString();
                        jiwangshi   = dt.Rows[0]["jiwangshi"].ToString();
                        guominshi   = dt.Rows[0]["guominshi"].ToString();
                        jiatingdz   = dt.Rows[0]["jiatingdz"].ToString();
                        lianxirdh   = dt.Rows[0]["lianxirdh"].ToString();
                        lianxiren   = dt.Rows[0]["lianxiren"].ToString();
                        dianhua     = dt.Rows[0]["dianhua"].ToString();
                        xingBie     = dt.Rows[0]["xingbie"].ToString();
                        if (string.IsNullOrEmpty(lianxiDh))
                        {
                            lianxiDh = string.IsNullOrEmpty(dianhua) ? dt.Rows[0]["lianxidh"].ToString() : dianhua;
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(zhengjianHm))
                        {
                            throw new Exception("证件号码不能为空!");
                        }
                    }
                }

                if (bingrenId == "null" || bingrenId == "Null" || bingrenId == "NULL")
                {
                    bingrenId = string.Empty;
                }

                #region 科室可预约年龄判断
                if (!Unity.shiFouKeGHNianLin(keshiDm, zhengjianHm))
                {
                    throw new Exception("年龄条件不符合,不能在本科室挂号/预约!");
                }
                #endregion
                #region 科室可预约性别判断
                if (!Unity.shiFouKeGHXingBie(keshiDm, zhengjianHm))
                {
                    throw new Exception("性别条件不符合,不能在本科室挂号/预约!");
                }
                #endregion

                #region 获取候诊时间
                string guaHaoHYMS = ConfigurationManager.AppSettings["GuaHaoYMS"];//挂号号源模式
                if (!string.IsNullOrEmpty(guaHaoHYMS) && guaHaoHYMS == "1")
                {
                }
                else
                {
                    OutObject.JIUZHENSJ = Unity.getJiuZhenSJD(yishengDm, keshiDm.ToString(), guahaoXh, yuyueLx, ((guahaoBc == "1") ? 0 : 1), guahaoLb, riQi);
                }
                if (OutObject.JIUZHENSJ.Contains("-"))
                {
                    houzhenkssj = OutObject.JIUZHENSJ.Split('-')[0];
                    houzhenjssj = OutObject.JIUZHENSJ.Split('-')[1];
                }
                #endregion


                //拼装交易字符串(2014-07-08,参考来源:his4.GHPKG.P_GH_BOOK)
                string jiaoyiZfc = bingrenId;                                    //外部病人ID为空
                jiaoyiZfc += "|" + jiuzhenKh;                                    //就诊卡号
                jiaoyiZfc += "|";                                                //医保卡号
                jiaoyiZfc += "|" + xingMing;                                     //姓名
                jiaoyiZfc += "|" + xingBie;                                      //性别
                jiaoyiZfc += "|" + zhengjianHm;                                  //证件号码
                jiaoyiZfc += "|" + chushengrq;                                   //出身日期
                jiaoyiZfc += "|" + xuexing;                                      //血型
                jiaoyiZfc += "|" + hunyin.Replace('|', '-');                     //婚姻状况
                jiaoyiZfc += "|" + zhiye;                                        //职业
                jiaoyiZfc += "|" + guoji;                                        //国籍
                jiaoyiZfc += "|" + minzu;                                        //民族
                jiaoyiZfc += "|" + jiwangshi;                                    //既往史
                jiaoyiZfc += "|" + guominshi;                                    //过敏史
                jiaoyiZfc += "|" + jiatingdz;                                    //家庭地址为空
                jiaoyiZfc += "|" + lianxiDh;                                     //联系电话
                jiaoyiZfc += "|" + lianxiren;                                    //联系人
                jiaoyiZfc += "|" + lianxiDh;                                     //联系电话
                jiaoyiZfc += "|" + (guahaoBc == "1" ? "S" : "X") + dangtianpbId; //排版ID
                jiaoyiZfc += "|2";                                               //排班模式
                jiaoyiZfc += "|" + riQi;                                         //就诊日期
                jiaoyiZfc += "|" + yuyueLx;                                      //预约类型
                jiaoyiZfc += "|" + yuyueLy;                                      //记录来源
                jiaoyiZfc += "|" + guahaoXh;                                     //预约挂号就诊序号
                jiaoyiZfc += "|";
                jiaoyiZfc += "|";
                jiaoyiZfc += "|" + InObject.BASEINFO.CAOZUOYDM;
                jiaoyiZfc += "|" + String.Empty; //yuyuehao 取号密码字段
                jiaoyiZfc += "|" + lianxiDh;     //家庭电话
                jiaoyiZfc += "|";                //单位电话
                jiaoyiZfc += "|" + houzhenkssj;  //候诊开始时间
                jiaoyiZfc += "|" + houzhenjssj;  //候诊结束时间

                //提交预约号-------------------------------------------------------------------------------------------
                OracleParameter[] paramJiaoYi = new OracleParameter[3];
                paramJiaoYi[0]           = new OracleParameter("PRM_JIAOYIZFC", OracleType.VarChar);
                paramJiaoYi[0].Value     = jiaoyiZfc;
                paramJiaoYi[0].Direction = ParameterDirection.Input;
                paramJiaoYi[1]           = new OracleParameter("PRM_APPCODE", OracleType.Number);
                paramJiaoYi[1].Value     = null;
                paramJiaoYi[1].Direction = ParameterDirection.Output;
                paramJiaoYi[2]           = new OracleParameter("PRM_DATABUFFER", OracleType.VarChar);
                paramJiaoYi[2].Value     = null;
                paramJiaoYi[2].Size      = 2000;
                paramJiaoYi[2].Direction = ParameterDirection.Output;

                log.InfoFormat("{0}", "执行存储过程:PKG_MZ_YUYUE.PRC_GY_TIJIAOYUYUEXX \r\nPRM_JIAOYIZFC:" + jiaoyiZfc + "\r\n");

                string        returnValue = string.Empty;
                DbTransaction transaction = null;
                DbConnection  conn        = DBVisitor.Connection;
                try
                {
                    transaction = conn.BeginTransaction();
                    DBVisitor.ExecuteProcedure("PKG_MZ_YUYUE.PRC_GY_TIJIAOYUYUEXX", paramJiaoYi, transaction);
                }
                catch (Exception ex)
                {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                        conn.Close();
                    }
                    throw new Exception(ex.Message);
                }
                //--------------------------------------------------------------------------------------------------
                //String filePath = System.Environment.CurrentDirectory; //取当前系统路径
                string errMsg = string.Empty;
                returnValue = paramJiaoYi[2].Value.ToString();
                if (!returnValue.Contains("|"))
                {
                    transaction.Rollback();
                    conn.Close();
                    throw new Exception(returnValue);
                }

                if (returnValue.Length > 3 && returnValue.Substring(0, 3).ToUpper() == "ERR")//获取信息错误
                {
                    errMsg = returnValue.Substring(returnValue.IndexOf('|') + 1);
                    transaction.Rollback();
                    conn.Close();
                    throw new Exception(errMsg);
                }
                else
                {
                    string yuYueHao = string.Empty;
                    if (returnValue.Contains("|"))
                    {
                        yuYueHao = returnValue.Split('|')[1];
                        //此处需要处理返回成功的xml
                        OutObject.QUHAOMM  = yuYueHao;
                        OutObject.GUAHAOXH = guahaoXh;

                        transaction.Commit();
                        conn.Close();
                    }
                    else
                    {
                        transaction.Rollback();
                        conn.Close();
                        throw new Exception("存储过程返回值格式有误!");
                    }
                }
                #endregion
            }
        }
Example #17
0
        public override void ProcessMessage()
        {
            //就诊卡类型
            if (string.IsNullOrEmpty(InObject.JIUZHENKLX))
            {
                throw new Exception(string.Format("入参[JIUZHENKLX]为空"));
            }
            //就诊卡号
            if (string.IsNullOrEmpty(InObject.JIUZHENKH))
            {
                throw new Exception(string.Format("入参[JIUZHENKH]为空"));
            }

            //姓名
            if (string.IsNullOrEmpty(InObject.XINGMING))
            {
                throw new Exception(string.Format("入参[XINGMING]为空"));
            }
            //联系电话
            if (string.IsNullOrEmpty(InObject.LIANXIDH))
            {
                throw new Exception(string.Format("入参[LIANXIDH]为空"));
            }
            //证件类型
            // if (string.IsNullOrEmpty(InObject.ZHENGJIANLX)) throw new Exception(string.Format("入参[ZHENGJIANLX]为空"));
            //证件号码
            if (string.IsNullOrEmpty(InObject.ZHENGJIANHM))
            {
                throw new Exception(string.Format("入参[ZHENGJIANHM]为空"));
            }
            //支付宝协议号
            if (string.IsNullOrEmpty(InObject.ZHIFUBXYH))
            {
                throw new Exception(string.Format("入参[ZHIFUBXYH]为空"));
            }
            //支付宝UserId
            if (string.IsNullOrEmpty(InObject.ZHIFUBYHH))
            {
                throw new Exception(string.Format("入参[ZHIFUBYHH]为空"));
            }
            //操作日期
            if (string.IsNullOrEmpty(InObject.CAOZUORQ))
            {
                throw new Exception(string.Format("入参[CAOZUORQ]为空"));
            }
            //操作类型
            if (string.IsNullOrEmpty(InObject.CAOZUOLX))
            {
                throw new Exception(string.Format("入参[CAOZUOLX]为空"));
            }
            if (string.IsNullOrEmpty(InObject.JIUZHENKLX))
            {
                //  2	社保卡
                throw new Exception(string.Format("入参[JIUZHENKLX]为空"));
            }
            if (InObject.JIUZHENKLX != "2" && InObject.JIUZHENKLX != "3")
            {
                throw new Exception(string.Format("就诊卡类型不正确"));
            }
            if (string.IsNullOrEmpty(InObject.BASEINFO.FENYUANDM))
            {
                throw new Exception(string.Format("医院代码不能为空"));
            }
            var FyInfo = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.HIS00022, InObject.BASEINFO.FENYUANDM));

            if (FyInfo == null)
            {
                throw new Exception(string.Format("查询不到医院代码为【{0}】的医院信息", InObject.BASEINFO.FENYUANDM));
            }
            InObject.JIUZHENKH = System.Convert.ToString(InObject.JIUZHENKH.ToUpper()).PadLeft(10, '0');
            //判断是否存在传入身份证号的病人信息
            string fydmwhere = "";

            if (InObject.JIUZHENKLX != "2") //2 社保卡 3就诊卡
            {                               //如果是就诊卡 则增加医院条件
                fydmwhere = string.Format(" and  FENYUANDM='{0}'", InObject.BASEINFO.FENYUANDM);
            }
            var existInfo = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.HIS00004, InObject.ZHENGJIANHM.ToLower(), InObject.JIUZHENKH, InObject.JIUZHENKLX, fydmwhere));

            var tran = DBVisitor.Connection.BeginTransaction();

            try
            {
                switch (InObject.CAOZUOLX)
                {
                case "1":
                    if (existInfo != null)
                    {
                        if (InObject.JIUZHENKLX == "3")
                        {    //就诊卡
                            DBVisitor.ExecuteNonQuery(string.Format("Update Gy_BangDingGx Set ShenFenZh='{0}'," +
                                                                    "BingRenXm='{1}',XieYiHm='{2}',BinRenSb='{3}',ZuoFeiPb = 0," +
                                                                    "LianXiDh='{4}',BangDingRq=To_Date('{5}','yyyy-mm-dd hh24:mi:ss'),CaoZuoRq=Sysdate,CaoZuoGh='{6}'," +
                                                                    "BeiZhuXx='{7}',PARTNER='{9}',SELLEREMAIL='{10}',JIUZHENKLX='{12}' where ShenFenZh='{8}' and JIUZHENKH='{11}'" +
                                                                    " and FENYUANDM='{13}' and  JIUZHENKLX='{12}'",
                                                                    InObject.ZHENGJIANHM.ToLower(),
                                                                    InObject.XINGMING,
                                                                    InObject.ZHIFUBXYH,
                                                                    InObject.ZHIFUBYHH,
                                                                    InObject.LIANXIDH,
                                                                    InObject.CAOZUORQ,
                                                                    InObject.BASEINFO.CAOZUOYDM,
                                                                    InObject.BEIZHUXX,
                                                                    InObject.ZHENGJIANHM.ToLower(),
                                                                    InObject.PARTNER,
                                                                    InObject.SELLEREMAIL,
                                                                    InObject.JIUZHENKH,
                                                                    InObject.JIUZHENKLX,
                                                                    InObject.BASEINFO.FENYUANDM
                                                                    ), tran);
                        }
                        else
                        {
                            //社保卡 不需要保存/判断医院代码
                            DBVisitor.ExecuteNonQuery(string.Format("Update Gy_BangDingGx Set ShenFenZh='{0}'," +
                                                                    "BingRenXm='{1}',XieYiHm='{2}',BinRenSb='{3}',ZuoFeiPb = 0," +
                                                                    "LianXiDh='{4}',BangDingRq=To_Date('{5}','yyyy-mm-dd hh24:mi:ss'),CaoZuoRq=Sysdate,CaoZuoGh='{6}'," +
                                                                    "BeiZhuXx='{7}',PARTNER='{9}',SELLEREMAIL='{10}',JIUZHENKLX='{12}' where ShenFenZh='{8}' and JIUZHENKH='{11}' " +
                                                                    "and  JIUZHENKLX='{12}'",
                                                                    InObject.ZHENGJIANHM.ToLower(),
                                                                    InObject.XINGMING,
                                                                    InObject.ZHIFUBXYH,
                                                                    InObject.ZHIFUBYHH,
                                                                    InObject.LIANXIDH,
                                                                    InObject.CAOZUORQ,
                                                                    InObject.BASEINFO.CAOZUOYDM,
                                                                    InObject.BEIZHUXX,
                                                                    InObject.ZHENGJIANHM.ToLower(),
                                                                    InObject.PARTNER,
                                                                    InObject.SELLEREMAIL,
                                                                    InObject.JIUZHENKH,
                                                                    InObject.JIUZHENKLX
                                                                    ), tran);
                        }
                    }
                    else
                    {
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00003, InObject.JIUZHENKH, InObject.ZHENGJIANHM.ToLower(), InObject.XINGMING, InObject.ZHIFUBXYH,
                                                                    InObject.ZHIFUBYHH, InObject.LIANXIDH, InObject.CAOZUORQ, InObject.BASEINFO.CAOZUOYDM,
                                                                    InObject.BEIZHUXX, InObject.PARTNER, InObject.SELLEREMAIL,
                                                                    InObject.JIUZHENKLX, InObject.BASEINFO.FENYUANDM), tran);
                    }

                    break;

                case "2":
                    if (existInfo == null)
                    {
                        throw new Exception(string.Format("查询不到就身份证号为[{0}]的绑定信息!", InObject.ZHENGJIANHM.ToLower()));
                    }
                    if (InObject.XINGMING.ToString() != existInfo.Items["BINGRENXM"].ToString())
                    {
                        throw new Exception(string.Format("传入病人姓名[{0}]与绑定账户姓名[{1}]不符", InObject.XINGMING, existInfo.Items["BINGRENXM"]));
                    }

                    //解绑更新作废判别
                    string dynamicSql = string.Format("Update Gy_BangDingGx Set ZuoFeiPb = 1,JieBangRq = To_Date('{2}','yyyy-mm-dd hh24:mi:ss') Where ShenFenZh = '{0}' And XieYiHm = '{1}' And ZuoFeiPb = 0 and JIUZHENKH='{3}' and FENYUANDM='{4}'", InObject.ZHENGJIANHM.ToLower(), InObject.ZHIFUBXYH, InObject.CAOZUORQ, InObject.JIUZHENKH, InObject.BASEINFO.FENYUANDM);
                    DBVisitor.ExecuteNonQuery(dynamicSql, tran);
                    break;

                default:
                    tran.Rollback();
                    throw new Exception("传入未定义的操作类型:" + InObject.CAOZUOLX);
                }
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw new Exception(ex.ToString());
            }
        }
Example #18
0
        /// <summary>
        /// 支付宝结算
        /// </summary>
        public override void ProcessMessage()
        {
            var listpbxx = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00002, InObject.WIDOUTTRADENO));

            LogUnit.Write(listpbxx.Rows.Count.ToString());
            if (listpbxx.Rows.Count > 0)
            {
                throw new Exception("商户订单号不能重复!");
            }

            #region //手机网页支付
            if (InObject.JIESUANLX == "1")
            {
                //支付宝网关地址
                string GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?";
                ////////////////////////////////////////////调用授权接口alipay.wap.trade.create.direct获取授权码token////////////////////////////////////////////

                //返回格式
                string format = "xml";
                //必填,不需要修改

                //返回格式
                string v = "2.0";
                //必填,不需要修改

                if (string.IsNullOrEmpty(InObject.QINGQIUDH))
                {
                    throw new Exception("请求单号不能为空!");
                }
                //请求号
                string req_id = InObject.QINGQIUDH; //DateTime.Now.ToString("yyyyMMddHHmmss");
                //必填,须保证每次请求都是唯一

                //req_data详细信息
                if (string.IsNullOrEmpty(InObject.NOTIFYURL))
                {
                    throw new Exception("服务器异步通知页面路径不能为空!");
                }
                //服务器异步通知页面路径
                string notify_url = InObject.NOTIFYURL;//"http://商户网关地址/WS_WAP_PAYWAP-CSHARP-UTF-8/notify_url.aspx";
                //需http://格式的完整路径,不允许加?id=123这类自定义参数

                if (string.IsNullOrEmpty(InObject.CALLBACKURL))
                {
                    throw new Exception("页面跳转同步通知页面路径不能为空!");
                }
                //页面跳转同步通知页面路径
                string call_back_url = InObject.CALLBACKURL;//"http://127.0.0.1:64704/WS_WAP_PAYWAP-CSHARP-UTF-8/call_back_url.aspx";
                //需http://格式的完整路径,不允许加?id=123这类自定义参数

                if (string.IsNullOrEmpty(InObject.MERCHANTURL))
                {
                    throw new Exception("操作中断返回地址不能为空!");
                }
                //操作中断返回地址
                string merchant_url = InObject.MERCHANTURL;// "http://127.0.0.1:64704/WS_WAP_PAYWAP-CSHARP-UTF-8/xxxxx.aspx";
                //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数

                if (string.IsNullOrEmpty(InObject.WIDOUTTRADENO))
                {
                    throw new Exception("商户订单号不能为空!");
                }
                //商户订单号
                string out_trade_no = InObject.WIDOUTTRADENO;// WIDout_trade_no.Text.Trim();
                //商户网站订单系统中唯一订单号,必填

                if (string.IsNullOrEmpty(InObject.WIDSUBJECT))
                {
                    throw new Exception("订单名称不能为空!");
                }
                //订单名称
                string subject = InObject.WIDSUBJECT;//WIDsubject.Text.Trim();
                //必填

                if (string.IsNullOrEmpty(InObject.WIDTOTALFEE))
                {
                    throw new Exception("付款金额不能为空!");
                }
                //付款金额
                string total_fee = InObject.WIDTOTALFEE; //WIDtotal_fee.Text.Trim();
                //必填

                //请求业务参数详细
                string req_dataToken = "<direct_trade_create_req><notify_url>" + notify_url +
                                       "</notify_url><call_back_url>" + call_back_url +
                                       "</call_back_url><seller_account_name>" + Common.Alipay.Config.Seller_email +
                                       "</seller_account_name><out_trade_no>" + out_trade_no +
                                       "</out_trade_no><subject>" + subject +
                                       "</subject><total_fee>" + total_fee +
                                       "</total_fee><merchant_url>" + merchant_url +
                                       "</merchant_url></direct_trade_create_req>";
                //必填

                //把请求参数打包成数组
                Dictionary <string, string> sParaTempToken = new Dictionary <string, string>();
                sParaTempToken.Add("partner", Config.Partner);
                sParaTempToken.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTempToken.Add("sec_id", Config.Sign_type.ToUpper());
                sParaTempToken.Add("service", "alipay.wap.trade.create.direct");
                sParaTempToken.Add("format", format);
                sParaTempToken.Add("v", v);
                sParaTempToken.Add("req_id", req_id);
                sParaTempToken.Add("req_data", req_dataToken);

                //建立请求
                string sHtmlTextToken = Submit.BuildRequest(GATEWAY_NEW, sParaTempToken);
                //URLDECODE返回的信息
                Encoding code = Encoding.GetEncoding(Config.Input_charset);
                sHtmlTextToken = System.Web.HttpUtility.UrlDecode(sHtmlTextToken, code);

                //解析远程模拟提交后返回的信息
                Dictionary <string, string> dicHtmlTextToken = Submit.ParseResponse(sHtmlTextToken);

                //获取token
                string request_token = dicHtmlTextToken["request_token"];


                ////////////////////////////////////////////根据授权码token调用交易接口alipay.wap.auth.authAndExecute////////////////////////////////////////////

                //业务详细
                string req_data = "<auth_and_execute_req><request_token>" + request_token + "</request_token></auth_and_execute_req>";
                //必填

                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00001,
                                                            InObject.QINGQIUDH,     //请求单号
                                                            '1',                    //结算类型 1手机网页支付 2二维码扫描支付 3商户代扣
                                                            InObject.NOTIFYURL,     //服务器异步通知页面路径
                                                            InObject.CALLBACKURL,   //页面跳转同步通知页面路径
                                                            InObject.MERCHANTURL,   //操作中断返回地址)
                                                            InObject.WIDOUTTRADENO, //商户订单号
                                                            InObject.WIDSUBJECT,    //订单名称
                                                            InObject.WIDTOTALFEE,   //订单金额
                                                            InObject.WIDBODY,       //订单描述
                                                            InObject.OUTTIME,       //超时时间取值范围
                                                            "",                     //买家支付宝用户号
                                                            "",                     //买家支付宝帐号
                                                            "",                     //授权号
                                                            "",                     //协议号
                                                            "0",                    //结算状态 0未结算 1结算成功 2结算失败
                                                            request_token));

                //把请求参数打包成数组
                Dictionary <string, string> sParaTemp = new Dictionary <string, string>();
                sParaTemp.Add("partner", Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("sec_id", Config.Sign_type.ToUpper());
                sParaTemp.Add("service", "alipay.wap.auth.authAndExecute");
                sParaTemp.Add("format", format);
                sParaTemp.Add("v", v);
                sParaTemp.Add("req_data", req_data);

                //建立请求
                string sHtmlText = Submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认");
                OutObject            = new ZHIFUBAOJS_OUT();
                OutObject.JIESUANURL = sHtmlText;
            }
            #endregion
            #region 二维码支付
            else if (InObject.JIESUANLX == "2")
            {
                if (string.IsNullOrEmpty(InObject.BASEINFO.FENYUANDM))
                {
                    throw new Exception("医院代码不能为空!");
                }
                if (string.IsNullOrEmpty(InObject.BASEINFO.CAOZUOYDM))
                {
                    throw new Exception("操作员代码不能为空!");
                }
                if (string.IsNullOrEmpty(InObject.BASEINFO.CAOZUOYXM))
                {
                    throw new Exception("操作员姓名不能为空!");
                }
                if (string.IsNullOrEmpty(InObject.JIUZHENKH))
                {
                    throw new Exception("就诊卡号不能为空!");
                }
                DataTable dt = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00006, InObject.BASEINFO.FENYUANDM));
                if (dt.Rows.Count <= 0)
                {
                    throw new Exception("查询不到医院代码为【" + InObject.BASEINFO.FENYUANDM + "】的医院信息");
                }
                var ddxx = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00002, InObject.WIDOUTTRADENO));
                if (ddxx.Rows.Count > 0)
                {
                    throw new Exception("已存在相同订单号的结算信息!");
                }
                if (string.IsNullOrEmpty(InObject.NOTIFYURL))
                {
                    throw new Exception("异步请求地址不能为空!");
                }
                //服务器异步通知页面路径
                string notify_url = ConfigurationManager.AppSettings["FWPTURL"] + "NotifyUrl2.aspx";//InObject.NOTIFYURL;
                //需http://格式的完整路径,不能加?id=123这类自定义参数
                //商户订单号
                string out_trade_no = InObject.WIDOUTTRADENO;// WIDout_trade_no.Text.Trim();
                //商户网站订单系统中唯一订单号,必填

                //订单名称
                string subject = InObject.WIDSUBJECT;// WIDsubject.Text.Trim();
                //必填

                //订单业务类型
                string product_code = "QR_CODE_OFFLINE";// WIDproduct_code.Text.Trim();
                //目前只支持QR_CODE_OFFLINE(二维码支付),必填

                //付款金额
                string total_fee = InObject.WIDTOTALFEE;// WIDtotal_fee.Text.Trim();
                //必填

                //卖家支付宝帐户
                string seller_email = dt.Rows[0]["SELLEREMAIL"].ToString(); //WIDseller_email.Text.Trim();
                //必填

                //订单描述
                string body = InObject.WIDBODY;

                //把请求参数打包成数组
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "alipay.acquire.precreate");
                sParaTemp.Add("notify_url", notify_url);
                sParaTemp.Add("out_trade_no", out_trade_no);
                sParaTemp.Add("subject", subject);
                sParaTemp.Add("product_code", product_code);
                sParaTemp.Add("total_fee", total_fee);
                sParaTemp.Add("seller_email", seller_email);
                sParaTemp.Add("body", body);
                sParaTemp.Add("it_b_pay", InObject.OUTTIME);
                sParaTemp.Add("key", "rfk3sw6dlq28k2tijjj54le6lfhw73s4");//取余杭卫生局的key
                //将请求数据 插入数据库
                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00001,
                                                            InObject.WIDOUTTRADENO,               //商户订单号
                                                            '2',                                  //结算类型 1手机网页支付 2二维码扫描支付 3商户代扣
                                                            InObject.NOTIFYURL,                   //服务器异步通知页面路径
                                                            "",                                   //页面跳转同步通知页面路径
                                                            "",                                   //操作中断返回地址)
                                                            InObject.WIDSUBJECT,                  //订单名称
                                                            InObject.WIDTOTALFEE,                 //订单金额
                                                            InObject.WIDBODY,                     //订单描述
                                                            InObject.OUTTIME,                     //超时时间取值范围
                                                            InObject.BUYERID,                     //买家支付宝用户号
                                                            InObject.BUYEREMAIL,                  //买家支付宝帐号
                                                            InObject.AUTHNO,                      //授权号
                                                            InObject.AGREENNO,                    //协议号
                                                            "0",                                  //结算状态 0未结算 1结算成功 2结算失败
                                                            "",
                                                            InObject.BASEINFO.FENYUANDM,          //分院代码
                                                            dt.Rows[0]["SELLEREMAIL"].ToString(), //收款帐号
                                                            InObject.BASEINFO.CAOZUOYXM,
                                                            InObject.BASEINFO.CAOZUOYDM,
                                                            "",                //身份证号
                                                            InObject.JIUZHENKH //就诊卡号
                                                            ));

                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp);
                //记录日志
                LogUnit.Write("JIESUANLX == 2###" + sHtmlText, "ZHIFUBAOJS");
                OutObject = new ZHIFUBAOJS_OUT();
                XmlDocument xmlDoc = new XmlDocument();
                try
                {
                    string PicUrl = "";
                    xmlDoc.LoadXml(sHtmlText);
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode("alipay").ChildNodes;
                    foreach (XmlNode xn in nodeList)
                    {
                        //判断是否异常,如果返回异常 则抛出
                        //if (xn.Name == "is_success" && xn.InnerText == "F")
                        //{
                        //    throw new Exception("支付宝请求生成二维码失败!");
                        //}
                        if (xn.Name == "error")
                        {
                            throw new Exception(xn.InnerText);
                        }
                        if (xn.Name == "response")
                        {
                            XmlElement  xe      = (XmlElement)xn;
                            XmlNodeList subList = xe.ChildNodes;
                            foreach (XmlNode xmlNode in subList)
                            {
                                if (xmlNode.Name == "alipay")
                                {
                                    XmlElement  xemx      = (XmlElement)xmlNode;
                                    XmlNodeList submxList = xemx.ChildNodes;

                                    foreach (XmlNode mxnode in submxList)
                                    {
                                        if (mxnode.Name == "detail_error_code")
                                        {
                                            OutObject.ERRORCODE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "detail_error_des")
                                        {
                                            OutObject.ERRORDES = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "big_pic_url")
                                        {
                                            //   OutObject.PICURL = mxnode.InnerText;
                                            PicUrl = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "out_trade_no")
                                        {
                                            OutObject.WIDOUTTRADENO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "qr_code")
                                        {
                                            OutObject.QRCODE = mxnode.InnerText;
                                        }
                                    }
                                    try
                                    {//将二维码图片下载到服务平台本地
                                        var path = HostingEnvironment.ApplicationPhysicalPath + "ZFBImg\\";
                                        DeletePic(path);
                                        System.Net.WebClient webClient = new System.Net.WebClient();
                                        webClient.DownloadFile(PicUrl, path + OutObject.WIDOUTTRADENO + ".jpg");
                                        OutObject.PICLOCAL = OutObject.WIDOUTTRADENO + ".jpg";
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception exp)
                {
                    throw new Exception(exp.Message.ToString());
                }
            }
            #endregion
            #region 签约账户支付 商户代扣
            else if (InObject.JIESUANLX == "3")
            {
                if (string.IsNullOrEmpty(InObject.BASEINFO.FENYUANDM))
                {
                    throw new Exception("医院代码不能为空!");
                }
                if (string.IsNullOrEmpty(InObject.BASEINFO.CAOZUOYDM))
                {
                    throw new Exception("操作员代码不能为空!");
                }
                if (string.IsNullOrEmpty(InObject.BASEINFO.CAOZUOYXM))
                {
                    throw new Exception("操作员姓名不能为空!");
                }
                if (string.IsNullOrEmpty(InObject.JIUZHENKH))
                {
                    throw new Exception("就诊卡号不能为空!");
                }
                DataTable dt = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00006, InObject.BASEINFO.FENYUANDM));
                if (dt.Rows.Count <= 0)
                {
                    throw new Exception("查询不到医院代码为【" + InObject.BASEINFO.FENYUANDM + "】的医院信息");
                }

                var ddxx = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00002, InObject.WIDOUTTRADENO));
                if (ddxx.Rows.Count > 0)
                {
                    throw new Exception("已存在相同订单号的结算信息!");
                }

                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "alipay.acquire.createandpay");
                sParaTemp.Add("notify_url", InObject.NOTIFYURL);
                sParaTemp.Add("seller_email", dt.Rows[0]["SELLEREMAIL"].ToString()); //Config.Seller_email);
                //sParaTemp.Add("seller_id", "2088121042783039");
                sParaTemp.Add("out_trade_no", InObject.WIDOUTTRADENO);               //InObject.WIDOUTTRADENO
                sParaTemp.Add("subject", InObject.WIDSUBJECT);
                sParaTemp.Add("product_code", "GENERAL_WITHHOLDING");
                sParaTemp.Add("total_fee", InObject.WIDTOTALFEE);
                sParaTemp.Add("agreement_info", "{\"agreement_no\":\"" + InObject.AGREENNO + "\"}"); //协议号 必传 签约后传回
                sParaTemp.Add("key", "rfk3sw6dlq28k2tijjj54le6lfhw73s4");                            //取余杭卫生局的key
                // sParaTemp.Add("royalty_type", "ROYALTY");
                // sParaTemp.Add("buyer_id", InObject.BUYERID);
                // sParaTemp.Add("buyer_email", InObject.BUYEREMAIL);
                // sParaTemp.Add("body", InObject.WIDBODY);
                //sParaTemp.Add("it_b_pay", InObject.OUTTIME);
                //sParaTemp.Add("dynamic_id_type", "bar_code");//动态ID类型
                //sParaTemp.Add("dynamic_id", "kff3hjwqzxrbvrrkd0");//动态ID
                //  sParaTemp.Add("auth_no", InObject.AUTHNO);

                string    sfzh = "";
                DataTable qyxx = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00021, InObject.AGREENNO));
                if (qyxx.Rows.Count >= 0)
                {
                    sfzh = qyxx.Rows[0]["SHENFENZH"].ToString();
                }
                //将请求数据 插入数据库
                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00001,
                                                            InObject.WIDOUTTRADENO,               //商户订单号
                                                            '3',                                  //结算类型 1手机网页支付 2二维码扫描支付 3商户代扣
                                                            "",                                   //服务器异步通知页面路径
                                                            "",                                   //页面跳转同步通知页面路径
                                                            "",                                   //操作中断返回地址)
                                                            InObject.WIDSUBJECT,                  //订单名称
                                                            InObject.WIDTOTALFEE,                 //订单金额
                                                            InObject.WIDBODY,                     //订单描述
                                                            InObject.OUTTIME,                     //超时时间取值范围
                                                            InObject.BUYERID,                     //买家支付宝用户号
                                                            InObject.BUYEREMAIL,                  //买家支付宝帐号
                                                            InObject.AUTHNO,                      //授权号
                                                            InObject.AGREENNO,                    //协议号
                                                            "0",                                  //结算状态 0未结算 1结算成功 2结算失败
                                                            "",
                                                            InObject.BASEINFO.FENYUANDM,          //分院代码
                                                            dt.Rows[0]["SELLEREMAIL"].ToString(), //收款帐号
                                                            InObject.BASEINFO.CAOZUOYXM,
                                                            InObject.BASEINFO.CAOZUOYDM,
                                                            sfzh,
                                                            InObject.JIUZHENKH
                                                            ));

                LogUnit.Write("开始请求支付宝!");
                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp);
                //记录日志
                LogUnit.Write("JIESUANLX == 3###" + sHtmlText, "ZHIFUBAOJS");
                OutObject = new ZHIFUBAOJS_OUT();
                XmlDocument xmlDoc = new XmlDocument();
                try
                {
                    xmlDoc.LoadXml(sHtmlText);
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode("alipay").ChildNodes;
                    foreach (XmlNode xn in nodeList)
                    {
                        if (xn.Name == "error")
                        {
                            DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set FAILERR='{0}',JIESUANZT='-1' where IOUTTRADENO='{1}' ", xn.InnerText, InObject.WIDOUTTRADENO));
                            throw new Exception(xn.InnerText);
                        }
                        if (xn.Name == "response")
                        {
                            XmlElement  xe      = (XmlElement)xn;
                            XmlNodeList subList = xe.ChildNodes;
                            foreach (XmlNode xmlNode in subList)
                            {
                                if (xmlNode.Name == "alipay")
                                {
                                    XmlElement  xemx      = (XmlElement)xmlNode;
                                    XmlNodeList submxList = xemx.ChildNodes;

                                    foreach (XmlNode mxnode in submxList)
                                    {
                                        if (mxnode.Name == "detail_error_code")
                                        {
                                            OutObject.ERRORCODE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "detail_error_des")
                                        {
                                            OutObject.ERRORDES = mxnode.InnerText;
                                            throw new Exception(mxnode.InnerText);
                                        }
                                        if (mxnode.Name == "result_code")
                                        {
                                            OutObject.RESULTCODE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "trade_no")
                                        {
                                            OutObject.TRADENO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "out_trade_no")
                                        {
                                            OutObject.WIDOUTTRADENO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "buyer_user_id")
                                        {
                                            OutObject.BUYERID = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "buyer_logon_id")
                                        {
                                            OutObject.BUYEREMAIL = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "total_fee")
                                        {
                                            OutObject.TOTALFREE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "gmt_payment")
                                        {
                                            OutObject.PAYMENTTIME = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "extend_info")
                                        {
                                            OutObject.EXTENDINFO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "fund_bill_list")
                                        {
                                            OutObject.FUNDBILLLIST = mxnode.InnerText;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (OutObject.RESULTCODE.ToUpper() == "ORDER_SUCCESS_PAY_SUCCESS")
                    {
                        DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set TRADENO='{0}',JIESUANZT='1',JIESUANSJ= sysdate,IBUYERID='{1}',IBUYEREMAIL='{2}'  where IOUTTRADENO='{3}' ", OutObject.TRADENO, OutObject.BUYERID, OutObject.BUYEREMAIL, InObject.WIDOUTTRADENO));
                    }
                    else
                    {
                        DBVisitor.ExecuteNonQuery(string.Format("update JR_ZHIFUBAOJSXX set FAILERR='{0}',JIESUANZT='-1',IBUYERID='{1}',IBUYEREMAIL='{2}'  where IOUTTRADENO='{3}' ", OutObject.ERRORDES, OutObject.BUYERID, OutObject.BUYEREMAIL, InObject.WIDOUTTRADENO));
                    }
                }
                catch (Exception ep)
                {
                    LogUnit.Write(ep.Message);
                    throw new Exception(ep.Message);
                }
            }
            #endregion
            else
            {
                throw new Exception("支付类型不正确!");
            }
        }
Example #19
0
        public override void ProcessMessage()
        {
            string yuyuesqdBh = InObject.YUYUESQDBH;
            string yewuLx     = InObject.YEWULX;
            string caozuoyDm  = InObject.BASEINFO.CAOZUOYDM;

            if (yuyuesqdBh == "" || yuyuesqdBh == "-1")
            {
                throw new Exception("预约申请单编号为空");
            }
            DataTable listyyxx = DBVisitor.ExecuteTable(string.Format("select * from sxzz_jianchasqd a where a.jianchasqdid = '{0}'", yuyuesqdBh));

            if (listyyxx.Rows.Count <= 0)
            {
                throw new Exception("找不到预约信息:申请单编号[" + yuyuesqdBh + "]");
            }
            if (yewuLx == "1")
            {
                if (listyyxx.Rows[0]["JIANCHASQDZT"].ToString() == "9")
                {
                    throw new Exception("预约申请单已取消!");
                }
                DataTable listyy = DBVisitor.ExecuteTable(string.Format("select * from sxzz_jianchasqd where jianchasqdid = '{0}'", yuyuesqdBh));
                if (listyy.Rows.Count <= 0)
                {
                    throw new Exception("未找到预约项目信息!");
                }
                if (listyy.Rows[0]["SHOUFEIBZ"].ToString() == "1" && listyy.Rows[0]["JIESHOUBZ"].ToString() == "1")
                {
                    throw new Exception("已登记不能取消!");
                }
                var resource = new HISYY_Cancel();
                resource.RequestNo = "";// listyyxx.Items["YYH"].ToString();
                resource.YYH       = listyyxx.Rows[0]["YIJIYYH"].ToString();
                resource.JCH       = listyyxx.Rows[0]["YIJISQDH"].ToString();

                //调用莱达WebService---------------------------------------------------------------
                string url    = System.Configuration.ConfigurationManager.AppSettings["LaiDa_Url"];
                string xml    = XMLHandle.EntitytoXML <HISYY_Cancel>(resource);
                string outxml = WSServer.Call <HISYY_Cancel>(url, xml).ToString();
                HISYY_Cancel_Result result = XMLHandle.XMLtoEntity <HISYY_Cancel_Result>(outxml);
                //---------------------------------------------------------------------------------
                if (result.Success == "False")
                {
                    throw new Exception("取消预约失败,错误原因:" + result.Message);
                }
                var trans = DBVisitor.Connection.BeginTransaction();

                try
                {
                    DBVisitor.ExecuteNonQuery(string.Format("update sxzz_jianchasqd a set a.jianchasqdzt = {1},quxiaogh = '{2}',quxiaorq = sysdate where a.jianchasqdid = {0}",
                                                            yuyuesqdBh, 9, caozuoyDm), trans);

                    DBVisitor.ExecuteNonQuery(string.Format("update sxzz_jianchasqd set JIESHOUBZ = '{1}',SHOUFEIBZ = '{2}' where jianchasqdid = '{0}'",
                                                            yuyuesqdBh, 0, 1), trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();

                    throw new Exception(ex.Message);
                }
            }
            else//检验的暂时不考虑
            {
                throw new Exception("检验业务建设中,敬请期待……");
            }
        }
Example #20
0
        public override void ProcessMessage()
        {
            OutObject = new JIESHOUSZSQ_OUT();
            string jiuzhenKh  = InObject.JIUZHENKH;
            string jiuzhenkLx = InObject.JIUZHENKLX;

            int JIUZHENKCD = Convert.ToInt32(ConfigurationManager.AppSettings["JIUZHENKCD"]);//就诊卡默认长度

            #region 基本入参判断
            if (InObject.YEWULX == null || InObject.YEWULX == "")
            {
                throw new Exception(string.Format("业务类型不能为空!"));
            }
            if (InObject.BINGRENXM == null || InObject.BINGRENXM == "")
            {
                throw new Exception(string.Format("病人姓名不能为空!"));
            }
            if (InObject.BINGRENXB == null || InObject.BINGRENXB == "")
            {
                throw new Exception(string.Format("病人性别不能为空!"));
            }
            if (InObject.BINGRENCSRQ == null || InObject.BINGRENCSRQ == "")
            {
                throw new Exception(string.Format("病人出生日期不能为空!"));
            }
            if (InObject.BINGRENSFZH == null || InObject.BINGRENSFZH == "")
            {
                throw new Exception(string.Format("病人身份证号不能为空!"));
            }
            if (InObject.BINGRENLXDH == null || InObject.BINGRENLXDH == "")
            {
                throw new Exception(string.Format("病人联系电话不能为空!"));
            }
            if (InObject.BINGRENLXDZ == null || InObject.BINGRENLXDZ == "")
            {
                throw new Exception(string.Format("病人联系地址不能为空!"));
            }
            if (InObject.SHENQINGJGDM == null || InObject.SHENQINGJGDM == "")
            {
                throw new Exception(string.Format("申请机构代码不能为空!"));
            }
            if (InObject.SHENQINGJGMC == null || InObject.SHENQINGJGMC == "")
            {
                throw new Exception(string.Format("申请机构名称不能为空!"));
            }
            if (InObject.SHENQINGYS == null || InObject.SHENQINGYS == "")
            {
                throw new Exception(string.Format("申请医生不能为空!"));
            }
            if (InObject.SHENQINGYSDH == null || InObject.SHENQINGYSDH == "")
            {
                throw new Exception(string.Format("申请医生电话不能为空!"));
            }
            if (InObject.SHENQINGRQ == null || InObject.SHENQINGRQ == "")
            {
                throw new Exception(string.Format("申请日期不能为空!"));
            }
            if (InObject.BINQINGMS == null || InObject.BINQINGMS == "")
            {
                throw new Exception(string.Format("病情描述不能为空!"));
            }
            if (InObject.ZHUANZHENZYSX == null || InObject.ZHUANZHENZYSX == "")
            {
                throw new Exception(string.Format("转诊注意事项不能为空!"));
            }
            #endregion

            if (JIUZHENKCD > 0)
            {
                if (jiuzhenKh.Length < JIUZHENKCD)
                {
                    jiuzhenKh = jiuzhenKh.PadLeft(JIUZHENKCD, '0');
                }
            }

            //转诊申请单号
            var zzsqdbh = DBVisitor.ExecuteScalar(SqlLoad.GetFormat("select seq_sxzz_zzsqd.nextval zzsqd from dual")).ToString();

            var tran = DBVisitor.Connection.BeginTransaction();
            try
            {
                #region//申请单信息
                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00007,
                                                            zzsqdbh, InObject.JIUZHENKLX, InObject.JIUZHENKH, InObject.YEWULX,
                                                            InObject.BINGRENXM, InObject.BINGRENXB, InObject.BINGRENCSRQ,
                                                            InObject.BINGRENNL, InObject.BINGRENSFZH, InObject.BINGRENLXDH,
                                                            InObject.BINGRENLXDZ, InObject.BINGRENFYLB, InObject.SHENQINGJGDM,
                                                            InObject.SHENQINGJGMC, InObject.SHENQINGJGLXDH, InObject.SHENQINGYS,
                                                            InObject.SHENQINGYSDH, InObject.SHENQINGRQ, InObject.ZHUANZHENYY,
                                                            InObject.BINQINGMS, InObject.ZHUANZHENZYSX, InObject.ZHUANZHENDH,
                                                            InObject.SZJSLXR, InObject.SZJSLXRDH, InObject.ZHUANRUKSDM,
                                                            InObject.ZHUANRUKSMC), tran);
                //申请单状态
                //DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00077, zzsqdbh), tran);
                #endregion
                #region //门诊处方信息
                foreach (var item in InObject.CHUFANGMX)
                {
                    int i = 0;
                    if (item.CHUFANGXXMX.Count > 0)
                    {
                        if (string.IsNullOrEmpty(item.CHUFANGID))
                        {
                            throw new Exception(string.Format("处方ID不能为空!"));
                        }
                        /*zzsqdh,cfid,cfly,cflx,kfrq,bz*/
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00008,
                                                                    zzsqdbh, item.CHUFANGID, item.CHUFANGLY, item.CHUFANGLX, item.KAIFANGRQ, item.BEIZHU), tran);
                        foreach (var itemmx in item.CHUFANGXXMX)
                        {
                            if (string.IsNullOrEmpty(itemmx.XIANGMUMC))
                            {
                                throw new Exception(string.Format("药品项目名称不能为空!"));
                            }
                            //门诊处方明细

                            /*xh,cfid,fylx,xmmc,yptym,ypspm,
                             *    cdmc,ypgg,dw,sl,pl,gytj,
                             *    yyts,dcyl,yldw,psjg,zcyts,
                             *    fyrq*/
                            ++i;
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00009,
                                                                        i, item.CHUFANGID, itemmx.FEIYONGLX, itemmx.XIANGMUMC, itemmx.YAOPINTYM, itemmx.YAOPINSPM,
                                                                        itemmx.CHANGDIMC, itemmx.YAOPINGG, itemmx.DANGWEI, itemmx.SHULIANG, itemmx.PINLV, itemmx.GEIYAOTJ,
                                                                        itemmx.YONGYAOTS, itemmx.DANCIYL, itemmx.YONGLIANGDW, itemmx.PISHIJG, itemmx.ZHONGCHAOYTS,
                                                                        itemmx.FAYAORQ, zzsqdbh), tran);
                        }
                    }
                }
                #endregion
                #region//检验处方信息
                foreach (var item in InObject.JIANYANMX)
                {
                    int i = 0;
                    if (item.JIANYANXXMX.Count > 0)
                    {
                        if (string.IsNullOrEmpty(item.JIANYANID))
                        {
                            throw new Exception(string.Format("检验ID不能为空!"));
                        }

                        /*zzsqdh,jyid,xmmc,kdrq,bz,jyjg,
                         * jcff,wjzbz,jczd,jcrq,yblxmc,ybh,
                         * shys,jyrq*/
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00010,
                                                                    zzsqdbh, item.JIANYANID, item.XIANGMUMC, item.KAIDANRQ, item.BEIZHU, item.JIANYANJG,
                                                                    item.JIANCEFF, item.WEIJIZBZ, item.JIANCHAZD, item.JIANCHARQ, item.YANGBENLXMC, item.YANGBENGH,
                                                                    item.SHENGHEYS, item.JIANYANRQ), tran);
                        foreach (var itemmx in item.JIANYANXXMX)
                        {
                            if (string.IsNullOrEmpty(itemmx.XIANGMUMC))
                            {
                                throw new Exception(string.Format("检验项目名称不能为空!"));
                            }
                            //检验处方明细

                            /*xh,jyid,xmmc,jyz,dyxh,dx,
                             *    fw,dw*/
                            ++i;
                            DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00011,
                                                                        i, item.JIANYANID, itemmx.XIANGMUMC, itemmx.JIANYANZ, itemmx.DAYINXH, itemmx.DINGXING,
                                                                        itemmx.FANWEI, itemmx.DANWEI, zzsqdbh), tran);
                        }
                    }
                }
                #endregion
                #region 检查信息
                foreach (var item in InObject.JIANCHAMX)
                {
                    /*zzsqdh,jcid,jclxmc,kdrq,xmmc,yxsj,
                     * zdjg,bz,bgdz,kdys*/
                    if (string.IsNullOrEmpty(item.JIANCHAID))
                    {
                        throw new Exception(string.Format("检查ID不能为空!"));
                    }
                    DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00012,
                                                                zzsqdbh, item.JIANCHAID, item.JIANCHALX, item.KAIDANRQ, item.XIANGMUMC, item.YIXIANGSJ,
                                                                item.ZHENDUAMJG, item.BEIZHU, item.BAOGAODZ, item.KAIDANYS), tran);
                }
                #endregion
                #region//住院医嘱信息
                foreach (var item in InObject.ZHUYUANYZMX)
                {
                    /*zzsqdh,yzid,yzlx,yzmc,yzzh,kssj,
                     * jssj,ycsl,yldw,zxrq,pl,yzlb,
                     * kdys,fyzid,psjg,gytj*/
                    if (string.IsNullOrEmpty(item.YIZHUXH))
                    {
                        throw new Exception(string.Format("医嘱序号不能为空!"));
                    }
                    string sql = SqlLoad.GetFormat(SQ.HIS00013,
                                                   zzsqdbh, item.YIZHUXH, item.YIZHULX, item.YIZHUMC, item.YIZHUZH, item.KAISHISJ,
                                                   item.TINGZHISJ, item.YICISL, item.YONGLIANGDW, item.ZHIXINGRQ, item.PINGLV, item.YIZHULB,
                                                   item.KAIDANYS, item.FUYIZXH, item.PISHIJG, item.GEIYAOTJ);
                    DBVisitor.ExecuteNonQuery(sql, tran);
                }
                #endregion
                tran.Commit();
                OutObject             = new JIESHOUSZSQ_OUT();
                OutObject.ZHUANZHENDH = zzsqdbh;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
        }
Example #21
0
        public override void ProcessMessage()
        {
            string    brxxcx      = "select * from gy_bingrenxx where bingrenid = '{0}'";
            DataTable dtBingRenXX = DBVisitor.ExecuteTable(string.Format(brxxcx, InObject.BINGRENID));

            if (dtBingRenXX.Rows.Count <= 0)
            {
                throw new Exception("未找到该病人信息,无法完成预约!");
            }

            //判断入参合法性
            if (InObject.YUYUERQ == null)
            {
                throw new Exception("预约日期不能为空!");
            }
            if (InObject.YUYUESJ == null)
            {
                throw new Exception("预约时间不能为空!");
            }
            if (InObject.BINGRENLX == null || Convert.ToInt32(InObject.BINGRENLX) < 1 || Convert.ToInt32(InObject.BINGRENLX) > 3)
            {
                throw new Exception("病人类型代码不对!");
            }
            if (InObject.SHENFENZH == null || InObject.SHENFENZH == string.Empty)
            {
                throw new Exception("病人身份证号不能为空!");
            }
            if (InObject.YEWULY == null)
            {
                InObject.YEWULY = InObject.BINGRENLX.ToString();
            }
            var jcsbdm = InObject.JIANCHASBDM.ToString(); //检查设备代码
            var yyrq   = InObject.YUYUERQ.ToString();     //预约日期
            var yysj   = InObject.YUYUESJ.ToString();     //预约时间
            var yyh    = "";                              //预约号



            //不能预约以前的日期
            if (string.Compare(yyrq, DateTime.Now.ToString("yyyy-MM-dd")) < 0)
            {
                throw new Exception("预约日期必须大于等于今天!");
            }
            var          SONGJIANKS = System.Configuration.ConfigurationManager.AppSettings["SXZZ_SONGJIANKS"]; //送检科室
            var          SONGJIANYS = System.Configuration.ConfigurationManager.AppSettings["SXZZ_SONGJIANYS"]; //送检医生
            HISYY_Submit resource   = new HISYY_Submit();

            //获取预约申请单编号
            var yysqdBh = DBVisitor.ExecuteTable("select seq_fsdyy_sq_yysqdbh.nextval yysqdbh from dual");

            //返回字段定义
            OutObject = new SHEBEIYY_OUT();
            //业务类型(1检查,2检验暂时不做)
            if (InObject.YEWULX == "1")
            {
                //调用包,判断入参是否正确
                var jyjcdxx = "";
                var jyjcmx  = "";
                var zdmx    = "";
                var jcxmdm  = "";
                int i       = 0;
                if (InObject.JIANCHALB.Count < 1)
                {
                    throw new Exception("检查项目不能为空!");
                }
                //检查单信息
                jyjcdxx += InObject.JIUZHENKLX + "|";                       //	就诊卡类型
                jyjcdxx += InObject.JIUZHENKH + "|";                        //	就诊卡号
                jyjcdxx += InObject.SHENQINGYSGH + "|";                     //	送检医生
                jyjcdxx += InObject.SHENQINGYYDM + "|";                     //	送检科室
                jyjcdxx += InObject.YUYUESF + "|";                          //	收费识别
                jyjcdxx += InObject.BINGQINGMS + "|";                       //	病情描述
                jyjcdxx += InObject.ZHENDUAN + "|";                         //	诊断
                jyjcdxx += InObject.BINGRENTZ + "|";                        //	病人体征
                jyjcdxx += InObject.QITAJC + "|";                           //	其它检查
                jyjcdxx += InObject.BINGRENZS + "|";                        //	病人主诉
                jyjcdxx += InObject.YEWULY + "|";                           //	检查来源
                jyjcdxx += InObject.BINGRENXM + "|";                        //	病人姓名
                jyjcdxx += InObject.SHENFENZH + "|";                        //	病人身份证号
                jyjcdxx += "0" + "|";                                       //	接收方式
                jyjcdxx += "|";                                             //	检查申请单号
                jyjcdxx += InObject.YUYUERQ + " " + InObject.YUYUESJ + "|"; //	检查日期
                jyjcdxx += InObject.BINGRENXB + "|";                        //	病人性别
                jyjcdxx += InObject.BINGRENNL;                              //	病人年龄

                //检验检查明细
                foreach (var item in InObject.JIANCHALB)
                {
                    if (i == 0)
                    {
                        jcxmdm = item.JIANCHAXMBH;
                    }
                    else
                    {
                        jcxmdm += "," + item.JIANCHAXMBH;
                    }
                    ++i;
                    jyjcmx += item.JIANCHAXMBH + "|"; //	检查项目编号
                    jyjcmx += item.JIANCHAXMMC + "|"; //	检查项目名称
                    jyjcmx += item.JIANCHAFLBM + "|"; //	检查分类编码
                    jyjcmx += item.JIANCHASTBW + "|"; //	检查身体部位
                    jyjcmx += item.JIANCHAFXDM + "|"; //	检查方向代码
                    jyjcmx += item.JIANCHAZYDM + "|"; //	检查肢位代码
                    jyjcmx += item.JIANCHATS + "^";   //	检查提示
                }
                //疾病明细
                foreach (var item in InObject.ZHENDUANLB)
                {
                    zdmx += item.ICD10 + "|";      //	ICD10
                    zdmx += item.ZHENDUANMC + "^"; //诊断名称
                }

                #region 调用莱达接口
                if (InObject.YEWULX == "2")
                {
                    resource.AdmissionSource = "10";
                }
                else
                {
                    resource.AdmissionSource = "50";
                }
                resource.HospitalCode = InObject.SHENQINGYYDM;// InObject.BASEINFO.JIGOUDM;
                resource.HospitalName = InObject.SHENQINGYYMC;
                resource.PatientName  = InObject.BINGRENXM;
                resource.IdNumber     = InObject.SHENFENZH;
                resource.RequestNo    = "";//预约的时候传空
                if (InObject.YEWULY == "2")
                {
                    resource.AdmissionID = InObject.BINGRENZYH;
                }
                else
                {
                    resource.AdmissionID = InObject.BINGRENMZH;
                }
                resource.ExaminePartTime   = InObject.XIANGMUHS;
                resource.PatientSex        = InObject.BINGRENXB.ToString();
                resource.PatientBorn       = InObject.BINGRENCSRQ;
                resource.PatientAge        = InObject.BINGRENNL;
                resource.PatientTel        = InObject.BINGRENLXDH;
                resource.PatientAddress    = InObject.BINGRENLXDZ;
                resource.PatientCard       = InObject.BINGRENID + "|" + InObject.JIUZHENKH;
                resource.InPatientAreaName = InObject.BINGRENBQMC;
                resource.InPatientAreaCode = InObject.BINGRENBQDM;
                resource.BedNum            = InObject.BINGRENCWH;
                resource.DeviceCode        = InObject.JIANCHASBDM.ToString();
                resource.DeviceName        = InObject.JIANCHASBMC;
                //,B.DAIMAID,B.DAIMAMC,D.KESHIMC
                string jcxmSql = @"SELECT A.*,B.DAIMAID,B.DAIMAMC,D.KESHIMC FROM GY_JIANCHAXM A, GY_JIANCHABW B, GY_JIANCHAXMBWDY C,  
                            GY_KESHI D,GY_YUANQU E  WHERE A.JIANCHAXMID = C.JIANCHAXMID AND B.DAIMAID = C.JIANCHABWID  
                            AND D.KESHIID=A.ZHIXINGKS AND A.ZUOFEIBZ = 0 AND B.ZUOFEIBZ = 0 AND D.YUANQUID = E.YUANQUID
                            AND A.JIANCHAXMID IN({0}) AND B.DAIMAID = {1} AND E.YUANQUMC = '{2}'";
                jcxmSql = string.Format(jcxmSql, jcxmdm, InObject.JIANCHABWDM.ToString(), ConfigurationManager.AppSettings["HospitalName_Fck"].ToString());

                DataTable jcxmDt = DBVisitor.ExecuteTable(jcxmSql);
                foreach (DataRow dr in jcxmDt.Rows)
                {
                    resource.StudiesExamine.Add(new StudiesExamine()
                    {
                        //HT  更改CODE取值 检查厂商使用的是HIS的部位ID和部位的名称,而没有检查项目ID
                        //ExamineCode = dr["JIANCHAXMID"].ToString(),
                        ExamineCode  = dr["DAIMAID"].ToString(),
                        ExamineName  = XMLHandle.encodeString(dr["DAIMAMC"].ToString()),
                        Numbers      = "1",
                        ExaminePrice = "0"//这里默认给个0
                    });
                }
                resource.StudiesExamine   = resource.StudiesExamine.Distinct().ToList();
                resource.ExamineFY        = resource.StudiesExamine.Sum <StudiesExamine>(group => { return(Convert.ToDecimal(group.ExaminePrice)); }).ToString();
                resource.ReceiptNum       = InObject.BINGRENFPH;
                resource.ZxDepartmentId   = jcxmDt.Rows[0]["zhixingks"].ToString();
                resource.ZxDepartmentName = jcxmDt.Rows[0]["keshimc"].ToString();
                resource.Sqrq             = InObject.BASEINFO.CAOZUORQ;
                resource.BespeakDateTime  = InObject.YUYUERQ + " " + InObject.YUYUESJ;
                resource.JZ = "0"; // InObject.JIZHEN;
                resource.ZQ = "0"; //InObject.ZENGQIANG;
                resource.LS = "0"; //InObject.LINSHI;
                resource.PF = "1";

                //调用莱达WEBSERVICE---------------------------------------------------------------
                string url = System.Configuration.ConfigurationManager.AppSettings["LaiDa_Url"];
                string xml = XMLHandle.EntitytoXML <HISYY_Submit>(resource);

                //LogHelper.WriteLog(typeof(GG_ShuangXiangZzBLL), "设备预约调用莱达XML入参:" + xml);
                string outxml = WSServer.Call <HISYY_Submit>(url, xml).ToString();

                //LogHelper.WriteLog(typeof(GG_ShuangXiangZzBLL), "设备预约调用莱达XML出参:" + outxml);
                HISYY_Submit_Result result = XMLHandle.XMLtoEntity <HISYY_Submit_Result>(outxml);
                //-------------------------------------------------------------------------------
                if (result.Success == "False")
                {
                    throw new Exception("预约失败,错误原因:" + result.Message);
                }
                #endregion

                //定义数据库transaction
                var tran = DBVisitor.Connection.BeginTransaction();
                var xh   = DBVisitor.ExecuteScalar("select seq_sxzz_jianchasqd.nextval from dual").ToString();
                //保存预约数据
                try
                {
                    //先插入到临时表

                    var JCSQDH = result.JCH;
                    //var jiuzhenid = DBVisitor.ExecuteScalar("select SEQ_ZJ_JIUZHENXX.NEXTVAL from dual").ToString();
                    int k = 0;
                    //插入检查单信息
                    string insJcd = @"insert into SXZZ_JIANCHASQD(JIANCHASQDID,JIUZHENKLX,JIUZHENKH,BINGRENXM,
                                      BINGRENSFZH,SONGJIANYSGH,SONGJIANKSDM,SHOUFEIBZ,
                                      BINGQINGMS,ZHENDUANMC,BINGRENTZ,QITAJC,
                                      BINGRENZS,JIANCHALY,JIESHOUFS,JIESHOURQ,
                                      JIESHOUBZ,YIJISQDH,JIANCHARQ,BINGRENXB,BINGRENNL,
                                        JIANCHASQDZT,YIJIZXKS,YIJIZXKSMC,BINGRENLX,
                                         BINGRENLXMC,ZHUYUANHAO,SONGJIANBQDM,SONGJIANBQMC,
                                         CHAUNGWEIID,CHUSHENGRQ,BINGRENLXDZ,BINGRENLXDH,
                                        SONGJIANYSXM,SONGJIANKSMC,SONGJIANYYDM,SONGJIANYYMC,
                                        YIJISBDM,YIJISBMC,YIJISBDZ,YIJIYYH,
                                        YIJIYYSJD,YIJIXXAPSJ,YIJIYYRQ)
                                      values({0},'{1}','{2}','{3}',
                                            '{4}','{5}','{6}','{7}',
                                            '{8}','{9}','{10}','{11}',
                                            '{12}','{13}','{14}',sysdate,
                                            0,'{15}',to_date('{16}','yyyy-mm-dd'),'{17}','{18}',
                                            '{19}','{20}','{21}','{22}',
                                            '{23}','{24}','{25}','{26}',
                                            '{27}',to_date('{28}','yyyy-mm-dd'),'{29}','{30}',
                                            '{31}','{32}','{33}','{34}',
                                            '{35}','{36}','{37}','{38}',
                                            '{39}','{40}',to_date('{41}','yyyy-mm-dd hh24:mi'))";

                    DBVisitor.ExecuteNonQuery(string.Format(insJcd, xh, "", InObject.JIUZHENKH, InObject.BINGRENXM,
                                                            InObject.SHENFENZH, SONGJIANYS, SONGJIANKS, 0,
                                                            InObject.BINGQINGMS, InObject.ZHENDUAN, InObject.BINGRENTZ, InObject.QITAJC,
                                                            InObject.BINGRENZS, InObject.YEWULX, 0, JCSQDH, InObject.YUYUERQ,
                                                            InObject.BINGRENXB, InObject.BINGRENNL,
                                                            InObject.YUYUEZT,
                                                            InObject.JIANCHAKSDM,
                                                            InObject.JIANCHAKSMC,
                                                            InObject.BINGRENLX,
                                                            InObject.BINGRENLXMC,
                                                            InObject.BINGRENZYH,
                                                            InObject.BINGRENBQDM,
                                                            InObject.BINGRENBQMC,
                                                            InObject.BINGRENCWH,
                                                            InObject.BINGRENCSRQ,
                                                            InObject.BINGRENLXDZ,
                                                            InObject.BINGRENLXDH,
                                                            InObject.SHENQINGYSMC,                    //申请医生姓名
                                                            "",                                       //申请科室名称
                                                            InObject.SHENQINGYYDM,                    //申请医院代码
                                                            InObject.SHENQINGYYMC,                    //申请医院名称
                                                                                                      //InObject.YUYUESJ,//检查时间
                                                                                                      //InObject.JIANCHAXMLX,//检查项目类型
                                                            InObject.JIANCHASBDM,                     //检查设备代码
                                                            InObject.JIANCHASBMC,                     //检查设备名称
                                                            InObject.JIANCHASBDD,                     //检查设备地点
                                                            result.YYH,                               //预约号
                                                            result.PDH,                               //时间段  预约申请时间段
                                                            InObject.XIANGMUHS,                       //详细安排时间
                                                            InObject.YUYUERQ + " " + InObject.YUYUESJ //预约日期
                                                            ), tran);

                    //插入检查明细
                    foreach (var item in InObject.JIANCHALB)
                    {
                        var    mxxh    = DBVisitor.ExecuteScalar("select seq_sxzz_jianchasqdmx.nextval from dual").ToString();
                        string insJcmx = @"insert into SXZZ_JIANCHASQDMX(JIANCHASQDID,JIANCHASQDMXID,JIANCHAXMBH,
                                           JIANCHAXMMC,JIANCHAFLBM,JIANCHASTBW,
                                           JIANCHAFXDM,JIANCHAZYDM,JIANCHATS)
                                           values({0},{1},'{2}',
                                           '{3}','{4}','{5}',
                                           '{6}','{7}','{8}')";

                        DBVisitor.ExecuteNonQuery(string.Format(insJcmx, xh, mxxh, item.JIANCHAXMBH,
                                                                item.JIANCHAXMMC, item.JIANCHAFLBM, item.JIANCHASTBW,
                                                                item.JIANCHAFXDM, item.JIANCHAZYDM, item.JIANCHATS), tran);
                    }
                    k = 0;
                    //插入诊断明细
                    foreach (var item in InObject.ZHENDUANLB)
                    {
                        var zdxh = DBVisitor.ExecuteScalar("select seq_sxzz_jianchasqdzd.nextval from dual").ToString();

                        string insZdmx = @"insert into SXZZ_JIANCHASQDZD(JIANCHASQDID,JIANCHADZDID,icd10,zhenduanmc)
                                           values({0},{1},'{2}','{3}')";

                        DBVisitor.ExecuteNonQuery(string.Format(insZdmx, xh, zdxh, item.ICD10, item.ZHENDUANMC), tran);
                    }

                    tran.Commit();

                    OutObject.YUYUERQ    = InObject.YUYUERQ;
                    OutObject.YUYUESJ    = InObject.YUYUESJ;
                    OutObject.YUYUEH     = result.YYH;
                    OutObject.JIANCHAH   = result.JCH;
                    OutObject.YUYUESQDBH = xh;
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    var resource1 = new HISYY_Cancel();
                    resource1.RequestNo = "";// listyyxx.Items["YYH"].ToString();
                    resource1.YYH       = result.YYH;
                    resource1.JCH       = result.PDH;
                    string url1    = System.Configuration.ConfigurationManager.AppSettings["LaiDa_Url"];
                    string xml1    = XMLHandle.EntitytoXML <HISYY_Cancel>(resource1);
                    string outxml1 = WSServer.Call <HISYY_Cancel>(url, xml).ToString();
                    HISYY_Cancel_Result result1 = XMLHandle.XMLtoEntity <HISYY_Cancel_Result>(outxml);
                    throw new Exception(ex.Message);
                }


                var trans = DBVisitor.Connection.BeginTransaction();
                try
                {
                    //拼装交易字符串
                    //--1 病人id
                    //--2 检查项目id
                    //--3 检查部位id列表
                    //--4 临床诊断
                    //--5 院区id
                    //--6 应用id
                    //--7 操作员工号
                    //--8 中间表申请单序号
                    string jianChaBWDM = string.Empty;
                    InObject.JIANCHALB.ForEach(o => jianChaBWDM += o.JIANCHASTBW + "#");
                    jianChaBWDM = jianChaBWDM.Trim('#');
                    string jiaoyiZfc = InObject.BINGRENID;          //病人id
                    jiaoyiZfc += "|" + InObject.JIANCHAXMDM;        //检查项目id
                    jiaoyiZfc += "|" + jianChaBWDM;                 //检查部位id列表
                    jiaoyiZfc += "|" + InObject.ZHENDUAN;           //临床诊断
                    jiaoyiZfc += "|" + InObject.BASEINFO.FENYUANDM; //院区id
                    jiaoyiZfc += "|" + "2301";                      //应用id
                    jiaoyiZfc += "|" + InObject.BASEINFO.CAOZUOYDM; //操作员工号
                    jiaoyiZfc += "|" + xh;                          //中间表申请单序号

                    //提交预约号-------------------------------------------------------------------------------------------
                    OracleParameter[] paramJiaoYi = new OracleParameter[3];
                    paramJiaoYi[0]           = new OracleParameter("Prm_Msg", OracleType.VarChar);
                    paramJiaoYi[0].Value     = jiaoyiZfc;
                    paramJiaoYi[0].Direction = ParameterDirection.Input;
                    paramJiaoYi[1]           = new OracleParameter("prm_AppCode", OracleType.Number);
                    paramJiaoYi[1].Value     = null;
                    paramJiaoYi[1].Direction = ParameterDirection.Output;
                    paramJiaoYi[2]           = new OracleParameter("prm_DataBuffer", OracleType.VarChar);
                    paramJiaoYi[2].Value     = null;
                    paramJiaoYi[2].Size      = 2000;
                    paramJiaoYi[2].Direction = ParameterDirection.Output;

                    log.InfoFormat("{0}", "执行存储过程:PKG_YJ_YUYUE_YH.Prc_YJ_ShuangXiangZZJC_JieKou \r\nPRM_JIAOYIZFC:" + jiaoyiZfc + "\r\n");

                    DBVisitor.ExecuteProcedure("PKG_YJ_YUYUE_YH.Prc_YJ_ShuangXiangZZJC_JieKou", paramJiaoYi, trans);

                    if (paramJiaoYi[1].Value.ToString() != "1")
                    {
                        throw new Exception("his系统计费失败!");
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    var resource1 = new HISYY_Cancel();
                    resource1.RequestNo = "";// listyyxx.Items["YYH"].ToString();
                    resource1.YYH       = result.YYH;
                    resource1.JCH       = result.PDH;
                    string url1    = System.Configuration.ConfigurationManager.AppSettings["LaiDa_Url"];
                    string xml1    = XMLHandle.EntitytoXML <HISYY_Cancel>(resource1);
                    string outxml1 = WSServer.Call <HISYY_Cancel>(url, xml).ToString();
                    HISYY_Cancel_Result result1 = XMLHandle.XMLtoEntity <HISYY_Cancel_Result>(outxml);
                    throw ex;
                }
            }
            //检验,暂时先不考虑----------------------------------------------------------------------------
            #region 检验设备预约
            else
            {
                //                //调用包,判断入参是否正确
                //                var jyjcdxx = "";
                //                var jyjcmx = "";
                //                var zdmx = "";
                //                var jcxmdm = "";
                //                int i = 0;
                //                if (InObject.JIANCHALB.Count < 1)
                //                {
                //                    throw new Exception(string.Format("检查项目不能为空!"));
                //                }
                //                //检查单信息
                //                jyjcdxx += InObject.JIUZHENKLX + "|";//	就诊卡类型
                //                jyjcdxx += InObject.JIUZHENKH + "|";//	就诊卡号
                //                jyjcdxx += SONGJIANKS + "|";//	送检医生
                //                jyjcdxx += SONGJIANYS + "|";//	送检科室
                //                jyjcdxx += InObject.YUYUESF + "|";//	收费识别
                //                jyjcdxx += InObject.BINGQINGMS + "|";//	病情描述
                //                jyjcdxx += InObject.ZHENDUAN + "|";//	诊断
                //                jyjcdxx += InObject.BINGRENTZ + "|";//	病人体征
                //                jyjcdxx += InObject.QITAJC + "|";//	其它检查
                //                jyjcdxx += InObject.BINGRENZS + "|";//	病人主诉
                //                jyjcdxx += InObject.YEWULY + "|";//	检查来源
                //                jyjcdxx += InObject.BINGRENXM + "|";//	病人姓名
                //                jyjcdxx += InObject.SHENFENZH + "|";//	病人身份证号
                //                jyjcdxx += "0" + "|";//	接收方式
                //                jyjcdxx += "|";//	检查申请单号
                //                jyjcdxx += InObject.YUYUERQ + " " + InObject.YUYUESJ + "|";//	检查日期
                //                jyjcdxx += InObject.BINGRENXB + "|";//	病人性别
                //                jyjcdxx += InObject.BINGRENNL;//	病人年龄

                //                //检验检查明细
                //                foreach (var item in InObject.JIANCHALB)
                //                {
                //                    if (i == 0)
                //                        jcxmdm = item.JIANCHAXMBH;
                //                    else
                //                        jcxmdm += "," + item.JIANCHAXMBH;
                //                    ++i;
                //                    jyjcmx += item.JIANCHAXMBH + "|";//	检查项目编号
                //                    jyjcmx += item.JIANCHAXMMC + "|";//	检查项目名称
                //                    jyjcmx += item.JIANCHAFLBM + "|";//	检查分类编码
                //                    jyjcmx += item.JIANCHASTBW + "|";//	检查身体部位
                //                    jyjcmx += item.JIANCHAFXDM + "|";//	检查方向代码
                //                    jyjcmx += item.JIANCHAZYDM + "|";//	检查肢位代码
                //                    jyjcmx += item.JIANCHATS + "^";//	检查提示

                //                }
                //                //疾病明细
                //                foreach (var item in InObject.ZHENDUANLB)
                //                {
                //                    zdmx += item.ICD10 + "|";//	ICD10
                //                    zdmx += item.ZHENDUANMC + "^";//	诊断名称
                //                }

                //                DBServer db = new DBServer();
                //                //调用检查开单包-------------------------------------------------------------------------------------------
                //                OracleParameter[] jiaoYi ={
                //                                new OracleParameter("ywlx",OracleDbType.VarChar,ParameterDirection.Input),
                //                                new OracleParameter("jyjcdxx",OracleDbType.VarChar,ParameterDirection.Input),
                //                                new OracleParameter("jyjcmx",OracleDbType.VarChar,ParameterDirection.Input),
                //                                new OracleParameter("zdmx",OracleDbType.VarChar,ParameterDirection.Input),
                //                                new OracleParameter("jylx",OracleDbType.VarChar,ParameterDirection.Input),
                //                                new OracleParameter("errno",OracleDbType.Integer,ParameterDirection.Output),
                //                                new OracleParameter("errmsg",OracleDbType.Integer,ParameterDirection.Output),
                //                                new OracleParameter("outdata",OracleDbType.VarChar,ParameterDirection.Output)
                //                                                };
                //                jiaoYi[0].Value = 2;
                //                jiaoYi[1].Value = jyjcdxx;
                //                jiaoYi[2].Value = jyjcmx;
                //                jiaoYi[3].Value = zdmx;
                //                jiaoYi[4].Value = 1;
                //                jiaoYi[5].Value = -1;
                //                jiaoYi[6].Value = string.Empty.PadRight(1024);
                //                jiaoYi[7].Value = string.Empty.PadRight(1024);
                //                try
                //                {
                //                    db.DbProOption("pkg_sxzz_jckd.prc_jsjcd", jiaoYi, 5);
                //                }
                //                catch (Exception ex)
                //                {
                //                    tradeOut = WcfCommon.GetXmlString(tradeHead, tradeType, tradeDetail, new DataTable(), -1, ex.Message);
                //                    return -1;
                //                }
                //                if (jiaoYi[5].Value.ToString() != "0")
                //                {
                //                    throw new Exception("更新预约信息失败:" + jiaoYi[6].Value.ToString());
                //                }

                //                OracleConnection conn = new OracleConnection(MediTrade.Common.ConfigInfo.SqlConn);
                //                OracleCommand comm = new OracleCommand();
                //                comm.Connection = conn;
                //                if (conn.State != System.Data.ConnectionState.Open)
                //                {
                //                    conn.Open();
                //                }
                //                OracleTransaction tran = conn.BeginTransaction();
                //                comm.Transaction = tran;
                //                try
                //                {
                //                    //先插入到临时表
                //                    var ID = new DBServer().GetCurrData("select seq_sxzz_jianchad.nextval from dual");
                //                    var xh = "";
                //                    var JCSQDH = "";
                //                    int k = 0;
                //                    if (ID == null)
                //                    {
                //                        throw new Exception(string.Format("检查单序列获取失败!"));
                //                    }
                //                    else
                //                    {
                //                        xh = ID.ToString();
                //                    }
                //                    var SQDH = new DBServer().GetCurrData("select SEQ_GY_YXSQD_SQDH.nextval from dual");
                //                    if (SQDH == null)
                //                    {
                //                        throw new Exception(string.Format("申请单号获取失败!"));
                //                    }
                //                    else
                //                    {
                //                        JCSQDH = SQDH.ToString();
                //                    }
                //                    //插入检查单信息
                //                    string insJcd = @"insert into sxzz_jianchad(JIANCHADXH,JIUZHENKLX,JIUZHENKH,BINGRENXM,
                //                                      BINGRENSFZH,SONGJIANYS,SONGJIANKS,SHOUFEISB,
                //                                      BINGQINGMS,ZHENDUAN,BINGRENTZ,QITAJC,
                //                                      BINGRENZS,JIANCHALY,JIESHOUFS,JIESHOURQ,
                //                                      JIESHOUBZ,JIANCHASQDH,JIANCHARQ,BINGRENXB,BINGRENNL,YYSQDBH)
                //                                      values({0},'{1}','{2}','{3}',
                //                                            '{4}','{5}','{6}','{7}',
                //                                            '{8}','{9}','{10}','{11}',
                //                                            '{12}','{13}','{14}',sysdate,
                //                                            0,'{15}','{16}','{17}','{18}','{19}')";
                //                    insJcd = string.Format(insJcd, xh, "", InObject.BINGRENMZH, InObject.BINGRENXM,
                //                                InObject.SHENFENZH, InObject.SHENQINGYSGH, InObject.JIANCHAKSDM, 0,
                //                                InObject.BINGQINGMS, InObject.ZHENDUAN, InObject.BINGRENTZ, InObject.QITAJC,
                //                                InObject.BINGRENZS, InObject.YEWULX, 0, JCSQDH, InObject.YUYUERQ,
                //                                InObject.BINGRENXB, InObject.BINGRENNL, yysqdBh);
                //                    comm.CommandText = insJcd;
                //                    comm.ExecuteNonQuery();
                //                    //插入检查明细
                //                    foreach (var item in InObject.JIANCHALB)
                //                    {
                //                        ++k;
                //                        string insJcmx = @"insert into sxzz_jianchadxm (JIANCHADXH,JIANCHADMXXH,JIANCHAXMBH,
                //                                          JIANCHAXMMC,JIANCHAFLBM,JIANCHASTBW,
                //                                          JIANCHAFXDM,JIANCHAZYDM,JIANCHATS)
                //                                          values({0},{1},'{2}',
                //                                          '{3}','{4}','{5}',
                //                                          '{6}','{7}','{8}')";
                //                        insJcmx = string.Format(insJcmx, xh, k, item.JIANCHAXMBH,
                //                            item.JIANCHAXMMC, item.JIANCHAFLBM, item.JIANCHASTBW,
                //                            item.JIANCHAFXDM, item.JIANCHAZYDM, item.JIANCHATS);
                //                        comm.CommandText = insJcmx;
                //                        comm.ExecuteNonQuery();
                //                    }
                //                    k = 0;
                //                    //插入诊断明细
                //                    foreach (var item in InObject.ZHENDUANLB)
                //                    {
                //                        ++k;
                //                        string insZdMx = @"insert into sxzz_jianchadzd (jianchadxh,jianchadzdxh,icd10,zhenduanmc)
                //                                           values({0},{1},'{2}','{3}')";
                //                        insZdMx = string.Format(insZdMx, xh, k, item.ICD10, item.ZHENDUANMC);
                //                        comm.CommandText = insZdMx;
                //                        comm.ExecuteNonQuery();
                //                    }

                //                    var yysqlsh = new DBServer().GetCurrData("select seq_fsdyy_sq_yysqlsh.nextval yysqlsh from dual");
                //                    //插入预约申请信息fdsyy_sq
                //                    string insYySqd = @"Insert into fsdyy_sq (yysqlsh,yysqdbh,yysqdmc,yysqdzt,jcksdm,jcksmc,brfph,brlx,brlxmc,brkh,brmzh,brzyh,brbqdm,brbqmc,brcwh,brxm,
                //                                        brxb,brnl,brcsrq,brlxdz,brlxdh,sqysgh,sqysmc,sqksdm,sqksmc,sqyydm,sqyymc,sqsj,jch,jcrq,jcsj,jcxmdm,jcxmmc
                //                                        ,jcxmlx,jcbwdm,jcbwmc,jcsbdm,jcsbmc,jcsbdd,yyh,sfzh,yysf,jcsqdbh,yxfx,yysjd,xxapsj,yyly,ywlx,sfzq,sfjz,sfls,yyrq,yyhxx)
                //                                        values({42}, --预约申请流水号
                //                                               {43},     --预约申请单编号
                //                                               '{0}',     --预约申请单名称
                //                                               {1},     --预约申请单状态(0未确认,1已确认,9作废)
                //                                               '{2}',     --检查科室代码
                //                                               '{3}',     --检查科室名称
                //                                               '{4}',     --病人发票号
                //                                               {5},     --病人类型
                //                                               '{6}',     --病人类型名称
                //                                               '{7}',     --病人卡号
                //                                               '{8}',     --病人门诊号
                //                                               '{9}',     --病人住院号
                //                                               '{10}',     --病人病区代码
                //                                               '{11}',     --病人病区名称
                //                                               '{12}',     --病人床位号
                //                                               '{13}',     --病人姓名
                //                                               {14},     --病人性别
                //                                               '{15}',     --病人年龄
                //                                               to_date('{16}','yyyy-MM-dd'),     --病人出生日期
                //                                               '{17}',     --病人联系地址
                //                                               '{18}',     --病人联系电话
                //                                               '{19}',     --申请医生工号
                //                                               '{20}',     --申请医生姓名
                //                                               '{21}',     --申请科室代码
                //                                               '{22}',     --申请科室名称
                //                                               '{23}',     --申请医院代码
                //                                               '{24}',     --申请医院名称
                //                                               sysdate,     --申请时间
                //                                               '{25}',     --检查号
                //                                               '{26}',     --检查日期
                //                                               '{27}',     --检查时间
                //                                               '{28}',     --检查项目代码
                //                                               '{29}',     --检查项目名称
                //                                               '{30}',     --检查项目类型
                //                                               '{31}',     --检查部位代码
                //                                               '{32}',     --检查部位名称
                //                                               '{33}',     --检查设备代码
                //                                               '{34}',     --检查设备名称
                //                                               '{35}',     --检查设备地点
                //                                               '{36}',     --预约号
                //                                               '{37}',     --身份证号
                //                                               {38},     --预约收费(0未收费,1已收费)
                //                                               '{39}',     --检查申请单编号
                //                                               '{40}',      --影像方向
                //                                               '{41}',      --预约时间段
                //                                               '{44}',      --详细安排时间
                //                                               '{45}',        --预约来源
                //                                               '{46}',       --业务类型
                //                                               '{47}',      --是否增强
                //                                               '{48}',      --是否急诊
                //                                               '{49}',      --是否临时
                //                                               to_date('{50}','yyyy-mm-dd HH24:mi:ss'),--预约日期
                //                                               '{51}')     --预约号信息";
                //                    insYySqd = string.Format(insYySqd, "申请单",//预约申请单名称
                //                       InObject.YUYUEZT,//预约申请单状态(0未确认,1已确认,9作废)
                //                       InObject.JIANCHAKSDM,//检查科室代码
                //                       InObject.JIANCHAKSMC,//检查科室名称
                //                       InObject.BINGRENFPH,//病人发票号
                //                       InObject.BINGRENLX,//病人类型
                //                       InObject.BINGRENLXMC,//病人类型名称
                //                       InObject.BINGRENKH,//病人卡号
                //                       InObject.BINGRENMZH,//病人门诊号
                //                       InObject.BINGRENZYH,//病人住院号
                //                       InObject.BINGRENBQDM,//病人病区代码
                //                       InObject.BINGRENBQMC,//病人病区名称
                //                       InObject.BINGRENCWH,//病人床位号
                //                       InObject.BINGRENXM,//病人姓名
                //                       InObject.BINGRENXB,//病人性别
                //                       InObject.BINGRENNL,//病人年龄
                //                       InObject.BINGRENCSRQ,//病人出生日期
                //                       InObject.BINGRENLXDZ,//病人联系地址
                //                       InObject.BINGRENLXDH,//病人联系电话
                //                       InObject.SHENQINGYSGH,//申请医生工号
                //                       InObject.SHENQINGYSMC,//申请医生姓名
                //                       "",//申请科室代码
                //                       "",//申请科室名称
                //                       InObject.SHENQINGYYDM,//申请医院代码
                //                       InObject.SHENQINGYYMC,//申请医院名称
                //                       JCSQDH,//检查号
                //                       InObject.YUYUERQ,//检查日期
                //                       InObject.YUYUESJ,//检查时间
                //                       jcxmdm,//InObject.JIANCHAXMDM,//检查项目代码
                //                       InObject.JIANCHAXMMC,//检查项目名称
                //                       InObject.JIANCHAXMLX,//检查项目类型
                //                       InObject.JIANCHABWDM,//检查部位代码
                //                       InObject.JIANCHABWMC,//检查部位名称
                //                       InObject.JIANCHASBDM,//检查设备代码
                //                       InObject.JIANCHASBMC,//检查设备名称
                //                       InObject.JIANCHASBDD,//检查设备地点
                //                       "",//预约号
                //                       InObject.SHENFENZH,//身份证号
                //                       InObject.YUYUESF,//预约收费(0未收费,1已收费)
                //                       InObject.JIANCHASQDBH,//检查申请单编号
                //                       InObject.YINGXIANGFX,//影像方向
                //                       "",//时间段
                //                       yysqlsh,//预约申请流水号
                //                       yysqdBh,//预约申请单编号
                //                       InObject.XIANGMUHS,//详细安排时间
                //                       InObject.YEWULY,
                //                       InObject.YEWULX,
                //                       InObject.ZENGQIANG,
                //                       InObject.JIZHEN,
                //                       InObject.LINSHI,
                //                       InObject.YUYUERQ + " " + InObject.YUYUESJ,//预约日期
                //                       0);
                //                    comm.CommandText = insYySqd;
                //                    comm.ExecuteNonQuery();

                //                    tran.Commit();
                //                    conn.Close();

                //                    OutObject = new SHEBEIYY_OUT();
                //                    //OutObject.YUYUERQ = InObject.YUYUERQ;
                //                    //OutObject.YUYUESJ = InObject.YUYUESJ;
                //                    //OutObject.YUYUEH = result.YYH;
                //                    //OutObject.JIANCHAH = result.JCH;
                //                    OutObject.YUYUESQDBH = yysqdBh;
                //                }
                //                catch (Exception ex)
                //                {
                //                    tran.Rollback();
                //                    conn.Close();
                //                    throw ex;
                //                }
            }
            #endregion
            //---------------------------------------------------------------------------------------------
        }
Example #22
0
        /// <summary>
        /// 转诊预约接口转发(桐庐) 和区域卫生做的对接 _______胡谦
        /// </summary>
        /// <param name="header"></param>
        /// <param name="body"></param>
        /// <param name="ehrXml"></param>
        public void DoBusiness(string header, string body, ref string ehrXml)
        {
            log.InfoFormat("DoBusiness##" + header + "###" + body);
            string ZHUANZHENYYLXDM = ConfigurationManager.AppSettings["ZHUANZHENYYLXDM"];
            int    i    = 0;
            string guid = Guid.NewGuid().ToString("N").ToUpper();

            log.InfoFormat("[{2}][{0}].IN  {1}", header, LogUnity.I.ShowXml(body), guid);

            Header head = new Header();

            head = MessageParse.ToXmlObject <Header>(header);

            Body inobject = MessageParse.ToXmlObject <Body>(body);

            BASEINFO baseinfo = new BASEINFO();

            baseinfo.CAOZUORQ  = head.RequestTime;
            baseinfo.CAOZUOYDM = head.UserId;
            baseinfo.JIGOUDM   = head.OrganizationId;
            baseinfo.MACDZ     = head.lient_Mac;

            Result result = new Result();

            result.Code = "0";
            result.Msg  = "OK";

            //modify by 沈宝
            try
            {
                switch (head.DocumentID)
                {
                    #region 挂号科室信息
                case "GUAHAOKSXX":
                    string ksdm = inobject.KESHIDM;
                    string sql  = "select * from v_ksxx_mcp";
                    if (!string.IsNullOrEmpty(ksdm))
                    {
                        sql += $" where  KESHIDM='{ksdm}'";
                    }
                    DataTable dt = DBVisitor.ExecuteTable(sql);

                    Body_GUAHAOKSXX outObj = new Body_GUAHAOKSXX
                    {
                        Result  = new Result(),
                        KESHIMX = new List <Entity.KESHIXX>()
                    };
                    outObj.Result = result;
                    foreach (DataRow dr in dt.Rows)
                    {
                        Entity.KESHIXX ksxx = new Entity.KESHIXX
                        {
                            JIUZHENDD = dr["WEIZHI"].ToString(),
                            KESHIDM   = dr["KESHIDM"].ToString(),
                            KESHIJS   = dr["KESHIJS"].ToString(),
                            KESHIMC   = dr["KESHIMC"].ToString(),
                            KESHIPX   = ""
                        };
                        outObj.KESHIMX.Add(ksxx);
                    }
                    ehrXml = MessageParse.GetXml(outObj);
                    log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);

                    return;

                    #endregion

                    #region 医生信息
                case "YISHENGJSXX":

                    string ysdm = inobject.YISHENGDM;
                    sql = "select * from v_zgxx_mcp ";
                    if (!string.IsNullOrEmpty(ysdm))
                    {
                        sql += $" where ZHIGONGID='{ysdm}'";
                    }
                    dt = DBVisitor.ExecuteTable(sql);

                    Body_YISHENGJSXX jsxxObj = new Body_YISHENGJSXX
                    {
                        Result    = new Result(),
                        YISHENGMX = new List <Entity.YISHENGXX>()
                    };
                    jsxxObj.Result = result;
                    foreach (DataRow dr in dt.Rows)
                    {
                        Entity.YISHENGXX ysxx = new Entity.YISHENGXX
                        {
                            YISHENGDM   = dr["ZHIGONGID"].ToString(),
                            YISHENGXM   = dr["ZHIGONGXM"].ToString(),
                            YISHENGXB   = dr["XB"].ToString(),
                            ZHENGJIANLX = "1",
                            ZHENGJIANHM = dr["shenfenzh"].ToString(),
                            YISHENGPX   = "",
                            YISHENGZC   = dr["ZHICHENG"].ToString(),
                            YISHENGTC   = dr["YISHENGSC"].ToString(),
                            YISHENGJS   = dr["DISCRIPTION"].ToString(),
                            ZHAOPIAN    = "",
                        };
                        jsxxObj.YISHENGMX.Add(ysxx);
                    }
                    ehrXml = MessageParse.GetXml(jsxxObj);
                    log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);

                    return;

                    #endregion

                    #region 排班信息 排班 上午和下午要分两条转 排班ID 要不一样
                case "YIYUANPBXX":
                    //mody by 沈宝2017/1/9
                    string ysdmpb = inobject.YISHENGDM == "" ? "1" : "2";
                    if (ysdmpb == "1")
                    {
                        string sql1 = (inobject.KESHIDM == "" ? "" : "and YIZHOUKSDM = " + inobject.KESHIDM);                    //过滤条件可是代码为空时传全部;
                        sql = $" select * from V_YIYUANYZPBXX_MCP where YIZHOUPNLBDM='1' and YUYUELX='{ZHUANZHENYYLXDM}'{sql1}"; //YUYUELX 10是分配给转诊预约的,测试时用2
                    }
                    else
                    {
                        string sql1 = (inobject.KESHIDM == "" ? "" : "and YIZHOUKSDM = " + inobject.KESHIDM);
                        sql = $" select * from V_YIYUANYZPBXX_MCP where YUYUELX='{ZHUANZHENYYLXDM}'{sql1}";
                    }
                    dt = DBVisitor.ExecuteTable(sql);

                    Body_YIYUANPBXX pbxxObj = new Body_YIYUANPBXX
                    {
                        Result   = new Result(),
                        PAIBANLB = new List <Entity.PAIBANMX>()
                    };
                    pbxxObj.Result = result;
                    int pd = Convert.ToInt32(inobject.GUAHAOBC);
                    //modify by 沈宝
                    foreach (DataRow dr in dt.Rows)
                    {
                        DateTime schedulingDate = ToolUnity.RqtoXq(dr["YIZHOUXQ"].ToString());
                        #region  午的排班
                        if (pd == 1)
                        {
                            Entity.PAIBANMX pbmx1 = new Entity.PAIBANMX
                            {
                                HAOYUANFPLX  = "0",
                                KESHIDM      = dr["YIZHOUKSDM"].ToString(),
                                KESHIMC      = dr["YIZHOUKSMC"].ToString(),
                                JIUZHENDD    = dr["GUAHAOKSWZMC"].ToString(),
                                KESHIJS      = "",
                                KESHIPX      = "",
                                YISHENGDM    = dr["YIZHOUYSDM"].ToString(),
                                YISHENGXM    = dr["YIZHOUPBLBDM"].ToString() == "1" ? dr["YIZHOUPBLBMC"].ToString() : dr["YIZHOUYSXM"].ToString(), //dr["YIZHOUPNLBDM"]=="1"?dr[]: dr["YIZHOUYSXM"].ToString(),
                                ZHENLIAOF    = dr["ZHENLIAOFEI"].ToString(),
                                ZHENLIAOJSF  = "0",
                                PAIBANRQ     = schedulingDate.ToString("yyyy-MM-dd"),
                                TINGZHENBZ   = "0",
                                GUAHAOBC     = "1",
                                GUAHAOLB     = dr[" "].ToString(),
                                YIZHOUPBID   = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|1",
                                DANGTIANPBID = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|1"
                            };
                            if (int.Parse(dr["YIZHOUSWZGXH"].ToString()) > 0)
                            {
                                pbxxObj.PAIBANLB.Add(pbmx1);
                            }
                        }
                        else if (pd == 2)
                        {
                            #endregion
                            #region  午的排班


                            Entity.PAIBANMX pbmx2 = new Entity.PAIBANMX
                            {
                                HAOYUANFPLX  = "0",
                                KESHIDM      = dr["YIZHOUKSDM"].ToString(),
                                KESHIMC      = dr["YIZHOUKSMC"].ToString(),
                                JIUZHENDD    = dr["GUAHAOKSWZMC"].ToString(),
                                KESHIJS      = "",
                                KESHIPX      = "",
                                YISHENGDM    = dr["YIZHOUYSDM"].ToString(),
                                YISHENGXM    = dr["YIZHOUPBLBDM"].ToString() == "1" ? dr["YIZHOUPBLBMC"].ToString() : dr["YIZHOUYSXM"].ToString(), // dr["YIZHOUYSXM"].ToString(),
                                ZHENLIAOF    = dr["ZHENLIAOFEI"].ToString(),
                                ZHENLIAOJSF  = "0",
                                PAIBANRQ     = schedulingDate.ToString("yyyy-MM-dd"),
                                TINGZHENBZ   = "0",
                                GUAHAOBC     = "2",
                                GUAHAOLB     = dr["YIZHOUPBLBDM"].ToString(),
                                YIZHOUPBID   = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|2",
                                DANGTIANPBID = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|2"
                            };
                            //pbmx2.YIZHOUPBID = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|2";
                            if (int.Parse(dr["YIZHOUXWZGXH"].ToString()) > 0)
                            {
                                pbxxObj.PAIBANLB.Add(pbmx2);
                            }
                        }
                        else if (pd == 4 || pd == 0)
                        {
                            #endregion
                            #region 全天的排班
                            Entity.PAIBANMX pbmx1 = new Entity.PAIBANMX
                            {
                                HAOYUANFPLX  = "0",
                                KESHIDM      = dr["YIZHOUKSDM"].ToString(),
                                KESHIMC      = dr["YIZHOUKSMC"].ToString(),
                                JIUZHENDD    = dr["GUAHAOKSWZMC"].ToString(),
                                KESHIJS      = "",
                                KESHIPX      = "",
                                YISHENGDM    = dr["YIZHOUYSDM"].ToString(),
                                YISHENGXM    = dr["YIZHOUPBLBDM"].ToString() == "1" ? dr["YIZHOUPBLBMC"].ToString() : dr["YIZHOUYSXM"].ToString(), // dr["YIZHOUYSXM"].ToString(),
                                ZHENLIAOF    = dr["ZHENLIAOFEI"].ToString(),
                                ZHENLIAOJSF  = "0",
                                PAIBANRQ     = schedulingDate.ToString("yyyy-MM-dd"),
                                TINGZHENBZ   = "0",
                                GUAHAOBC     = pd.ToString(),
                                GUAHAOLB     = dr["YIZHOUPBLBDM"].ToString(),
                                YIZHOUPBID   = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|1",
                                DANGTIANPBID = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|1"
                            };
                            if (int.Parse(dr["YIZHOUSWZGXH"].ToString()) > 0)
                            {
                                pbxxObj.PAIBANLB.Add(pbmx1);
                            }

                            PAIBANMX pbmx2 = new Entity.PAIBANMX
                            {
                                HAOYUANFPLX  = "0",
                                KESHIDM      = dr["YIZHOUKSDM"].ToString(),
                                KESHIMC      = dr["YIZHOUKSMC"].ToString(),
                                JIUZHENDD    = dr["GUAHAOKSWZMC"].ToString(),
                                KESHIJS      = "",
                                KESHIPX      = "",
                                YISHENGDM    = dr["YIZHOUYSDM"].ToString(),
                                YISHENGXM    = dr["YIZHOUPBLBDM"].ToString() == "1" ? dr["YIZHOUPBLBMC"].ToString() : dr["YIZHOUYSXM"].ToString(), //dr["YIZHOUYSXM"].ToString(),
                                ZHENLIAOF    = dr["ZHENLIAOFEI"].ToString(),
                                ZHENLIAOJSF  = "0",
                                PAIBANRQ     = schedulingDate.ToString("yyyy-MM-dd"),
                                TINGZHENBZ   = "0",
                                GUAHAOBC     = pd.ToString(),
                                GUAHAOLB     = dr["YIZHOUPBLBDM"].ToString(),
                                YIZHOUPBID   = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|2",
                                DANGTIANPBID = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|2"
                            };
                            //pbmx2.YIZHOUPBID = dr["YIZHOUPBID"].ToString() + "|" + dr["YIZHOUYSDM"].ToString() + "|2";
                            if (int.Parse(dr["YIZHOUXWZGXH"].ToString()) > 0)
                            {
                                pbxxObj.PAIBANLB.Add(pbmx2);
                            }
                            #endregion
                        }
                        else
                        {
                            //inobject.GUAHAOBC = '3';晚上排班;
                            pbxxObj.Result.Msg = "无晚上排班";
                        }
                    }
                    ehrXml = MessageParse.GetXml(pbxxObj);
                    log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);

                    return;

                    #endregion

                    #region 号源信息
                case "GUAHAOHYXX":
                    //已挂号号源信息
                    sql = "SELECT  * from V_GUAHAOYSYHYXX_MCP A where 1=1 ";
                    if (!string.IsNullOrEmpty(inobject.KESHIDM))
                    {
                        sql += $" and PAIBANKSDM='{inobject.KESHIDM}'";
                    }
                    if (!string.IsNullOrEmpty(inobject.YISHENGDM))
                    {
                        sql += $" and PAIBANYSGH='{inobject.YISHENGDM}'";
                    }
                    DataTable YghDt = DBVisitor.ExecuteTable(sql);

                    //挂号号源信息 预约类型代码10开放给转诊预约---测试的时候用2 正式使用的时候是10
                    sql = $"SELECT* FROM V_YIYUANGHHYXX_MCP WHERE   YUYUELXDM= '{ZHUANZHENYYLXDM}'";
                    if (!string.IsNullOrEmpty(inobject.KESHIDM))
                    {
                        sql += $" and YIZHOUKSDM='{inobject.KESHIDM}'";
                    }
                    if (!string.IsNullOrEmpty(inobject.YISHENGDM))
                    {
                        sql += $" and YIZHOUYSDM='{inobject.YISHENGDM}'";
                    }
                    if (!string.IsNullOrEmpty(inobject.GUAHAOBC))
                    {
                        if (inobject.GUAHAOBC != "0" && inobject.GUAHAOBC != "4")
                        {
                            sql += $" and PAIBANLX='{inobject.GUAHAOBC}'";
                        }
                    }
                    DataTable ghhyDt = DBVisitor.ExecuteTable(sql);
                    if (ghhyDt.Rows.Count < 1)
                    {
                        result.Msg = "无所要查询号源信息";
                    }

                    DataTable HouZhenSj = DBVisitor.ExecuteTable("select * from mz_houzhensj a");

                    Body_GUAHAOHYXX hyxxOut = new Body_GUAHAOHYXX {
                        Result = new Result()
                    };
                    hyxxOut.Result    = result;
                    hyxxOut.HAOYUANMX = new List <Entity.HAOYUANXX>();
                    foreach (DataRow variable in ghhyDt.Rows)
                    {
                        #region      //上午号源
                        if (int.Parse(variable["SHANGWUYYXH"].ToString()) > 0)
                        {
                            string[] guaHaoSwXh = variable["SHANGWUYYXHMX"].ToString().Split('^');
                            foreach (var SwXhmx in guaHaoSwXh)
                            {
                                if (!string.IsNullOrEmpty(SwXhmx))
                                {
                                    //判断号源是否被占用
                                    DataRow[] dr =
                                        YghDt.Select(
                                            $"PAIBANID='{variable["YIZHOUPBID"].ToString()}' and PAIBANKSDM='{variable["YIZHOUKSDM"].ToString()}'" +
                                            $" and PAIBANYSGH='{variable["YIZHOUYSDM"].ToString()}' and PAIBANGHLB='{variable["YIZHOUPBLBDM"].ToString()}'" +
                                            $" and HAOYUANSYSJ='1' and HAOYUANSYXH='{SwXhmx}'");
                                    if (dr.Length == 0)
                                    {
                                        Entity.HAOYUANXX hymx1 = new Entity.HAOYUANXX
                                        {
                                            PAIBANRQ   = variable["schedulingdate"].ToString().Substring(0, 10),
                                            GUAHAOBC   = "1",
                                            GUAHAOLB   = variable["YIZHOUPBLBDM"].ToString(),
                                            YISHENGDM  = variable["YIZHOUYSDM"].ToString(),
                                            KESHIDM    = variable["YIZHOUKSDM"].ToString(),
                                            YIZHOUPBID =
                                                variable["YIZHOUPBID"].ToString() + "|" +
                                                variable["YIZHOUYSDM"].ToString() + "|1",
                                            DANGTIANPBID =
                                                variable["YIZHOUPBID"].ToString() + "|" +
                                                variable["YIZHOUYSDM"].ToString() + "|1",
                                            HAOYUANLB = "1",
                                            GUAHAOXH  = SwXhmx,
                                            HAOYUANID =
                                                variable["YIZHOUPBID"].ToString() + "|" +
                                                variable["YIZHOUYSDM"].ToString() + "|1|" + SwXhmx
                                        };
                                        DataRow[] HzSjDr =
                                            HouZhenSj.Select(
                                                $"qishighxh<={SwXhmx} and jieshughxh>={SwXhmx} and shangxiawbz=0 and yishengid='{variable["YIZHOUYSDM"].ToString()}' and KESHIID='{variable["YIZHOUKSDM"].ToString()}'");
                                        if (HzSjDr.Length > 0)
                                        {
                                            hymx1.JIUZHENSJ = HzSjDr[0]["KAISHISJ"].ToString() + "-" +
                                                              HzSjDr[0]["JIESHUSJ"].ToString();
                                        }
                                        else
                                        {
                                            hymx1.JIUZHENSJ = "07:30-12:00";
                                        }
                                        hyxxOut.HAOYUANMX.Add(hymx1);
                                    }
                                }
                            }
                        }
                        #endregion

                        #region   午号源
                        if (int.Parse(variable["XIAWUYYXH"].ToString()) > 0)
                        {
                            string[] guaHaoXwXh = variable["xiawuyyyhmx"].ToString().Split('^');
                            foreach (var XwXhmx in guaHaoXwXh)
                            {
                                if (!string.IsNullOrEmpty(XwXhmx))
                                {
                                    //判断号源是否被占用
                                    DataRow[] dr =
                                        YghDt.Select(
                                            $"PAIBANID='{variable["YIZHOUPBID"].ToString()}' and PAIBANKSDM='{variable["YIZHOUKSDM"].ToString()}'" +
                                            $" and PAIBANYSGH='{variable["YIZHOUYSDM"].ToString()}' and PAIBANGHLB='{variable["YIZHOUPBLBDM"].ToString()}'" +
                                            $" and HAOYUANSYSJ='1' and HAOYUANSYXH='{XwXhmx}'");
                                    if (dr.Length == 0)
                                    {
                                        Entity.HAOYUANXX hymx2 = new Entity.HAOYUANXX
                                        {
                                            PAIBANRQ   = variable["schedulingdate"].ToString().Substring(0, 10),
                                            GUAHAOBC   = "1",
                                            GUAHAOLB   = variable["YIZHOUPBLBDM"].ToString(),
                                            YISHENGDM  = variable["YIZHOUYSDM"].ToString(),
                                            KESHIDM    = variable["YIZHOUKSDM"].ToString(),
                                            YIZHOUPBID =
                                                variable["YIZHOUPBID"].ToString() + "|" +
                                                variable["YIZHOUYSDM"].ToString() + "|2",
                                            DANGTIANPBID =
                                                variable["YIZHOUPBID"].ToString() + "|" +
                                                variable["YIZHOUYSDM"].ToString() + "|2",
                                            HAOYUANLB = "1",
                                            GUAHAOXH  = XwXhmx,
                                            HAOYUANID =
                                                variable["YIZHOUPBID"].ToString() + "|" +
                                                variable["YIZHOUYSDM"].ToString() + "|2|" + XwXhmx
                                        };
                                        //候诊时间
                                        DataRow[] HzSjDr =
                                            HouZhenSj.Select(
                                                $"qishighxh<={XwXhmx} and jieshughxh>={XwXhmx} and shangxiawbz=1 and yishengid='{variable["YIZHOUYSDM"].ToString()}' and KESHIID='{variable["YIZHOUKSDM"].ToString()}'");
                                        if (HzSjDr.Length > 0)
                                        {
                                            hymx2.JIUZHENSJ = HzSjDr[0]["KAISHISJ"].ToString() + "-" +
                                                              HzSjDr[0]["JIESHUSJ"].ToString();
                                        }
                                        else
                                        {
                                            hymx2.JIUZHENSJ = "13:30-17:00";
                                        }
                                        hyxxOut.HAOYUANMX.Add(hymx2);
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                    ehrXml = MessageParse.GetXml(hyxxOut);
                    log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);

                    return;

                    #endregion

                    #region 预约挂号
                case "YUYUEGH":
                    inobject.YUYUEXX.YIZHOUPBID = inobject.YUYUEXX.YIZHOUPBID.Split('|')[0] == "" ? inobject.YUYUEXX.DANGTIANPBID.Split('|')[0] : inobject.YUYUEXX.YIZHOUPBID.Split('|')[0];

                    Body_YUYUEGH yyghOut = new Body_YUYUEGH();
                    yyghOut.Result = new Result();
                    yyghOut.Result = result;
                    sql            = $"select * from V_YIYUANYZPBXX_MCP where YIZHOUPBID='{inobject.YUYUEXX.YIZHOUPBID}'";//YUYUELX 10是分配给转诊预约的,测试时用2
                    dt             = DBVisitor.ExecuteTable(sql);
                    if (dt.Rows.Count == 0)
                    {
                        result.Code    = "-1";
                        result.Msg     = $"找不到排班信息";
                        yyghOut.Result = result;
                        ehrXml         = MessageParse.GetXml(yyghOut);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    GUAHAOYY_IN ghyy = new GUAHAOYY_IN();
                    ghyy.BASEINFO     = new BASEINFO();
                    ghyy.BASEINFO     = baseinfo;
                    ghyy.JIUZHENKLX   = inobject.YUYUEXX.JIUZHENKLX == "2" ? "3" : "2";
                    ghyy.JIUZHENKH    = inobject.YUYUEXX.JIUZHENKH;
                    ghyy.ZHENGJIANLX  = "1";
                    ghyy.ZHENGJIANHM  = inobject.YUYUEXX.ZHENGJIANHM;
                    ghyy.XINGMING     = inobject.YUYUEXX.XINGMING;
                    ghyy.YIZHOUPBID   = inobject.YUYUEXX.YIZHOUPBID;
                    ghyy.DANGTIANPBID = inobject.YUYUEXX.YIZHOUPBID;
                    ghyy.RIQI         = inobject.YUYUEXX.PAIBANRQ;
                    ghyy.GUAHAOBC     = inobject.YUYUEXX.GUAHAOBC;
                    ghyy.GUAHAOLB     = inobject.YUYUEXX.GUAHAOLB;
                    ghyy.KESHIDM      = inobject.YUYUEXX.KESHIDM;
                    ghyy.YISHENGDM    = inobject.YUYUEXX.YISHENGDM;
                    ghyy.GUAHAOXH     = inobject.YUYUEXX.GUAHAOXH;
                    ghyy.LIANXIDH     = inobject.YUYUEXX.LIANXIDH;
                    ghyy.YUYUELY      = "10";
                    string TradeMsg    = MessageParse.GetXml(ghyy);
                    string TradeMsgOut = "";
                    int    j           = RunService("HIS4.Biz.GUAHAOYY", TradeMsg, ref TradeMsgOut);
                    //   ehrXml = TradeMsgOut;
                    GUAHAOYY_OUT yyout = new GUAHAOYY_OUT();
                    yyout = MessageParse.ToXmlObject <GUAHAOYY_OUT>(TradeMsgOut);
                    if (yyout.OUTMSG.ERRNO != "0")
                    {
                        result.Code    = "-1";
                        result.Msg     = yyout.OUTMSG.ERRMSG;
                        yyghOut.Result = result;
                        ehrXml         = MessageParse.GetXml(yyghOut);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }

                    yyghOut.GUAHAOYY = new GUAHAOYY();
                    GUAHAOYY Outghyy = new GUAHAOYY
                    {
                        YUYUEID   = yyout.QUHAOMM,
                        QUHAOMM   = yyout.QUHAOMM,
                        JIUZHENSJ = yyout.JIUZHENSJ,
                        GUAHAOXH  = yyout.GUAHAOXH
                    };
                    yyghOut.GUAHAOYY = Outghyy;

                    yyghOut.FEIYONGMX = new List <Entity.FEIYONGXX>();

                    Entity.FEIYONGXX fyxx1 = new Entity.FEIYONGXX
                    {
                        XIANGMUXH = dt.Rows[0]["ZHENLIAOFEIDM"].ToString(),
                        XIANGMUMC = dt.Rows[0]["ZHENLIAOFEIMC"].ToString(),
                        FEIYONGLX = "04",
                        DANJIA    = dt.Rows[0]["ZHENLIAOFEI"].ToString(),
                        XIANGMUDW = "次",
                        SHULIANG  = "1",
                        JINE      = dt.Rows[0]["ZHENLIAOFEI"].ToString(),
                        YIBAODJ   = "",
                        YIBAODM   = "",
                        YIBAOZFBL = ""
                    };
                    yyghOut.FEIYONGMX.Add(fyxx1);

                    Entity.FEIYONGXX fyxx2 = new Entity.FEIYONGXX
                    {
                        XIANGMUXH = dt.Rows[0]["ZHENLIAOJSFDM"].ToString(),
                        XIANGMUMC = dt.Rows[0]["ZHENLIAOJSFMC"].ToString(),
                        FEIYONGLX = "14",
                        DANJIA    = dt.Rows[0]["ZHENLIAOJSF"].ToString(),
                        XIANGMUDW = "次",
                        SHULIANG  = "1",
                        JINE      = dt.Rows[0]["ZHENLIAOJSF"].ToString(),
                        YIBAODJ   = "",
                        YIBAODM   = "",
                        YIBAOZFBL = ""
                    };
                    yyghOut.FEIYONGMX.Add(fyxx2);
                    ehrXml = MessageParse.GetXml(yyghOut);
                    log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                    break;

                    #endregion
                    #region 预约退号
                case "YUYUETH":
                    Body_YUYUETH yyth = new Body_YUYUETH();
                    yyth.Result = result;
                    GUAHAOYYTH_IN yythIn = new GUAHAOYYTH_IN();
                    yythIn.BASEINFO    = new BASEINFO();
                    yythIn.BASEINFO    = baseinfo;
                    yythIn.JIUZHENKLX  = inobject.JIUZHENKLX == "2" ? "3" : "2";
                    yythIn.JIUZHENKH   = inobject.JIUZHENKH;
                    yythIn.ZHENGJIANLX = "1";
                    yythIn.ZHENGJIANHM = inobject.ZHENGJIANHM;
                    yythIn.XINGMING    = inobject.XINGMING;
                    yythIn.YUYUELY     = "10";
                    yythIn.QUHAOMM     = inobject.QUHAOMM;
                    TradeMsg           = MessageParse.GetXml(yythIn);
                    TradeMsgOut        = "";
                    j = RunService("HIS4.Biz.GUAHAOYYTH", TradeMsg, ref TradeMsgOut);
                    GUAHAOYYTH_OUT yythout = new GUAHAOYYTH_OUT();
                    yythout = MessageParse.ToXmlObject <GUAHAOYYTH_OUT>(TradeMsgOut);
                    if (yythout.OUTMSG.ERRNO != "0")
                    {
                        result.Code = "-1";
                        result.Msg  = yythout.OUTMSG.ERRMSG;
                        yyth.Result = result;
                        ehrXml      = MessageParse.GetXml(yyth);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    ehrXml = MessageParse.GetXml(yyth);
                    log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                    break;

                    #endregion
                    #region  病情自述
                //modify by 沈宝
                case "BINGQINGZS":
                    Body_BINGQINGZS bqzs = new Body_BINGQINGZS();
                    bqzs.Result = result;
                    BINGQINGZS_IN bqzs_in = new BINGQINGZS_IN();
                    bqzs_in.BASEINFO   = new BASEINFO();
                    bqzs_in.BASEINFO   = baseinfo;
                    bqzs_in.YILIAOJGDM = inobject.YILIAOJGDM;
                    if (string.IsNullOrEmpty(bqzs_in.YILIAOJGDM))
                    {
                        result.Code = "-1";
                        result.Msg  = "医疗机构不能为空!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    bqzs_in.JIUZHENKLX  = inobject.JIUZHENKLX;
                    bqzs_in.JIUZHENKH   = inobject.JIUZHENKH;
                    bqzs_in.ZHENGJIANLX = inobject.ZHENGJIANLX;
                    if (string.IsNullOrEmpty(bqzs_in.ZHENGJIANLX))
                    {
                        result.Code = "-1";
                        result.Msg  = "证件类型不能为空!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    bqzs_in.ZHENGJIANHM = inobject.ZHENGJIANHM;
                    if (string.IsNullOrEmpty(bqzs_in.ZHENGJIANHM))
                    {
                        result.Code = "-1";
                        result.Msg  = "证件号码不能为空!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    bqzs_in.XINGMING = inobject.XINGMING;
                    if (string.IsNullOrEmpty(bqzs_in.XINGMING))
                    {
                        result.Code = "-1";
                        result.Msg  = "姓名不能为空!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    bqzs_in.YUYUEID = inobject.YUYUEID;      //预约ID 是返回的信息的唯一标示;
                    if (string.IsNullOrEmpty(bqzs_in.YUYUEID))
                    {
                        result.Code = "-1";
                        result.Msg  = "预约ID不能为空!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    bqzs_in.GUAHAOXH = inobject.GUAHAOXH;
                    if (string.IsNullOrEmpty(bqzs_in.GUAHAOXH))
                    {
                        result.Code = "-1";
                        result.Msg  = "挂号序号不能为空!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    bqzs_in.RIQI = inobject.RIQI;
                    if (string.IsNullOrEmpty(bqzs_in.RIQI))
                    {
                        result.Code = "-1";
                        result.Msg  = "日期不能为空!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    bqzs_in.YUYUELY = inobject.YUYUELY;
                    if (string.IsNullOrEmpty(bqzs_in.YUYUELY))
                    {
                        result.Code = "-1";
                        result.Msg  = "预约来源不能为空!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    bqzs_in.GUOMINYW   = inobject.GUOMINYW;
                    bqzs_in.BINGQINGMS = inobject.BINGQINGMS;
                    string    yuYuesj   = @"select * from mz_guahaoyy where yuyueid = '{0}'and yuyuezt='0'";  //预约状态 0 未取,为1 取过,为2 取消;取过挂号单不在病情描述;
                    DataTable dtYuYueJL = DBVisitor.ExecuteTable(string.Format(yuYuesj, bqzs_in.YUYUEID));
                    if (dtYuYueJL == null || dtYuYueJL.Rows.Count <= 0)
                    {
                        result.Code = "-1";
                        result.Msg  = "未找到预约记录!";
                        bqzs.Result = result;
                        ehrXml      = MessageParse.GetXml(bqzs);
                        log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                        return;
                    }
                    else
                    {
                        string bingqingmsgx = @"update mz_guahaoyy set JIWANGSHI='{0}',GUOMINSHI='{1}' where yuyueid = '{2}'";
                        try
                        {
                            DBVisitor.ExecuteNonQuery(string.Format(bingqingmsgx, bqzs_in.BINGQINGMS, bqzs_in.GUOMINYW, bqzs_in.YUYUEID));
                        }
                        catch (Exception e)
                        {
                            result.Code = "-1";
                            result.Msg  = e.Message;
                            bqzs.Result = result;
                            ehrXml      = MessageParse.GetXml(bqzs);
                            log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                            return;
                        }
                    }
                    ehrXml = MessageParse.GetXml(bqzs);
                    log.InfoFormat("[{2}][{0}].OUT  {1}", head.DocumentID, LogUnity.I.ShowXml(ehrXml), guid);
                    break;
                    #endregion

                case "PAIBANHYXX":

                    break;
                }
            }
            catch (Exception e)
            {
                log.InfoFormat("{0}", e.Message);
            }
        }
Example #23
0
        public override void ProcessMessage()
        {
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "alipay.acquire.cancel");
            sParaTemp.Add("out_trade_no", InObject.WIDOUTTRADENO); //out_trade_no	商户网站唯一订单号	String(64)	支付宝合作商户网站唯一订单号。	不可空	HZ0120131127001
            sParaTemp.Add("trade_no", InObject.TRADENO);           //trade_no	支付宝交易号	String(64)	该交易在支付宝系统中的交易流水号。最短16位,最长64位。如果同时传了out_trade_no和trade_no,则以trade_no为准。	可空	2013112611001004680073956707
            sParaTemp.Add("operator_id", InObject.BASEINFO.CAOZUOYDM);
            string sHtmlText = Submit.BuildRequest(sParaTemp);

            LogUnit.Write("sHtmlText", "ZHIFUBAOCANCLE");
            OutObject = new ZHIFUBAOCANCLE_OUT();
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(sHtmlText);
                XmlNodeList nodeList = xmlDoc.SelectSingleNode("alipay").ChildNodes;
                foreach (XmlNode xn in nodeList)
                {
                    if (xn.Name == "error")
                    {
                        throw new Exception(xn.InnerText);
                    }
                    if (xn.Name == "response")
                    {
                        XmlElement  xe      = (XmlElement)xn;
                        XmlNodeList subList = xe.ChildNodes;
                        foreach (XmlNode xmlNode in subList)
                        {
                            if (xmlNode.Name == "alipay")
                            {
                                XmlElement  xemx      = (XmlElement)xmlNode;
                                XmlNodeList submxList = xemx.ChildNodes;

                                foreach (XmlNode mxnode in submxList)
                                {
                                    if (mxnode.Name == "detail_error_code")
                                    {
                                        OutObject.ERRORCODE = mxnode.InnerText;
                                    }
                                    if (mxnode.Name == "detail_error_des")
                                    {
                                        OutObject.ERRORDES = mxnode.InnerText;
                                    }
                                    if (mxnode.Name == "result_code")
                                    {
                                        OutObject.RESULTCODE = mxnode.InnerText;
                                    }
                                    if (mxnode.Name == "trade_no")
                                    {
                                        OutObject.TRADENO = mxnode.InnerText;
                                    }
                                    if (mxnode.Name == "out_trade_no")
                                    {
                                        OutObject.WIDOUTREQUESTNO = mxnode.InnerText;
                                    }
                                    if (mxnode.Name == "retry_flag")
                                    {
                                        OutObject.RETRYFLAG = mxnode.InnerText;
                                    }
                                }
                            }
                        }
                    }
                }
                if (OutObject.RESULTCODE.ToUpper() == "SUCCESS")
                {
                    DBVisitor.ExecuteNonQuery(string.Format("update ZHIFUBAOJSXX set TUIFEITIME=sysdate,JIESUANZT='-3' where IQINGQIUDH='{0}' ", InObject.WIDOUTTRADENO));
                }
            }
            catch (Exception exp)
            {
                throw new Exception(exp.Message.ToString());
            }
        }
Example #24
0
        public override void ProcessMessage()
        {
            //取得预约信息
            OutObject = new SHEBEIYYQR_OUT();
            if (InObject.YUYUESQDBH == null || InObject.YUYUESQDBH == "")
            {
                throw new Exception(string.Format("预约申请单编号为空!"));
            }
            var listyyxx = DBVisitor.ExecuteModel(SqlLoad.GetFormat(SQ.FSD00004, InObject.YUYUESQDBH.ToString()));

            if (listyyxx == null)
            {
                OutObject.OUTMSG.ERRNO  = "-2";
                OutObject.OUTMSG.ERRMSG = string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString());
                return;
                //throw new Exception(string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString()));
            }
            if (listyyxx.Items.Count == 0)
            {
                OutObject.OUTMSG.ERRNO  = "-2";
                OutObject.OUTMSG.ERRMSG = string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString());
                return;
                //throw new Exception(string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString()));
            }
            else
            {
                var tran = DBVisitor.Connection.BeginTransaction();
                try
                {
                    if (InObject.YUYUEQRLX == "1")
                    {
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00005, InObject.YUYUESQDBH.ToString(), 1), tran);
                    }
                    else if (InObject.YUYUEQRLX == "2")
                    {
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00015, InObject.YUYUESQDBH.ToString(), 1), tran);
                    }
                    else if (InObject.YUYUEQRLX == "3")
                    {
                        DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.FSD00016, InObject.YUYUESQDBH.ToString(), 1), tran);
                    }
                    else
                    {
                        OutObject.OUTMSG.ERRNO  = "-2";
                        OutObject.OUTMSG.ERRMSG = string.Format("找不到预约信息:申请单编号[{0}]", InObject.YUYUESQDBH.ToString());
                        return;
                    }

                    tran.Commit();
                    OutObject         = new SHEBEIYYQR_OUT();
                    OutObject.YUYUEH  = listyyxx.Items["YYH"].ToString();
                    OutObject.YUYUERQ = listyyxx.Items["JCRQ"].ToString();
                    OutObject.YUYUESJ = listyyxx.Items["JCSJ"].ToString();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
            }
        }
Example #25
0
        public override void ProcessMessage()
        {
            OutObject = new GUAHAOYYTH_OUT();
            string quhaoMm = InObject.QUHAOMM;//取号密码即预约号????

            #region 基本入参判断

            //if (string.IsNullOrEmpty(jiuzhenKh) && string.IsNullOrEmpty(zhengjianHm)) {
            //    throw new Exception("就诊卡号和证件号码不能同时为空!");
            //}

            if (string.IsNullOrEmpty(quhaoMm))
            {
                throw new Exception("取号密码不能为空");
            }
            #endregion

            string yuYueCZFS = ConfigurationManager.AppSettings["GUAHAOYYCZFS"];//挂号预约处理方式
            if (!string.IsNullOrEmpty(yuYueCZFS) && yuYueCZFS == "1")
            {
                #region  兴悦城妇儿业务流程
                string    yuYueJL   = @"select * from gy_jiuzhenyy where jiuzhenyyid = '{0}'";
                DataTable dtYuYueJL = DBVisitor.ExecuteTable(string.Format(yuYueJL, quhaoMm));
                if (dtYuYueJL == null || dtYuYueJL.Rows.Count <= 0)
                {
                    throw new Exception("未找到预约记录!");
                }

                string jiuZhenBZ = dtYuYueJL.Rows[0]["jiuzhenbz"].ToString();
                if (string.IsNullOrEmpty(jiuZhenBZ))
                {
                    jiuZhenBZ = "0";
                }
                if (jiuZhenBZ != "0")
                {
                    throw new Exception("该病人已就诊,无法取消预约!");
                }

                string quXiaoYY = "update gy_jiuzhenyy set zuofeibz = 1 where jiuzhenyyid = '{0}'";
                DBVisitor.ExecuteNonQuery(string.Format(quXiaoYY, quhaoMm));

                #endregion
            }
            else
            {
                #region 标准his4版本业务流程



                OracleParameter[] paramJiaoYi = new OracleParameter[3];
                paramJiaoYi[0]           = new OracleParameter("PRM_YUYUEHAO", OracleType.VarChar);
                paramJiaoYi[0].Value     = quhaoMm;
                paramJiaoYi[0].Direction = ParameterDirection.Input;
                paramJiaoYi[1]           = new OracleParameter("PRM_APPCODE", OracleType.Number);
                paramJiaoYi[1].Value     = null;
                paramJiaoYi[1].Direction = ParameterDirection.Output;
                paramJiaoYi[2]           = new OracleParameter("PRM_DATABUFFER", OracleType.VarChar);
                paramJiaoYi[2].Value     = null;
                paramJiaoYi[2].Size      = 2000;
                paramJiaoYi[2].Direction = ParameterDirection.Output;

                log.InfoFormat("{0}", "执行存储过程:PKG_MZ_YUYUE.PRC_GY_QUXIAOYY \r\nPRM_YUYUEHAO:" + quhaoMm + "\r\n");

                DbTransaction transaction = null;
                DbConnection  conn        = DBVisitor.Connection;
                try
                {
                    transaction = conn.BeginTransaction();
                    DBVisitor.ExecuteProcedure("PKG_MZ_YUYUE.PRC_GY_QUXIAOYY", paramJiaoYi, transaction);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    conn.Close();
                    throw new Exception(ex.Message);
                }
                //--------------------------------------------------------------------------------------------------
                string returnValue = paramJiaoYi[2].Value.ToString();
                if (returnValue.Length > 2 && returnValue.Substring(0, 2).ToUpper() == "OK")//取消预约成功
                {
                    transaction.Commit();
                    conn.Close();
                    OutObject.OUTMSG.ERRMSG = "预约取消成功!";
                    //tradeOut = WcfCommon.GetXmlString(tradeHead, tradeType, tradeDetail, new DataTable(), 0, "挂号预约退号成功");
                    //return 0;
                }
                else
                {
                    transaction.Rollback();
                    conn.Close();
                    throw new Exception(returnValue.Substring(returnValue.IndexOf('|') + 1));
                }

                #endregion
            }
        }