예제 #1
0
        public async Task <IActionResult> GetDoctorListByParentOfficeNodeAsync([FromBody] GetDoctorListByParentOfficeNodeRequestDto requestDto)
        {
            var officeBiz = new OfficeBiz();

            //获取选择的科室model
            var officeModel = await officeBiz.GetAsync(requestDto.OfficeGuid);

            var officeIds = new List <string>();
            //获取医院下所有科室
            var officeModels = await officeBiz.GetHospitalOfficeAllAsync(requestDto.HospitalGuid);

            if (string.IsNullOrWhiteSpace(requestDto.OfficeGuid))
            {
                var levelOneOffices = officeBiz.GetHospitalOffice(requestDto.HospitalGuid, null);
                foreach (var item in levelOneOffices)
                {
                    officeIds.AddRange(officeBiz.GetOfficeListByParentOfficeNode(item.OfficeGuid, officeModels));
                }
            }
            else
            {
                officeIds.AddRange(officeBiz.GetOfficeListByParentOfficeNode(officeModel.OfficeGuid, officeModels));
            }

            requestDto.OfficeIds = officeIds;
            var response = await new DoctorBiz().GetDoctorListByParentOfficeNodeAsync(requestDto);

            return(Success(response));
        }
예제 #2
0
        public IActionResult GetHospitalOfficeTree()
        {
            var hospitalBiz = new HospitalBiz();
            var officeBiz   = new OfficeBiz();
            var hospitals   = hospitalBiz.GetAllHospital();

            if (hospitals == null)
            {
                return(Failed(ErrorCode.Empty, "没有查到医院数据!"));
            }
            var hospitalDto = hospitals.Select(a => a.ToDto <GetHospitalOfficeTreeItemDto>()).ToList();

            foreach (var hospital in hospitalDto)
            {
                var topOffices = officeBiz.GetHospitalOffice(hospital.HospitalGuid, null);
                if (topOffices == null || !topOffices.Any())
                {
                    continue;
                }
                var officeDtos = topOffices.Select(a => a.ToDto <GetHospitalOfficeTreeOfficeItemDto>()).ToList();
                officeDtos.ForEach(GetSubordinateOffeces);
                hospital.Offeces = officeDtos;
            }
            return(Success(hospitalDto));
        }
예제 #3
0
        public async Task <IActionResult> DisableEnableOfficeAsync([FromBody] DisableEnableOfficeRequestDto request)
        {
            var officeBiz = new OfficeBiz();
            var officeAll = await officeBiz.GetAllAsync();

            var officeModelList = officeAll.Where(a => a.OfficeName == request.OfficeName).ToList();

            var childOffice = officeAll.Where(a => officeAll.Where(aa => aa.OfficeName == request.OfficeName).Select(aa => aa.OfficeGuid).Contains(a.ParentOfficeGuid)).ToList();

            foreach (var item in childOffice)
            {
                item.LastUpdatedBy   = UserID;
                item.LastUpdatedDate = DateTime.Now;
                item.Enable          = request.Enable;
            }
            foreach (var item in officeModelList)
            {
                item.LastUpdatedBy   = UserID;
                item.LastUpdatedDate = DateTime.Now;
                item.Enable          = request.Enable;
            }
            officeModelList.AddRange(childOffice);
            var result = await officeBiz.UpdateAsync(officeModelList);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "修改失败"));
            }
            return(Success());
        }
예제 #4
0
        public async Task <IActionResult> GetFirstOfficeListAsync()
        {
            var officeBiz = new OfficeBiz();
            var officeAll = await officeBiz.GetAllAsync(enable : true);

            officeAll = officeAll.Where(a => a.ParentOfficeGuid == null || !officeAll.Any(b => b.OfficeGuid == a.ParentOfficeGuid)).ToList();
            return(Success(officeAll.Select(a => a.OfficeName).Distinct()));
        }
예제 #5
0
        public async Task <IActionResult> SearchOfficeAsync([FromBody] SearchOfficeRequestDto request)
        {
            OfficeBiz officeBiz = new OfficeBiz();

            var officeModels = await officeBiz.SearchOfficeAsync(request);

            return(Success(officeModels));
        }
예제 #6
0
        public async Task <IActionResult> GetHospitalOfficesAsync([FromQuery] string hospitalGuid)
        {
            var officeBiz = new OfficeBiz();

            var offices = await officeBiz.GetHospitalFirstLevelOfficesAsync(hospitalGuid);

            return(Success(offices));
        }
예제 #7
0
        public async Task <IActionResult> GetOfficeListAsync([FromBody] GetOfficeListRequestDto request)
        {
            OfficeBiz officeBiz    = new OfficeBiz();
            var       officeModels = await officeBiz.GetOfficeListAsync(request);

            var response = officeModels.GetTree(null, a => a.ParentName, a => a.OfficeName, a => new GetOfficeTreeItemDto
            {
                OfficeName  = a.OfficeName,
                ParentName  = a.ParentName,
                Enable      = a.Enable,
                Sort        = a.Sort,
                PictureGuid = a.PictureGuid,
            });

            return(Success(response));
        }
예제 #8
0
        public async Task <IActionResult> UpdataOfficeAsync([FromBody] UpdataOfficeRequestDto request)
        {
            var officeBiz = new OfficeBiz();
            var officeAll = await officeBiz.GetAllAsync();

            if (request.ParentName == request.OfficeName)
            {
                return(Failed(ErrorCode.UserData, "一级科室不能是自己"));
            }
            var officeModelList = officeAll.Where(a => a.OfficeName == request.OfficeName).ToList();

            var childOffice = officeAll.Where(a => officeAll.Where(aa => aa.OfficeName == request.OfficeName).Select(aa => aa.OfficeGuid).Contains(a.ParentOfficeGuid)).ToList();

            if (!string.IsNullOrWhiteSpace(request.ParentName) && childOffice.Any())
            {
                return(Failed(ErrorCode.UserData, "此科室存二级科室,不能移动到其他科室下面"));
            }
            //foreach (var item in childOffice)
            //{
            //    item.ParentOfficeGuid = officeAll.FirstOrDefault(b => b.OfficeName == request.OfficeName && b.HospitalGuid == item.HospitalGuid)?.ParentOfficeGuid;
            //}
            foreach (var item in officeModelList)
            {
                item.LastUpdatedBy = UserID;
                item.OfficeName    = request.NewOfficeName;
                if (request.ParentName == null)
                {
                    item.ParentOfficeGuid = null;
                }
                else
                {
                    item.ParentOfficeGuid = officeAll.FirstOrDefault(b => b.OfficeName == request.ParentName && b.HospitalGuid == item.HospitalGuid)?.OfficeGuid;
                }
                item.Recommend   = false;
                item.Enable      = request.Enable;
                item.Sort        = request.Sort;
                item.PictureGuid = request.PictureGuid;
            }
            //officeModelList.AddRange(childOffice);
            var result = await officeBiz.UpdateAsync(officeModelList, request.OfficeName, request.NewOfficeName);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "添加失败"));
            }
            return(Success());
        }
예제 #9
0
        public async Task <IActionResult> GetDoctorByFirstLevelOfficeNameAsync([FromQuery] GetDoctorByFirstLevelOfficeNameRequestDto requestDto)
        {
            var officeBiz       = new OfficeBiz();
            var levelOneOffices = await officeBiz.GetModelByNameAsync(requestDto.OfficeName);

            var officeIds    = new List <string>();
            var officeModels = await officeBiz.GetAllAsync();

            foreach (var item in levelOneOffices)
            {
                officeIds.AddRange(officeBiz.GetOfficeListByParentOfficeNode(item.OfficeGuid, officeModels));
            }
            requestDto.OfficeIds = officeIds;
            var response = await new DoctorBiz().GetDoctorByFirstLevelOfficeNameAsync(requestDto);

            return(Success(response));
        }
예제 #10
0
        /// <summary>
        /// 递归获取下属科室
        /// </summary>
        /// <param name="offceDto"></param>
        private void GetSubordinateOffeces(GetHospitalOfficeTreeOfficeItemDto offceDto)
        {
            var officeBiz = new OfficeBiz();
            var offices   = officeBiz.GetHospitalOffice(offceDto.HospitalGuid, offceDto.OfficeGuid);

            if (offices == null || !offices.Any())
            {
                return;
            }
            var tmps = offices.Select(a => a.ToDto <GetHospitalOfficeTreeOfficeItemDto>()).ToList();

            offceDto.SubordinateOffeces = tmps;
            foreach (var item in tmps)
            {
                GetSubordinateOffeces(item);
            }
        }
예제 #11
0
        public IActionResult GetOfficesByParent([FromBody] GetOfficesByParentRequestDto officeDto)
        {
            OfficeBiz officeBiz = new OfficeBiz();
            var       offices   = officeBiz.GetHospitalOffice(officeDto.HospitalGuid, officeDto.ParentOfficeGuid);

            if (offices == null || !offices.Any())
            {
                return(Failed(ErrorCode.Empty, "没有获取到下属科室"));
            }
            var responseDto = offices.Select(a => new GetOfficesByParentResponseDto
            {
                OfficeGuid = a.OfficeGuid,
                OfficeName = a.OfficeName
            });

            return(Success(responseDto));
        }
예제 #12
0
        public async Task <IActionResult> AddOfficeAsync([FromBody] AddOfficeRequestDto request)
        {
            var officeBiz = new OfficeBiz();
            var officeAll = await officeBiz.GetAllAsync();

            if (officeAll.Any(a => a.OfficeName == request.OfficeName.Trim()))
            {
                return(Failed(ErrorCode.UserData, "系统中存在相同的科室名称"));
            }
            var hospitalBiz = new HospitalBiz();
            var hospitalAll = await hospitalBiz.GetAllAsync();

            var officeModelList = new List <OfficeModel>();

            foreach (var item in hospitalAll)
            {
                officeModelList.Add(new OfficeModel
                {
                    CreatedBy        = UserID,
                    LastUpdatedBy    = UserID,
                    Enable           = request.Enable,
                    OrgGuid          = string.Empty,
                    HospitalGuid     = item.HospitalGuid,
                    HospitalName     = item.HosName,
                    OfficeGuid       = Guid.NewGuid().ToString("N"),
                    OfficeName       = request.OfficeName,
                    ParentOfficeGuid = officeAll.FirstOrDefault(b => b.HospitalGuid == item.HospitalGuid && b.OfficeName == request.ParentName)?.OfficeGuid,
                    PictureGuid      = request.PictureGuid,
                    Recommend        = false,
                    Sort             = request.Sort
                });
            }
            var result = await officeBiz.InsertListAsync(officeModelList);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "添加失败"));
            }
            return(Success());
        }
예제 #13
0
        public async Task <IActionResult> ModifyDoctorInfoAsync([FromBody] ModifyDoctorInfoRequestDto doctorDto)
        {
            var doctorModelGuid = UserID;
            var doctorBiz       = new DoctorBiz();
            var checkDoctor     = await doctorBiz.GetAsync(doctorModelGuid);

            if (checkDoctor == null)
            {
                return(Failed(ErrorCode.DataBaseError, "该用户未注册医生!"));
            }

            var userModel = await new UserBiz().GetModelAsync(UserID);

            userModel.UserName       = doctorDto.UserName;
            userModel.IdentityNumber = doctorDto.IdentityNumber;
            userModel.Birthday       = doctorDto.Birthday;
            userModel.Gender         = doctorDto.Gender;

            var hospitalBiz  = new HospitalBiz();
            var officeBiz    = new OfficeBiz();
            var accessoryBiz = new AccessoryBiz();
            var doctorModel  = new DoctorModel();

            doctorModel = checkDoctor;

            //医生数据
            doctorModel.HospitalGuid       = doctorDto.HospitalGuid;
            doctorModel.OfficeGuid         = doctorDto.DocOffice;
            doctorModel.WorkCity           = doctorDto.City;
            doctorModel.PractisingHospital = doctorDto.PractisingHospital;
            doctorModel.Honor      = doctorDto.Honor;
            doctorModel.Background = doctorDto.Background;
            doctorModel.TitleGuid  = doctorDto.DocTitle;
            doctorModel.AdeptTags  = doctorDto.Adepts;
            doctorModel.Status     = StatusEnum.Submit.ToString();
            //doctorModel.SignatureGuid = doctorDto.SignatureGuid;
            doctorModel.CreatedBy       = UserID;
            doctorModel.OrgGuid         = "";
            doctorModel.LastUpdatedBy   = UserID;
            doctorModel.PortraitGuid    = doctorDto.PortraitGuid;
            doctorModel.LastUpdatedDate = DateTime.Now;

            //医院名称
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;

            //医生证书配置项 & 附件
            var lstCertificate = new List <CertificateModel>();
            var lstAccessory   = new List <AccessoryModel>();

            if (doctorDto.Certificates.Any())
            {
                foreach (var certificate in doctorDto.Certificates)
                {
                    var certificateModel = new CertificateModel
                    {
                        CertificateGuid = Guid.NewGuid().ToString("N"),
                        PictureGuid     = certificate.AccessoryGuid,
                        OwnerGuid       = doctorModel.DoctorGuid,
                        DicGuid         = certificate.DicGuid,
                        CreatedBy       = UserID,
                        OrgGuid         = "",
                        LastUpdatedBy   = UserID
                    };
                    lstCertificate.Add(certificateModel);
                    var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid);

                    if (accModel != null)
                    {
                        accModel.OwnerGuid       = certificateModel.CertificateGuid;
                        accModel.LastUpdatedDate = DateTime.Now;
                        lstAccessory.Add(accModel);
                    }
                }
            }
            var doctorCompositeBiz = new DoctorCompositeBiz();
            var result             = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, false);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生数据修改失败!"));
        }
예제 #14
0
        public async Task <IActionResult> RegisterDoctor([FromBody] RegisterDoctorRequestDto doctorDto)
        {
            var doctorModelGuid = UserID;
            var doctorBiz       = new DoctorBiz();
            var checkModel      = await doctorBiz.GetAsync(doctorModelGuid, true, true);

            bool isAdd       = checkModel == null;;//当前为更新操作还是新增操作
            var  statusCheck = string.Equals(checkModel?.Status, StatusEnum.Submit.ToString(), StringComparison.OrdinalIgnoreCase) || string.Equals(checkModel?.Status, StatusEnum.Approved.ToString(), StringComparison.OrdinalIgnoreCase);

            if (checkModel != null && statusCheck && checkModel.Enable)
            {
                return(Failed(ErrorCode.DataBaseError, "该用户已注册过医生!"));
            }

            var doctorCertificates = await new DictionaryBiz().GetListByParentGuidAsync(DictionaryType.DoctorDicConfig);

            foreach (var item in doctorCertificates)
            {
                if (doctorDto.Certificates.FirstOrDefault(a => a.DicGuid == item.DicGuid) == null)
                {
                    var eMsg = $"[{item.ConfigName}]没有上传";
                    return(Failed(ErrorCode.UserData, $"上传的医生证书项和系统配置的项不符,请核对,详情:{eMsg}"));
                }
            }

            var userModel = await new UserBiz().GetModelAsync(UserID);

            userModel.UserName       = doctorDto.UserName;
            userModel.IdentityNumber = doctorDto.IdentityNumber;
            userModel.Birthday       = doctorDto.Birthday;
            userModel.Gender         = doctorDto.Gender;
            var hospitalBiz  = new HospitalBiz();
            var officeBiz    = new OfficeBiz();
            var accessoryBiz = new AccessoryBiz();
            var doctorModel  = new DoctorModel();

            if (!isAdd)
            {
                doctorModel = checkModel;
            }
            //医生数据
            doctorModel.DoctorGuid         = doctorModelGuid;
            doctorModel.HospitalGuid       = doctorDto.HospitalGuid;
            doctorModel.OfficeGuid         = doctorDto.DocOffice;
            doctorModel.WorkCity           = doctorDto.City;
            doctorModel.PractisingHospital = doctorDto.PractisingHospital;
            doctorModel.Honor           = doctorDto.Honor;
            doctorModel.Background      = doctorDto.Background;
            doctorModel.TitleGuid       = doctorDto.DocTitle;
            doctorModel.AdeptTags       = Newtonsoft.Json.JsonConvert.SerializeObject(doctorDto.Adepts);
            doctorModel.Status          = StatusEnum.Submit.ToString();
            doctorModel.SignatureGuid   = doctorDto.SignatureGuid;
            doctorModel.CreatedBy       = UserID;
            doctorModel.OrgGuid         = "";
            doctorModel.LastUpdatedBy   = UserID;
            doctorModel.PortraitGuid    = doctorDto.PortraitGuid;
            doctorModel.LastUpdatedDate = DateTime.Now;
            doctorModel.Enable          = true;

            //医院名称
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;

            //医生证书配置项 & 附件
            var lstCertificate = new List <CertificateModel>();
            var lstAccessory   = new List <AccessoryModel>();

            if (doctorDto.Certificates.Any())
            {
                foreach (var certificate in doctorDto.Certificates)
                {
                    var certificateModel = new CertificateModel
                    {
                        CertificateGuid = Guid.NewGuid().ToString("N"),
                        PictureGuid     = certificate.AccessoryGuid,
                        OwnerGuid       = doctorModel.DoctorGuid,
                        DicGuid         = certificate.DicGuid,
                        CreatedBy       = UserID,
                        OrgGuid         = "",
                        LastUpdatedBy   = UserID
                    };
                    lstCertificate.Add(certificateModel);
                    var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid);

                    if (accModel != null)
                    {
                        accModel.OwnerGuid       = certificateModel.CertificateGuid;
                        accModel.LastUpdatedDate = DateTime.Now;
                        lstAccessory.Add(accModel);
                    }
                }
            }
            var doctorCompositeBiz = new DoctorCompositeBiz();
            var result             = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, isAdd);

            if (result)
            {
                new DoctorActionBiz().RegisterDoctor(this.UserID);
            }
            return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生注册数据插入不成功!"));
        }
예제 #15
0
        public async Task <IActionResult> EvaluvationAsync([FromBody] CreateHospitalEvaluvationRequestDto request)
        {
            if (request.Tags.Count() <= 0)
            {
                return(Failed(ErrorCode.Empty, "评价标签必填"));
            }

            var tag = string.Join("", request.Tags);

            if (tag.Length > 500)
            {
                return(Failed(ErrorCode.Empty, "评价标签超过最大长度限制"));
            }

            if (request.Score <= 0 || request.Score > 5)
            {
                return(Failed(ErrorCode.Empty, "满意度参数不正确"));
            }

            var hospitalBiz = new HospitalBiz();
            var hospital    = await hospitalBiz.GetAsync(request.HospitalGuid);

            if (hospital is null)
            {
                return(Failed(ErrorCode.Empty, "医院不存在,请检查提交参数"));
            }

            if (!hospital.Enable)
            {
                return(Failed(ErrorCode.Empty, $"医院“{hospital.HosName}”已被禁用,无法提交"));
            }

            var officeBiz = new OfficeBiz();
            var office    = await officeBiz.GetAsync(request.OfficeGuid);

            if (office is null)
            {
                return(Failed(ErrorCode.Empty, "科室不存在,请检查提交参数"));
            }

            if (!office.Enable)
            {
                return(Failed(ErrorCode.Empty, $"科室“{office.OfficeName}”已被禁用,无法提交"));
            }

            if (!office.HospitalGuid.Equals(hospital.HospitalGuid))
            {
                return(Failed(ErrorCode.Empty, $"科室“{office.OfficeName}”不属于医院“{hospital.HosName}”,无法提交"));
            }

            var evaluationBiz = new HospitalEvaluationBiz();
            var evaluvation   = await evaluationBiz.GetAsync(request.EvaluationGuid);

            if (evaluvation is null)
            {
                return(Failed(ErrorCode.Empty, "预评论参数不正确,请检查"));
            }

            if (!string.IsNullOrEmpty(evaluvation.UserGuid))
            {
                return(Failed(ErrorCode.Empty, "已提交,请勿重复提交"));
            }

            evaluvation.UserGuid        = UserID;
            evaluvation.HospitalGuid    = hospital.HospitalGuid;
            evaluvation.OfficeGuid      = office.OfficeGuid;
            evaluvation.EvaluationTag   = JsonConvert.SerializeObject(request.Tags);
            evaluvation.Score           = request.Score;
            evaluvation.ConditionDetail = request.ConditionDetail;
            evaluvation.Anonymous       = request.Anonymous;
            evaluvation.CreatedBy       = UserID;
            evaluvation.LastUpdatedBy   = UserID;

            var result = await evaluationBiz.UpdateAsync(evaluvation);

            if (!result)
            {
                return(Failed(ErrorCode.DataBaseError, "提交评论失败,请稍后重试"));
            }
            return(Success());
        }