Example #1
0
        public ApiJsonResultData MedicalInsuranceXmlCancelSettlement([FromUri] MedicalInsuranceXmlUiParam param)
        {
            return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                //更新医保信息
                var strXmlIntoParam = XmlSerializeHelper.XmlParticipationParam();
                //回参构建
                var xmlData = new HospitalSettlementCancelXml()
                {
                    SettlementNo = param.SettlementNo
                };

                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXmlData = new SaveXmlData();
                saveXmlData.OrganizationCode = userBase.OrganizationCode;
                saveXmlData.AuthCode = userBase.AuthCode;
                saveXmlData.BusinessId = param.BusinessId;
                saveXmlData.TransactionId = param.TransKey;
                saveXmlData.MedicalInsuranceBackNum = "CXJB003";
                saveXmlData.BackParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam);
                saveXmlData.IntoParam = CommonHelp.EncodeBase64("utf-8", strXmlIntoParam);
                saveXmlData.MedicalInsuranceCode = "42";
                saveXmlData.UserId = userBase.UserId;
                //存基层
                webServiceBasic.HIS_InterfaceList("38", JsonConvert.SerializeObject(saveXmlData));
            }));
        }
        public ApiJsonResultData MedicalInsuranceXml([FromUri] MedicalInsuranceXmlUiParam param)
        {
            return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                //更新医保信息
                var strXmlIntoParam = XmlSerializeHelper.XmlParticipationParam();
                //回参构建
                var xmlData = new HospitalizationRegisterXml()
                {
                    MedicalInsuranceType = "10",
                    MedicalInsuranceHospitalizationNo = "44116476",
                };

                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXmlData = new SaveXmlData();
                saveXmlData.OrganizationCode = userBase.OrganizationCode;
                saveXmlData.AuthCode = userBase.AuthCode;
                saveXmlData.BusinessId = param.BusinessId;
                saveXmlData.TransactionId = Guid.Parse("E67C69F5-5FA8-438A-94EC-85E092CA56E9").ToString("N");
                saveXmlData.MedicalInsuranceBackNum = "CXJB002";
                saveXmlData.BackParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam);
                saveXmlData.IntoParam = CommonHelp.EncodeBase64("utf-8", strXmlIntoParam);
                saveXmlData.MedicalInsuranceCode = "21";
                saveXmlData.UserId = userBase.UserId;
                //存基层
                webServiceBasic.HIS_InterfaceList("38", JsonConvert.SerializeObject(saveXmlData));
            }));
        }
        public ApiJsonResultData OutpatientSettlement([FromBody] UiBaseDataParam param)
        {
            return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                userBase.TransKey = param.TransKey;
                //回参构建88866
                var xmlData = new OutpatientDepartmentCostXml()
                {
                    AccountBalance = 10,
                    MedicalInsuranceOutpatientNo = "88866",
                    CashPayment = 0,
                    SettlementNo = "88866",
                    AllAmount = Convert.ToDecimal(0.07),
                    PatientName = "代美玲",
                    AccountAmountPay = 0,
                    MedicalInsuranceType = "342"
                };

                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml = new SaveXmlDataParam()
                {
                    User = userBase,
                    MedicalInsuranceBackNum = "zydj",
                    MedicalInsuranceCode = "48",
                    BusinessId = param.BusinessId,
                    BackParam = strXmlBackParam
                };
                //存基层
                webServiceBasic.SaveXmlData(saveXml);
            }));
        }
        /// <summary>
        /// icd10对码
        /// </summary>
        /// <param name="param"></param>
        public void Icd10PairCode(Icd10PairCodeParam param)
        {  //回参构建
            var icd10List = new List <Icd10PairCodeDateXml>();

            icd10List.Add(new Icd10PairCodeDateXml()
            {
                DiseaseId     = param.DiseaseId,
                DiseaseName   = param.ProjectName,
                DiseaseCoding = param.ProjectCode
            });
            var dd = new Icd10PairCodeDateXml()
            {
                DiseaseId     = param.DiseaseId,
                DiseaseName   = param.ProjectName,
                DiseaseCoding = param.ProjectCode
            };
            var xmlData = new Icd10PairCodeXml()
            {
                row = icd10List
            };
            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = param.User,
                MedicalInsuranceBackNum = "CXJB002",
                MedicalInsuranceCode    = "91",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            //存基层
            _webServiceBasic.SaveXmlData(saveXml);
            _hisSqlRepository.Icd10PairCode(param);
        }
        public ApiJsonResultData OutpatientDepartmentCostInput([FromBody] OutpatientPlanBirthSettlementUiParam param)
        {
            return(new ApiJsonResultData(ModelState).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                userBase.TransKey = param.TransKey;
                var json =
                    "{\"发生费用金额\":0.0250,\"生育补助\":500.0,\"基本统筹支付\":0.0,\"补充医疗保险支付金额\":0.0,\"公务员补贴\":0.0,\"公务员补助\":0.0,\"其它支付金额\":0.0,\"账户支付\":0.0,\"现金支付\":0.0,\"起付金额\":0.0}";
                //var iniData = JsonConvert.DeserializeObject<WorkerBirthPreSettlementJsonDto>(json);
                var resultData = JsonConvert.DeserializeObject <WorkerBirthSettlementDto>(json);

                var ccc = new GetOutpatientPersonParam()
                {
                    User = userBase,
                    UiParam = param,
                    IdentityMark = param.IdentityMark,
                    AfferentSign = param.AfferentSign,
                    InsuranceType = param.InsuranceType,
                    AccountBalance = param.AccountBalance,
                    SettlementXml = param.SettlementJson,
                };
                //获取门诊病人数据
                var outpatientPerson = webServiceBasicService.GetOutpatientPerson(ccc);
                var accountPayment = resultData.AccountPayment + resultData.CivilServantsSubsidies +
                                     resultData.CivilServantsSubsidy + resultData.OtherPaymentAmount +
                                     resultData.BirthAllowance + resultData.SupplementPayAmount;
                var cashPayment = CommonHelp.ValueToDouble((outpatientPerson.MedicalTreatmentTotalCost - accountPayment));
                // 回参构建
                var xmlData = new OutpatientDepartmentCostXml()
                {
                    AccountBalance = !string.IsNullOrWhiteSpace(param.AccountBalance) == true ? Convert.ToDecimal(param.AccountBalance) : 0,
                    MedicalInsuranceOutpatientNo = "54901231",
                    CashPayment = cashPayment < 0?0: cashPayment,
                    SettlementNo = "54901231",
                    AllAmount = CommonHelp.ValueToDouble(outpatientPerson.MedicalTreatmentTotalCost),
                    PatientName = "代美玲",
                    AccountAmountPay = 0,
                    MedicalInsuranceType = "1",
                };

                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml = new SaveXmlDataParam()
                {
                    User = userBase,
                    MedicalInsuranceBackNum = "zydj",
                    MedicalInsuranceCode = "48",
                    BusinessId = param.BusinessId,
                    BackParam = strXmlBackParam
                };
                ////存基层
                webServiceBasic.SaveXmlData(saveXml);
            }));
        }
        public ApiJsonResultData Settlement([FromUri] BaseUiBusinessIdDataParam param)
        {
            return(new ApiJsonResultData(ModelState).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                userBase.TransKey = param.TransKey;
                //54901231
                //回参构建
                var xmlData = new OutpatientDepartmentCostXml()
                {
                    AccountBalance = 0,
                    MedicalInsuranceOutpatientNo = "54901231",
                    CashPayment = Convert.ToDecimal(-295.2),
                    SettlementNo = "54901231",
                    AllAmount = Convert.ToDecimal(4.8),
                    PatientName = "陈继美",
                    AccountAmountPay = 0,
                    MedicalInsuranceType = "345",
                };

                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml = new SaveXmlDataParam()
                {
                    User = userBase,
                    MedicalInsuranceBackNum = "zydj",
                    MedicalInsuranceCode = "48",
                    BusinessId = param.BusinessId,
                    BackParam = strXmlBackParam
                };
                //存基层
                webServiceBasic.SaveXmlData(saveXml);
                //var dd = new ResidentUserInfoParam { IdentityMark = "1", InformationNumber = "111" };
                //var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                //var strXmlIntoParam = XmlSerializeHelper.XmlSerialize(dd);
                //var strXmlBackParam = XmlSerializeHelper.XmlSerialize(dd);
                //var saveXmlData = new SaveXmlData();
                //saveXmlData.OrganizationCode = userBase.OrganizationCode;
                //saveXmlData.AuthCode = userBase.AuthCode;
                //saveXmlData.BusinessId = param.BusinessId;
                //saveXmlData.TransactionId = param.BusinessId;
                //saveXmlData.MedicalInsuranceBackNum = "CXJB009";
                //saveXmlData.BackParam = CommonHelp.EncodeBase64("utf-8", strXmlIntoParam);
                //saveXmlData.IntoParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam);
                //saveXmlData.MedicalInsuranceCode = "41";
                //saveXmlData.UserId = param.UserId;
                // webServiceBasic.HIS_InterfaceList("38", JsonConvert.SerializeObject(saveXmlData));
            }));
        }
        public ApiJsonResultData MedicalInsuranceXmlCancel([FromUri] MedicalInsuranceXmlUiParam param)
        {
            return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                userBase.TransKey = param.TransKey;
                //回参构建
                var xmlData = new HospitalSettlementCancelXml()
                {
                    SettlementNo = param.SettlementNo,
                };
                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml = new SaveXmlDataParam()
                {
                    User = userBase,
                    MedicalInsuranceBackNum = "CXJB011",
                    MedicalInsuranceCode = "42",
                    BusinessId = param.BusinessId,
                    BackParam = strXmlBackParam
                };
                //存基层
                webServiceBasic.SaveXmlData(saveXml);
                //var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                ////更新医保信息
                //var strXmlIntoParam = XmlSerializeHelper.XmlParticipationParam();
                ////回参构建
                //var xmlData = new HospitalizationRegisterCancelXml()
                //{

                //    MedicalInsuranceHospitalizationNo = "44116476",

                //};

                //var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                //var saveXmlData = new SaveXmlData();
                //saveXmlData.OrganizationCode = userBase.OrganizationCode;
                //saveXmlData.AuthCode = userBase.AuthCode;
                //saveXmlData.BusinessId = param.BusinessId;
                //saveXmlData.TransactionId = Guid.Parse("EA144C5D-1146-4229-87FB-7D9EEA0B3F78").ToString("N");
                //saveXmlData.MedicalInsuranceBackNum = "CXJB003";
                //saveXmlData.BackParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam);
                //saveXmlData.IntoParam = CommonHelp.EncodeBase64("utf-8", strXmlIntoParam);
                //saveXmlData.MedicalInsuranceCode = "22";
                //saveXmlData.UserId = userBase.UserId;
                ////存基层
                //webServiceBasic.HIS_InterfaceList("38", JsonConvert.SerializeObject(saveXmlData));
            }));
        }
        public ApiJsonResultData MedicalInsuranceXmlUpload([FromUri] MedicalInsuranceXmlUiParam param)
        {
            return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);

                var hospitalizationFeeList = hisSqlRepository.InpatientInfoDetailQuery(
                    new InpatientInfoDetailQueryParam()
                {
                    BusinessId = param.BusinessId
                });


                var rowXml = hospitalizationFeeList.Where(d => d.UploadMark == 0).Select(c =>
                                                                                         new HospitalizationFeeUploadRowXml()
                {
                    SerialNumber = c.DetailId
                }).ToList();


                var xmlData = new HospitalizationFeeUploadXml()
                {
                    MedicalInsuranceHospitalizationNo = "44116476",
                    RowDataList = rowXml,
                };
                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                //
                var transactionId = Guid.Parse("79D71ACA-EDBB-419C-A382-2271922E708D").ToString("N");
                var saveXmlData = new SaveXmlData();
                saveXmlData.OrganizationCode = userBase.OrganizationCode;
                saveXmlData.AuthCode = userBase.AuthCode;
                saveXmlData.BusinessId = param.BusinessId;
                saveXmlData.TransactionId = transactionId;
                saveXmlData.MedicalInsuranceBackNum = "CXJB004";
                saveXmlData.BackParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam);
                saveXmlData.IntoParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam);
                saveXmlData.MedicalInsuranceCode = "31";
                saveXmlData.UserId = userBase.UserId;
                webServiceBasic.HIS_InterfaceList("38", JsonConvert.SerializeObject(saveXmlData));
            }));
        }
 public ApiJsonResultData CancelOutpatientDepartmentCost([FromUri] CancelOutpatientDepartmentCostUiParam param)
 {
     return(new ApiJsonResultData(ModelState).RunWithTry(y =>
     {
         var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
         userBase.TransKey = param.TransKey;
         var xmlData = new MedicalInsuranceXmlDto();
         xmlData.BusinessId = param.BusinessId;
         xmlData.HealthInsuranceNo = "42";//42MZ
         xmlData.TransactionId = param.TransKey;
         xmlData.AuthCode = userBase.AuthCode;
         xmlData.UserId = param.UserId;
         xmlData.OrganizationCode = userBase.OrganizationCode;
         var jsonParam = JsonConvert.SerializeObject(xmlData);
         var data = webServiceBasic.HIS_Interface("39", jsonParam);
         HisHospitalizationSettlementCancelJsonDto dataValue = JsonConvert.DeserializeObject <HisHospitalizationSettlementCancelJsonDto>(data.Msg);
         //{\"基础信息\":{\"ORGID\":\"9F44A548B22A4F84BC59A59FF4796D53\",\"YBCODE\":\"123\",\"INFID\":\"6F63E04260974852B0F461D6108DB688\",\"结算编号\":\"34556\",\"就诊编号\":\"34556\",\"经办人\":\"医保接口\"}}
         ////回参构建
         var xmlDatas = new OutpatientDepartmentCostCancelXml()
         {
             SettlementNo = dataValue.InfoData.SettlementNo
         };
         var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlDatas);
         var saveXml = new SaveXmlDataParam()
         {
             User = userBase,
             MedicalInsuranceBackNum = "Qxjs",
             MedicalInsuranceCode = "42MZ",
             BusinessId = param.BusinessId,
             BackParam = strXmlBackParam
         };
         //存基层
         webServiceBasic.SaveXmlData(saveXml);
         //_outpatientDepartmentNewService.CancelOutpatientDepartmentCost(param);
     }));
 }
        /// <summary>
        /// 门诊费用录入
        /// </summary>
        public OutpatientDepartmentCostInputDto OutpatientDepartmentCostInput(GetOutpatientPersonParam param)
        {
            OutpatientDepartmentCostInputDto resultData = null;
            //获取门诊病人数据
            var outpatientPerson = _serviceBasicService.GetOutpatientPerson(param);

            if (outpatientPerson == null)
            {
                throw new Exception("his中未获取到当前病人!!!");
            }
            //if (string.IsNullOrWhiteSpace(outpatientPerson.IdCardNo)) throw new Exception("当前病人的身份证号码不能为空!!!");
            var inputParam = new OutpatientDepartmentCostInputParam()
            {
                AllAmount    = outpatientPerson.MedicalTreatmentTotalCost,
                IdentityMark = param.IdentityMark,
                AfferentSign = param.AfferentSign,
                Operators    = param.User.UserName
            };

            //医保数据写入
            resultData = _outpatientDepartmentRepository.OutpatientDepartmentCostInput(inputParam);
            if (resultData == null)
            {
                throw new Exception("门诊费用医保执行失败!!!");
            }

            param.IsSave = true;
            param.Id     = Guid.NewGuid();
            //保存门诊病人
            _serviceBasicService.GetOutpatientPerson(param);
            //中间层数据写入
            var saveData = new MedicalInsuranceDto
            {
                AdmissionInfoJson = JsonConvert.SerializeObject(param),
                BusinessId        = param.UiParam.BusinessId,
                Id                                = Guid.NewGuid(),
                IsModify                          = false,
                InsuranceType                     = 999,
                MedicalInsuranceState             = MedicalInsuranceState.MedicalInsuranceHospitalized,
                MedicalInsuranceHospitalizationNo = resultData.DocumentNo,
                AfferentSign                      = param.AfferentSign,
                IdentityMark                      = param.IdentityMark
            };

            //存中间库
            _medicalInsuranceSqlRepository.SaveMedicalInsurance(param.User, saveData);

            //日志写入
            _systemManageRepository.AddHospitalLog(new AddHospitalLogParam()
            {
                User            = param.User,
                JoinOrOldJson   = JsonConvert.SerializeObject(inputParam),
                ReturnOrNewJson = JsonConvert.SerializeObject(resultData),
                RelationId      = param.Id,
                BusinessId      = param.UiParam.BusinessId,
                Remark          = "[R][OutpatientDepartment]门诊病人结算"
            });
            //获取病人的基础信息
            var userInfoData = _residentMedicalInsuranceRepository.GetUserInfo(new ResidentUserInfoParam()
            {
                IdentityMark = param.IdentityMark,
                AfferentSign = param.AfferentSign,
            });
            //回参构建
            var xmlData = new OutpatientDepartmentCostXml()
            {
                AccountBalance = userInfoData.InsuranceType == "342" ? userInfoData.ResidentInsuranceBalance : userInfoData.WorkersInsuranceBalance,
                MedicalInsuranceOutpatientNo = resultData.DocumentNo,
                CashPayment          = resultData.SelfPayFeeAmount,
                SettlementNo         = resultData.DocumentNo,
                AllAmount            = outpatientPerson.MedicalTreatmentTotalCost,
                PatientName          = outpatientPerson.PatientName,
                AccountAmountPay     = 0,
                MedicalInsuranceType = userInfoData.InsuranceType == "310" ? "1" : userInfoData.InsuranceType,
            };

            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = param.User,
                MedicalInsuranceBackNum = "zydj",
                MedicalInsuranceCode    = "48",
                BusinessId = param.UiParam.BusinessId,
                BackParam  = strXmlBackParam
            };

            //存基层
            _webBasicRepository.SaveXmlData(saveXml);
            var updateParam = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = param.User.UserId,
                ReimbursementExpensesAmount = resultData.ReimbursementExpensesAmount,
                SelfPayFeeAmount            = resultData.SelfPayFeeAmount,
                OtherInfo    = JsonConvert.SerializeObject(resultData),
                Id           = saveData.Id,
                SettlementNo = resultData.DocumentNo,
                MedicalInsuranceAllAmount = outpatientPerson.MedicalTreatmentTotalCost,
                SettlementTransactionId   = param.User.TransKey,
                MedicalInsuranceState     = MedicalInsuranceState.HisSettlement
            };

            //更新中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParam);

            return(resultData);
        }
        /// <summary>
        /// 门诊生育结算
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WorkerHospitalizationPreSettlementDto OutpatientPlanBirthSettlement(
            OutpatientPlanBirthSettlementUiParam param)
        {
            WorkerHospitalizationPreSettlementDto resultData = null;
            var userBase = _serviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            //门诊病人信息存储
            var id = Guid.NewGuid();
            var outpatientParam = new GetOutpatientPersonParam()
            {
                User    = userBase,
                UiParam = param,
                Id      = id,
            };
            var outpatientPerson = _serviceBasicService.GetOutpatientPerson(outpatientParam);

            if (outpatientPerson == null)
            {
                throw new Exception("his中未获取到当前病人!!!");
            }
            var outpatientDetailPerson = _serviceBasicService.GetOutpatientDetailPerson(new OutpatientDetailParam()
            {
                User       = userBase,
                BusinessId = param.BusinessId,
            });
            var queryResidentParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId = param.BusinessId,
            };
            //获取医保病人信息
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(queryResidentParam);

            if (residentData.MedicalInsuranceState != MedicalInsuranceState.MedicalInsurancePreSettlement)
            {
                throw new Exception("当前病人未办理预结算,不能办理结算!!!");
            }
            if (residentData.MedicalInsuranceState == MedicalInsuranceState.HisSettlement)
            {
                throw new Exception("当前病人已办理医保结算,不能办理再次结算!!!");
            }
            //获取数据明细
            var iniParam = GetOutpatientPlanBirthSettlementParam
                               (param);

            iniParam.AfferentSign = param.AfferentSign;
            iniParam.IdentityMark = param.IdentityMark;
            iniParam.OutpatientNo = CommonHelp.GuidToStr(param.BusinessId);

            // 医保执行
            resultData = _outpatientDepartmentRepository.OutpatientPlanBirthSettlement(iniParam);
            _serviceBasicService.GetOutpatientPerson(outpatientParam);
            var updateData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = userBase.UserId,
                ReimbursementExpensesAmount = CommonHelp.ValueToDouble(resultData.ReimbursementExpenses),
                SelfPayFeeAmount            = resultData.CashPayment,
                OtherInfo    = JsonConvert.SerializeObject(resultData),
                Id           = residentData.Id,
                SettlementNo = resultData.DocumentNo,
                MedicalInsuranceAllAmount = resultData.TotalAmount,
                SettlementTransactionId   = userBase.UserId,
                MedicalInsuranceState     = MedicalInsuranceState.MedicalInsuranceSettlement
            };

            //存入中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateData);
            //日志写入
            _systemManageRepository.AddHospitalLog(new AddHospitalLogParam()
            {
                User            = userBase,
                JoinOrOldJson   = JsonConvert.SerializeObject(iniParam),
                ReturnOrNewJson = JsonConvert.SerializeObject(resultData),
                RelationId      = outpatientParam.Id,
                BusinessId      = param.BusinessId,
                Remark          = "[R][OutpatientDepartment]门诊生育结算"
            });
            //获取病人的基础信息
            var userInfoData = _residentMedicalInsuranceRepository.GetUserInfo(new ResidentUserInfoParam()
            {
                IdentityMark = param.IdentityMark,
                AfferentSign = param.AfferentSign,
            });
            // 回参构建
            var xmlData = new OutpatientDepartmentCostXml()
            {
                AccountBalance = userInfoData.InsuranceType == "342" ? userInfoData.ResidentInsuranceBalance : userInfoData.WorkersInsuranceBalance,
                MedicalInsuranceOutpatientNo = resultData.DocumentNo,
                CashPayment          = resultData.CashPayment,
                SettlementNo         = resultData.DocumentNo,
                AllAmount            = outpatientPerson.MedicalTreatmentTotalCost,
                PatientName          = outpatientPerson.PatientName,
                AccountAmountPay     = resultData.AccountPayment,
                MedicalInsuranceType = userInfoData.InsuranceType == "310" ? "1" : userInfoData.InsuranceType,
            };

            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = userBase,
                MedicalInsuranceBackNum = "zydj",
                MedicalInsuranceCode    = "48",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            ////存基层
            _webBasicRepository.SaveXmlData(saveXml);
            var updateParamData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = param.UserId,
                Id     = residentData.Id,
                MedicalInsuranceState = MedicalInsuranceState.HisSettlement,
                IsHisUpdateState      = true
            };

            //  更新中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParamData);

            return(resultData);
        }
        //门诊取消结算
        public void CancelOutpatientDepartmentCost(CancelOutpatientDepartmentCostUiParam param)
        {
            var userBase = _serviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            //获取医保病人信息
            var queryResidentParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId       = param.BusinessId,
                OrganizationCode = userBase.OrganizationCode
            };
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(queryResidentParam);

            if (residentData == null)
            {
                throw new Exception("当前病人未结算,不能取消结算!!!");
            }
            if (residentData.MedicalInsuranceState != MedicalInsuranceState.HisSettlement)
            {
                throw new Exception("当前病人未结算,不能取消结算!!!");
            }
            //计划生育
            if (residentData.IsBirthHospital == 1)
            {
                _outpatientDepartmentRepository.OutpatientPlanBirthSettlementCancel(new OutpatientPlanBirthSettlementCancelParam()
                {
                    SettlementNo  = residentData.SettlementNo,
                    CancelRemarks = param.CancelSettlementRemarks
                });
            }
            else  //普通门诊
            {
                _outpatientDepartmentRepository.CancelOutpatientDepartmentCost(new CancelOutpatientDepartmentCostParam()
                {
                    DocumentNo = residentData.SettlementNo
                });
            }



            //添加日志
            var logParam = new AddHospitalLogParam()
            {
                JoinOrOldJson = JsonConvert.SerializeObject(param),
                User          = userBase,
                Remark        = "门诊取消结算",
                RelationId    = residentData.Id,
                BusinessId    = param.BusinessId,
            };

            _systemManageRepository.AddHospitalLog(logParam);

            //回参构建
            var xmlData = new OutpatientDepartmentCostCancelXml()
            {
                SettlementNo = residentData.SettlementNo
            };
            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = userBase,
                MedicalInsuranceBackNum = "Qxjs",
                MedicalInsuranceCode    = "42MZ",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            //存基层
            _webBasicRepository.SaveXmlData(saveXml);

            var updateParamData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = param.UserId,
                Id     = residentData.Id,
                CancelTransactionId     = param.TransKey,
                MedicalInsuranceState   = MedicalInsuranceState.MedicalInsuranceCancelSettlement,
                IsHisUpdateState        = true,
                CancelSettlementRemarks = param.CancelSettlementRemarks
            };

            //更新中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParamData);
        }
Example #13
0
        /// <summary>
        /// 门诊异地划卡
        /// </summary>
        /// <param name="param"></param>
        public WorkerHospitalSettlementCardBackDto YdOutpatientPayCard(GetYdOutpatientPayCardParam param)
        {
            var resultData = new WorkerHospitalSettlementCardBackDto();
            var outputData =
                XmlSerializeHelper.YdDeSerializer <YdOutpatientPayCardXml>(param.SettlementJson);
            //YdOutpatientPayCardXml
            var userBase = _serviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            //门诊病人信息存储
            var id = Guid.NewGuid();
            var outpatientParam = new GetOutpatientPersonParam()
            {
                User    = userBase,
                UiParam = param,
                Id      = id,
                IsSave  = true,
            };
            var outpatientPerson = _serviceBasicService.GetOutpatientPerson(outpatientParam);

            if (outpatientPerson == null)
            {
                throw new Exception("his中未获取到当前病人!!!");
            }
            //储存明细
            var outpatientDetailPerson = _serviceBasicService.GetOutpatientDetailPerson(new OutpatientDetailParam()
            {
                User       = userBase,
                BusinessId = param.BusinessId,
                IsSave     = true,
                PatientId  = id.ToString()
            });
            var queryResidentParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId = param.BusinessId,
            };

            //日志写入
            _systemManageRepository.AddHospitalLog(new AddHospitalLogParam()
            {
                User            = userBase,
                JoinOrOldJson   = JsonConvert.SerializeObject(param),
                ReturnOrNewJson = JsonConvert.SerializeObject(outputData),
                RelationId      = outpatientParam.Id,
                BusinessId      = param.BusinessId,
                Remark          = outputData.SerialNumber + "异地刷卡支付"
            });
            //获取医保病人信息
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(queryResidentParam);

            if (residentData.MedicalInsuranceState != MedicalInsuranceState.MedicalInsurancePreSettlement)
            {
                throw new Exception("当前病人未办理预结算,不能办理结算!!!");
            }
            //存中间库

            var updateData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId           = userBase.UserId,
                SelfPayFeeAmount = CommonHelp.ValueToDouble(outpatientPerson.MedicalTreatmentTotalCost - outputData.AccountPayAmount),
                OtherInfo        = JsonConvert.SerializeObject(resultData),
                Id           = residentData.Id,
                SettlementNo = outputData.SerialNumber,
                MedicalInsuranceAllAmount = outpatientPerson.MedicalTreatmentTotalCost,
                SettlementTransactionId   = userBase.UserId,
                MedicalInsuranceState     = MedicalInsuranceState.MedicalInsuranceSettlement,
                SettlementType            = "2",
                PatientId = id.ToString()
            };

            //存入中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateData);

            // 回参构建
            var xmlData = new OutpatientDepartmentCostXml()
            {
                AccountBalance = param.AccountBalance,
                MedicalInsuranceOutpatientNo = outputData.SerialNumber,
                CashPayment          = outputData.CashPayAmount,
                SettlementNo         = outputData.SerialNumber,
                AllAmount            = CommonHelp.ValueToDouble(outpatientPerson.MedicalTreatmentTotalCost),
                PatientName          = outpatientPerson.PatientName,
                AccountAmountPay     = outputData.AccountPayAmount,
                MedicalInsuranceType = "1",
            };
            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = userBase,
                MedicalInsuranceBackNum = "zydj",
                MedicalInsuranceCode    = "48",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            //存基层
            _webBasicRepository.SaveXmlData(saveXml);
            var updateParamData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = param.UserId,
                Id     = residentData.Id,
                MedicalInsuranceState = MedicalInsuranceState.HisSettlement,
                IsHisUpdateState      = true
            };

            //  更新中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParamData);
            resultData.AccountBalance = param.AccountBalance;
            resultData.AccountPayment = outputData.AccountPayAmount;
            resultData.CashPayment    = outputData.CashPayAmount;

            return(resultData);
        }
Example #14
0
        /// <summary>
        /// 取消医保出院结算
        /// </summary>
        /// <param name="param"></param>
        /// <param name="infoParam"></param>
        /// <returns></returns>
        public void LeaveHospitalSettlementCancel(LeaveHospitalSettlementCancelParam param,
                                                  LeaveHospitalSettlementCancelInfoParam infoParam)
        {
            var cancelLimit = param.CancelLimit;

            if (param.CancelLimit == "1")
            {
                Cancel(param);
                var updateParam = new UpdateMedicalInsuranceResidentSettlementParam()
                {
                    UserId = infoParam.User.UserId,
                    Id     = infoParam.Id,
                    CancelTransactionId   = infoParam.User.TransKey,
                    MedicalInsuranceState = MedicalInsuranceState.MedicalInsurancePreSettlement
                };
                //存入中间层
                _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParam);
                //添加日志
                var logParam = new AddHospitalLogParam()
                {
                    JoinOrOldJson = JsonConvert.SerializeObject(param),
                    User          = infoParam.User,
                    Remark        = "居民住院结算取消",
                    RelationId    = infoParam.Id,
                };
                //回参构建
                var xmlData = new HospitalizationRegisterXml()
                {
                    MedicalInsuranceHospitalizationNo = param.MedicalInsuranceHospitalizationNo,
                };
                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml         = new SaveXmlDataParam()
                {
                    User = infoParam.User,
                    MedicalInsuranceBackNum = "CXJB011",
                    MedicalInsuranceCode    = "42",
                    BusinessId = infoParam.BusinessId,
                    BackParam  = strXmlBackParam
                };
                //存基层
                _webBasicRepository.SaveXmlData(saveXml);
            }
            else if (param.CancelLimit == "2") //取消入院登记并删除资料
            {
                Cancel(param);
                //回参构建
                var xmlData = new HospitalizationRegisterCancelXml()
                {
                    MedicalInsuranceHospitalizationNo = param.MedicalInsuranceHospitalizationNo
                };
                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml         = new SaveXmlDataParam()
                {
                    User = infoParam.User,
                    MedicalInsuranceBackNum = "CXJB004",
                    MedicalInsuranceCode    = "22",
                    BusinessId = infoParam.BusinessId,
                    BackParam  = strXmlBackParam
                };
                //存基层
                _webBasicRepository.SaveXmlData(saveXml);
            }
            void Cancel(LeaveHospitalSettlementCancelParam paramc)
            {
                var xmlStr = XmlHelp.SaveXml(paramc);

                if (xmlStr)
                {
                    int result = MedicalInsuranceDll.CallService_cxjb("CXJB011");
                    if (result == 1)
                    {
                        var data = XmlHelp.DeSerializerModel(new IniDto(), true);
                    }
                }
            }
        }
Example #15
0
        /// <summary>
        /// 处方数据上传
        /// </summary>
        /// <param name="param"></param>
        /// <param name="businessId"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        private PrescriptionUploadDto PrescriptionUploadData(PrescriptionUploadParam param, string businessId,
                                                             UserInfoDto user)
        {
            var data   = new PrescriptionUploadDto();
            var rowXml = param.RowDataList.Select(c => new HospitalizationFeeUploadRowXml()
            {
                SerialNumber = c.DetailId
            }).ToList();
            var xmlStr = XmlHelp.SaveXml(param);

            if (xmlStr)
            {
                int result = MedicalInsuranceDll.CallService_cxjb("CXJB004");
                if (result == 1)
                {
                    //如果业务id存在则不直接抛出异常
                    if (!string.IsNullOrWhiteSpace(businessId))
                    {
                        data = XmlHelp.DeSerializerModel(new PrescriptionUploadDto(), false);
                    }
                    else
                    {
                        data = XmlHelp.DeSerializerModel(new PrescriptionUploadDto(), true);
                    }

                    if (data.ReturnState == "1")
                    {
                        //交易码
                        var transactionId = Guid.NewGuid().ToString("N");
                        //添加批次
                        var updateFeeParam = param.RowDataList.Select(d => new UpdateHospitalizationFeeParam
                        {
                            Id            = d.Id,
                            BatchNumber   = data.ProjectBatch,
                            TransactionId = transactionId,
                            UploadAmount  = d.Amount
                        }).ToList();
                        _medicalInsuranceSqlRepository.UpdateHospitalizationFee(updateFeeParam, false, user);

                        //回参
                        var xmlData = new HospitalizationFeeUploadXml()
                        {
                            MedicalInsuranceHospitalizationNo = param.MedicalInsuranceHospitalizationNo,
                            RowDataList = rowXml,
                        };

                        var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                        user.TransKey = businessId;
                        var saveXml = new SaveXmlDataParam()
                        {
                            User = user,
                            MedicalInsuranceBackNum = "CXJB004",
                            MedicalInsuranceCode    = "31",
                            BusinessId = businessId,
                            BackParam  = strXmlBackParam
                        };
                        //存基层
                        _webBasicRepository.SaveXmlData(saveXml);
                        var batchConfirmParam = new BatchConfirmParam()
                        {
                            ConfirmType = 1,
                            MedicalInsuranceHospitalizationNo = param.MedicalInsuranceHospitalizationNo,
                            BatchNumber = data.ProjectBatch,
                            Operators   = CommonHelp.GuidToStr(user.UserId)
                        };
                        var batchConfirmData = BatchConfirm(batchConfirmParam);
                        //如果批次号确认失败,更新病人处方上传标示为 0(未上传)
                        if (batchConfirmData == false)
                        {
                            _medicalInsuranceSqlRepository.UpdateHospitalizationFee(updateFeeParam, true, user);
                        }
                    }
                }
                else
                {
                    throw new Exception("[" + user.UserId + "]" + "处方上传执行出错!!!");
                }
            }

            return(data);
        }
        public void DeletePrescriptionUpload(BaseUiBusinessIdDataParam param)
        {
            var userBase = _webserviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            //获取医保病人信息
            var residentDataParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId       = param.BusinessId,
                OrganizationCode = userBase.OrganizationCode,
            };
            List <QueryInpatientInfoDetailDto> queryData;
            //获取病人明细
            var queryDataDetail = _hisSqlRepository.InpatientInfoDetailQuery
                                      (new InpatientInfoDetailQueryParam()
            {
                BusinessId = param.BusinessId
            });

            //获取选择
            queryData = param.DataIdList != null?queryDataDetail.Where(c => param.DataIdList.Contains(c.Id.ToString())).ToList() : queryDataDetail;

            //获取病人医保信息
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(residentDataParam);

            if (queryData.Any())
            {
                //获取已上传数据、
                var uploadDataId    = queryData.Where(c => c.UploadMark == 1).Select(d => d.Id).ToList();
                var batchNumberList = queryData.Where(c => c.UploadMark == 1).GroupBy(d => d.BatchNumber).Select(b => b.Key).ToList();
                if (batchNumberList.Any())
                {
                    var deleteParam = new DeletePrescriptionUploadParam()
                    {
                        BatchNumber = string.Join(",", batchNumberList.ToArray()),
                        MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceHospitalizationNo
                    };
                    _residentMedicalInsuranceRepository.DeletePrescriptionUpload(deleteParam, uploadDataId, userBase);
                    //取消医保上传状态
                    var updateFeeParam =
                        uploadDataId.Select(c => new UpdateHospitalizationFeeParam {
                        Id = c
                    })
                        .ToList();
                    _medicalInsuranceSqlRepository.UpdateHospitalizationFee(updateFeeParam, true, userBase);
                    //日志
                    var joinJson = JsonConvert.SerializeObject(queryData.Select(c => c.DetailId).ToList());
                    var logParam = new AddHospitalLogParam
                    {
                        User            = userBase,
                        RelationId      = Guid.Parse(param.BusinessId),
                        JoinOrOldJson   = joinJson,
                        ReturnOrNewJson = "",
                        BusinessId      = param.BusinessId,
                        Remark          = "医保取消处方明细id执行成功"
                    };
                    _systemManageRepository.AddHospitalLog(logParam);
                    // 回参构建
                    var xmlData = new HospitalizationFeeUploadCancelXml()
                    {
                        MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceHospitalizationNo,
                        RowDataList = queryData.Select(c => new HospitalizationFeeUploadRowXml()
                        {
                            SerialNumber = c.DetailId
                        }).ToList()
                    };
                    var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                    var saveXml         = new SaveXmlDataParam()
                    {
                        User = userBase,
                        MedicalInsuranceBackNum = "CXJB005",
                        MedicalInsuranceCode    = "32",
                        BusinessId = param.BusinessId,
                        BackParam  = strXmlBackParam
                    };
                    //存基层
                    _webBasicRepository.SaveXmlData(saveXml);
                    //日志
                    logParam.Remark = "基层取消处方明细id执行成功";
                    _systemManageRepository.AddHospitalLog(logParam);
                }
            }
            else
            {
                throw new Exception("未获取到医保退处方数据,请核实数据的正确性!!!");
            }
        }
        /// <summary>
        /// 职工生育入院登记
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WorkerBirthHospitalizationRegisterDto WorkerBirthHospitalizationRegister(WorkerBirthHospitalizationRegisterUiParam param)
        {
            var userBase = _serviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            var infoData = new GetInpatientInfoParam()
            {
                User       = userBase,
                BusinessId = param.BusinessId,
            };
            //获取病人
            var inpatientData = _serviceBasicService.GetInpatientInfo(infoData);

            if (inpatientData == null)
            {
                throw new Exception("获取基层病人失败!!!");
            }
            var paramIni = GetWorkerHospitalizationWorkerBirth(inpatientData, param);
            var data     = _workerMedicalInsuranceRepository.WorkerBirthHospitalizationRegister(paramIni);

            if (data == null)
            {
                throw new Exception("职工生育入院登记未反馈数据!!!");
            }

            var saveData = new MedicalInsuranceDto
            {
                AdmissionInfoJson = JsonConvert.SerializeObject(paramIni),
                BusinessId        = param.BusinessId,
                Id                                = Guid.NewGuid(),
                IsModify                          = false,
                InsuranceType                     = 310,
                MedicalInsuranceState             = MedicalInsuranceState.MedicalInsuranceHospitalized,
                MedicalInsuranceHospitalizationNo = data.MedicalInsuranceInpatientNo,
                IsBirthHospital                   = 1,
                IdentityMark                      = param.IdentityMark,
                AfferentSign                      = param.AfferentSign
            };

            ////存中间库
            _medicalInsuranceSqlRepository.SaveMedicalInsurance(userBase, saveData);
            //回参构建
            var xmlData = new HospitalizationRegisterXml()
            {
                MedicalInsuranceType = "1",
                MedicalInsuranceHospitalizationNo = data.MedicalInsuranceInpatientNo,
                InsuranceNo = null,
            };
            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = userBase,
                MedicalInsuranceBackNum = "zydj",
                MedicalInsuranceCode    = "21",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            //存基层
            _webBasicRepository.SaveXmlData(saveXml);
            saveData.MedicalInsuranceState = MedicalInsuranceState.HisHospitalized;
            //更新中间库
            _medicalInsuranceSqlRepository.SaveMedicalInsurance(userBase, saveData);
            //保存入院数据
            infoData.IsSave = true;
            _serviceBasicService.GetInpatientInfo(infoData);
            return(data);
        }
        /// <summary>
        /// 职工划卡
        /// </summary>
        /// <param name="param"></param>
        public void WorkerStrokeCard(WorkerStrokeCardParam param)
        {
            var queryResidentParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId = param.BusinessId,
            };
            //获取医保病人信息
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(queryResidentParam);

            var userInfoData = _residentMedicalInsuranceRepository.GetUserInfo(new ResidentUserInfoParam()
            {
                IdentityMark = residentData.IdentityMark,
                AfferentSign = residentData.AfferentSign
            });

            //回参构建
            var xmlData = new HospitalSettlementXml()
            {
                MedicalInsuranceHospitalizationNo = param.MedicalInsuranceHospitalizationNo,
                CashPayment      = param.SelfPayFeeAmount,
                SettlementNo     = param.DocumentNo,
                PaidAmount       = 0,
                AllAmount        = param.AllAmount,
                PatientName      = userInfoData.PatientName,
                AccountBalance   = userInfoData.WorkersInsuranceBalance,
                AccountAmountPay = param.AccountPayAmount,
            };
            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = param.User,
                MedicalInsuranceBackNum = param.DocumentNo,
                MedicalInsuranceCode    = "41",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            //结算存基层
            _webBasicRepository.SaveXmlData(saveXml);
            var updateParam = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = param.User.UserId,
                ReimbursementExpensesAmount = param.AccountPayAmount,
                SelfPayFeeAmount            = param.SelfPayFeeAmount,
                OtherInfo             = JsonConvert.SerializeObject(xmlData),
                Id                    = param.Id,
                WorkersStrokeCardNo   = param.DocumentNo,
                WorkersStrokeCardInfo = JsonConvert.SerializeObject(xmlData),
                MedicalInsuranceState = MedicalInsuranceState.HisSettlement
            };

            //  更新中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParam);
            //添加日志
            var logParam = new AddHospitalLogParam()
            {
                JoinOrOldJson   = JsonConvert.SerializeObject(param),
                ReturnOrNewJson = JsonConvert.SerializeObject(xmlData),
                User            = param.User,
                Remark          = "职工病人划卡结算",
                RelationId      = param.Id,
            };

            _systemManageRepository.AddHospitalLog(logParam); //回参构建
        }
        public ApiJsonResultData MedicalInsuranceXmlCancelSettlement([FromUri] MedicalInsuranceXmlUiParam param)
        {
            return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                userBase.TransKey = param.TransKey;

                //回参构建
                var xmlData = new OutpatientDepartmentCostCancelXml()
                {
                    SettlementNo = param.SettlementNo
                };
                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml = new SaveXmlDataParam()
                {
                    User = userBase,
                    MedicalInsuranceBackNum = "Qxjs",
                    MedicalInsuranceCode = "42MZ",
                    BusinessId = param.BusinessId,
                    BackParam = strXmlBackParam
                };
                //存基层
                webServiceBasic.SaveXmlData(saveXml);

                ////回参构建
                //var xmlData = new HospitalSettlementCancelXml()
                //{
                //    SettlementNo = param.SettlementNo,
                //};
                //var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                //var saveXml = new SaveXmlDataParam()
                //{
                //    User = userBase,
                //    MedicalInsuranceBackNum = "CXJB011",
                //    MedicalInsuranceCode = "42",
                //    BusinessId = param.BusinessId,
                //    BackParam = strXmlBackParam
                //};
                ////存基层
                //webServiceBasic.SaveXmlData(saveXml);

                //var ddd = "123";
                ////更新医保信息
                //var strXmlIntoParam = XmlSerializeHelper.XmlParticipationParam();
                ////回参构建
                //var xmlData = new HospitalSettlementCancelXml()
                //{


                //    SettlementNo = param.SettlementNo
                //};

                //var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                //var saveXmlData = new SaveXmlData();
                //saveXmlData.OrganizationCode = userBase.OrganizationCode;
                //saveXmlData.AuthCode = userBase.AuthCode;
                //saveXmlData.BusinessId = param.BusinessId;
                //saveXmlData.TransactionId =param.TransKey;
                //saveXmlData.MedicalInsuranceBackNum = "CXJB003";
                //saveXmlData.BackParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam);
                //saveXmlData.IntoParam = CommonHelp.EncodeBase64("utf-8", strXmlIntoParam);
                //saveXmlData.MedicalInsuranceCode = "42";
                //saveXmlData.UserId = userBase.UserId;
                ////存基层
                //webServiceBasic.HIS_InterfaceList("38", JsonConvert.SerializeObject(saveXmlData));
            }));
        }
        /// <summary>
        /// 居民住院结算
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public HospitalizationPresettlementDto LeaveHospitalSettlement(LeaveHospitalSettlementUiParam param)
        {
            // 获取操作人员信息
            var userBase           = _webserviceBasicService.GetUserBaseInfo(param.UserId);
            var queryResidentParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId       = param.BusinessId,
                OrganizationCode = userBase.OrganizationCode
            };

            userBase.TransKey = param.TransKey;
            var infoData = new GetInpatientInfoParam()
            {
                User       = userBase,
                BusinessId = param.BusinessId,
            };
            //获取his结算
            var hisSettlement = _webserviceBasicService.GetHisHospitalizationSettlement(infoData);
            //获取医保病人信息
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(queryResidentParam);

            if (residentData.MedicalInsuranceState != MedicalInsuranceState.MedicalInsurancePreSettlement)
            {
                throw new Exception("当前病人未办理预结算,不能办理结算!!!");
            }
            if (residentData.MedicalInsuranceState == MedicalInsuranceState.HisSettlement)
            {
                throw new Exception("当前病人已办理医保结算,不能办理再次结算!!!");
            }

            var inpatientInfoParam = new QueryInpatientInfoParam()
            {
                BusinessId = param.BusinessId
            };
            //获取住院病人
            var inpatientInfoData = _hisSqlRepository.QueryInpatientInfo(inpatientInfoParam);

            if (inpatientInfoData == null)
            {
                throw new Exception("该病人未在中心库中,请检查是否办理医保入院!!!");
            }

            var settlementParam = new LeaveHospitalSettlementParam()
            {
                MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceHospitalizationNo,
                LeaveHospitalDate           = Convert.ToDateTime(hisSettlement.LeaveHospitalDate).ToString("yyyyMMdd"),
                UserId                      = hisSettlement.LeaveHospitalOperator,
                LeaveHospitalInpatientState = param.LeaveHospitalInpatientState,
            };
            //获取诊断
            var diagnosisData = CommonHelp.GetDiagnosis(param.DiagnosisList);

            settlementParam.LeaveHospitalMainDiagnosisIcd10  = diagnosisData.AdmissionMainDiagnosisIcd10;
            settlementParam.LeaveHospitalDiagnosisIcd10Two   = diagnosisData.DiagnosisIcd10Two;
            settlementParam.LeaveHospitalDiagnosisIcd10Three = diagnosisData.DiagnosisIcd10Three;
            settlementParam.LeaveHospitalMainDiagnosis       = diagnosisData.DiagnosisDescribe;
            var infoParam = new LeaveHospitalSettlementInfoParam()
            {
                User        = userBase,
                Id          = residentData.Id,
                InsuranceNo = residentData.InsuranceNo,
                BusinessId  = inpatientInfoData.BusinessId,
                IdCardNo    = inpatientInfoData.IdCardNo,
            };
            //医保执行
            var data = _residentMedicalInsuranceRepository.LeaveHospitalSettlement(settlementParam, infoParam);

            if (data == null)
            {
                throw new Exception("居民住院结算反馈失败");
            }
            var updateData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = userBase.UserId,
                ReimbursementExpensesAmount = CommonHelp.ValueToDouble(data.ReimbursementExpenses),
                SelfPayFeeAmount            = data.CashPayment,
                OtherInfo    = JsonConvert.SerializeObject(data),
                Id           = residentData.Id,
                SettlementNo = data.DocumentNo,
                MedicalInsuranceAllAmount = data.TotalAmount,
                SettlementTransactionId   = userBase.UserId,
                MedicalInsuranceState     = MedicalInsuranceState.MedicalInsuranceSettlement
            };

            //存入中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateData);
            //添加日志
            var logParam = new AddHospitalLogParam()
            {
                JoinOrOldJson   = JsonConvert.SerializeObject(param),
                ReturnOrNewJson = JsonConvert.SerializeObject(data),
                User            = userBase,
                Remark          = "居民住院结算",
                RelationId      = residentData.Id,
                BusinessId      = param.BusinessId,
            };


            var userInfoData = _residentMedicalInsuranceRepository.GetUserInfo(new ResidentUserInfoParam()
            {
                IdentityMark = residentData.IdentityMark,
                AfferentSign = residentData.AfferentSign,
            });

            // 回参构建
            var xmlData = new HospitalSettlementXml()
            {
                MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceHospitalizationNo,
                CashPayment      = data.CashPayment,
                SettlementNo     = data.DocumentNo,
                PaidAmount       = data.PaidAmount,
                AllAmount        = data.TotalAmount,
                PatientName      = userInfoData.PatientName,
                AccountBalance   = userInfoData.WorkersInsuranceBalance,
                AccountAmountPay = 0,
            };


            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = userBase,
                MedicalInsuranceBackNum = data.DocumentNo,
                MedicalInsuranceCode    = "41",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            //结算存基层
            _webBasicRepository.SaveXmlData(saveXml);


            var updateParamData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = param.UserId,
                Id     = residentData.Id,
                MedicalInsuranceState = MedicalInsuranceState.HisSettlement,
                IsHisUpdateState      = true
            };

            //  更新中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParamData);
            //结算后保存信息
            var saveParam = AutoMapper.Mapper.Map <SaveInpatientSettlementParam>(hisSettlement);

            saveParam.Id   = (Guid)inpatientInfoData.Id;
            saveParam.User = userBase;
            saveParam.LeaveHospitalDiagnosisJson = JsonConvert.SerializeObject(param.DiagnosisList);
            _hisSqlRepository.SaveInpatientSettlement(saveParam);
            return(data);
        }
        /// <summary>
        /// 入院登记
        /// </summary>
        /// <returns></returns>
        public void HospitalizationRegister(ResidentHospitalizationRegisterUiParam param)
        { //his登陆
            var userBase = _webserviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            var infoData = new GetInpatientInfoParam()
            {
                User       = userBase,
                BusinessId = param.BusinessId,
            };
            //获取医保病人
            var inpatientData = _webserviceBasicService.GetInpatientInfo(infoData);
            var registerParam = GetResidentHospitalizationRegisterParam(param, inpatientData);
            var residentData  = _residentMedicalInsuranceRepository.HospitalizationRegister(registerParam);
            var saveData      = new MedicalInsuranceDto
            {
                AdmissionInfoJson = JsonConvert.SerializeObject(registerParam),
                BusinessId        = param.BusinessId,
                Id            = Guid.NewGuid(),
                InsuranceType = 342,
                MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceInpatientNo,
                MedicalInsuranceState             = MedicalInsuranceState.MedicalInsuranceHospitalized,
                AfferentSign = param.AfferentSign,
                IdentityMark = param.IdentityMark
            };

            //保存中间库
            _medicalInsuranceSqlRepository.SaveMedicalInsurance(userBase, saveData);
            //回参构建
            var xmlData = new HospitalizationRegisterXml()
            {
                MedicalInsuranceType = "10",
                MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceInpatientNo,
                InsuranceNo = null,
            };
            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = userBase,
                MedicalInsuranceBackNum = "CXJB002",
                MedicalInsuranceCode    = "21",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            //存基层
            _webBasicRepository.SaveXmlData(saveXml);
            //更新中间库
            saveData.MedicalInsuranceState = MedicalInsuranceState.HisHospitalized;
            _medicalInsuranceSqlRepository.SaveMedicalInsurance(userBase, saveData);
            //日志
            var logParam = new AddHospitalLogParam
            {
                User            = userBase,
                RelationId      = saveData.Id,
                JoinOrOldJson   = JsonConvert.SerializeObject(param),
                ReturnOrNewJson = JsonConvert.SerializeObject(residentData),
                BusinessId      = param.BusinessId,
                Remark          = "医保入院登记;TransactionId:" + userBase.TransKey
            };

            _systemManageRepository.AddHospitalLog(logParam);
            //保存入院数据
            infoData.IsSave = true;
            _webserviceBasicService.GetInpatientInfo(infoData);
        }
        /// <summary>
        ///取消结算
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string WorkerSettlementCancel(WorkerSettlementCancelParam param)
        {
            string resultData = null;

            if (param.CancelLimit == "1")
            { //划卡取消
                if (param.WorkersStrokeCardNo != null)
                {
                    _workerMedicalInsuranceRepository.CancelWorkerStrokeCard(new CancelWorkersStrokeCardParam()
                    {
                        WorkersStrokeCardNo = param.WorkersStrokeCardNo,
                        Operate             = param.User.UserName,
                        Remarks             = param.CancelSettlementRemarks
                    });
                }

                // 结算取消
                resultData = _workerMedicalInsuranceRepository.WorkerSettlementCancel(param);
                //取消交易id
                var cancelTransactionId = param.User.TransKey;
                //回参构建
                var xmlData = new HospitalSettlementCancelXml()
                {
                    SettlementNo = param.SettlementNo,
                };
                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml         = new SaveXmlDataParam()
                {
                    User = param.User,
                    MedicalInsuranceBackNum = param.MedicalInsuranceHospitalizationNo,
                    MedicalInsuranceCode    = "42",
                    BusinessId = param.BusinessId,
                    BackParam  = strXmlBackParam
                };
                //存基层
                _webBasicRepository.SaveXmlData(saveXml);
                var updateParam = new UpdateMedicalInsuranceResidentSettlementParam()
                {
                    UserId = param.User.UserId,
                    Id     = param.Id,
                    CancelTransactionId     = cancelTransactionId,
                    MedicalInsuranceState   = MedicalInsuranceState.MedicalInsurancePreSettlement,
                    CancelSettlementRemarks = param.CancelSettlementRemarks
                };
                //存入中间层
                _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParam);
                //添加日志
                var logParam = new AddHospitalLogParam()
                {
                    JoinOrOldJson   = JsonConvert.SerializeObject(param),
                    ReturnOrNewJson = "{ yearSign= " + resultData + " }",
                    User            = param.User,
                    Remark          = "职工住院结算取消",
                    RelationId      = param.Id,
                };
                _systemManageRepository.AddHospitalLog(logParam);
            }
            else if (param.CancelLimit == "2")//取消结算,并删除资料<==>删除资料与取消入院
            {
                //回参构建
                var xmlData = new HospitalizationRegisterXml()
                {
                    MedicalInsuranceHospitalizationNo = param.MedicalInsuranceHospitalizationNo,
                };
                var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                var saveXml         = new SaveXmlDataParam()
                {
                    User = param.User,
                    MedicalInsuranceBackNum = "Qxjs",
                    MedicalInsuranceCode    = "22",
                    BusinessId = param.BusinessId,
                    BackParam  = strXmlBackParam
                };
                //存基层
                _webBasicRepository.SaveXmlData(saveXml);

                var updateParamData = new UpdateMedicalInsuranceResidentSettlementParam()
                {
                    UserId = param.User.UserId,
                    Id     = param.Id,
                    CancelTransactionId   = param.User.TransKey,
                    MedicalInsuranceState = MedicalInsuranceState.MedicalInsuranceCancelSettlement,
                    IsHisUpdateState      = true
                };
                //更新中间层
                _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParamData);
            }



            //if (param.CancelLimit == "2") //取消结算,并删除资料<==>删除资料与取消入院
            //{
            //    //回参构建
            //    var xmlData = new HospitalizationRegisterXml()
            //    {
            //        MedicalInsuranceHospitalizationNo = param.MedicalInsuranceHospitalizationNo,
            //    };
            //    var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            //    var saveXml = new SaveXmlDataParam()
            //    {
            //        User = param.User,
            //        MedicalInsuranceBackNum = "Qxjs",
            //        MedicalInsuranceCode = "22",
            //        BusinessId = param.BusinessId,
            //        BackParam = strXmlBackParam
            //    };
            //    //存基层
            //    _webBasicRepository.SaveXmlData(saveXml);

            //    var updateParamData = new UpdateMedicalInsuranceResidentSettlementParam()
            //    {
            //        UserId = param.User.UserId,
            //        Id = param.Id,
            //        CancelTransactionId = cancelTransactionId,
            //        MedicalInsuranceState = MedicalInsuranceState.MedicalInsuranceCancelSettlement,
            //        IsHisUpdateState = true
            //    };
            //    //更新中间层
            //    _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParamData);

            //}
            return(resultData);
        }
        public ApiJsonResultData Icd10BatchUpload([FromBody] UiBaseDataParam param)
        {
            return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y =>
            {
                var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId);
                userBase.TransKey = param.TransKey;
                var dataList = new List <Icd10PairCodeDataParam>();

                //基层
                var queryDataNew = _sqlSugarRepository.QueryICD10PairCode();
                var queryData = queryDataNew.Where(c => c.IsDelete == false && c.State == 0).ToList();
                if (queryData.Any())
                {
                    dataList = queryData.Select(d => new Icd10PairCodeDataParam
                    {
                        DiseaseId = d.DiseaseId,
                        ProjectName = d.ProjectName,
                        ProjectCode = d.ProjectCode
                    }).ToList();
                }

                if (dataList.Any())
                {
                    int a = 0;
                    int limit = 400; //限制条数
                    int num = dataList.Count;
                    var count = Convert.ToInt32(num / limit) + ((num % limit) > 0 ? 1 : 0);
                    var idList = new List <string>();
                    while (a < count)
                    {
                        //排除已上传数据

                        var rowDataListAll = dataList.Where(d => !idList.Contains(d.DiseaseId))
                                             .ToList();
                        var sendList = rowDataListAll.Take(limit).ToList();


                        //回参构建
                        var icd10List = new List <Icd10PairCodeDateXml>();
                        icd10List.AddRange(sendList.Select(c => new Icd10PairCodeDateXml()
                        {
                            DiseaseId = c.DiseaseId,
                            DiseaseName = c.ProjectName,
                            DiseaseCoding = c.ProjectCode
                        }));

                        var xmlData = new Icd10PairCodeXml()
                        {
                            row = icd10List
                        };
                        var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
                        var saveXml = new SaveXmlDataParam()
                        {
                            User = userBase,
                            MedicalInsuranceBackNum = "CXJB002",
                            MedicalInsuranceCode = "91",
                            BusinessId = param.BusinessId,
                            BackParam = strXmlBackParam
                        };
                        //存基层
                        webServiceBasic.SaveXmlData(saveXml);
                        idList.AddRange(sendList.Select(c => c.DiseaseId));
                        a++;
                    }


                    hisSqlRepository.ExecuteSql("update [dbo].[ICD10PairCode] set state=1 where  [PairCodeUserName]='医保接口对码'");
                }
            }));
        }
        /// <summary>
        /// 职工生育结算
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WorkerHospitalizationPreSettlementDto WorkerBirthSettlement(WorkerBirthSettlementUiParam param)
        {
            //获取操作人员信息
            var userBase = _serviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            var infoData = new GetInpatientInfoParam()
            {
                User       = userBase,
                BusinessId = param.BusinessId,
            };
            //获取his结算
            var hisSettlement      = _serviceBasicService.GetHisHospitalizationSettlement(infoData);
            var queryResidentParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId       = param.BusinessId,
                OrganizationCode = userBase.OrganizationCode
            };
            //获取医保病人信息
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(queryResidentParam);

            if (residentData.MedicalInsuranceState == MedicalInsuranceState.HisSettlement)
            {
                throw new Exception("当前病人已办理医保结算,不能办理预结算!!!");
            }
            if (residentData.MedicalInsuranceState != MedicalInsuranceState.MedicalInsurancePreSettlement)
            {
                throw new Exception("当前病人未办理预结算,不能办理结算!!!");
            }
            var inpatientInfoParam = new QueryInpatientInfoParam()
            {
                BusinessId = param.BusinessId
            };
            //获取住院病人
            var inpatientInfoData = _hisSqlRepository.QueryInpatientInfo(inpatientInfoParam);

            if (inpatientInfoData == null)
            {
                throw new Exception("该病人未在中心库中,请检查是否办理医保入院!!!");
            }

            var infoParam = new WorkerBirthSettlementParam()
            {
                LeaveHospitalInpatientState = param.LeaveHospitalInpatientState,
                FetusNumber     = param.FetusNumber,
                MedicalCategory = param.MedicalCategory,
                Operator        = userBase.UserName,
                MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceHospitalizationNo,
                LeaveHospitalDate = Convert.ToDateTime(hisSettlement.LeaveHospitalDate).ToString("yyyyMMdd"),
            };
            //获取诊断
            var diagnosisData = CommonHelp.GetDiagnosis(param.DiagnosisList);

            infoParam.AdmissionMainDiagnosisIcd10 = diagnosisData.AdmissionMainDiagnosisIcd10;
            infoParam.DiagnosisIcd10Two           = diagnosisData.DiagnosisIcd10Two;
            infoParam.DiagnosisIcd10Three         = diagnosisData.DiagnosisIcd10Three;
            infoParam.AdmissionMainDiagnosis      = diagnosisData.DiagnosisDescribe;

            // 医保
            var resultData = _workerMedicalInsuranceRepository.WorkerBirthSettlement(infoParam);
            //报销金额 =统筹支付+补充医疗保险支付金额+专项基金支付金额+
            //公务员补贴+公务员补助+其它支付金额
            decimal reimbursementExpenses = resultData.BasicOverallPay + resultData.SupplementPayAmount + resultData.SpecialFundPayAmount
                                            + resultData.CivilServantsSubsidies + resultData.CivilServantsSubsidy + resultData.OtherPaymentAmount;

            resultData.ReimbursementExpenses = reimbursementExpenses;
            var updateData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = userBase.UserId,
                ReimbursementExpensesAmount = CommonHelp.ValueToDouble(reimbursementExpenses),
                SelfPayFeeAmount            = resultData.CashPayment,
                OtherInfo    = JsonConvert.SerializeObject(resultData),
                Id           = residentData.Id,
                SettlementNo = resultData.DocumentNo,
                MedicalInsuranceAllAmount = resultData.TotalAmount,
                SettlementTransactionId   = userBase.UserId,
                MedicalInsuranceState     = MedicalInsuranceState.MedicalInsuranceSettlement
            };

            //存入中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateData);
            //添加日志
            var logParam = new AddHospitalLogParam()
            {
                JoinOrOldJson   = JsonConvert.SerializeObject(param),
                ReturnOrNewJson = JsonConvert.SerializeObject(resultData),
                User            = userBase,
                Remark          = "职工住院结算",
                RelationId      = residentData.Id,
            };
            //存入基层
            var userInfoData = _residentMedicalInsuranceRepository.GetUserInfo(new ResidentUserInfoParam()
            {
                IdentityMark = residentData.IdentityMark,
                AfferentSign = residentData.AfferentSign,
            });

            // 回参构建
            var xmlData = new HospitalSettlementXml()
            {
                MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceHospitalizationNo,
                CashPayment      = resultData.CashPayment,
                SettlementNo     = resultData.DocumentNo,
                PaidAmount       = resultData.PaidAmount,
                AllAmount        = resultData.TotalAmount,
                PatientName      = userInfoData.PatientName,
                AccountBalance   = userInfoData.WorkersInsuranceBalance,
                AccountAmountPay = resultData.AccountPayment,
            };


            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = userBase,
                MedicalInsuranceBackNum = resultData.DocumentNo,
                MedicalInsuranceCode    = "41",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            //结算存基层
            _webBasicRepository.SaveXmlData(saveXml);

            var updateParamData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = param.UserId,
                Id     = residentData.Id,
                MedicalInsuranceState = MedicalInsuranceState.HisSettlement,
                IsHisUpdateState      = true
            };

            //  更新中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParamData);


            //结算后保存信息
            var saveParam = AutoMapper.Mapper.Map <SaveInpatientSettlementParam>(hisSettlement);

            saveParam.Id   = (Guid)inpatientInfoData.Id;
            saveParam.User = userBase;
            saveParam.LeaveHospitalDiagnosisJson = JsonConvert.SerializeObject(param.DiagnosisList);
            _hisSqlRepository.SaveInpatientSettlement(saveParam);
            return(resultData);
        }
Example #25
0
        /// <summary>
        /// 门诊计划生育结算
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WorkerBirthSettlementDto OutpatientPlanBirthSettlement(
            OutpatientPlanBirthSettlementUiParam param)
        {
            WorkerBirthSettlementDto resultData;

            var iniData = JsonConvert.DeserializeObject <WorkerBirthPreSettlementJsonDto>(param.SettlementJson);

            resultData = AutoMapper.Mapper.Map <WorkerBirthSettlementDto>(iniData);
            var userBase = _serviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            //门诊病人信息存储
            var id = Guid.NewGuid();
            var outpatientParam = new GetOutpatientPersonParam()
            {
                User    = userBase,
                UiParam = param,
                Id      = id,
            };
            var outpatientPerson = _serviceBasicService.GetOutpatientPerson(outpatientParam);

            if (outpatientPerson == null)
            {
                throw new Exception("his中未获取到当前病人!!!");
            }
            var outpatientDetailPerson = _serviceBasicService.GetOutpatientDetailPerson(new OutpatientDetailParam()
            {
                User       = userBase,
                BusinessId = param.BusinessId,
            });
            var queryResidentParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId = param.BusinessId,
            };
            //获取医保病人信息
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(queryResidentParam);

            if (residentData.MedicalInsuranceState != MedicalInsuranceState.MedicalInsurancePreSettlement)
            {
                throw new Exception("当前病人未办理预结算,不能办理结算!!!");
            }
            if (residentData.MedicalInsuranceState == MedicalInsuranceState.HisSettlement)
            {
                throw new Exception("当前病人已办理医保结算,不能办理再次结算!!!");
            }

            _serviceBasicService.GetOutpatientPerson(outpatientParam);
            var accountPayment = resultData.AccountPayment + resultData.CivilServantsSubsidies +
                                 resultData.CivilServantsSubsidy + resultData.OtherPaymentAmount +
                                 resultData.BirthAallowance + resultData.SupplementPayAmount;
            var updateData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = userBase.UserId,
                ReimbursementExpensesAmount = CommonHelp.ValueToDouble(accountPayment),
                SelfPayFeeAmount            = resultData.CashPayment,
                OtherInfo    = JsonConvert.SerializeObject(resultData),
                Id           = residentData.Id,
                SettlementNo = resultData.DocumentNo,
                MedicalInsuranceAllAmount = resultData.TotalAmount,
                SettlementTransactionId   = userBase.UserId,
                MedicalInsuranceState     = MedicalInsuranceState.MedicalInsuranceSettlement
            };

            //存入中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateData);
            var iniParam = GetOutpatientPlanBirthSettlementParam(param);

            //日志写入
            _systemManageRepository.AddHospitalLog(new AddHospitalLogParam()
            {
                User            = userBase,
                JoinOrOldJson   = JsonConvert.SerializeObject(iniParam),
                ReturnOrNewJson = JsonConvert.SerializeObject(resultData),
                RelationId      = outpatientParam.Id,
                Remark          = "[R][OutpatientDepartment]门诊生育结算"
            });

            // 回参构建
            var xmlData = new OutpatientDepartmentCostXml()
            {
                AccountBalance = !string.IsNullOrWhiteSpace(param.AccountBalance) == true?Convert.ToDecimal(param.AccountBalance) : 0,

                                     MedicalInsuranceOutpatientNo = resultData.DocumentNo,
                                     CashPayment          = resultData.CashPayment,
                                     SettlementNo         = resultData.DocumentNo,
                                     AllAmount            = outpatientPerson.MedicalTreatmentTotalCost,
                                     PatientName          = outpatientPerson.PatientName,
                                     AccountAmountPay     = resultData.AccountPayment,
                                     MedicalInsuranceType = param.InsuranceType == "310" ? "1" : param.InsuranceType,
            };

            var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData);
            var saveXml         = new SaveXmlDataParam()
            {
                User = userBase,
                MedicalInsuranceBackNum = "zydj",
                MedicalInsuranceCode    = "48",
                BusinessId = param.BusinessId,
                BackParam  = strXmlBackParam
            };

            ////存基层
            _webBasicRepository.SaveXmlData(saveXml);
            var updateParamData = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                UserId = param.UserId,
                Id     = residentData.Id,
                MedicalInsuranceState = MedicalInsuranceState.HisSettlement,
                IsHisUpdateState      = true
            };

            //  更新中间层
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParamData);

            return(resultData);
        }