Пример #1
0
        public void Login(string organizationCode)
        {
            var hospitalData = _systemManageRepository.QueryHospitalOrganizationGrade(organizationCode);

            if (hospitalData == null)
            {
                throw new Exception("当前医院无等级信息,请设置");
            }
            if (string.IsNullOrWhiteSpace(hospitalData.MedicalInsuranceAccount))
            {
                throw new Exception("当前医院未设置,医保账户,请设置!!!");
            }
            var result =
                MedicalInsuranceDll.ConnectAppServer_cxjb(hospitalData.MedicalInsuranceAccount,
                                                          hospitalData.MedicalInsurancePwd);

            if (result != 1)
            {
                XmlHelp.DeSerializerModel(new IniXmlDto(), true);
            }
        }
        /// <summary>
        /// 职工住院预结算
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WorkerHospitalizationPreSettlementDto WorkerHospitalizationPreSettlement(UiBaseDataParam 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 hisPreSettlementData = _serviceBasicService.GetHisHospitalizationPreSettlement(infoData);
            var preSettlementData    = hisPreSettlementData.PreSettlementData.FirstOrDefault();
            //获取医保病人信息
            var residentData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(queryResidentParam);
            //获取医院等级
            var gradeData = _systemManageRepository.QueryHospitalOrganizationGrade(userBase.OrganizationCode);

            if (string.IsNullOrWhiteSpace(preSettlementData.EndDate))
            {
                throw new Exception("当前病人在基层中未办理出院,不能办理医保预结算!!!");
            }
            //获取医保账号
            var userData = _systemManageRepository.QueryHospitalOperator(
                new QueryHospitalOperatorParam()
            {
                UserId = param.UserId
            });
            var preSettlement = new WorkerHospitalizationPreSettlementParam()
            {
                User       = userBase,
                Id         = residentData.Id,
                BusinessId = param.BusinessId,
                MedicalInsuranceHospitalizationNo = residentData.MedicalInsuranceHospitalizationNo,
                LeaveHospitalDate          = Convert.ToDateTime(preSettlementData.EndDate).ToString("yyyyMMdd"),
                AdministrativeArea         = gradeData.AdministrativeArea,
                Operators                  = preSettlementData.Operator,
                IsHospitalizationFrequency = "0",
                OrganizationCode           = gradeData.MedicalInsuranceAccount,
            };
            //医保结算
            var resultData = _workerMedicalInsuranceRepository.WorkerHospitalizationPreSettlement(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);
        }