/// <summary>
        /// 住院医保查询
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public QueryMedicalInsuranceDetailInfoDto QueryMedicalInsuranceDetail(
            QueryMedicalInsuranceUiParam param)
        {
            var resultData = new QueryMedicalInsuranceDetailInfoDto();
            var userBase   = GetUserBaseInfo(param.UserId);
            var queryData  = _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(
                new QueryMedicalInsuranceResidentInfoParam()
            {
                OrganizationCode = userBase.OrganizationCode,
                BusinessId       = param.BusinessId
            });

            if (queryData == null)
            {
                throw new Exception("当前病人未办理医保入院!!!");
            }
            if (string.IsNullOrWhiteSpace(queryData.AdmissionInfoJson))
            {
                throw new Exception("当前病人没有入参参数记录!!!");
            }
            if (queryData.InsuranceType == "310")
            {
                resultData = QueryWorkerMedicalInsuranceDetail(queryData.AdmissionInfoJson);
            }
            if (queryData.InsuranceType == "342")
            {
                resultData = QueryResidentMedicalInsuranceDetail(queryData.AdmissionInfoJson);
            }
            resultData.Id = queryData.Id;
            resultData.MedicalInsuranceHospitalizationNo = queryData.MedicalInsuranceHospitalizationNo;
            resultData.InsuranceType = queryData.InsuranceType;
            return(resultData);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取取消结算参数
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string GetCancelOutpatientDepartmentCostParam(CancelOutpatientDepartmentCostUiParam param)
        {
            string resultData = null;
            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)
            {
                var inputParam = new OutpatientPlanBirthSettlementCancelParam()
                {
                    SettlementNo  = residentData.SettlementNo,
                    CancelRemarks = param.CancelSettlementRemarks
                };
                resultData = XmlSerializeHelper.XmlSerialize(inputParam);
            }
            else
            {
                var inputParam = new CancelOutpatientDepartmentCostParam()
                {
                    DocumentNo = residentData.SettlementNo
                };
                resultData = XmlSerializeHelper.XmlSerialize(inputParam);
            }

            return(resultData);
        }
        /// <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);
        }
        //门诊取消结算
        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);
        }
Ejemplo n.º 5
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);
        }
        /// <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);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 医保处方上传
        /// </summary>
        /// <param name="param"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public RetrunPrescriptionUploadDto PrescriptionUpload(PrescriptionUploadUiParam param, UserInfoDto user)
        {
            //处方上传解决方案
            //1.判断是id上传还是单个用户上传
            //3.获取医院等级判断金额是否符合要求
            //4.数据上传
            //4.1 id上传
            //4.1.2 获取医院等级判断金额是否符合要求
            //4.1.3 数据上传
            //4.1.3.1 数据上传失败,数据回写到日志
            //4.1.3.2 数据上传成功,保存批次号,数据回写至基层
            //4.2   单个病人整体上传
            //4.2.2 获取医院等级判断金额是否符合要求
            //4.2.3 数据上传
            //4.2.3.1 数据上传失败,数据回写到日志
            var resultData = new RetrunPrescriptionUploadDto();
            List <QueryInpatientInfoDetailDto> queryData;
            var queryParam = new InpatientInfoDetailQueryParam();

            //1.判断是id上传还是单个用户上传
            if (param.DataIdList != null && param.DataIdList.Any())
            {
                queryParam.IdList     = param.DataIdList;
                queryParam.UploadMark = 0;
            }
            else
            {
                queryParam.BusinessId = param.BusinessId;
                queryParam.UploadMark = 0;
            }

            //获取病人明细
            queryData = _hisSqlRepository.InpatientInfoDetailQuery(queryParam);
            if (queryData.Any())
            {
                var queryBusinessId = (!string.IsNullOrWhiteSpace(queryParam.BusinessId))
                    ? param.BusinessId
                    : queryData.Select(c => c.BusinessId).FirstOrDefault();
                var medicalInsuranceParam = new QueryMedicalInsuranceResidentInfoParam()
                {
                    BusinessId = queryBusinessId
                };
                //获取病人医保信息
                var medicalInsurance =
                    _medicalInsuranceSqlRepository.QueryMedicalInsuranceResidentInfo(medicalInsuranceParam);
                if (medicalInsurance == null)
                {
                    if (!string.IsNullOrWhiteSpace(queryParam.BusinessId))
                    {
                        resultData.Msg += "病人未办理医保入院";
                    }
                    else
                    {
                        throw new Exception("病人未办理医保入院");
                    }
                }
                else
                {
                    var queryPairCodeParam = new QueryMedicalInsurancePairCodeParam()
                    {
                        DirectoryCodeList = queryData.Select(d => d.DirectoryCode).Distinct().ToList(),
                        OrganizationCode  = user.OrganizationCode,
                    };
                    //获取医保对码数据
                    var queryPairCode =
                        _medicalInsuranceSqlRepository.QueryMedicalInsurancePairCode(queryPairCodeParam);
                    //处方上传数据金额验证
                    var validData     = PrescriptionDataUnitPriceValidation(queryData, queryPairCode, user);
                    var validDataList = validData.Values.FirstOrDefault();
                    //错误提示信息
                    var validDataMsg = validData.Keys.FirstOrDefault();
                    if (!string.IsNullOrWhiteSpace(validDataMsg))
                    {
                        resultData.Msg += validDataMsg;
                    }

                    //获取处方上传入参
                    var paramIni = GetPrescriptionUploadParam(validDataList, queryPairCode, user,
                                                              medicalInsurance.InsuranceType);
                    //医保住院号
                    paramIni.MedicalInsuranceHospitalizationNo = medicalInsurance.MedicalInsuranceHospitalizationNo;
                    int num = paramIni.RowDataList.Count;
                    resultData.Count = num;
                    int a      = 0;
                    int limit  = 40; //限制条数
                    var count  = Convert.ToInt32(num / limit) + ((num % limit) > 0 ? 1 : 0);
                    var idList = new List <Guid>();
                    while (a < count)
                    {
                        //排除已上传数据

                        var rowDataListAll = paramIni.RowDataList.Where(d => !idList.Contains(d.Id))
                                             .OrderBy(c => c.PrescriptionSort).ToList();
                        var sendList = rowDataListAll.Take(limit).Select(s => s.Id).ToList();
                        //新的数据上传参数
                        var uploadDataParam = paramIni;
                        uploadDataParam.RowDataList = rowDataListAll.Where(c => sendList.Contains(c.Id)).ToList();
                        //数据上传
                        var uploadData = PrescriptionUploadData(uploadDataParam, param.BusinessId, user);
                        if (uploadData.ReturnState != "1")
                        {
                            resultData.Msg += uploadData.ReturnState;
                        }
                        else
                        {
                            //更新数据上传状态
                            idList.AddRange(sendList);
                            //获取总行数
                            resultData.Num += sendList.Count();
                        }

                        a++;
                    }
                }
            }


            return(resultData);
        }