def getAccountInfo(userDict): if userDict is None: return doctor=Doctor.getByUserId(userDict.get('id')) if doctor: if doctor.identityPhone: userDict['identityPhone']=doctor.identityPhone if doctor.hospital and doctor.hospital.name: userDict['hospitalName']=doctor.hospital.name return userDict return None
def getAccountInfo(userDict): if userDict is None: return doctor = Doctor.getByUserId(userDict.get('id')) if doctor: if doctor.identityPhone: userDict['identityPhone'] = doctor.identityPhone if doctor.hospital and doctor.hospital.name: userDict['hospitalName'] = doctor.hospital.name return userDict return None
def updateDoctorInfo(): form = DoctorUpdateForm(request.form) doctor = Doctor(form.userId) doctor.departmentId = form.department doctor.hospitalId = form.hospital doctor.status = form.status doctor.title = form.title Doctor.update(doctor) doctor = Doctor.getByUserId(form.userId) if doctor: for skill in form.skills: doctorsKill = Doctor2Skill(doctor.id, skill) Doctor2Skill.save(doctorsKill) User.update(form.userId, status=constant.ModelStatus.Normal) result = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, None) return json.dumps(result.__dict__, ensure_ascii=False)
def updateDoctorInfo(): form=DoctorUpdateForm(request.form) doctor=Doctor(form.userId) doctor.departmentId=form.department doctor.hospitalId=form.hospital doctor.status=form.status doctor.title=form.title Doctor.update(doctor) doctor=Doctor.getByUserId(form.userId) if doctor: for skill in form.skills: doctorsKill=Doctor2Skill(doctor.id,skill) Doctor2Skill.save(doctorsKill) User.update(form.userId,status=constant.ModelStatus.Normal) result=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,None) return json.dumps(result.__dict__,ensure_ascii=False)
def setDiagnoseCommentsDetailInfo(diagnoseCommentsDict): if diagnoseCommentsDict is None or len(diagnoseCommentsDict) < 1: return for diagnoseComment in diagnoseCommentsDict: if diagnoseComment.has_key('observer'): observer = diagnoseComment.get('observer') user = User.getById(observer) if user: diagnoseComment['avatar'] = user.imagePath diagnoseComment['senderName'] = user.name if diagnoseComment.has_key('receiver'): receiver = diagnoseComment.get('receiver') user = User.getById(receiver) if user: #diagnoseComment['receiverName']=user.name doctor = Doctor.getByUserId(receiver) if doctor and hasattr(doctor, "hospital") and doctor.hospital: diagnoseComment['doctorUserId'] = receiver diagnoseComment['hospitalId'] = doctor.hospitalId diagnoseComment['hospitalName'] = doctor.hospital.name diagnoseComment['receiverName'] = doctor.username if diagnoseComment.has_key('diagnoseId'): diagnose = Diagnose.getDiagnoseById( diagnoseComment.get('diagnoseId')) if diagnose: if diagnose.score: diagnoseComment['scoreName'] = constant.DiagnoseScore[ diagnose.score] # if diagnose.hospitalId and hasattr(diagnose,'hospital') and diagnose.hospital and diagnose.hospita.name: # diagnoseComment['hospitalId']= diagnose.hospitalId # diagnoseComment['hospitalName']=diagnose.hospital.name if hasattr(diagnose, "pathology") and diagnose.pathology: pathology = diagnose.pathology if hasattr(pathology, "pathologyPostions" ) and pathology.pathologyPostions: pathologyPositons = pathology.pathologyPostions if pathologyPositons and len(pathologyPositons) > 0: positions = u'' for pathologyPositon in pathologyPositons: position = pathologyPositon.position positions += (u' ' + position.name) diagnoseComment['positionName'] = positions
def getDiagnoseListByDoctor(): userId = session['userId'] # user=User.getById(userId) # if user is None: # return json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False) # #权限查看 # if UserRole.checkRole(db_session,userId,constant.RoleId.Admin): # return json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False) doctor = Doctor.getByUserId(userId) if doctor: status = request.args.get('type') if status: import string status = string.atoi(status) startDateStr = request.args.get('startDate') startDate = None if startDateStr: startDate = datetime.strptime(startDateStr, "%Y-%m-%d") else: startDate = constant.SystemTimeLimiter.startTime endDateStr = request.args.get('endDate') endDate = None if endDateStr: endDate = datetime.strptime(endDateStr, "%Y-%m-%d") else: endDate = constant.SystemTimeLimiter.endTime pageNo = request.args.get('pageNo') pageSize = request.args.get('pageSize') pager = Pagger(pageNo, pageSize) diagnoses = Diagnose.getDiagnosesByDoctorId(db_session, doctor.id, pager, status, startDate, endDate) diagnosesDict = dataChangeService.userCenterDiagnoses(diagnoses) resultStatus = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, diagnosesDict) resultDict = resultStatus.__dict__ return json.dumps(resultDict, ensure_ascii=False) return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
def endterDoctorHome(): userId = session['userId'] doctor = Doctor.getByUserId(userId) if doctor is None: return redirect(ERROR_URL) resultDate = {} messageCount = Message.getMessageCountByReceiver(userId) resultDate['messageCount'] = messageCount diagnoseCount = Diagnose.getNewDiagnoseCountByDoctorId(doctor.id) resultDate['diagnoseCount'] = diagnoseCount resultDate['doctor'] = doctor pager = Pagger(1, 20) diagnoses = Diagnose.getDiagnosesByDoctorId(db_session, doctor.id, pager) diagnoseDict = dataChangeService.userCenterDiagnoses(diagnoses) resultDate['diagnoses'] = diagnoseDict return render_template("doctorHome.html", data=resultDate)
def endterDoctorHome(): userId=session['userId'] doctor=Doctor.getByUserId(userId) if doctor is None: return redirect(ERROR_URL) resultDate={} messageCount=Message.getMessageCountByReceiver(userId) resultDate['messageCount']=messageCount diagnoseCount=Diagnose.getNewDiagnoseCountByDoctorId(doctor.id) resultDate['diagnoseCount']=diagnoseCount resultDate['doctor']=doctor pager=Pagger(1,20) diagnoses=Diagnose.getDiagnosesByDoctorId(db_session,doctor.id,pager) diagnoseDict=dataChangeService.userCenterDiagnoses(diagnoses) resultDate['diagnoses']=diagnoseDict return render_template("doctorHome.html",data=resultDate)
def setDiagnoseCommentsDetailInfo(diagnoseCommentsDict): if diagnoseCommentsDict is None or len(diagnoseCommentsDict)<1: return for diagnoseComment in diagnoseCommentsDict: if diagnoseComment.has_key('observer'): observer=diagnoseComment.get('observer') user=User.getById(observer) if user: diagnoseComment['avatar']=user.imagePath diagnoseComment['senderName']=user.name if diagnoseComment.has_key('receiver'): receiver=diagnoseComment.get('receiver') user=User.getById(receiver) if user: #diagnoseComment['receiverName']=user.name doctor=Doctor.getByUserId(receiver) if doctor and hasattr(doctor,"hospital") and doctor.hospital : diagnoseComment['doctorUserId']=receiver diagnoseComment['hospitalId']= doctor.hospitalId diagnoseComment['hospitalName']=doctor.hospital.name diagnoseComment['receiverName']=doctor.username if diagnoseComment.has_key('diagnoseId'): diagnose=Diagnose.getDiagnoseById(diagnoseComment.get('diagnoseId')) if diagnose: if diagnose.score: diagnoseComment['scoreName']=constant.DiagnoseScore[diagnose.score] # if diagnose.hospitalId and hasattr(diagnose,'hospital') and diagnose.hospital and diagnose.hospita.name: # diagnoseComment['hospitalId']= diagnose.hospitalId # diagnoseComment['hospitalName']=diagnose.hospital.name if hasattr(diagnose,"pathology") and diagnose.pathology: pathology=diagnose.pathology if hasattr(pathology,"pathologyPostions") and pathology.pathologyPostions: pathologyPositons=pathology.pathologyPostions if pathologyPositons and len(pathologyPositons)>0: positions=u'' for pathologyPositon in pathologyPositons: position=pathologyPositon.position positions+=(u' '+position.name) diagnoseComment['positionName']=positions
def addThankNote(): form = ThanksNoteForm(request.form) formResult=form.validate() userId=session['userId'] if userId is None: json.dumps(rs.NO_LOGIN.__dict__,ensure_ascii=False) userId=string.atoi(userId) if formResult.status==rs.SUCCESS.status: thanksNote=ThanksNote(userId,form.receiver,form.title,form.content) ThanksNote.save(db_session,thanksNote) doctor=Doctor.getByUserId(userId) if doctor: if doctor.thankNoteCount: doctor.thankNoteCount+=1 else: doctor.thankNoteCount=1 Doctor.save(doctor) return json.dumps(formResult.__dict__,ensure_ascii=False) return json.dumps(formResult.__dict__,ensure_ascii=False)
def getDiagnoseListByDoctor(): userId=session['userId'] # user=User.getById(userId) # if user is None: # return json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False) # #权限查看 # if UserRole.checkRole(db_session,userId,constant.RoleId.Admin): # return json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False) doctor=Doctor.getByUserId(userId) if doctor: status=request.args.get('type') if status: import string status=string.atoi(status) startDateStr=request.args.get('startDate') startDate=None if startDateStr: startDate=datetime.strptime(startDateStr,"%Y-%m-%d") else: startDate=constant.SystemTimeLimiter.startTime endDateStr=request.args.get('endDate') endDate=None if endDateStr: endDate=datetime.strptime(endDateStr,"%Y-%m-%d") else: endDate=constant.SystemTimeLimiter.endTime pageNo=request.args.get('pageNo') pageSize=request.args.get('pageSize') pager=Pagger(pageNo,pageSize) diagnoses=Diagnose.getDiagnosesByDoctorId(db_session,doctor.id,pager,status,startDate,endDate) diagnosesDict=dataChangeService.userCenterDiagnoses(diagnoses) resultStatus=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,diagnosesDict) resultDict=resultStatus.__dict__ return json.dumps(resultDict,ensure_ascii=False) return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
def addThankNote(): form = ThanksNoteForm(request.form) formResult = form.validate() userId = session.get('userId') #userId='5' if userId is None: json.dumps(rs.NO_LOGIN.__dict__, ensure_ascii=False) userId = string.atoi(userId) if formResult.status == rs.SUCCESS.status: thanksNote = ThanksNote(userId, form.receiver, form.title, form.content) ThanksNote.save(db_session, thanksNote) doctor = Doctor.getByUserId(userId) if doctor: if doctor.thankNoteCount: doctor.thankNoteCount += 1 else: doctor.thankNoteCount = 1 Doctor.save(doctor) return json.dumps(formResult.__dict__, ensure_ascii=False) return json.dumps(formResult.__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 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)