Exemplo n.º 1
0
        /// <summary>
        /// 职工生育预结算
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WorkerHospitalizationPreSettlementDto WorkerBirthPreSettlement(WorkerBirthPreSettlementParam param)
        {
            WorkerHospitalizationPreSettlementDto data = null;
            var xmlStr = XmlHelp.SaveXml(param);

            if (!xmlStr)
            {
                throw new Exception("职工生育预结算保存参数出错");
            }
            int result = MedicalInsuranceDll.CallService_cxjb("SYBX002");

            if (result != 1)
            {
                throw new Exception("职工生育预结算执行出错!!!");
            }
            var dataIni = XmlHelp.DeSerializerModel(new WorkerBirthPreSettlementJsonDto(), true);

            if (dataIni != null)
            {
                data = AutoMapper.Mapper.Map <WorkerHospitalizationPreSettlementDto>(dataIni);
            }
            return(data);
        }
        /// <summary>
        /// 职工生育预结算
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WorkerHospitalizationPreSettlementDto WorkerBirthPreSettlement(WorkerBirthPreSettlementUiParam param)
        {
            //获取操作人员信息
            var userBase = _serviceBasicService.GetUserBaseInfo(param.UserId);

            userBase.TransKey = param.TransKey;
            var queryResidentParam = new QueryMedicalInsuranceResidentInfoParam()
            {
                BusinessId       = param.BusinessId,
                OrganizationCode = userBase.OrganizationCode
            };
            var infoData = new GetInpatientInfoParam()
            {
                User       = userBase,
                BusinessId = param.BusinessId,
            };
            //获取his结算
            var settlementData = _serviceBasicService.GetHisHospitalizationSettlement(infoData);

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

            if (string.IsNullOrWhiteSpace(settlementData.LeaveHospitalDate))
            {
                throw new Exception("当前病人在基层中未办理出院,不能办理医保预结算!!!");
            }

            var preSettlement = new WorkerBirthPreSettlementParam()
            {
                MedicalCategory = param.MedicalCategory,
                FetusNumber     = param.FetusNumber,
                MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceHospitalizationNo,
                LeaveHospitalDate = Convert.ToDateTime(settlementData.LeaveHospitalDate).ToString("yyyyMMdd"),
            };
            //获取诊断
            var diagnosisData = CommonHelp.GetDiagnosis(param.DiagnosisList);

            preSettlement.AdmissionMainDiagnosisIcd10 = diagnosisData.AdmissionMainDiagnosisIcd10;
            preSettlement.DiagnosisIcd10Two           = diagnosisData.DiagnosisIcd10Two;
            preSettlement.DiagnosisIcd10Three         = diagnosisData.DiagnosisIcd10Three;
            //医保结算
            var resultData = _workerMedicalInsuranceRepository.WorkerBirthPreSettlement(preSettlement);

            //报销金额 =统筹支付+补充医疗保险支付金额+专项基金支付金额+
            //公务员补贴+公务员补助+其它支付金额
            decimal reimbursementExpenses = resultData.BasicOverallPay + resultData.SupplementPayAmount + resultData.SpecialFundPayAmount
                                            + resultData.CivilServantsSubsidies + resultData.CivilServantsSubsidy + resultData.OtherPaymentAmount;
            var updateParam = new UpdateMedicalInsuranceResidentSettlementParam()
            {
                ReimbursementExpensesAmount = CommonHelp.ValueToDouble(reimbursementExpenses),
                SelfPayFeeAmount            = resultData.CashPayment,
                OtherInfo    = JsonConvert.SerializeObject(resultData),
                Id           = residentData.Id,
                UserId       = userBase.UserId,
                SettlementNo = resultData.DocumentNo,
                MedicalInsuranceAllAmount  = resultData.TotalAmount,
                PreSettlementTransactionId = userBase.TransKey,
                MedicalInsuranceState      = MedicalInsuranceState.MedicalInsurancePreSettlement
            };

            //存入中间库
            _medicalInsuranceSqlRepository.UpdateMedicalInsuranceResidentSettlement(updateParam);
            var logParam = new AddHospitalLogParam()
            {
                JoinOrOldJson   = JsonConvert.SerializeObject(param),
                ReturnOrNewJson = JsonConvert.SerializeObject(resultData),
                User            = userBase,
                Remark          = "职工生育住院病人预结算"
            };

            _systemManageRepository.AddHospitalLog(logParam);

            return(resultData);
        }