Esempio n. 1
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, "医生数据修改失败!"));
        }
Esempio n. 2
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, "医生注册数据插入不成功!"));
        }