def getConsultsByDoctor(doctorId): sourceId = request.args.get('source_id') status = request.args.get('status') if status is None: status = -1 else: status = string.atoi(status) if doctorId: consuts = None if sourceId: consuts = Consult.getConsultsByDoctorId(doctorId, string.atoi(sourceId), status) else: consuts = Consult.getConsultsByDoctorId(doctorId, status=status) consutsDict = object2dict.objects2dicts(consuts) dataChangeService.setConsultsResult(consutsDict, long(session["userId"])) resultStatus = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, consutsDict) resultDict = resultStatus.__dict__ return json.dumps(resultDict, ensure_ascii=False) return json.dumps(rs.PARAM_ERROR, ensure_ascii=False)
def addConsult(): form = ConsultForm(request.form) formResult = form.validate() if formResult.status == rs.SUCCESS.status: # session['remember_me'] = form.remember_me.data # login and validate the user... consult = Consult(form.userId, form.doctorId, form.title, form.content) Consult.save(consult) # flash('成功添加诊断评论') return json.dumps(formResult.__dict__, ensure_ascii=False) return json.dumps(formResult.__dict__, ensure_ascii=False)
def getConsultsByUser(userId): sourceId=request.args.get('source_id') if userId: consuts=None if sourceId: consuts=Consult.getConsultsByUserId(userId,string.atoi(sourceId)) else: consuts=Consult.getConsultsByUserId(userId) consutsDict=object2dict.objects2dicts(consuts) dataChangeService.setConsultsResult(consutsDict) resultStatus=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,consutsDict) resultDict=resultStatus.__dict__ return json.dumps(resultDict,ensure_ascii=False) return json.dumps(rs.PARAM_ERROR,ensure_ascii=False)
def getConsultsByUser(userId): if userId: consuts = Consult.getConsultsByUserId(userId) consutsDict = object2dict.objects2dicts(consuts) resultStatus = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, consutsDict) resultDict = resultStatus.__dict__ return json.dumps(resultDict, ensure_ascii=False) return json.dumps(rs.PARAM_ERROR, ensure_ascii=False)
def getConsultsByDoctor(doctorId): sourceId=request.args.get('source_id') status=request.args.get('status') if status is None: status=-1 else: status=string.atoi(status) if doctorId: consuts=None if sourceId: consuts=Consult.getConsultsByDoctorId(doctorId,string.atoi(sourceId),status) else: consuts=Consult.getConsultsByDoctorId(doctorId,status=status) consutsDict=object2dict.objects2dicts(consuts) dataChangeService.setConsultsResult(consutsDict, long(session["userId"])) resultStatus=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,consutsDict) resultDict=resultStatus.__dict__ return json.dumps(resultDict,ensure_ascii=False) return json.dumps(rs.PARAM_ERROR,ensure_ascii=False)
def addConsult(): user_id=None if session.has_key('userId'): userId=session['userId'] if userId is None: redirect(LOGIN_URL) form = ConsultForm(request.form) formResult=form.validate() if formResult.status==rs.SUCCESS.status : #session['remember_me'] = form.remember_me.data # login and validate the user... if form.doctorId is None or form.doctorId==u'': dignose=Diagnose.getDiagnoseById(form.diagnose_id) if dignose and dignose.doctorId: form.doctorId=dignose.doctorId else: return redirect(ERROR_URL) if hasattr(dignose,'patient') and dignose.patient: userId=dignose.patient.userID if form.source_id is None or form.source_id == u'': form.source_id=-1 if form.userId is not None and form.userId != u'': userId = form.userId consult=Consult(userId,form.doctorId,form.title,form.content,form.parent_id,form.source_id,form.type,form.diagnose_id) Consult.save(consult) if form.source_id: sourceConsult=Consult.getById(form.source_id) if sourceConsult: sourceConsult.count+=1 if (form.type == 0): sourceConsult.status = 3 else: sourceConsult.status = 4 Consult.update(consult) #LOG.info('%d 成功添加诊断评论')%userId return json.dumps(formResult.__dict__,ensure_ascii=False) return json.dumps(formResult.__dict__,ensure_ascii=False)
def addConsult(): user_id=None if session.has_key('userId'): userId=session['userId'] #userId='5' if userId is None: redirect(LOGIN_URL) form = ConsultForm(request.form) formResult=form.validate() if formResult.status==rs.SUCCESS.status: #session['remember_me'] = form.remember_me.data # login and validate the user... consult=Consult(form.userId,form.doctorId,form.title,form.content,form.parent_id,form.source_id,form.type,form.diagnose_id) Consult.save(consult) if form.source_id: sourceConsult=Consult.getById(form.source_id) if sourceConsult: sourceConsult.count+=1 Consult.update(consult) LOG.info(userId+' 成功添加诊断评论') return json.dumps(formResult.__dict__,ensure_ascii=False) return json.dumps(formResult.__dict__,ensure_ascii=False)
def changeConsultRead(consultId): consult = Consult.getConsultByConsultId(consultId) userId = long(session["user_id"]) if consult.type == 0: if consult.status == constant.ConsultStatus.DoctorComments: Consult.changeReadStatus(consultId) return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False) if consult.userId == userId: return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False) if consult.type == 1: if consult.status == constant.ConsultStatus.PatientComments: Consult.changeReadStatus(consultId) return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False) if consult.doctorId == userId: return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False) Consult.changeReadStatus(consultId) return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
def changeConsultRead(consultId): consult = Consult.getConsultByConsultId(consultId) userId = long(session["user_id"]) if consult.type == 0: if consult.status == constant.ConsultStatus.DoctorComments: Consult.changeReadStatus(consultId) return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False) if consult.userId == userId: return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False) if consult.type == 1: if consult.status == constant.ConsultStatus.PatientComments: Consult.changeReadStatus(consultId) return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False) if consult.doctorId == userId: return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False) Consult.changeReadStatus(consultId) return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
def addConsult(): user_id = None if session.has_key('userId'): userId = session['userId'] if userId is None: redirect(LOGIN_URL) form = ConsultForm(request.form) formResult = form.validate() if formResult.status == rs.SUCCESS.status: #session['remember_me'] = form.remember_me.data # login and validate the user... if form.doctorId is None or form.doctorId == u'': dignose = Diagnose.getDiagnoseById(form.diagnose_id) if dignose and dignose.doctorId: form.doctorId = dignose.doctorId else: return redirect(ERROR_URL) if hasattr(dignose, 'patient') and dignose.patient: userId = dignose.patient.userID if form.source_id is None or form.source_id == u'': form.source_id = -1 if form.userId is not None and form.userId != u'': userId = form.userId consult = Consult(userId, form.doctorId, form.title, form.content, form.parent_id, form.source_id, form.type, form.diagnose_id) Consult.save(consult) if form.source_id: sourceConsult = Consult.getById(form.source_id) if sourceConsult: sourceConsult.count += 1 if (form.type == 0): sourceConsult.status = 3 else: sourceConsult.status = 4 Consult.update(consult) #LOG.info('%d 成功添加诊断评论')%userId return json.dumps(formResult.__dict__, ensure_ascii=False) return json.dumps(formResult.__dict__, ensure_ascii=False)
def changeConsultRead(consultId): Consult.changeReadStatus(consultId) return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)