Exemple #1
0
def rollbackDiagnose(diagnoseId):
    userId=session['userId']
    if userId is None:
        return json.dumps(rs.NO_LOGIN.__dict__,ensure_ascii=False)
    userId=string.atoi(userId)

    status=request.form.get('status')
    comments=request.form.get('comments')
    if status:
        status=string.atoi(status)
    diagnose=Diagnose.getDiagnoseById(diagnoseId)
    if diagnose is None:
        return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
    if hasattr(diagnose,'adminId') and diagnose.adminId and  diagnose.adminId==userId:
        if status is None:
            status=constant.DiagnoseStatus.Draft
        diagnose.status=status
        Diagnose.save(diagnose)

        diagoseLog=DiagnoseLog(userId,diagnoseId,constant.DiagnoseLogAction.DiagnoseNeedUpateAction)
        diagoseLog.description=comments
        DiagnoseLog.save(db_session,diagoseLog)

        if hasattr(diagnose,'patient') and diagnose.patient.userID:
            content=dataChangeService.getPatienDiagnoseMessageContent(diagnose)

            #诊断通知
            message=Message(constant.DefaultSystemAdminUserId,diagnose.patient.userID,'诊断通知',content,constant.MessageType.Diagnose)
            Message.save(message)

        return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
    else:
        return  json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)
Exemple #2
0
def sendMessageAndRecordLog(diagnose,userId):
    if diagnose and hasattr(diagnose,'patient') and diagnose.patient.userID:
        userId=diagnose.patient.userID
        content=dataChangeService.getPatienDiagnoseMessageContent(diagnose)
        message=Message(constant.DefaultSystemAdminUserId,diagnose.patient.userID,'诊断通知',content,constant.MessageType.Diagnose)
        Message.save(message)

    diagnoseLog=DiagnoseLog(userId,diagnose.id,constant.DiagnoseLogAction.DiagnoseFinished)
    DiagnoseLog.save(db_session,diagnoseLog)
def addMessage():
    form = None
    if form.validate():
        #session['remember_me'] = form.remember_me.data
        # login and validate the user...
        message=Message(form.senderId.data,form.receiverId.data,form.title.data,form.content.data,form.type.data)
        Message.save(message)
        #flash('成功添加诊断评论')
        return redirect(url_for('homepage'))
    return render_template('message.html', form=form)
def remarkMessage(messageId):
    status=request.args.get('status')
    result=None
    if status:
        result=Message.remarkMessage(db_session,messageId,status)
    else:
        result=Message.remarkMessage(db_session,messageId)
    resultStatus=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,result)
    resultDict=resultStatus.__dict__
    return jsonify(resultDict)
def remarkMessage(messageId):
    status = request.args.get('status')
    result = None
    if status:
        result = Message.remarkMessage(db_session, messageId, status)
    else:
        result = Message.remarkMessage(db_session, messageId)
    resultStatus = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, result)
    resultDict = resultStatus.__dict__
    return jsonify(resultDict)
Exemple #6
0
def addOrUpdateReport():

    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) == False:
        return  json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)

    form =  ReportForm(request.form)
    formResult=form.validate()
    if formResult.status==rs.SUCCESS.status:
        diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
        if diagnose is None:
            return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
        #session['remember_me'] = form.remember_me.data
        # login and validate the user...
        report = None
        if form.reportId:
            report=Report.getReportById(form.reportId)
            if report.type==constant.ReportType.Doctor:
                return  json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)
            Report.update(form.reportId,None,form.status,None,form.techDesc,form.imageDesc,form.diagnoseDesc)
        else:
            report=Report(form.techDesc,form.imageDesc,form.diagnoseDesc,form.fileUrl,ReportType.Admin,form.status)
            Report.save(report)

            diagnose.reportId=report.id
            Diagnose.save(diagnose)
        #flash('成功添加诊断评论')
        if form.status and form.status == constant.ReportStatus.Commited:
            diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
            if diagnose:
                Diagnose.changeDiagnoseStatus(diagnose.id,constant.DiagnoseStatus.NeedDiagnose)
            if form.reportId is None and report:
                form.reportId = report.id
            Report.update(form.reportId,constant.ReportType.Doctor,status=constant.ReportStatus.Draft)
            if diagnose and hasattr(diagnose,'doctor'):
                doctor=diagnose.doctor
                if doctor and doctor.userId:
                    content=dataChangeService.getDoctorNeedDiagnoseMessageContent(diagnose,doctor)

                    #诊断通知
                    message=Message(constant.DefaultSystemAdminUserId,doctor.userId,'诊断通知',content,constant.MessageType.Diagnose)
                    Message.save(message)

                    #诊断日志
                    diagoseLog=DiagnoseLog(userId,form.diagnoseId,constant.DiagnoseLogAction.FetchDiagnoseEndAction)
                    DiagnoseLog.save(db_session,diagoseLog)

            return json.dumps(formResult.__dict__,ensure_ascii=False)
    return json.dumps(formResult.__dict__,ensure_ascii=False)
def addMessage():
    form = None
    if form.validate():
        #session['remember_me'] = form.remember_me.data
        # login and validate the user...
        message = Message(form.senderId.data, form.receiverId.data,
                          form.title.data, form.content.data, form.type.data)
        Message.save(message)
        #flash('成功添加诊断评论')
        return redirect(url_for('homepage'))
    return render_template('message.html', form=form)
Exemple #8
0
def rollbackDiagnose(diagnoseId):
    userId=session['userId']
    if userId is None:
        return json.dumps(rs.NO_LOGIN.__dict__,ensure_ascii=False)
    userId=string.atoi(userId)

    status=request.form.get('status')
    comments=request.form.get('comments')
    if status:
        status=string.atoi(status)
    diagnose=Diagnose.getDiagnoseById(diagnoseId)
    if diagnose is None:
        return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
    if (hasattr(diagnose,'adminId') and diagnose.adminId and  diagnose.adminId==userId) or (hasattr(diagnose,'doctorId') and diagnose.doctorId and  diagnose.doctor.userId == userId):
        if status is None:
            status=constant.DiagnoseStatus.Draft
        diagnose.status=status
        Diagnose.save(diagnose)

        diagoseLog=DiagnoseLog(userId,diagnoseId,constant.DiagnoseLogAction.DiagnoseNeedUpateAction)
        diagoseLog.description=comments
        DiagnoseLog.save(db_session,diagoseLog)

        if hasattr(diagnose,'patient') and diagnose.patient.userID:
            content=dataChangeService.getPatienDiagnoseMessageContent(diagnose)

            #诊断通知
            message=Message(constant.DefaultSystemAdminUserId,diagnose.patient.userID,'诊断通知',content,constant.MessageType.Diagnose)
            Message.save(message)

        if(hasattr(diagnose,'doctorId') and diagnose.doctorId and  diagnose.doctor.userId == userId):
            reportDiagnoseRelations = ReportDiagnoseRelation.getReportsByDiagnoseId(diagnose.id)
            for reportDiagnoseRelation in reportDiagnoseRelations:
                if reportDiagnoseRelation.report.status != constant.ReportStatus.Del:
                    if reportDiagnoseRelation.report.type == constant.ReportType.Doctor:
                        print 'doctor report'
                        #delete doctor report if exist
                        # reportDiagnoseRelation.report.status = constant.ModelStatus.Del
                        Report.update(reportDiagnoseRelation.report.id,status=constant.ReportStatus.Del)
                        ReportDiagnoseRelation.update(reportDiagnoseRelation.id,status=constant.ModelStatus.Del)
                    elif reportDiagnoseRelation.report.type == constant.ReportType.Admin:
                        print 'admin report'
                        #set diagnose report to admin report

                        diagnose.reportId = reportDiagnoseRelation.report.id
                        Diagnose.update(diagnose)





        return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
    else:
        return  json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)
Exemple #9
0
def sendMessageAndRecordLog(diagnose, userId):
    if diagnose and hasattr(diagnose, 'patient') and diagnose.patient.userID:
        userId = diagnose.patient.userID
        content = dataChangeService.getPatienDiagnoseMessageContent(diagnose)
        message = Message(constant.DefaultSystemAdminUserId,
                          diagnose.patient.userID, '诊断通知', content,
                          constant.MessageType.Diagnose)
        Message.save(message)

    diagnoseLog = DiagnoseLog(userId, diagnose.id,
                              constant.DiagnoseLogAction.DiagnoseFinished)
    DiagnoseLog.save(db_session, diagnoseLog)
Exemple #10
0
def sendAllMessage(userId, diagnose):
    new_diagnoselog = DiagnoseLog(diagnose.uploadUserId, diagnose.id,
                                  DiagnoseLogAction.NewDiagnoseAction)
    DiagnoseLog.save(db_session, new_diagnoselog)
    payUrl = generateAliPay(userId, diagnose.id, diagnose)
    if payUrl:
        sendMobileMessage(userId, diagnose.id, diagnose, payUrl)
        #诊断通知
        content = dataChangeService.getPatienDiagnoseMessageContent(
            diagnose, "您好系统中有一个诊断需要支付才能继续进行,请先支付")
        message = Message(constant.DefaultSystemAdminUserId, userId, '诊断通知',
                          content, constant.MessageType.Diagnose)
        message.url = payUrl
        Message.save(message)
Exemple #11
0
def messagesBySender(senderId):
    status=request.args.get('status')

    messages=None
    if status:
        messages=Message.getMessageByReceiver(senderId,status)
    else:
        messages=Message.getMessageByReceiver(senderId)
    if messages is None or len(messages)<1:
        return jsonify(rs.SUCCESS.__dict__)
    messagesDict=object2dict.objects2dicts(messages)
    resultStatus=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,messagesDict)
    resultDict=resultStatus.__dict__
    return jsonify(resultDict)
Exemple #12
0
def messagesBySender(senderId):
    status = request.args.get('status')

    messages = None
    if status:
        messages = Message.getMessageByReceiver(senderId, status)
    else:
        messages = Message.getMessageByReceiver(senderId)
    if messages is None or len(messages) < 1:
        return jsonify(rs.SUCCESS.__dict__)
    messagesDict = object2dict.objects2dicts(messages)
    resultStatus = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg,
                                   messagesDict)
    resultDict = resultStatus.__dict__
    return jsonify(resultDict)
Exemple #13
0
def homepage():

    resultData = {}
    pager = Pagger(1, 6)
    doctors = Doctor.get_doctor_list(0, 0, "", pager)
    doctorsList = dataChangeService.get_doctors_dict(doctors)
    resultData['doctorlist'] = doctorsList
    if len(doctorsList['doctor']) > 0:
        resultData['doctor'] = doctorsList['doctor'][0]
    diagnoseComments = Comment.getRecentComments()
    if diagnoseComments and len(diagnoseComments) > 0:
        diagnoseCommentsDict = object2dict.objects2dicts_2(diagnoseComments)
        dataChangeService.setDiagnoseCommentsDetailInfo(diagnoseCommentsDict)
        resultData['comments'] = diagnoseCommentsDict
    else:
        resultData['comments'] = None

    resultData['ishomepage'] = True
    if session.has_key('userId'):
        userId = session['userId']
        messageCount = Message.getMessageCountByReceiver(userId)
        resultData['messageCount'] = messageCount
        if UserRole.checkRole(db_session, userId, constant.RoleId.Patient):
            resultData['isPatient'] = True

    return render_template("home.html", data=resultData)
Exemple #14
0
def endterPatientHome():
    userId=session['userId']
    user=User.getById(userId)

    if user is None:
        return redirect(ERROR_URL)

    resultDate={}
    messageCount=Message.getMessageCountByReceiver(userId)
    resultDate['messageCount']=messageCount

    diagnoseCount=Diagnose.getNewDiagnoseCountByUserId(userId)
    resultDate['diagnoseCount']=diagnoseCount

    resultDate['user']=user
    #pager=Pagger(1,20)
    # diagnoses=Diagnose.getDiagnosesByDoctorId(db_session,doctor.id,pager)
    # diagnoseDict=dataChangeService.userCenterDiagnoses(diagnoses)
    # resultDate['diagnoses']=diagnoseDict
    return render_template("patientHome.html",data=resultDate)
Exemple #15
0
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)
Exemple #16
0
def homepage():

    resultData={}
    pager = Pagger(1, 6)
    doctors = Doctor.get_doctor_list(0, 0, "", pager)
    doctorsList = dataChangeService.get_doctors_dict(doctors)
    resultData['doctorlist'] = doctorsList
    if len(doctorsList['doctor']) > 0:
        resultData['doctor'] = doctorsList['doctor'][0]
    diagnoseComments=Comment.getRecentComments()
    if diagnoseComments  and  len(diagnoseComments)>0:
        diagnoseCommentsDict=object2dict.objects2dicts_2(diagnoseComments)
        dataChangeService.setDiagnoseCommentsDetailInfo(diagnoseCommentsDict)
        resultData['comments']=diagnoseCommentsDict
    else:
        resultData['comments']=None
    if session.has_key('userId'):
        userId=session['userId']
        messageCount=Message.getMessageCountByReceiver(userId)
        resultData['messageCount']=messageCount
    return render_template("home.html", result=resultData)
Exemple #17
0
def endterPatientHome():
    if session.has_key('userId'):
        userId = session['userId']
        user = User.getById(userId)

        if user is None:
            return redirect(ERROR_URL)

        resultDate = {}
        messageCount = Message.getMessageCountByReceiver(userId)
        resultDate['messageCount'] = messageCount

        diagnoseCount = Diagnose.getNewDiagnoseCountByUserId(userId)
        resultDate['diagnoseCount'] = diagnoseCount

        resultDate['user'] = user
        #pager=Pagger(1,20)
        # diagnoses=Diagnose.getDiagnosesByDoctorId(db_session,doctor.id,pager)
        # diagnoseDict=dataChangeService.userCenterDiagnoses(diagnoses)
        # resultDate['diagnoses']=diagnoseDict
        return render_template("patientHome.html", data=resultDate)
    else:
        return redirect(LOGIN_URL)
Exemple #18
0
def rollbackDiagnose(diagnoseId):
    userId = session['userId']
    if userId is None:
        return json.dumps(rs.NO_LOGIN.__dict__, ensure_ascii=False)
    userId = string.atoi(userId)

    status = request.form.get('status')
    comments = request.form.get('comments')
    if status:
        status = string.atoi(status)
    diagnose = Diagnose.getDiagnoseById(diagnoseId)
    if diagnose is None:
        return json.dumps(rs.NO_DATA.__dict__, ensure_ascii=False)
    if (hasattr(diagnose, 'adminId') and diagnose.adminId and diagnose.adminId
            == userId) or (hasattr(diagnose, 'doctorId') and diagnose.doctorId
                           and diagnose.doctor.userId == userId):
        if status is None:
            status = constant.DiagnoseStatus.Draft
        diagnose.status = status
        Diagnose.save(diagnose)

        diagoseLog = DiagnoseLog(
            userId, diagnoseId,
            constant.DiagnoseLogAction.DiagnoseNeedUpateAction)
        diagoseLog.description = comments
        DiagnoseLog.save(db_session, diagoseLog)

        if hasattr(diagnose, 'patient') and diagnose.patient.userID:
            content = dataChangeService.getPatienDiagnoseMessageContent(
                diagnose)

            #诊断通知
            message = Message(constant.DefaultSystemAdminUserId,
                              diagnose.patient.userID, '诊断通知', content,
                              constant.MessageType.Diagnose)
            Message.save(message)

        if (hasattr(diagnose, 'doctorId') and diagnose.doctorId
                and diagnose.doctor.userId == userId):
            reportDiagnoseRelations = ReportDiagnoseRelation.getReportsByDiagnoseId(
                diagnose.id)
            for reportDiagnoseRelation in reportDiagnoseRelations:
                if reportDiagnoseRelation.report.status != constant.ReportStatus.Del:
                    if reportDiagnoseRelation.report.type == constant.ReportType.Doctor:
                        print 'doctor report'
                        #delete doctor report if exist
                        # reportDiagnoseRelation.report.status = constant.ModelStatus.Del
                        Report.update(reportDiagnoseRelation.report.id,
                                      status=constant.ReportStatus.Del)
                        ReportDiagnoseRelation.update(
                            reportDiagnoseRelation.id,
                            status=constant.ModelStatus.Del)
                    elif reportDiagnoseRelation.report.type == constant.ReportType.Admin:
                        print 'admin report'
                        #set diagnose report to admin report

                        diagnose.reportId = reportDiagnoseRelation.report.id
                        Diagnose.update(diagnose)

        return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
    else:
        return json.dumps(rs.PERMISSION_DENY.__dict__, ensure_ascii=False)
Exemple #19
0
def addOrUpdateReport():

    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) == False:
        return json.dumps(rs.PERMISSION_DENY.__dict__, ensure_ascii=False)

    form = ReportForm(request.form)
    formResult = form.validate()
    if formResult.status == rs.SUCCESS.status:
        diagnose = Diagnose.getDiagnoseById(form.diagnoseId)
        if diagnose is None:
            return json.dumps(rs.NO_DATA.__dict__, ensure_ascii=False)
        #session['remember_me'] = form.remember_me.data
        # login and validate the user...
        report = None
        if form.reportId:
            report = Report.getReportById(form.reportId)
            if report.type == constant.ReportType.Doctor:
                return json.dumps(rs.PERMISSION_DENY.__dict__,
                                  ensure_ascii=False)
            Report.update(form.reportId, None, form.status, None,
                          form.techDesc, form.imageDesc, form.diagnoseDesc)
        else:
            report = Report(form.techDesc, form.imageDesc, form.diagnoseDesc,
                            form.fileUrl, ReportType.Admin, form.status)
            Report.save(report)

            diagnose.reportId = report.id
            Diagnose.save(diagnose)

            #add report and diagnose to relation table
            reportDiagnoseRelation = ReportDiagnoseRelation(
                report.id, diagnose.id)
            ReportDiagnoseRelation.save(reportDiagnoseRelation)

        #flash('成功添加诊断评论')
        if form.status and form.status == constant.ReportStatus.Commited:
            diagnose = Diagnose.getDiagnoseById(form.diagnoseId)
            if diagnose:
                Diagnose.changeDiagnoseStatus(
                    diagnose.id, constant.DiagnoseStatus.NeedDiagnose)
            if form.reportId is None and report:
                form.reportId = report.id
            #copy a report and add to relation table
            newReport = Report(form.techDesc, form.imageDesc,
                               form.diagnoseDesc, form.fileUrl,
                               ReportType.Doctor, constant.ReportStatus.Draft)
            Report.save(newReport)

            reportDiagnoseRelation = ReportDiagnoseRelation(
                newReport.id, diagnose.id)
            ReportDiagnoseRelation.save(reportDiagnoseRelation)

            diagnose.reportId = newReport.id
            Diagnose.save(diagnose)
            #end copy

            if diagnose and hasattr(diagnose, 'doctor'):
                doctor = diagnose.doctor
                if doctor and doctor.userId:
                    content = dataChangeService.getDoctorNeedDiagnoseMessageContent(
                        diagnose, doctor)

                    #诊断通知
                    message = Message(constant.DefaultSystemAdminUserId,
                                      doctor.userId, '诊断通知', content,
                                      constant.MessageType.Diagnose)
                    Message.save(message)

                    #诊断日志
                    diagoseLog = DiagnoseLog(
                        userId, form.diagnoseId,
                        constant.DiagnoseLogAction.FetchDiagnoseEndAction)
                    DiagnoseLog.save(db_session, diagoseLog)

            return json.dumps(formResult.__dict__, ensure_ascii=False)
    return json.dumps(formResult.__dict__, ensure_ascii=False)