/// <summary> /// 医保信息保存 /// </summary> /// <param name="param"></param> /// <returns></returns> public async Task MedicalInsuranceSave(UserInfoDto user, MedicalInsuranceParam param) { var num = await _dataBaseHelpService.QueryMedicalInsurance(param.业务ID); if (num == 0) { throw new Exception("数据库中未找到相应的住院业务ID的医保信息!"); } else { var oResult = await _webServiceBasic.HIS_InterfaceListAsync("37", "{'验证码':'" + param.验证码 + "','业务ID':'" + param.业务ID + "'}", user.职员ID); if (oResult.Result == "1") { throw new Exception("此业务ID已经报销过,在试图调用接口删除中心住院医保信息时异常。中心返回删除失败消息:" + oResult.Msg.FirstOrDefault()?.ToString() + "!"); } var count = await _dataBaseHelpService.DeleteMedicalInsurance(user, param.业务ID); } List <MedicalInsuranceDto> result; var init = new MedicalInsuranceDto(); var data = await _webServiceBasic.HIS_InterfaceListAsync("36", JsonConvert.SerializeObject(param), user.职员ID); result = GetResultData(init, data); var resultFirst = result.FirstOrDefault(); if (resultFirst != null) { //var msg = "获取住院号【" + resultFirst.住院号 + "】,业务ID【" + param.业务ID + "】的时间段内的住院费用成功,共" + result.Count + // "条记录"; } }
/// <summary> /// 医保信息保存 /// </summary> /// <param name="user"></param> /// <param name="param"></param> public void MedicalInsuranceSave(UserInfoDto user, MedicalInsuranceParam param) { // var num = _hisSqlRepository.QueryMedicalInsurance(param.业务ID); //if (num == 0) //{ // throw new Exception("数据库中未找到相应的住院业务ID的医保信息!"); //} //else //{ // var oResult = _webServiceBasic.HIS_InterfaceList("37", // "{'验证码':'" + param.验证码 + "','业务ID':'" + param.业务ID + "'}", user.UserId); // if (oResult.Result == "1") // { // throw new Exception("此业务ID已经报销过,在试图调用接口删除中心住院医保信息时异常。中心返回删除失败消息:" + // oResult.Msg.FirstOrDefault()?.ToString() + "!"); // } // var count = _hisSqlRepository.DeleteMedicalInsurance(user, param.业务ID); //} List <MedicalInsuranceDto> result; var init = new MedicalInsuranceDto(); var data = _webServiceBasic.HIS_InterfaceList("36", JsonConvert.SerializeObject(param)); result = GetResultData(init, data); var resultFirst = result.FirstOrDefault(); if (resultFirst != null) { //var msg = "获取住院号【" + resultFirst.住院号 + "】,业务ID【" + param.业务ID + "】的时间段内的住院费用成功,共" + result.Count + // "条记录"; } }
/// <summary> /// 医保信息保存 /// </summary> /// <param name="user"></param> /// <param name="param"></param> /// <returns></returns> public void SaveMedicalInsurance(UserInfoDto user, MedicalInsuranceDto param) { using (var sqlConnection = new SqlConnection(_connectionString)) { string strSql = null; try { sqlConnection.Open(); if (param.MedicalInsuranceState == MedicalInsuranceState.HisHospitalized) { strSql = $@"update [dbo].[MedicalInsurance] set MedicalInsuranceState={(int)param.MedicalInsuranceState} where [Id]='{param.Id}'"; } else if (param.IsModify) { strSql = $@"update [dbo].[MedicalInsurance] set AdmissionInfoJson='{param.AdmissionInfoJson}' where [Id]='{param.Id}' and OrganizationCode='{user.OrganizationCode}'"; } else { strSql = $@"INSERT INTO [dbo].[MedicalInsurance]([Id],[BusinessId],[InsuranceNo],[MedicalInsuranceAllAmount],[IdentityMark],[AfferentSign] ,[AdmissionInfoJson],[ReimbursementExpensesAmount] ,[SelfPayFeeAmount],[OtherInfo],[MedicalInsuranceHospitalizationNo],[IsBirthHospital] ,[CreateTime],[IsDelete] ,OrganizationCode,CreateUserId,OrganizationName,InsuranceType,MedicalInsuranceState) VALUES('{param.Id}','{param.BusinessId}','{param.InsuranceNo}', 0,'{param.IdentityMark}','{param.AfferentSign}', '{param.AdmissionInfoJson}',0,0,NULL,'{param.MedicalInsuranceHospitalizationNo}',{param.IsBirthHospital}, GETDATE(),0,'{user.OrganizationCode}','{user.UserId}','{user.OrganizationName }',{param.InsuranceType},{(int)param.MedicalInsuranceState});"; strSql = $"update [dbo].[MedicalInsurance] set [IsDelete]=1,DeleteUserId='{user.UserId}',DeleteTime=GETDATE() where [BusinessId]='{param.BusinessId}';" + strSql; } sqlConnection.Execute(strSql); } catch (Exception e) { _log.Debug(strSql); throw new Exception(e.Message); } } }
/// <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="uiParam"></param> public void ModifyWorkerHospitalization(HospitalizationModifyUiParam uiParam) { //his登陆 var userBase = _serviceBasicService.GetUserBaseInfo(uiParam.UserId); userBase.TransKey = uiParam.TransKey; var param = GetWorkerHospitalizationModify(uiParam, userBase); //医保执行 _workerMedicalInsuranceRepository.ModifyWorkerHospitalization(param); // 回参构建 var xmlData = new HospitalizationModifyXml() { MedicalInsuranceHospitalizationNo = param.MedicalInsuranceHospitalizationNo, }; //var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData); //var saveXml = new SaveXmlDataParam() //{ // User = param.User, // MedicalInsuranceBackNum = "zyzlxgall", // MedicalInsuranceCode = "23", // BusinessId = param.BusinessId, // BackParam = strXmlBackParam //}; ////存基层 //_webBasicRepository.SaveXmlData(saveXml); var paramStr = ""; var queryData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo( new QueryMedicalInsuranceResidentInfoParam { BusinessId = param.BusinessId, OrganizationCode = param.User.OrganizationCode }); if (!string.IsNullOrWhiteSpace(queryData.AdmissionInfoJson)) { var data = JsonConvert.DeserializeObject <WorKerHospitalizationRegisterParam>(queryData .AdmissionInfoJson); if (!string.IsNullOrWhiteSpace(param.AdmissionDate)) { data.AdmissionDate = param.AdmissionDate; } if (!string.IsNullOrWhiteSpace(param.AdmissionMainDiagnosis)) { data.AdmissionMainDiagnosis = param.AdmissionMainDiagnosis; } if (!string.IsNullOrWhiteSpace(param.AdmissionMainDiagnosisIcd10)) { data.AdmissionMainDiagnosisIcd10 = param.AdmissionMainDiagnosisIcd10; } if (!string.IsNullOrWhiteSpace(param.DiagnosisIcd10Three)) { data.DiagnosisIcd10Three = param.DiagnosisIcd10Three; } if (!string.IsNullOrWhiteSpace(param.DiagnosisIcd10Two)) { data.DiagnosisIcd10Two = param.DiagnosisIcd10Two; } if (!string.IsNullOrWhiteSpace(param.InpatientDepartmentCode)) { data.InpatientDepartmentCode = param.InpatientDepartmentCode; } if (!string.IsNullOrWhiteSpace(param.BedNumber)) { data.BedNumber = param.BedNumber; } data.Id = queryData.Id; paramStr = JsonConvert.SerializeObject(data); } var saveData = new MedicalInsuranceDto { AdmissionInfoJson = paramStr, BusinessId = queryData.BusinessId, Id = queryData.Id, IsModify = true, }; _medicalInsuranceSqlRepository.SaveMedicalInsurance(param.User, saveData); //日志 var logParam = new AddHospitalLogParam(); logParam.User = param.User; logParam.RelationId = queryData.Id; logParam.JoinOrOldJson = queryData.AdmissionInfoJson; logParam.ReturnOrNewJson = paramStr; logParam.Remark = "医保入院登记修改"; _systemManageRepository.AddHospitalLog(logParam); }
/// <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 OutpatientPlanBirthPreSettlement(OutpatientPlanBirthPreSettlementUiParam param) { WorkerHospitalizationPreSettlementDto data = null; var userBase = _serviceBasicService.GetUserBaseInfo(param.UserId); userBase.TransKey = param.TransKey; var outpatientParam = new GetOutpatientPersonParam() { User = userBase, UiParam = param, }; var outpatientPerson = _serviceBasicService.GetOutpatientPerson(outpatientParam); if (outpatientPerson == null) { throw new Exception("his中未获取到当前病人!!!"); } var outpatientDetailPerson = _serviceBasicService.GetOutpatientDetailPerson(new OutpatientDetailParam() { User = userBase, BusinessId = param.BusinessId, }); var iniParam = GetOutpatientPlanBirthPreSettlementParam (param); iniParam.AfferentSign = param.AfferentSign; iniParam.IdentityMark = param.IdentityMark; //医保执行 data = _outpatientDepartmentRepository.OutpatientPlanBirthPreSettlement(iniParam); //保存门诊病人 outpatientParam.IsSave = true; outpatientParam.Id = Guid.NewGuid(); _serviceBasicService.GetOutpatientPerson(outpatientParam); var saveData = new MedicalInsuranceDto { AdmissionInfoJson = JsonConvert.SerializeObject(param), BusinessId = param.BusinessId, Id = Guid.NewGuid(), IsModify = false, InsuranceType = 999, MedicalInsuranceState = MedicalInsuranceState.MedicalInsurancePreSettlement, AfferentSign = param.AfferentSign, IdentityMark = param.IdentityMark, IsBirthHospital = 1 }; //存中间库 _medicalInsuranceSqlRepository.SaveMedicalInsurance(userBase, saveData); //日志写入 _systemManageRepository.AddHospitalLog(new AddHospitalLogParam() { User = userBase, JoinOrOldJson = JsonConvert.SerializeObject(iniParam), ReturnOrNewJson = JsonConvert.SerializeObject(data), RelationId = outpatientParam.Id, BusinessId = param.BusinessId, Remark = "[R][OutpatientDepartment]门诊计划生育预结算" }); //明细存入 _serviceBasicService.GetOutpatientDetailPerson(new OutpatientDetailParam() { IsSave = true, BusinessId = param.BusinessId, User = userBase }); 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> /// <param name="user"></param> public void HospitalizationModify(HospitalizationModifyUiParam param) {//his登陆 var userBase = _webserviceBasicService.GetUserBaseInfo(param.UserId); userBase.TransKey = param.TransKey; var modifyParam = GetResidentHospitalizationModify(param); _residentMedicalInsuranceRepository.HospitalizationModify(modifyParam, userBase); var paramStr = ""; var queryData = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo( new QueryMedicalInsuranceResidentInfoParam { BusinessId = param.BusinessId, OrganizationCode = userBase.OrganizationCode }); if (!string.IsNullOrWhiteSpace(queryData.AdmissionInfoJson)) { var data = JsonConvert.DeserializeObject <QueryMedicalInsuranceDetailDto>(queryData .AdmissionInfoJson); if (!string.IsNullOrWhiteSpace(modifyParam.AdmissionDate)) { data.AdmissionDate = modifyParam.AdmissionDate; } if (!string.IsNullOrWhiteSpace(modifyParam.AdmissionMainDiagnosis)) { data.AdmissionMainDiagnosis = modifyParam.AdmissionMainDiagnosis; } if (!string.IsNullOrWhiteSpace(modifyParam.AdmissionMainDiagnosisIcd10)) { data.AdmissionMainDiagnosisIcd10 = modifyParam.AdmissionMainDiagnosisIcd10; } if (!string.IsNullOrWhiteSpace(modifyParam.DiagnosisIcd10Three)) { data.DiagnosisIcd10Three = modifyParam.DiagnosisIcd10Three; } if (!string.IsNullOrWhiteSpace(modifyParam.DiagnosisIcd10Two)) { data.DiagnosisIcd10Two = modifyParam.DiagnosisIcd10Two; } if (!string.IsNullOrWhiteSpace(param.FetusNumber)) { data.FetusNumber = param.FetusNumber; } if (!string.IsNullOrWhiteSpace(param.HouseholdNature)) { data.HouseholdNature = param.HouseholdNature; } if (!string.IsNullOrWhiteSpace(param.InpatientDepartmentCode)) { data.InpatientDepartmentCode = param.InpatientDepartmentCode; } if (!string.IsNullOrWhiteSpace(param.BedNumber)) { data.BedNumber = param.BedNumber; } data.Id = queryData.Id; paramStr = JsonConvert.SerializeObject(data); } var saveData = new MedicalInsuranceDto { AdmissionInfoJson = paramStr, BusinessId = queryData.BusinessId, Id = queryData.Id, IsModify = true, MedicalInsuranceHospitalizationNo = queryData.MedicalInsuranceHospitalizationNo }; _medicalInsuranceSqlRepository.SaveMedicalInsurance(userBase, saveData); //日志 var logParam = new AddHospitalLogParam { User = userBase, RelationId = queryData.Id, JoinOrOldJson = queryData.AdmissionInfoJson, ReturnOrNewJson = paramStr, BusinessId = param.BusinessId, Remark = "医保入院登记修改" }; _systemManageRepository.AddHospitalLog(logParam); }