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)
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 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)
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 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)
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)