public string OrderCurReg(request <Entity.SRequest.orderCurReg> orderCurRegInfo)
        {
            if (orderCurRegInfo == null)
            {
                return(RsXmlHelper.ResXml(-1, "XML格式错误"));
            }
            var feeinfo = feeinfoBLL.Get(orderCurRegInfo.model.psOrdNum);

            if (feeinfo != null)
            {
                return(XMLHelper.XmlSerialize(new response <Entity.SResponse.orderCurReg>()
                {
                    model = new Entity.SResponse.orderCurReg()
                    {
                        resultCode = 0,
                        resultMessage = "",
                        hisOrdNum = feeinfo.regid.ToString(),
                        treatFee = orderCurRegInfo.model.regFee
                    }
                }));
            }

            reg_arrange reg_Arrange = null;
            pt_info     pt_Info     = null;
            var         dept        = new sys_dept();
            var         doctor      = new sys_userinfo();


            if (!string.IsNullOrWhiteSpace(orderCurRegInfo.model.workId))
            {
                reg_Arrange = regArrangeBLL.GetReg_Arrange(Convert.ToInt32(orderCurRegInfo.model.workId));
            }
            else
            {
                dept        = sysDeptBLL.GetDeptByCode(orderCurRegInfo.model.deptCode);
                doctor      = sysUserinfoBLL.GetRDoctor(orderCurRegInfo.model.doctorCode);
                reg_Arrange = regArrangeBLL.GetReg_Arrange(dept.name, doctor.username, orderCurRegInfo.model.beginTime, orderCurRegInfo.model.endTime, Convert.ToInt32(orderCurRegInfo.model.timeFlag));
            }
            if (reg_Arrange == null)
            {
                return(RsXmlHelper.ResXml(-1, "无号源信息"));
            }

            var feetype = "";

            if (!string.IsNullOrWhiteSpace(orderCurRegInfo.model.SSCardNumber) && !string.IsNullOrWhiteSpace(orderCurRegInfo.model.SSCodeId))
            {
                feetype = "医疗保险";
                if (string.IsNullOrWhiteSpace(orderCurRegInfo.model.SSPwd))
                {
                    orderCurRegInfo.model.SSPwd = "000000";
                }
                pt_Info = ptInfoBLL.GetPt_Info(x => x.yno == orderCurRegInfo.model.SSCardNumber);
                if (pt_Info == null)
                {
                    pt_Info = ptInfoBLL.GetPt_Info(x => x.cno == orderCurRegInfo.model.patCardNo || x.idno == orderCurRegInfo.model.patCardNo);
                    if (string.IsNullOrWhiteSpace(pt_Info.yno))
                    {
                        pt_Info.yno = orderCurRegInfo.model.SSCardNumber;
                        ptInfoBLL.Update(pt_Info);
                    }
                }
            }
            else
            {
                feetype = "自费";
                pt_Info = ptInfoBLL.GetPt_Info(x => x.cno == orderCurRegInfo.model.patCardNo || x.idno == orderCurRegInfo.model.patCardNo);
            }

            var regInfo = reginfoBLL.Get(x => x.doctor == doctor.username && x.dept == dept.name && pt_Info.pid == x.pid && x.status == "候诊" && x.validate > DateTime.Now);

            if (regInfo != null && regInfo.del == true)
            {
                return(XMLHelper.XmlSerialize(new response <Entity.SResponse.orderCurReg>()
                {
                    model = new Entity.SResponse.orderCurReg()
                    {
                        resultCode = 0,
                        resultMessage = "",
                        hisOrdNum = regInfo.regid.ToString(),
                        treatFee = orderCurRegInfo.model.ghhj.ToString()
                    }
                }));
            }

            if (regInfo != null && regInfo.del == false)
            {
                return(RsXmlHelper.ResXml(-1, "你已挂当前科室号"));
            }

            var reg_Info = reginfoBLL.Add(new reg_info()
            {
                feetype = feetype
            }, pt_Info, reg_Arrange, orderCurRegInfo.model.orderNo, orderCurRegInfo.model.psOrdNum, out decimal amount, out int mzno, out int feeid, out List <comm_fee> commFees);

            if (reg_Info == null)
            {
                return(RsXmlHelper.ResXml(99, "挂号失败"));
            }

            if (feetype == "医疗保险")
            {
                var regtrialId = regTrialBLL.AddReturnId(new reg_trial()
                {
                    akc190 = "HZS10" + mzno,
                    aaz500 = orderCurRegInfo.model.SSCodeId,
                    bzz269 = orderCurRegInfo.model.SSPwd,
                    aka130 = "11",
                    akf001 = dept.ybno,
                    bkc368 = CodeConvertUtils.SwichRegType(reg_Arrange.regtype).ToString(),
                    bke384 = "HZS10" + DateTime.Now.ToString("yyyyMMdd") + feeid,
                    akc264 = commFees.Sum(x => x.prices),
                    regid  = reg_Info.regid
                });

                List <reg_trialdetail> reg_Trialdetails = new List <reg_trialdetail>();
                foreach (var commFee in commFees)
                {
                    reg_Trialdetails.Add(new reg_trialdetail()
                    {
                        regtrialid = regtrialId,
                        aae072     = commKeyBLL.GetYBDJH().ToString(),
                        bkf500     = commKeyBLL.GetYBXLH().ToString(),
                        ake001     = commFee.scode,
                        ake005     = commFee.itemid,
                        ake006     = commFee.itemname,
                        aae019     = commFee.prices
                    });
                }
                regTrialdetailBLL.Adds(reg_Trialdetails);
            }

            return(XMLHelper.XmlSerialize(new response <Entity.SResponse.orderCurReg>()
            {
                model = new Entity.SResponse.orderCurReg()
                {
                    resultCode = 0,
                    resultMessage = "",
                    hisOrdNum = reg_Info.regid.ToString(),
                    treatFee = amount.ToString()
                }
            }));
        }
Esempio n. 2
0
        public reg_info Add(reg_info reg_Info, pt_info pt_Info, reg_arrange reg_Arrange, string sno, string psOrdNum, out decimal amount, out int mzno, out int feeid, out List <comm_fee> commFees)
        {
            reg_Info.pid    = pt_Info.pid;
            reg_Info.argid  = reg_Arrange.argid;
            reg_Info.rtype  = reg_Arrange.regtype;
            reg_Info.dept   = reg_Arrange.dept;
            reg_Info.doctor = reg_Arrange.doctor;
            List <string> mznoQuery = new List <string>()
            {
                "update comm_key set id += 1 where sn = 52;",
                "SELECT [id] FROM [ZSHIS].[dbo].[comm_key] WHERE sn = 52"
            };

            mzno               = iReginfo.GetMzno(mznoQuery);
            reg_Info.mzno      = mzno;
            reg_Info.pname     = pt_Info.pname;
            reg_Info.sex       = pt_Info.sex;
            reg_Info.age       = EString.GetAge(pt_Info.birth.ToString()).ToString();
            reg_Info.agetype   = "岁";
            reg_Info.birth     = pt_Info.birth;
            reg_Info.addr1     = pt_Info.addr1;
            reg_Info.addr3     = pt_Info.addr3;
            reg_Info.tel       = pt_Info.tel;
            reg_Info.memo      = "自助机挂号";
            reg_Info.addperson = "自助机";
            reg_Info.status    = "候诊";
            reg_Info.addtime   = DateTime.Now;
            reg_Info.del       = true;
            reg_Info.doctor2   = reg_Arrange.doctor;

            var sysdictList = iReginfo.GetSysDict("SELECT [id] ,[fid] ,[code] ,[type] ,[detail] ,[sortno] ,[memo] ,[status] ,[del] ,[addtime] ,[moditime] ,[addperson] ,[fth] FROM [ZSHIS].[dbo].[sys_dict] where fid = 13999");

            var dept = string.Empty;

            if (sysdictList.Where(x => x.type == reg_Arrange.dept && x.type != "全部科室").Count() > 0)
            {
                dept = reg_Arrange.dept;
            }
            else
            {
                dept = "所有科室";
            }

            DateTime validate;
            var      memo = Convert.ToInt32(sysdictList.Where(x => x.detail == reg_Info.feetype && x.type == dept).FirstOrDefault().memo);

            if (memo == 0)
            {
                validate = Convert.ToDateTime("9999-12-31");
            }
            else
            {
                validate = Convert.ToDateTime(DateTime.Now.AddDays(memo - 1).ToShortDateString() + " 23:59:59");
            }

            var isCommQuery = "SELECT TOP 1 [iscomm] FROM [ZSHIS].[dbo].[reg_type] inner join reg_manage on reg_type.regtid = reg_manage.regtid where reg_type.del = 0 and reg_manage.del = 0 and mgrid = " + reg_Arrange.mgrid;

            reg_Info.iscomm   = iReginfo.GetComm(isCommQuery) > 0;
            reg_Info.validate = validate;

            var regid = iReginfo.Add(reg_Info);

            reg_Info.regid = regid;

            List <int> itemid = new List <int>();

            itemid.Add(Convert.ToInt32(reg_Arrange.itemid));
            commFees = iReginfo.GetComm_Fees(itemid.ToArray(), reg_Info.feetype == "医疗保险" ? 5 : 3);

            fee_info fee_Info = new fee_info()
            {
                pid       = pt_Info.pid,
                mzno      = mzno,
                regid     = regid,
                userid    = 89757,
                ftype     = 2,
                amountcol = commFees.Sum(x => x.prices),
                amountrec = commFees.Sum(x => x.prices),
                amountbak = 0,
                mantissa  = 0,
                username  = "******",
                addtime   = DateTime.Now,
                printqty  = 0,
                feeidoff  = 0,
                del       = true,
                status    = 0,
                sno       = psOrdNum
            };

            feeid = iFeeinfo.AddReturnId(fee_Info);
            var FeeInfoDetail = new List <fee_infodetail>();

            foreach (var commfee in commFees)
            {
                FeeInfoDetail.Add(new fee_infodetail()
                {
                    feeid      = feeid,
                    billid     = 0,
                    bdid       = 0,
                    dgid       = commfee.dgid,
                    itemid     = commfee.itemid ?? commfee.itemid,
                    itemname   = commfee.itemname ?? commfee.itemname,
                    spec       = "",
                    itemtype   = commfee.itemtype ?? commfee.itemtype,
                    unit       = commfee.unit,
                    prices     = commfee.prices == 0 ? commfee.prices : commfee.prices,
                    qty        = 1,
                    totalprice = commfee.prices == 0 ? commfee.prices * 1 : commfee.prices * 1,
                    feetype    = reg_Info.feetype,
                    disc       = 0,
                    execdept   = reg_Arrange.dept,
                    exectime   = DateTime.Now,
                    addtime    = DateTime.Now,
                    del        = true,
                    addperson  = "自助机缴费",
                    status     = 0
                });
            }
            amount = Convert.ToDecimal(commFees.Sum(x => x.prices) * 100);

            iFeeinfodetail.Adds(FeeInfoDetail.ToArray());
            reg_Arrange.regno    = reg_Info.regid;
            reg_Arrange.moditime = DateTime.Now;
            iRegarrange.Update(reg_Arrange);
            return(reg_Info);
        }