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

    score=request.args.get('score')
    description=request.args.get('description')
    if score:
        score=string.atoi(score)
    else:
        return  json.dumps(rs.PARAM_ERROR.__dict__,ensure_ascii=False)

    diagnose=Diagnose.getDiagnoseById(diagnoseId)
    if diagnose is None:
        return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
    if hasattr(diagnose,'patient') and diagnose.patient and diagnose.patient.userID and  diagnose.patient.userID==userId:
        diagnose.status=constant.DiagnoseStatus.Diagnosed
        diagnose.score=score
        Diagnose.save(diagnose)

        diagoseLog=DiagnoseLog(userId,diagnoseId,constant.DiagnoseLogAction.DiagnoseFinished)
        diagoseLog.description=description
        DiagnoseLog.save(db_session,diagoseLog)
        return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
    else:
        return  json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)
Example #2
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)
Example #3
0
def evaluateDiagnose(diagnoseId):
    userId = session['uesrId']
    if userId is None:
        return json.dumps(rs.NO_LOGIN.__dict__, ensure_ascii=False)
    userId = string.atoi(userId)

    score = request.args.get('score')
    description = request.args.get('description')
    if score:
        score = string.atoi(score)
    else:
        return json.dumps(rs.PARAM_ERROR.__dict__, ensure_ascii=False)

    diagnose = Diagnose.getDiagnoseById(diagnoseId)
    if diagnose is None:
        return json.dumps(rs.NO_DATA.__dict__, ensure_ascii=False)
    if hasattr(
            diagnose, 'patient'
    ) and diagnose.patient and diagnose.patient.userID and diagnose.patient.userID == userId:
        diagnose.status = constant.DiagnoseStatus.Diagnosed
        diagnose.score = score
        Diagnose.save(diagnose)

        diagoseLog = DiagnoseLog(userId, diagnoseId,
                                 constant.DiagnoseLogAction.DiagnoseFinished)
        diagoseLog.description = description
        DiagnoseLog.save(db_session, diagoseLog)
        return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
    else:
        return json.dumps(rs.PERMISSION_DENY.__dict__, ensure_ascii=False)
Example #4
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)
Example #5
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)