コード例 #1
0
def setConsultsResult(consutsDict, userId=0):
    if consutsDict is None:
        return
    for consutDict in consutsDict:
        type = consutDict.get('type')
        if type == 1:
            if consutDict.get('doctorId'):
                doctor = Doctor.getById(consutDict.get('doctorId'))
                if doctor:
                    consutDict['doctorName'] = doctor.username
                    consutDict['doctorTitle'] = doctor.title
                    if hasattr(
                            doctor,
                            'user') and doctor.user and doctor.user.imagePath:
                        consutDict['avartarUrl'] = doctor.user.imagePath
                consutDict["statusText"] = getStatusText(
                    consutDict.get("status"),
                    UserRole.checkRole(db_session, userId,
                                       constant.RoleId.Doctor))

        if type == 0:
            if consutDict.get('userId'):
                user = User.getById(consutDict.get('userId'))
                if user:
                    consutDict['userName'] = user.name
                    consutDict['avartarUrl'] = user.imagePath
                    consutDict["statusText"] = getStatusText(
                        consutDict.get("status"),
                        UserRole.checkRole(db_session, userId,
                                           constant.RoleId.Doctor))
        consutDict['amount'] = consutDict.get('count')
コード例 #2
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def getMobileVerifyCode():
    try:
        from DoctorSpring.util import verify_code,sms_utils
        verifyCode= verify_code.generatorVerifyCode()
        LOG.info("产生验证码")
        session['verifyCode']=verifyCode
        telPhoneNo=None
        userId=session.get('userId')
        diagnoseId=request.args.get('diagnoseId')

        diagnose=Diagnose.getDiagnoseById(diagnoseId)

        if diagnose and hasattr(diagnose,'patient') and diagnose.patient:
            telPhoneNo=diagnose.patient.identityPhone
            if telPhoneNo is None and hasattr(diagnose.patient,'user') and diagnose.patient.user:
                telPhoneNo=diagnose.patient.user.phone
        if telPhoneNo is None:
            user=User.getById(userId)
            telPhoneNo=user.phone
        if telPhoneNo:
            smsRc=sms_utils.RandCode()
            template_param = {'param1':verifyCode}
            smsRc.send_emp_sms(telPhoneNo,smsRc.TEMPLATE_ID_1,json.dumps(template_param))
            return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
        else:
            LOG.error("诊断[%s]发送验证码错误"%diagnoseId)
            return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)

    except Exception,e:
        LOG.error(e.message)
        return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
コード例 #3
0
ファイル: user_center.py プロジェクト: LichuanLu/blueberry
def avatarfileUpload():
    userId=None
    if session.has_key('userId'):
        userId=session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    user=User.getById(userId)
    if user is None:
        return  json.dumps(rs.ResultStatus(rs.FAILURE.status,"账户不存在"),ensure_ascii=False )

    try:
        if request.method == 'POST':
            file_infos = []
            files = request.files
            for key, file in files.iteritems():
                if file and isPicture(file.filename):
                    filename = file.filename
                    # file_url = oss_util.uploadFile(diagnoseId, filename)
                    from DoctorSpring.util.oss_util import uploadAvatarFromFileStorage
                    fileurl = uploadAvatarFromFileStorage(userId, filename, file,'',{})
                    if fileurl:
                        user.imagePath=fileurl
                        file_infos.append(dict(
                                           name=filename,
                                           url=fileurl))
                        result=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,file_infos)
                        return json.dumps(result.__dict__,ensure_ascii=False)
                else:
                    return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
        return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
    except Exception,e:
        print e.message
        return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
コード例 #4
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def getAcountInfo():
    type = request.args.get('type')
    if type:
        type = string.atoi(type)  #医生:1 病人:2
    else:
        type = 2
    userId = None
    if session.has_key('userId'):
        userId = session['userId']
    #userId='5'
    if userId is None:
        return redirect(LOGIN_URL)
    user = User.getById(userId)
    if user:
        userDict = object2dict.to_json(user, user.__class__)
        userDict['mobile'] = userDict.get('phone')
        if type == 2:
            result = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg,
                                     userDict)
            return json.dumps(result.__dict__, ensure_ascii=False)
        elif type == 1:
            userDict = dataChangeService.getAccountInfo(userDict)
            userDict['userName'] = userDict.get('name')
            result = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg,
                                     userDict)
            return json.dumps(result.__dict__, ensure_ascii=False)
        else:
            return json.dumps(rs.PARAM_ERROR.__dict__, ensure_ascii=False)

    return json.dumps(rs.NO_LOGIN.__dict__, ensure_ascii=False)
コード例 #5
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def getMobileVerifyCode():
    try:
        from DoctorSpring.util import verify_code, sms_utils
        verifyCode = verify_code.generatorVerifyCode()
        LOG.info("产生验证码")
        session['verifyCode'] = verifyCode
        telPhoneNo = None
        userId = session.get('userId')
        diagnoseId = request.args.get('diagnoseId')

        diagnose = Diagnose.getDiagnoseById(diagnoseId)

        if diagnose and hasattr(diagnose, 'patient') and diagnose.patient:
            telPhoneNo = diagnose.patient.identityPhone
            if telPhoneNo is None and hasattr(
                    diagnose.patient, 'user') and diagnose.patient.user:
                telPhoneNo = diagnose.patient.user.phone
        if telPhoneNo is None:
            user = User.getById(userId)
            telPhoneNo = user.phone
        if telPhoneNo:
            smsRc = sms_utils.RandCode()
            template_param = {'param1': verifyCode}
            smsRc.send_emp_sms(telPhoneNo, smsRc.TEMPLATE_ID_1,
                               json.dumps(template_param))
            return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
        else:
            LOG.error("诊断[%s]发送验证码错误" % diagnoseId)
            return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)

    except Exception, e:
        LOG.error(e.message)
        return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
コード例 #6
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def avatarfileUpload():
    userId = None
    userId = request.form.get("userId")
    if session.has_key('userId') and userId is None:
        userId = session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    userId = string.atoi(userId)
    user = User.getById(userId, None)
    if user is None:
        return json.dumps(rs.ResultStatus(rs.FAILURE.status, "账户不存在"),
                          ensure_ascii=False)

    try:
        if request.method == 'POST':
            file_infos = []
            files = request.files
            for key, file in files.iteritems():
                if file and isPicture(file.filename):
                    filename = file.filename
                    # file_url = oss_util.uploadFile(diagnoseId, filename)
                    from DoctorSpring.util.oss_util import uploadAvatarFromFileStorage
                    fileurl = uploadAvatarFromFileStorage(
                        userId, filename, file, '', {})
                    if fileurl:
                        user.imagePath = fileurl
                        User.update(userId, imagePath=fileurl)
                        file_infos.append(dict(name=filename, url=fileurl))
                        return jsonify(files=file_infos)
                else:
                    return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
        return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
    except Exception, e:
        print e.message
        return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
コード例 #7
0
def setConsultsResult(consutsDict, userId=0):
    if consutsDict is None:
        return
    for consutDict in consutsDict:
        type=consutDict.get('type')
        if type==1:
            if consutDict.get('doctorId'):
                    doctor=Doctor.getById(consutDict.get('doctorId'))
                    if doctor:
                        consutDict['doctorName']=doctor.username
                        consutDict['doctorTitle']=doctor.title
                        if hasattr(doctor,'user') and doctor.user and doctor.user.imagePath:
                            consutDict['avartarUrl']= doctor.user.imagePath
                    consutDict["statusText"] = getStatusText(consutDict.get("status"),
                                                             UserRole.checkRole(db_session,userId,constant.RoleId.Doctor))

        if type==0:
            if consutDict.get('userId'):
                user=User.getById(consutDict.get('userId'))
                if user:
                    consutDict['userName']=user.name
                    consutDict['avartarUrl']=user.imagePath
                    consutDict["statusText"] = getStatusText(consutDict.get("status"),
                                                             UserRole.checkRole(db_session,userId,constant.RoleId.Doctor))
        consutDict['amount']=consutDict.get('count')
コード例 #8
0
ファイル: diagnose.py プロジェクト: LichuanLu/blueberry
def updateReport():

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

    form =  ReportForm(request.form)

    if form.reportId:
        #session['remember_me'] = form.remember_me.data
        # login and validate the user...
        if form.status and form.status==constant.ReportStatus.Commited:

            fileUrl=pdf_utils.generatorPdf(form.diagnoseId)#需要先生存文檔上傳到服務器,獲取url
            report=Report.update(form.reportId,constant.ReportType.Doctor,form.status,fileUrl,form.techDesc,form.imageDesc,form.diagnoseDesc)
            Diagnose.changeDiagnoseStatus(form.diagnoseId,constant.DiagnoseStatus.Diagnosed)
            #需要給用戶發信和記錄操作日誌
            diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
            sendMessageAndRecordLog(diagnose,userId)

        else:
            fileUrl=None#這是草稿,不需要生存文檔

            diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
            if diagnose is None:
                return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
            report=Report.update(form.reportId,constant.ReportType.Doctor,form.status,fileUrl,form.techDesc,form.imageDesc,form.diagnoseDesc)
            recordDiagnoseLog(diagnose,userId)

        return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
    return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
コード例 #9
0
ファイル: user_center.py プロジェクト: LichuanLu/blueberry
def getAcountInfo():
    type=request.args.get('type')
    if type:
        type=string.atoi(type)  #医生:1 病人:2
    else:
        type=2
    userId=None
    if session.has_key('userId'):
        userId=session['userId']
    #userId='5'
    if userId is None:
        return redirect(LOGIN_URL)
    user=User.getById(userId)
    if user:
        userDict=object2dict.to_json(user,user.__class__)
        if type==2:
            result=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,userDict)
            return json.dumps(result.__dict__,ensure_ascii=False)
        elif type==1:
            userDict=dataChangeService.getAccountInfo(userDict)
            result=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,userDict)
            return json.dumps(result.__dict__,ensure_ascii=False)
        else:
            return  json.dumps(rs.PARAM_ERROR.__dict__,ensure_ascii=False)

    return json.dumps(rs.NO_LOGIN.__dict__,ensure_ascii=False)
コード例 #10
0
ファイル: front.py プロジェクト: LichuanLu/redberry
def sendMobileMessage(userId, diagnoseId, diagnose=None, message=None):
    telPhoneNo = None

    if diagnoseId:
        diagnose = Diagnose.getDiagnoseById(diagnoseId)
    else:
        diagnose = Diagnose.getDiagnoseById(diagnose.id)

    if diagnose and hasattr(diagnose, 'patient') and diagnose.patient:
        telPhoneNo = diagnose.patient.identityPhone
        if telPhoneNo is None and hasattr(diagnose.patient,
                                          'user') and diagnose.patient.user:
            telPhoneNo = diagnose.patient.user.phone
    if telPhoneNo is None:
        user = User.getById(userId)
        telPhoneNo = user.phone
    if telPhoneNo:
        smsRc = sms_utils.RandCode()
        param1 = diagnose.diagnoseSeriesNumber
        param3 = constant.MobileMessageConstant.UrlPrefix + diagnose.alipayHashCode
        param4 = constant.MobileMessageConstant.KefuPhone
        from DoctorSpring.util.helper import getPayCountByDiagnoseId
        param2 = getPayCountByDiagnoseId(diagnose.id)
        template_param = {
            'param1': param1,
            'param2': param2,
            'param3': param3,
            'param4': param4
        }
        smsRc.send_emp_sms(telPhoneNo, smsRc.TEMPLATE_PAY,
                           json.dumps(template_param))
コード例 #11
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def resetPasswd(mobileNumber):
    userId=str(int(User.get_id_by_phone(mobileNumber)[0]))
    form=UserResetPasswdForm(request.form)
    result=form.validate()
    if result.status==rs.SUCCESS.status:
        user = User.getById(userId)
        newHashPasswd=generate_password_hash(form.newPasswd)
        User.update(userId,passwd=newHashPasswd)
    return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
コード例 #12
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def resetPasswd(mobileNumber):
    userId = str(int(User.get_id_by_phone(mobileNumber)[0]))
    form = UserResetPasswdForm(request.form)
    result = form.validate()
    if result.status == rs.SUCCESS.status:
        user = User.getById(userId)
        newHashPasswd = generate_password_hash(form.newPasswd)
        User.update(userId, passwd=newHashPasswd)
    return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
コード例 #13
0
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
コード例 #14
0
ファイル: diagnose.py プロジェクト: LichuanLu/redberry
def updateReport():

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

    form = ReportForm(request.form)

    patient_id = Diagnose.get_patientID_by_diagnoseID(form.diagnoseId)
    identity_Phone = Patient.get_identityPhone_by_patientID(patient_id)
    #identityPhone = Patient.get_identityPhone_by_patientID(patient_id)[0].decode(encoding='UTF-8')

    identityPhone = identity_Phone[0]
    #print(identityPhone)

    if form.reportId:
        #session['remember_me'] = form.remember_me.data
        # login and validate the user...
        if form.status and form.status == constant.ReportStatus.Commited:

            #first update based on form , then generate html
            Report.update(reportId=form.reportId,
                          techDesc=form.techDesc,
                          imageDesc=form.imageDesc,
                          diagnoseDesc=form.diagnoseDesc)
            # fileUrl=pdf_utils.generatorPdf(form.diagnoseId, identityPhone)#需要先生存文檔上傳到服務器,獲取url
            fileUrl = pdf_utils.generatorHtml(form.diagnoseId, identityPhone)
            if fileUrl:
                report = Report.update(form.reportId,
                                       constant.ReportType.Doctor, form.status,
                                       fileUrl, form.techDesc, form.imageDesc,
                                       form.diagnoseDesc)
                Diagnose.changeDiagnoseStatus(
                    form.diagnoseId, constant.DiagnoseStatus.Diagnosed)
                #需要給用戶發信和記錄操作日誌
                diagnose = Diagnose.getDiagnoseById(form.diagnoseId)
                sendMessageAndRecordLog(diagnose, userId)
            else:
                return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
        else:
            fileUrl = None  #這是草稿,不需要生存文檔

            diagnose = Diagnose.getDiagnoseById(form.diagnoseId)
            if diagnose is None:
                return json.dumps(rs.NO_DATA.__dict__, ensure_ascii=False)
            report = Report.update(form.reportId, constant.ReportType.Doctor,
                                   form.status, fileUrl, form.techDesc,
                                   form.imageDesc, form.diagnoseDesc)
            recordDiagnoseLog(diagnose, userId)

        return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
    return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
コード例 #15
0
ファイル: diagnose.py プロジェクト: LichuanLu/blueberry
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)
コード例 #16
0
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
コード例 #17
0
def setThanksNoteDetail(thanksNoteDicts):
    if thanksNoteDicts and len(thanksNoteDicts) < 1:
        return
    for thanksNoteDict in thanksNoteDicts:
        if thanksNoteDict.has_key('sender'):
            observer = thanksNoteDict.get('sender')
            user = User.getById(observer)
            if user:
                thanksNoteDict['observer'] = observer
                thanksNoteDict['observerName'] = user.name
                if user.imagePath:
                    thanksNoteDict["avatarUrl"] = user.imagePath
コード例 #18
0
def setThanksNoteDetail(thanksNoteDicts):
    if thanksNoteDicts and len(thanksNoteDicts) < 1:
        return
    for thanksNoteDict in thanksNoteDicts:
        if thanksNoteDict.has_key("sender"):
            observer = thanksNoteDict.get("sender")
            user = User.getById(observer)
            if user:
                thanksNoteDict["observer"] = observer
                thanksNoteDict["observerName"] = user.name
                if user.imagePath:
                    thanksNoteDict["avatarUrl"] = user.imagePath
コード例 #19
0
ファイル: diagnose.py プロジェクト: LichuanLu/redberry
def updateReport():

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

    form =  ReportForm(request.form)

    patient_id = Diagnose.get_patientID_by_diagnoseID(form.diagnoseId)
    identity_Phone = Patient.get_identityPhone_by_patientID(patient_id)
    #identityPhone = Patient.get_identityPhone_by_patientID(patient_id)[0].decode(encoding='UTF-8')

    identityPhone = identity_Phone[0]
    #print(identityPhone)

    if form.reportId:
        #session['remember_me'] = form.remember_me.data
        # login and validate the user...
        if form.status and form.status==constant.ReportStatus.Commited:


            #first update based on form , then generate html
            Report.update(reportId=form.reportId,techDesc=form.techDesc,imageDesc=form.imageDesc,diagnoseDesc=form.diagnoseDesc)
            # fileUrl=pdf_utils.generatorPdf(form.diagnoseId, identityPhone)#需要先生存文檔上傳到服務器,獲取url
            fileUrl=pdf_utils.generatorHtml(form.diagnoseId, identityPhone)
            if fileUrl:
                report=Report.update(form.reportId,constant.ReportType.Doctor,form.status,fileUrl,form.techDesc,form.imageDesc,form.diagnoseDesc)
                Diagnose.changeDiagnoseStatus(form.diagnoseId,constant.DiagnoseStatus.Diagnosed)
                #需要給用戶發信和記錄操作日誌
                diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
                sendMessageAndRecordLog(diagnose,userId)
            else:
                return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
        else:
            fileUrl=None#這是草稿,不需要生存文檔

            diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
            if diagnose is None:
                return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
            report=Report.update(form.reportId,constant.ReportType.Doctor,form.status,fileUrl,form.techDesc,form.imageDesc,form.diagnoseDesc)
            recordDiagnoseLog(diagnose,userId)

        return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
    return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
コード例 #20
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def renderHtmlFromDiagnose(diagnose):
    if hasattr(diagnose,'report'):
        report=diagnose.report
        #edit by lichuan , any one can take a look at the html
        # if diagnose and report and report.status==ReportStatus.Commited and report.type==ReportType.Doctor:
        if diagnose and report:
            data={}
            data['techDesc']=report.techDesc
            data['imageDesc']=report.imageDesc
            if hasattr(diagnose,'diagnoseSeriesNumber'):
                data['diagnoseSN'] = diagnose.diagnoseSeriesNumber
            data['diagnoseDesc']=report.diagnoseDesc
            data['seriesNumber']=report.seriesNumber
            data['fileUrl']=report.fileUrl
            createDate=report.createDate
            if createDate:
                createDate=createDate.strftime('%Y-%m-%d')
                data['createDate']=createDate

            postions=dataChangeService.getDiagnosePositonFromDiagnose(diagnose)
            if postions:
                data['postions']=postions
            if hasattr(diagnose,'patient') and diagnose.patient:
                data['gender']=diagnose.patient.gender
                birthDate=diagnose.patient.birthDate
                if birthDate:
                    birthDate=birthDate.strftime('%Y-%m-%d')
                    data['birthDate']=pdf_utils.getAge(birthDate)
                data['name']=diagnose.patient.realname
            if hasattr(diagnose,'doctor'):
                data['doctorName']=diagnose.doctor.username

            if hasattr(diagnose,'adminId'):
                adminUser = User.getById(diagnose.adminId)
                if adminUser.name:
                    data['adminName']= adminUser.name



            html =  render_template('diagnoseResultPdf.html',data=data)
            # fileName=constant.DirConstant.DIAGNOSE_PDF_DIR+'test.pdf'
            # result = open(fileName, 'wb') # Changed from file to filename
            #
            # pdf = pdf_utils.save_pdf(html,result,diagnoseId,fileName)
            # result.close()
            # return render_template("testpdf.html",getAvatar=getAvatar)
            return html
    return None
コード例 #21
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def renderHtmlFromDiagnose(diagnose):
    if hasattr(diagnose, 'report'):
        report = diagnose.report
        #edit by lichuan , any one can take a look at the html
        # if diagnose and report and report.status==ReportStatus.Commited and report.type==ReportType.Doctor:
        if diagnose and report:
            data = {}
            data['techDesc'] = report.techDesc
            data['imageDesc'] = report.imageDesc
            if hasattr(diagnose, 'diagnoseSeriesNumber'):
                data['diagnoseSN'] = diagnose.diagnoseSeriesNumber
            data['diagnoseDesc'] = report.diagnoseDesc
            data['seriesNumber'] = report.seriesNumber
            data['fileUrl'] = report.fileUrl
            createDate = report.createDate
            if createDate:
                createDate = createDate.strftime('%Y-%m-%d')
                data['createDate'] = createDate

            postions = dataChangeService.getDiagnosePositonFromDiagnose(
                diagnose)
            if postions:
                data['postions'] = postions
            if hasattr(diagnose, 'patient') and diagnose.patient:
                data['gender'] = diagnose.patient.gender
                birthDate = diagnose.patient.birthDate
                if birthDate:
                    birthDate = birthDate.strftime('%Y-%m-%d')
                    data['birthDate'] = pdf_utils.getAge(birthDate)
                data['name'] = diagnose.patient.realname
            if hasattr(diagnose, 'doctor'):
                data['doctorName'] = diagnose.doctor.username

            if hasattr(diagnose, 'adminId'):
                adminUser = User.getById(diagnose.adminId)
                if adminUser.name:
                    data['adminName'] = adminUser.name

            html = render_template('diagnoseResultPdf.html', data=data)
            # fileName=constant.DirConstant.DIAGNOSE_PDF_DIR+'test.pdf'
            # result = open(fileName, 'wb') # Changed from file to filename
            #
            # pdf = pdf_utils.save_pdf(html,result,diagnoseId,fileName)
            # result.close()
            # return render_template("testpdf.html",getAvatar=getAvatar)
            return html
    return None
コード例 #22
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def changePasswd():
    userId = None
    if session.has_key('userId'):
        userId = session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    form = UserChangePasswdForm(request.form)
    result = form.validate()
    if result.status == rs.SUCCESS.status:
        user = User.getById(userId)
        if user and user.check_password(form.oldPasswd):
            newHashPasswd = generate_password_hash(form.newPasswd)
            User.update(userId, passwd=newHashPasswd)
            return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
        else:
            resultStatus = rs.ResultStatus(rs.FAILURE.status, "未登录或者密码错误")
            return json.dumps(resultStatus.__dict__, ensure_ascii=False)
    return json.dumps(result.__dict__, ensure_ascii=False)
コード例 #23
0
ファイル: user_center.py プロジェクト: LichuanLu/blueberry
def changePasswd():
    userId=None
    if session.has_key('userId'):
        userId=session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    form=UserChangePasswdForm(request.form)
    result=form.validate()
    if result.status==rs.SUCCESS.status:
        user = User.getById(userId)
        if user and user.check_password(form.oldPasswd):
            newHashPasswd=generate_password_hash(form.newPasswd)
            User.update(userId,passwd=newHashPasswd)
            return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
        else:
            resultStatus=rs.ResultStatus(rs.FAILURE.status,"未登录或者密码错误")
            return json.dumps(resultStatus.__dict__,ensure_ascii=False)
    return json.dumps(result.__dict__,ensure_ascii=False)
コード例 #24
0
def setConsultsResult(consutsDict):
    if consutsDict is None:
        return
    for consutDict in consutsDict:
        type=consutDict.get('type')
        if type==1:
            if consutDict.get('doctorId'):
                    doctor=Doctor.getById(consutDict.get('doctorId'))
                    if doctor:
                        consutDict['doctorName']=doctor.username
                        consutDict['doctorTitle']=doctor.title
                        if hasattr(doctor,'user') and doctor.user and doctor.user.imagePath:
                            consutDict['avartarUrl']= doctor.user.imagePath
        if type==0:
            if consutDict.get('userId'):
                user=User.getById(consutDict.get('userId'))
                if user:
                    consutDict['userName']=user.name
                    consutDict['avartarUrl']=user.imagePath
コード例 #25
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def endterHospitalUserHome():
    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("hospitalUser.html", data=resultDate)
コード例 #26
0
ファイル: user_center.py プロジェクト: LichuanLu/blueberry
def endterHospitalUserHome():
    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("hospitalUser.html",data=resultDate)
コード例 #27
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
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)
コード例 #28
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
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)
コード例 #29
0
ファイル: pdf_utils.py プロジェクト: LichuanLu/redberry
def generatorHtml(diagnoseId, identityPhone):
    diagnose=Diagnose.getDiagnoseById(diagnoseId)
    report=None
    if hasattr(diagnose,'report'):
        report=diagnose.report
        if diagnose and report and report.type==constant.ReportType.Doctor:
            data={}
            data['techDesc']=report.techDesc
            data['imageDesc']=report.imageDesc
            data['diagnoseDesc']=report.diagnoseDesc
            data['seriesNumber']=report.seriesNumber
            data['fileUrl']=report.fileUrl
            if hasattr(diagnose,'diagnoseSeriesNumber'):
                data['diagnoseSN'] = diagnose.diagnoseSeriesNumber
            createDate=report.createDate
            if createDate:
                createDate=createDate.strftime('%Y-%m-%d')
                data['createDate']=createDate
            import  DoctorSpring.views.data_change_service as dataChangeService
            postions=dataChangeService.getDiagnosePositonFromDiagnose(diagnose)
            if postions:
                data['postions']=postions
            if hasattr(diagnose,'patient') and diagnose.patient:
                data['gender']=diagnose.patient.gender
                birthDate=diagnose.patient.birthDate
                if birthDate:
                    birthDate=birthDate.strftime('%Y-%m-%d')
                    data['birthDate']=getAge(birthDate)
                data['name']=diagnose.patient.realname
            if hasattr(diagnose,'doctor'):
                data['doctorName']=diagnose.doctor.username

            if hasattr(diagnose,'adminId'):
                adminUser = User.getById(diagnose.adminId)
                if adminUser.name:
                    data['adminName']= adminUser.name

            html =  render_template('diagnoseResultPdf.html',data=data)
            fileName=constant.DirConstant.DIAGNOSE_PDF_DIR+'diagnose'+str(diagnoseId)+'Html.html'
            result = open(fileName, 'w+b') # Changed from file to filename
            result.write(html)
            result.close()

            fileLink = 'file://'+fileName
            pdfLink = constant.DirConstant.DIAGNOSE_PDF_DIR+'diagnose'+str(diagnoseId)+'Pdf.pdf'
            print fileLink
            print pdfLink
            returnCode = generate_pdf_from_html(fileLink,pdfLink)
            # return render_template("testpdf.html",getAvatar=getAvatar)
            if(returnCode == 0):
                #add encrypt for pdf
                output = PdfFileWriter()
                with open(pdfLink, "r+") as f1:
                    input1 = PdfFileReader(f1)

                    for i in range(input1.getNumPages()):
                        output.addPage(input1.getPage(i))
                    #print(identityPhone)
                    password = str(int(identityPhone))
                    owner_pwd = ''.join(random.choice(string.letters + string.digits) for _ in range(64))
                    #print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + owner_pwd)
                    output.encrypt(password, owner_pwd)
                    f1.seek(0)
                    output.write(f1)
                    f1.truncate()
                    fileUrl=upload_pdf(pdfLink,diagnoseId)
                    return fileUrl
            else:
                return None
    return None
コード例 #30
0
ファイル: user_view.py プロジェクト: LichuanLu/redberry
def load_user(id):
    return User.getById(int(id))
コード例 #31
0
ファイル: user_view.py プロジェクト: LichuanLu/redberry
def load_user(id):
    return User.getById(int(id))
コード例 #32
0
ファイル: pdf_utils.py プロジェクト: LichuanLu/redberry
def generatorHtml(diagnoseId, identityPhone):
    diagnose = Diagnose.getDiagnoseById(diagnoseId)
    report = None
    if hasattr(diagnose, 'report'):
        report = diagnose.report
        if diagnose and report and report.type == constant.ReportType.Doctor:
            data = {}
            data['techDesc'] = report.techDesc
            data['imageDesc'] = report.imageDesc
            data['diagnoseDesc'] = report.diagnoseDesc
            data['seriesNumber'] = report.seriesNumber
            data['fileUrl'] = report.fileUrl
            if hasattr(diagnose, 'diagnoseSeriesNumber'):
                data['diagnoseSN'] = diagnose.diagnoseSeriesNumber
            createDate = report.createDate
            if createDate:
                createDate = createDate.strftime('%Y-%m-%d')
                data['createDate'] = createDate
            import DoctorSpring.views.data_change_service as dataChangeService
            postions = dataChangeService.getDiagnosePositonFromDiagnose(
                diagnose)
            if postions:
                data['postions'] = postions
            if hasattr(diagnose, 'patient') and diagnose.patient:
                data['gender'] = diagnose.patient.gender
                birthDate = diagnose.patient.birthDate
                if birthDate:
                    birthDate = birthDate.strftime('%Y-%m-%d')
                    data['birthDate'] = getAge(birthDate)
                data['name'] = diagnose.patient.realname
            if hasattr(diagnose, 'doctor'):
                data['doctorName'] = diagnose.doctor.username

            if hasattr(diagnose, 'adminId'):
                adminUser = User.getById(diagnose.adminId)
                if adminUser.name:
                    data['adminName'] = adminUser.name

            html = render_template('diagnoseResultPdf.html', data=data)
            fileName = constant.DirConstant.DIAGNOSE_PDF_DIR + 'diagnose' + str(
                diagnoseId) + 'Html.html'
            result = open(fileName, 'w+b')  # Changed from file to filename
            result.write(html)
            result.close()

            fileLink = 'file://' + fileName
            pdfLink = constant.DirConstant.DIAGNOSE_PDF_DIR + 'diagnose' + str(
                diagnoseId) + 'Pdf.pdf'
            print fileLink
            print pdfLink
            returnCode = generate_pdf_from_html(fileLink, pdfLink)
            # return render_template("testpdf.html",getAvatar=getAvatar)
            if (returnCode == 0):
                #add encrypt for pdf
                output = PdfFileWriter()
                with open(pdfLink, "r+") as f1:
                    input1 = PdfFileReader(f1)

                    for i in range(input1.getNumPages()):
                        output.addPage(input1.getPage(i))
                    #print(identityPhone)
                    password = str(int(identityPhone))
                    owner_pwd = ''.join(
                        random.choice(string.letters + string.digits)
                        for _ in range(64))
                    #print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + owner_pwd)
                    output.encrypt(password, owner_pwd)
                    f1.seek(0)
                    output.write(f1)
                    f1.truncate()
                    fileUrl = upload_pdf(pdfLink, diagnoseId)
                    return fileUrl
            else:
                return None
    return None
コード例 #33
0
ファイル: diagnose.py プロジェクト: LichuanLu/redberry
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)