コード例 #1
0
ファイル: message_comment.py プロジェクト: houzx910/blueberry
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)
コード例 #2
0
ファイル: message_comment.py プロジェクト: LichuanLu/redberry
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)
コード例 #3
0
ファイル: message_comment.py プロジェクト: LichuanLu/redberry
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)
コード例 #4
0
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)