def addUserFavorties(): form = UserFavortiesForm(request.form) formResult = form.validate() userId = session['userId'] if userId is None: return redirect(LOGIN_URL) if formResult.status == rs.SUCCESS.status: if UserFavorites.checkUerFavorties(db_session, userId, constant.UserFavoritesType.Doctor, form.doctorId): return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False) userFavorites = UserFavorites.getUerFavortiesByDelStatus( db_session, userId, constant.UserFavoritesType.Doctor, form.doctorId) if userFavorites: userFavorites.status = constant.ModelStatus.Normal db_session.commit() return json.dumps(formResult.__dict__, ensure_ascii=False) else: userFavorites = UserFavorites(userId, form.type, form.doctorId, form.hospitalId, form.docId) UserFavorites.save(userFavorites) #flash('成功添加诊断评论') return json.dumps(formResult.__dict__, ensure_ascii=False) return json.dumps(formResult.__dict__, ensure_ascii=False)
def getUserFavorties(userId): type=request.args.get('type') if type is None: json.dumps(rs.PARAM_ERROR.__dict__,ensure_ascii=False) type=string.atoi(type) userFavorites=UserFavorites.getUserFavorties(userId,type) userFavoritesDict=dataChangeService.getUserFavoritiesDict(userFavorites) resultStatus=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,userFavoritesDict) return json.dumps(resultStatus.__dict__,ensure_ascii=False)
def getUserFavorties(userId): type = request.args.get('type') if type is None: json.dumps(rs.PARAM_ERROR.__dict__, ensure_ascii=False) type = string.atoi(type) userFavorites = UserFavorites.getUserFavorties(userId, type) userFavoritesDict = dataChangeService.getUserFavoritiesDict(userFavorites) resultStatus = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, userFavoritesDict) return json.dumps(resultStatus.__dict__, ensure_ascii=False)
def addUserFavorties(): form = UserFavortiesForm(request.form) formResult=form.validate() userId=session['userId'] if userId is None: return redirect(LOGIN_URL) if formResult.status==rs.SUCCESS.status: if UserFavorites.checkUerFavorties(db_session,userId,constant.UserFavoritesType.Doctor,form.doctorId): return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False) userFavorites=UserFavorites.getUerFavortiesByDelStatus(db_session,userId,constant.UserFavoritesType.Doctor,form.doctorId) if userFavorites: userFavorites.status=constant.ModelStatus.Normal db_session.commit() return json.dumps(formResult.__dict__,ensure_ascii=False) else: userFavorites=UserFavorites(userId,form.type,form.doctorId,form.hospitalId,form.docId) UserFavorites.save(userFavorites) #flash('成功添加诊断评论') return json.dumps(formResult.__dict__,ensure_ascii=False) return json.dumps(formResult.__dict__,ensure_ascii=False)
def cancleUserFavorties(id): UserFavorites.cancleFavorites(id) return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
def endterDoctorSite(userId): #user=User.getById(userId) doctor = Doctor.getByUserId(userId) if doctor is None: return redirect(ERROR_URL) if hasattr(doctor, 'user') != True: return redirect(ERROR_URL) resultDate = {} userFavortiesCount = UserFavorites.getFavortiesCountByDoctorId(doctor.id) resultDate['userFavortiesCount'] = userFavortiesCount diagnoseCount = Diagnose.getDiagnoseCountByDoctorId(db_session, doctor.id) resultDate['diagnoseCount'] = diagnoseCount goodDiagnoseCount = Diagnose.getDiagnoseCountByDoctorId( db_session, doctor.id, 1) #good goodDiagnoseCount += Diagnose.getDiagnoseCountByDoctorId( db_session, doctor.id, 2) resultDate['goodDiagnoseCount'] = goodDiagnoseCount resultDate['doctor'] = dataChangeService.get_doctor(doctor) thanksNoteCount = ThanksNote.getThanksNoteCountByReceiver( db_session, userId) resultDate['thanksNoteCount'] = thanksNoteCount diagnoseCommentCount = Comment.getCountByReceiver(userId) resultDate['diagnoseCommentCount'] = diagnoseCommentCount if session.has_key('userId'): loginUserId = session.get('userId') if loginUserId: loginUserId = string.atoi(loginUserId) userfavor = UserFavorites.getUerFavortiesByNormalStatus( db_session, loginUserId, constant.UserFavoritesType.Doctor, doctor.id) if userfavor: resultDate['userFavortiesId'] = userfavor.id pager = constant.Pagger(1, 10) diagnoseComments = Comment.getCommentByReceiver( userId, constant.ModelStatus.Normal, constant.CommentType.DiagnoseComment, pager) if diagnoseComments and len(diagnoseComments) > 0: diagnoseCommentsDict = object2dict.objects2dicts(diagnoseComments) dataChangeService.setDiagnoseCommentsDetailInfo(diagnoseCommentsDict) resultDate['comments'] = diagnoseCommentsDict else: resultDate['comments'] = None thanksNotes = ThanksNote.getThanksNoteByReceiver(db_session, userId) if thanksNotes and len(thanksNotes) > 0: thanksNotesDict = object2dict.objects2dicts(thanksNotes) dataChangeService.setThanksNoteDetail(thanksNotesDict) resultDate['thanksNotes'] = thanksNotesDict intros = DoctorProfile.getDoctorProfiles(userId, constant.DoctorProfileType.Intro) resultDate['intros'] = object2dict.objects2dicts(intros) resumes = DoctorProfile.getDoctorProfiles( userId, constant.DoctorProfileType.Resume) resultDate['resumes'] = object2dict.objects2dicts(resumes) awards = DoctorProfile.getDoctorProfiles(userId, constant.DoctorProfileType.Award) resultDate['awards'] = object2dict.objects2dicts(awards) others = DoctorProfile.getDoctorProfiles(userId, constant.DoctorProfileType.Other) resultDate['others'] = object2dict.objects2dicts(others) return render_template("doctorSite.html", data=resultDate)
def cancleUserFavorties(id): UserFavorites.cancleFavorites(id) return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
def endterDoctorSite(userId): #user=User.getById(userId) doctor=Doctor.getByUserId(userId) if doctor is None: return redirect(ERROR_URL) if hasattr(doctor,'user') !=True: return redirect(ERROR_URL) resultDate={} userFavortiesCount=UserFavorites.getFavortiesCountByDoctorId(doctor.id) resultDate['userFavortiesCount']=userFavortiesCount diagnoseCount=Diagnose.getDiagnoseCountByDoctorId(db_session,doctor.id) resultDate['diagnoseCount']=diagnoseCount goodDiagnoseCount=Diagnose.getDiagnoseCountByDoctorId(db_session,doctor.id,1)#good goodDiagnoseCount+=Diagnose.getDiagnoseCountByDoctorId(db_session,doctor.id,2) resultDate['goodDiagnoseCount']=goodDiagnoseCount resultDate['doctor']=dataChangeService.get_doctor(doctor) thanksNoteCount=ThanksNote.getThanksNoteCountByReceiver(db_session,userId) resultDate['thanksNoteCount']=thanksNoteCount diagnoseCommentCount=Comment.getCountByReceiver(userId) resultDate['diagnoseCommentCount']=diagnoseCommentCount if session.has_key('userId'): loginUserId=session.get('userId') if loginUserId: loginUserId=string.atoi(loginUserId) userfavor=UserFavorites.getUerFavortiesByNormalStatus(db_session,loginUserId,constant.UserFavoritesType.Doctor,doctor.id) if userfavor: resultDate['userFavortiesId']=userfavor.id pager=constant.Pagger(1,10) diagnoseComments=Comment.getCommentByReceiver(userId,constant.ModelStatus.Normal,constant.CommentType.DiagnoseComment,pager) if diagnoseComments and len(diagnoseComments)>0: diagnoseCommentsDict=object2dict.objects2dicts(diagnoseComments) dataChangeService.setDiagnoseCommentsDetailInfo(diagnoseCommentsDict) resultDate['comments']=diagnoseCommentsDict else: resultDate['comments']=None thanksNotes=ThanksNote.getThanksNoteByReceiver(db_session,userId) if thanksNotes and len(thanksNotes)>0: thanksNotesDict=object2dict.objects2dicts(thanksNotes) dataChangeService.setThanksNoteDetail(thanksNotesDict) resultDate['thanksNotes']=thanksNotesDict intros=DoctorProfile.getDoctorProfiles(userId,constant.DoctorProfileType.Intro) resultDate['intros']=object2dict.objects2dicts(intros) resumes=DoctorProfile.getDoctorProfiles(userId,constant.DoctorProfileType.Resume) resultDate['resumes']=object2dict.objects2dicts(resumes) awards=DoctorProfile.getDoctorProfiles(userId,constant.DoctorProfileType.Award) resultDate['awards']=object2dict.objects2dicts(awards) others=DoctorProfile.getDoctorProfiles(userId,constant.DoctorProfileType.Other) resultDate['others']=object2dict.objects2dicts(others) return render_template("doctorSite.html",data=resultDate)