def patientReportUpload(): try: if request.method == 'POST': file_infos = [] files = request.files for key, file in files.iteritems(): if file and allowed_file(file.filename): filename = file.filename # file_url = oss_util.uploadFile(diagnoseId, filename) from DoctorSpring.util.oss_util import uploadFileFromFileStorage fileurl = uploadFileFromFileStorage(4, filename, file,'',{}) new_file = File(FileType.FileAboutDiagnose, filename, '11', fileurl) File.save(new_file) file_infos.append(dict(id=new_file.id, name=filename, size=11, url=fileurl)) else: return jsonify({'code': 1, 'message' : "error", 'data': ''}) return jsonify(files=file_infos) except Exception,e: print e.message return jsonify({'code': 1, 'message' : "error", 'data': ''})
def diagnosefileUpload(filetype): userId = session.get('userId') diagnoseId = request.args.get('diagnoseId') diagnose = Diagnose.getDiagnoseById(diagnoseId) if diagnose and userId: userId = string.atoi(userId) if diagnose.uploadUserId == userId: File.deleteFileByPathologyId(diagnose.pathologyId, filetype)
def applyDiagnose(): if session.has_key('userId'): userId = session['userId'] if userId is None: return redirect('/loginPage') data = {} hospitals = Hospital.getAllHospitals(db_session) hospitalsDict = object2dict.objects2dicts(hospitals) data['hospitals'] = hospitalsDict positions = Position.getPositions() positionsDict = object2dict.objects2dicts(positions) data['positions'] = positionsDict locations = Location.getAllLocations(db_session) locationsDict = object2dict.objects2dicts(locations) data['locations'] = locationsDict #hospital user if 'type' in request.args.keys(): data['type'] = int(request.args.get('type')) if 'edit' in request.args.keys() and 'diagnoseid' in request.args.keys(): new_diagnose = Diagnose.getDiagnoseById(request.args['diagnoseid']) data['edit'] = 1 else: new_diagnose = Diagnose.getNewDiagnoseByStatus(ModelStatus.Draft, session['userId']) if new_diagnose is not None: data['doctor'] = new_diagnose.doctor data['patient'] = new_diagnose.patient data['pathology'] = new_diagnose.pathology new_file = File.getFiles(new_diagnose.pathologyId, constant.FileType.Dicom) data['dicomfile'] = new_file new_files = File.getFiles(new_diagnose.pathologyId, constant.FileType.FileAboutDiagnose) data['fileAboutDiagnose'] = new_files pathologyPositions = [] if hasattr(new_diagnose, 'pathology') and hasattr( new_diagnose.pathology, 'pathologyPostions'): pathologyPositions = object2dict.objects2dicts( new_diagnose.pathology.pathologyPostions) data['pathologyPositions'] = pathologyPositions patients = Patient.get_patient_by_user(session['userId']) if patients is None or len(patients) < 1: patientdict = [] else: patientdict = object2dict.objects2dicts(patients) data['patientdict'] = patientdict return render_template("applyDiagnose.html", result=data)
def dicomfileUpload(): userId=session.get('userId') if userId is None: return redirect(LOGIN_URL) userId=string.atoi(userId) type=request.form.get('type') diagnoseId=request.form.get("diagnoseId") if diagnoseId is None: return jsonify({'code': 1, 'message' : "error", 'data': ''}) diagnoseId=string.atoi(diagnoseId) if type: type=string.atoi(type) else: type=constant.FileType.Dicom try: diagnose=Diagnose.getDiagnoseById(diagnoseId) if diagnose and diagnose.pathologyId: file_infos = [] files = request.files for key, file in files.iteritems(): if file and allowed_file(file.filename): filename = file.filename # file_url = oss_util.uploadFile(diagnoseId, filename) from DoctorSpring.util.oss_util import uploadFileFromFileStorage fileurl = uploadFileFromFileStorage(diagnoseId, filename, file,'',{}) new_file = File(FileType.Dicom, filename, '11', fileurl,diagnose.pathologyId) File.save(new_file) if type==FileType.Dicom: filesAboutDiagnose=File.getFiles(diagnose.pathologyId,FileType.FileAboutDiagnose) if filesAboutDiagnose and len(filesAboutDiagnose)>0: diagnoseChange=Diagnose() diagnoseChange.id=diagnoseId diagnoseChange.ossUploaded=constant.DiagnoseUploaed.Uploaded diagnose.uploadUserId=userId Diagnose.update(diagnoseChange) if type==FileType.FileAboutDiagnose: filesAboutDiagnose=File.getFiles(diagnose.pathologyId,FileType.Dicom) if filesAboutDiagnose and len(filesAboutDiagnose)>0: diagnoseChange=Diagnose() diagnoseChange.id=diagnoseId diagnoseChange.ossUploaded=constant.DiagnoseUploaed.Uploaded diagnose.uploadUserId=userId Diagnose.update(diagnoseChange) file_infos.append(dict(id=new_file.id, name=filename, size=11, url=fileurl)) else: return jsonify({'code': 1, 'message' : "error", 'data': ''}) return jsonify(files=file_infos) except Exception,e: print e.message return jsonify({'code': 1, 'message' : "error", 'data': ''})
def getDiagnoseDetailInfo(diagnose): if diagnose is None: return diagDict = {} diagDict['id'] = diagnose.id if diagnose.diagnoseSeriesNumber: diagDict['diagnosenumber'] = diagnose.diagnoseSeriesNumber if hasattr(diagnose, "patient") and diagnose.patient: if diagnose.patient.realname: diagDict['patientName'] = diagnose.patient.realname if diagnose.patient.gender: diagDict['gender'] = constant.Gender[diagnose.patient.gender] if diagnose.patient.birthDate: diagDict['birthDate'] = diagnose.patient.birthDate.strftime( '%Y-%m-%d') #diagDict['type']=diagnose.type if hasattr(diagnose, "doctor") and diagnose.doctor and diagnose.doctor.username: diagDict['doctorName'] = diagnose.doctor.username if diagnose.createDate: diagDict["date"] = diagnose.createDate.strftime('%Y-%m-%d') # if hasattr(diagnose,"hospital") and diagnose.hospital: # diagDict['hospitalHistory']=diagnose.hospital.name # diagDict['hospitalId']=diagnose.hospitalId if diagnose.pathologyId: diagDict['dicomUrl'] = File.getDicomFileUrl(diagnose.pathologyId) if diagnose.pathologyId: diagDict['docUrl'] = File.getFilesUrl(diagnose.pathologyId) if hasattr(diagnose, "pathology") and diagnose.pathology: pathology = diagnose.pathology diagDict['caseHistory'] = pathology.caseHistory diagDict['diagnoseType'] = pathology.diagnoseMethod 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) diagDict['positionName'] = positions if hasattr(pathology, "hospital") and pathology.hospital: diagDict['hospitalHistory'] = pathology.hospital.name diagDict['hospitalId'] = pathology.hospitalId if hasattr(diagnose, 'report') and diagnose.report: diagDict['reportId'] = diagnose.reportId diagDict['techDes'] = diagnose.report.techDesc diagDict['imageDes'] = diagnose.report.imageDesc diagDict['diagnoseResult'] = diagnose.report.diagnoseDesc return diagDict
def checkFilesExisting(new_diagnose): dicomCount = File.getFileCountbypathologyId(new_diagnose.pathologyId, FileType.Dicom) if dicomCount > 0: otherCount = File.getFileCountbypathologyId(new_diagnose.pathologyId, FileType.FileAboutDiagnose) if otherCount > 0: return True return False
def getDiagnoseDetailInfo(diagnose): if diagnose is None: return diagDict={} diagDict['id']=diagnose.id if diagnose.diagnoseSeriesNumber: diagDict['diagnosenumber']=diagnose.diagnoseSeriesNumber if hasattr(diagnose,"patient") and diagnose.patient: if diagnose.patient.realname: diagDict['patientName']=diagnose.patient.realname if diagnose.patient.gender: diagDict['gender']=constant.Gender[diagnose.patient.gender] if diagnose.patient.birthDate: diagDict['birthDate']=diagnose.patient.birthDate.strftime('%Y-%m-%d') #diagDict['type']=diagnose.type if hasattr(diagnose,"doctor") and diagnose.doctor and diagnose.doctor.username: diagDict['doctorName']=diagnose.doctor.username if diagnose.createDate: diagDict["date"]=diagnose.createDate.strftime('%Y-%m-%d') # if hasattr(diagnose,"hospital") and diagnose.hospital: # diagDict['hospitalHistory']=diagnose.hospital.name # diagDict['hospitalId']=diagnose.hospitalId if diagnose.pathologyId: diagDict['dicomUrl']=File.getDicomFileUrl(diagnose.pathologyId) if diagnose.pathologyId: diagDict['docUrl']=File.getFilesUrl(diagnose.pathologyId) if hasattr(diagnose,"pathology") and diagnose.pathology: pathology=diagnose.pathology diagDict['caseHistory']=pathology.caseHistory diagDict['diagnoseType']=pathology.diagnoseMethod 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) diagDict['positionName']=positions if hasattr(pathology,"hospital") and pathology.hospital: diagDict['hospitalHistory']=pathology.hospital.name diagDict['hospitalId']=pathology.hospitalId if hasattr(diagnose,'report') and diagnose.report: diagDict['reportId']=diagnose.reportId diagDict['techDes']=diagnose.report.techDesc diagDict['imageDes']=diagnose.report.imageDesc diagDict['diagnoseResult']=diagnose.report.diagnoseDesc return diagDict
def applyDiagnose(): if session.has_key('userId'): userId=session['userId'] if userId is None: return redirect('/loginPage') data = {} hospitals = Hospital.getAllHospitals(db_session) hospitalsDict = object2dict.objects2dicts(hospitals) data['hospitals'] = hospitalsDict positions = Position.getPositions() positionsDict = object2dict.objects2dicts(positions) data['positions'] = positionsDict locations = Location.getAllLocations(db_session) locationsDict = object2dict.objects2dicts(locations) data['locations'] = locationsDict if 'edit' in request.args.keys() and 'diagnoseid' in request.args.keys(): new_diagnose = Diagnose.getDiagnoseById(request.args['diagnoseid']) data['edit'] = 1 else: new_diagnose = Diagnose.getNewDiagnoseByStatus(ModelStatus.Draft, session['userId']) if new_diagnose is not None: data['doctor'] = new_diagnose.doctor data['patient'] = new_diagnose.patient data['pathology'] = new_diagnose.pathology new_file = File.getFiles(new_diagnose.pathologyId, constant.FileType.Dicom) data['dicomfile'] = new_file new_files = File.getFiles(new_diagnose.pathologyId, constant.FileType.FileAboutDiagnose) data['fileAboutDiagnose'] = new_files pathologyPositions = [] if hasattr(new_diagnose, 'pathology') and hasattr(new_diagnose.pathology, 'pathologyPostions'): pathologyPositions = object2dict.objects2dicts(new_diagnose.pathology.pathologyPostions) data['pathologyPositions'] = pathologyPositions patients = Patient.get_patient_by_user(session['userId']) if patients is None or len(patients) < 1: patientdict = [] else: patientdict = object2dict.objects2dicts(patients) data['patientdict'] = patientdict return render_template("applyDiagnose.html", result=data)
def getDiagnoseDetailInfo(diagnose): if diagnose is None: return diagDict = {} diagDict["id"] = diagnose.id if hasattr(diagnose, "patient") and diagnose.patient: if diagnose.patient.realname: diagDict["patientName"] = diagnose.patient.realname if diagnose.patient.gender: diagDict["gender"] = constant.Gender[diagnose.patient.gender] if diagnose.patient.birthDate: diagDict["birthDate"] = diagnose.patient.birthDate.strftime("%Y-%m-%d") # diagDict['type']=diagnose.type if hasattr(diagnose, "doctor") and diagnose.doctor and diagnose.doctor.username: diagDict["doctorName"] = diagnose.doctor.username if diagnose.createDate: diagDict["date"] = diagnose.createDate.strftime("%Y-%m-%d") # if hasattr(diagnose,"hospital") and diagnose.hospital: # diagDict['hospitalHistory']=diagnose.hospital.name # diagDict['hospitalId']=diagnose.hospitalId if diagnose.pathologyId: diagDict["dicomUrl"] = File.getDicomFileUrl(diagnose.pathologyId) if diagnose.pathologyId: diagDict["docUrl"] = File.getFilesUrl(diagnose.pathologyId) if hasattr(diagnose, "pathology") and diagnose.pathology: pathology = diagnose.pathology diagDict["caseHistory"] = pathology.caseHistory diagDict["diagnoseType"] = pathology.diagnoseMethod 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 diagDict["positionName"] = positions if hasattr(pathology, "hospital") and pathology.hospital: diagDict["hospitalHistory"] = pathology.hospital.name diagDict["hospitalId"] = pathology.hospitalId if hasattr(diagnose, "report") and diagnose.report: diagDict["reportId"] = diagnose.reportId diagDict["techDes"] = diagnose.report.techDesc diagDict["imageDes"] = diagnose.report.imageDesc diagDict["diagnoseResult"] = diagnose.report.diagnoseDesc return diagDict
def getPatientFile(patientId): userId = None if session.has_key('userId'): userId = session['userId'] if userId is None: return redirect(LOGIN_URL) if patientId is None or patientId < 0: return jsonify(FAILURE) patient = Patient.get_patient_by_id(patientId) if patient is None or patient.userID != string.atoi(userId): return jsonify(FAILURE) pathologs = Pathology.getByPatientId(patientId) files = [] if pathologs and len(pathologs) > 0: for patholog in pathologs: files.extend(File.getFilebypathologyId(patholog.id), constant.FileType.FileAboutDiagnose) fileResults = None if len(files) > 0: fileResults = dataChangeService.getFilesResult(files) resultStatus = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, fileResults) return jsonify(resultStatus.__dict__)
def userCenterDiagnoses(diagnoses): if diagnoses is None or len(diagnoses)<1: return result=[] for diagnose in diagnoses: diagDict={} if hasattr(diagnose,"patient") and diagnose.patient and diagnose.patient.realname: diagDict['patientName']=diagnose.patient.realname if hasattr(diagnose,"doctor") and diagnose.doctor and diagnose.doctor.username: diagDict['doctorName']=diagnose.doctor.username if hasattr(diagnose.doctor,'hospital') and diagnose.doctor.hospital and diagnose.doctor.hospital.name: diagDict['doctorHispital']= diagnose.doctor.hospital.name if hasattr(diagnose,"hospital") and diagnose.hospital and diagnose.hospital.name: diagDict['hispital']=diagnose.hospital.name if diagnose.createDate: diagDict["date"]=diagnose.createDate.strftime('%Y-%m-%d') if diagnose.id: diagDict['id']=diagnose.id if diagnose.diagnoseSeriesNumber: diagDict['diagnosenumber']=diagnose.diagnoseSeriesNumber if diagnose.status or diagnose.status==0: diagDict['statusId']=diagnose.status diagDict['status']=constant.DiagnoseStatus.getStatusName(diagnose.status) if diagnose.pathologyId: dicomUrl=File.getDicomFileUrl(diagnose.pathologyId) if dicomUrl: diagDict['dicomUrl'] = dicomUrl if hasattr(diagnose,'report') and diagnose.report and diagnose.report.fileUrl: diagDict['reportUrl']= diagnose.report.fileUrl 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) diagDict['positionName']=positions #print diagDict['doctorName'],diagDict['positons'] isFeedback=Comment.existCommentBydiagnose(diagnose.id,type=constant.CommentType.DiagnoseComment) diagDict['isFeedback']=isFeedback result.append(diagDict) return result
def patientReportUpload(): diagnoseId = request.form.get('diagnoseId') if diagnoseId is None: return jsonify({'code': 1, 'message': "error", 'data': ''}) diagnoseId = string.atoi(diagnoseId) try: if request.method == 'POST': file_infos = [] files = request.files for key, file in files.iteritems(): if file and allowed_file(file.filename): filename = file.filename extension = getFileExtension(filename) # file_url = oss_util.uploadFile(diagnoseId, filename) from DoctorSpring.util.oss_util import uploadFileFromFileStorage, getFileName, size fileurl = uploadFileFromFileStorage( diagnoseId, filename, file, '', {}, extension) newFileName = getFileName(diagnoseId, filename, extension) size = size(newFileName) new_file = File(FileType.FileAboutDiagnose, filename, size, fileurl, None) File.save(new_file) file_infos.append( dict(id=new_file.id, name=filename, size=size, url=fileurl)) else: return jsonify({'code': 1, 'message': "error", 'data': ''}) return jsonify(files=file_infos) except Exception, e: print e.message return jsonify({'code': 1, 'message': "error", 'data': ''})
def get_pathology(pathology): pathologyDict = {} pathologyDict["id"] = pathology.id if hasattr(pathology, "diagnoseMethod") and pathology.diagnoseMethod: pathologyDict["type"] = pathology.diagnoseMethod if hasattr(pathology, "name") and pathology.name: pathologyDict["dicomFile"] = pathology.name if hasattr(pathology, "pathologyPostions") and len(pathology.pathologyPostions) >= 1: positions = "" for position in pathology.pathologyPostions: if position.position: positions = positions + position.position.name + ", " pathologyDict["position"] = positions dicomUrl = File.getDicomFileUrl(pathology.id) pathologyDict["dicomUrl"] = dicomUrl return pathologyDict
def get_pathology(pathology): pathologyDict={} pathologyDict['id'] = pathology.id pathologyDict['dicomFile'] = getDocomFileName(pathology.id) if hasattr(pathology, "diagnoseMethod") and pathology.diagnoseMethod: pathologyDict['type'] = pathology.diagnoseMethod if hasattr(pathology, "pathologyPostions") and len(pathology.pathologyPostions) >= 1: positions = '' for position in pathology.pathologyPostions: if position.position: positions = positions + position.position.name + ', ' pathologyDict["position"] = positions dicomUrl = File.getDicomFileUrl(pathology.id) pathologyDict["dicomUrl"] = dicomUrl return pathologyDict
def get_pathology(pathology): pathologyDict = {} pathologyDict['id'] = pathology.id pathologyDict['dicomFile'] = getDocomFileName(pathology.id) if hasattr(pathology, "diagnoseMethod") and pathology.diagnoseMethod: pathologyDict['type'] = pathology.diagnoseMethod if hasattr(pathology, "pathologyPostions") and len(pathology.pathologyPostions) >= 1: positions = '' for position in pathology.pathologyPostions: if position.position: positions = positions + position.position.name + ', ' pathologyDict["position"] = positions dicomUrl = File.getDicomFileUrl(pathology.id) pathologyDict["dicomUrl"] = dicomUrl return pathologyDict
def getPatientFile(patientId): userId=None if session.has_key('userId'): userId=session['userId'] if userId is None: redirect(LOGIN_URL) if patientId is None or patientId<0 : return jsonify(FAILURE) patient=Patient.get_patient_by_id(patientId) if patient is None or patient.userID!=string.atoi(userId): return jsonify(FAILURE) pathologs=Pathology.getByPatientId(patientId) files=[] if pathologs and len(pathologs)>0: for patholog in pathologs: files.extend(File.getFilebypathologyId(patholog.id),constant.FileType.FileAboutDiagnose) fileResults=None if len(files)>0: fileResults=dataChangeService.getFilesResult(files) resultStatus = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, fileResults) return jsonify(resultStatus.__dict__)
def disableFile(): try: disgnoseId = request.form.get('diagnoseId') type = request.form.get('type') if disgnoseId is None: disgnoseId = string.atoi(disgnoseId) if type is None: type = constant.FileType.Dicom else: type = string.atoi(type) diagnose = Diagnose.getDiagnoseById(disgnoseId) if diagnose and diagnose.pathologyId: pathologyId = diagnose.pathologyId result = File.deleteFileByPathologyId(pathologyId, type) if result > 0: diagnose.ossUploaded = constant.DiagnoseUploaed.NoUploaded Diagnose.save(diagnose) return jsonify(rs.SUCCESS.__dict__, ensure_ascii=False) return jsonify(rs.FAILURE.__dict__, ensure_ascii=False) except Exception, e: LOG.error(e.message) return redirect(ERROR_URL)
def applyDiagnoseForm(formid): if (int(formid) == 1) : form = DiagnoseForm3(request.form) form_result = form.validate() if form_result.status == rs.SUCCESS.status: if(form.diagnoseId): new_diagnose = Diagnose.getDiagnoseById(form.diagnoseId) else: new_diagnose = Diagnose.getNewDiagnoseByStatus(DiagnoseStatus.Draft, session['userId']) if(new_diagnose is None): new_diagnose = Diagnose() new_diagnose.status = DiagnoseStatus.Draft new_diagnose.doctorId = form.doctorId new_diagnose.uploadUserId = session['userId'] Diagnose.save(new_diagnose) form_result.data = {'formId': 2, 'diagnoseId': new_diagnose.id} return jsonify(form_result.__dict__) elif (int(formid) == 2) : form = DiagnoseForm1(request.form) form_result = form.validate() if form_result.status == rs.SUCCESS.status: if form.diagnoseId is not None: new_diagnose = Diagnose.getDiagnoseById(form.diagnoseId) else: new_diagnose = Diagnose.getNewDiagnoseByStatus(DiagnoseStatus.Draft, int(session['userId'])) if(new_diagnose is not None): # 去拿没有draft的用户 if(form.exist): new_patient = Patient.get_patient_by_id(form.patientid) else: new_patient = Patient.get_patient_draft(new_diagnose.patientId) if new_patient is None: new_patient = Patient() new_patient.type = PatientStatus.diagnose new_patient.userID = session['userId'] new_patient.realname = form.patientname new_patient.gender = form.patientsex new_patient.birthDate = datetime.strptime(form.birthdate, "%Y-%m-%d") new_patient.identityCode = form.identitynumber new_patient.locationId = form.locationId new_patient.identityPhone = form.phonenumber new_patient.status = ModelStatus.Draft # new_patient.locationId = form.location Patient.save(new_patient) new_diagnose.patientId = new_patient.id Diagnose.save(new_diagnose) # Hospital User 注册用户 if(form.isHospitalUser): new_user = User(form.phonenumber, random.sample('zyxwvutsrqponmlkjihgfedcba1234567890',6), False) new_user.type = UserStatus.patent new_user.status = ModelStatus.Draft User.save(new_user) new_patient.userID = new_user.id Patient.save(new_patient) new_userrole = UserRole(new_user.id, RoleId.Patient) UserRole.save(new_userrole) form_result.data = {'formId': 3, } else: form_result = ResultStatus(FAILURE.status, "找不到第一步草稿") return jsonify(form_result.__dict__) elif (int(formid) == 3): form = DiagnoseForm2(request.form) form_result = form.validate() if form_result.status == rs.SUCCESS.status: if form.diagnoseId is not None: new_diagnose = Diagnose.getDiagnoseById(form.diagnoseId) else: new_diagnose = Diagnose.getNewDiagnoseByStatus(DiagnoseStatus.Draft, int(session['userId'])) if new_diagnose is not None: if form.exist: new_pathology = Pathology.getById(form.pathologyId) elif new_diagnose.pathologyId: new_pathology = Pathology.getById(new_diagnose.pathologyId) else: new_pathology = Pathology.getByPatientStatus(session['userId'], ModelStatus.Draft) if new_pathology is None: new_pathology = Pathology(new_diagnose.patientId) new_pathology.diagnoseMethod = form.dicomtype new_pathology.status = ModelStatus.Draft new_pathology.save(new_pathology) PathologyPostion.deleteByPathologyId(new_pathology.id) for position in form.patientlocation: new_position_id = PathologyPostion(new_pathology.id, position) PathologyPostion.save(new_position_id) File.cleanDirtyFile(form.fileurl, new_pathology.id, FileType.Dicom) for fileurl in form.fileurl: new_file = File.getFilebyId(int(fileurl)) new_file.pathologyId = new_pathology.id File.save(new_file) new_diagnose.pathologyId = new_pathology.id Diagnose.save(new_diagnose) form_result.data = {'formId': 4} else: form_result = ResultStatus(FAILURE.status, "找不到上步的草稿") return jsonify(form_result.__dict__) elif (int(formid) == 4): form = DiagnoseForm4(request.form) form_result = form.validate() if form_result.status == rs.SUCCESS.status: if form.diagnoseId is not None: new_diagnose = Diagnose.getDiagnoseById(form.diagnoseId) else: new_diagnose = Diagnose.getNewDiagnoseByStatus(DiagnoseStatus.Draft, int(session['userId'])) if(new_diagnose is not None): new_pathology = Pathology.getById(new_diagnose.pathologyId) if(new_pathology is not None): new_pathology.caseHistory = form.illnessHistory new_pathology.hospitalId = form.hospitalId new_pathology.status = ModelStatus.Normal Pathology.save(new_pathology) File.cleanDirtyFile(form.fileurl, new_pathology.id, FileType.FileAboutDiagnose) for fileurl in form.fileurl: new_file = File.getFilebyId(int(fileurl)) new_file.pathologyId = new_pathology.id File.save(new_file) new_patient = Patient.get_patient_by_id(new_diagnose.patientId) new_patient.status = PatientStatus.diagnose new_diagnose.status = DiagnoseStatus.NeedPay Diagnose.save(new_diagnose) new_diagnoselog = DiagnoseLog(new_diagnose.uploadUserId, new_diagnose.id, DiagnoseLogAction.NewDiagnoseAction) DiagnoseLog.save(db_session, new_diagnoselog) else: form_result = ResultStatus(FAILURE.status, "找不到上步的草稿1") else: form_result = ResultStatus(FAILURE.status, "找不到上步的草稿2") form_result.data = {'isFinal': True} return jsonify(form_result.__dict__) else: return jsonify(ResultStatus(FAILURE.status, "错误的表单号").__dict__)
def getDocomFileName(pathologyId): if pathologyId is None: return files=File.getFiles(pathologyId,constant.FileType.Dicom) if files and len(files): return files[0].name
def getDiagnoseListByKefu(diagnoses): if diagnoses is None or len(diagnoses)<1: return result=[] for diagnose in diagnoses: diagDict={} if hasattr(diagnose,"patient") and diagnose.patient and diagnose.patient.realname: diagDict['patientName']=diagnose.patient.realname if hasattr(diagnose,"patient") and diagnose.patient: diagDict['mobile']=diagnose.patient.identityPhone if hasattr(diagnose,"doctor") and diagnose.doctor and diagnose.doctor.username: diagDict['doctorName']=diagnose.doctor.username if hasattr(diagnose.doctor,'hospital') and diagnose.doctor.hospital and diagnose.doctor.hospital.name: diagDict['doctorHispital']= diagnose.doctor.hospital.name if hasattr(diagnose,"hospital") and diagnose.hospital and diagnose.hospital.name: diagDict['hispital']=diagnose.hospital.name if diagnose.createDate: diagDict["date"]=diagnose.createDate.strftime('%Y-%m-%d') if diagnose.id: diagDict['id']=diagnose.id if diagnose.diagnoseSeriesNumber: diagDict['diagnosenumber']=diagnose.diagnoseSeriesNumber if diagnose.status or diagnose.status==0: diagDict['statusId']=diagnose.status diagDict['status']=constant.DiagnoseStatus.getStatusName(diagnose.status) if diagnose.pathologyId: dicomUrl=File.getDicomFileUrl(diagnose.pathologyId) if dicomUrl: diagDict['dicomUrl'] = dicomUrl otherUrls=File.getFilesUrl(diagnose.pathologyId) if otherUrls: diagDict['otherUrls']=otherUrls if hasattr(diagnose,'report') and diagnose.report and diagnose.report.fileUrl: diagDict['reportUrl']= diagnose.report.fileUrl if hasattr(diagnose,"pathology") and diagnose.pathology: pathology=diagnose.pathology postionLen=0 if hasattr(pathology,"pathologyPostions") and pathology.pathologyPostions: pathologyPositons=pathology.pathologyPostions postionLen=len(pathologyPositons) if pathologyPositons and len(pathologyPositons)>0: positions=u'' for pathologyPositon in pathologyPositons: position=pathologyPositon.position positions+=(u' '+position.name) diagDict['positionName']=positions #print diagDict['doctorName'],diagDict['positons'] if pathology.diagnoseMethod==constant.DiagnoseMethod.Mri: diagDict['payAmount']=diagnose.getPayCount(constant.DiagnoseMethod.Mri,postionLen,diagnose.getUserDiscount(diagnose.patientId)) diagDict['diagnoseMethod']=constant.DiagnoseMethod.Mri elif pathology.diagnoseMethod==constant.DiagnoseMethod.Ct: diagDict['payAmount']=diagnose.getPayCount(constant.DiagnoseMethod.Ct,postionLen,diagnose.getUserDiscount(diagnose.patientId)) diagDict['diagnoseMethod']=constant.DiagnoseMethod.Ct isFeedback=Comment.existCommentBydiagnose(diagnose.id,type=constant.CommentType.DiagnoseComment) diagDict['isFeedback']=isFeedback result.append(diagDict) return result
def getDiagnoseDetailInfoByPatient(session, diagnose): if diagnose is None: return diagDict = {} diagDict["id"] = diagnose.id if hasattr(diagnose, "patient") and diagnose.patient: if diagnose.patient.realname: diagDict["patientName"] = diagnose.patient.realname if diagnose.patient.gender: diagDict["gender"] = constant.Gender[diagnose.patient.gender] if diagnose.patient.birthDate: diagDict["birthDate"] = diagnose.patient.birthDate.strftime("%Y-%m-%d") if diagnose.diagnoseSeriesNumber: diagDict["diagnosenumber"] = diagnose.diagnoseSeriesNumber # diagDict['type']=diagnose.type if hasattr(diagnose, "doctor") and diagnose.doctor and diagnose.doctor.username: diagDict["doctorName"] = diagnose.doctor.username if diagnose.createDate: diagDict["applyTime"] = diagnose.createDate.strftime("%Y-%m-%d") if diagnose.status: diagDict["diagnoseStatus"] = diagnose.status # if hasattr(diagnose,"hospital") and diagnose.hospital: # diagDict['hospitalHistory']=diagnose.hospital.name # diagDict['hospitalId']=diagnose.hospitalId if diagnose.pathologyId: diagDict["dicomUrl"] = File.getDicomFileUrl(diagnose.pathologyId) if diagnose.pathologyId: diagDict["docUrl"] = File.getFilesUrl(diagnose.pathologyId) if hasattr(diagnose, "pathology") and diagnose.pathology: pathology = diagnose.pathology diagDict["caseHistory"] = pathology.caseHistory diagDict["diagnoseType"] = pathology.diagnoseMethod 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 diagDict["positionName"] = positions if hasattr(pathology, "hospital") and pathology.hospital: diagDict["hospitalHistory"] = pathology.hospital.name diagDict["hospitalId"] = pathology.hospitalId if hasattr(diagnose, "report") and diagnose.report: diagDict["reportId"] = diagnose.reportId # diagDict['techDes']=diagnose.report.techDesc # diagDict['imageDes']=diagnose.report.imageDesc # diagDict['diagnoseResult']=diagnose.report.diagnoseDesc diagnoseLogs = DiagnoseLog.getDiagnoseLogByDiagnoseId(session, diagnose.id) diagnoseLogsDict = getDiagnoseLogsDict(diagnoseLogs) if diagnoseLogs and len(diagnoseLogs) > 0: diagDict["actions"] = diagnoseLogsDict isFeedback = Comment.existCommentBydiagnose(diagnose.id, type=constant.CommentType.DiagnoseComment) diagDict["isFeedback"] = str(isFeedback) return diagDict
def userCenterDiagnoses(diagnoses, type=None): if diagnoses is None or len(diagnoses) < 1: return result = [] for diagnose in diagnoses: diagDict = {} if hasattr( diagnose, "patient") and diagnose.patient and diagnose.patient.realname: diagDict['patientName'] = diagnose.patient.realname if hasattr(diagnose, "doctor") and diagnose.doctor and diagnose.doctor.username: diagDict['doctorName'] = diagnose.doctor.username if hasattr( diagnose.doctor, 'hospital' ) and diagnose.doctor.hospital and diagnose.doctor.hospital.name: diagDict['doctorHispital'] = diagnose.doctor.hospital.name if hasattr( diagnose, "hospital") and diagnose.hospital and diagnose.hospital.name: diagDict['hispital'] = diagnose.hospital.name if diagnose.createDate: diagDict["date"] = diagnose.createDate.strftime('%Y-%m-%d') if diagnose.id: diagDict['id'] = diagnose.id if diagnose.diagnoseSeriesNumber: diagDict['diagnosenumber'] = diagnose.diagnoseSeriesNumber if diagnose.status or diagnose.status == 0: diagDict['statusId'] = diagnose.status diagDict['status'] = constant.DiagnoseStatus.getStatusName( diagnose.status) dicomUrl = None otherUrls = None if diagnose.pathologyId: dicomUrl = File.getDicomFileUrl(diagnose.pathologyId, type) if dicomUrl: diagDict['hasDicom'] = True else: diagDict['hasDicom'] = False otherUrls = File.getFilesUrl(diagnose.pathologyId, type) if otherUrls: diagDict['hasDoc'] = True else: diagDict['hasDoc'] = False if type: diagDict['dicomUrl'] = parseFileUrl(dicomUrl) diagDict['docUrl'] = parseFilesUrl(otherUrls) else: diagDict['dicomUrl'] = dicomUrl diagDict['docUrl'] = otherUrls if hasattr(diagnose, 'report') and diagnose.report and diagnose.report.fileUrl: diagDict['reportUrl'] = diagnose.report.fileUrl 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) diagDict['positionName'] = positions #print diagDict['doctorName'],diagDict['positons'] isFeedback = Comment.existCommentBydiagnose( diagnose.id, type=constant.CommentType.DiagnoseComment) diagDict['isFeedback'] = isFeedback result.append(diagDict) return result
def applyDiagnoseForm(formid): if (int(formid) == 1): form = DiagnoseForm3(request.form) form_result = form.validate() if form_result.status == rs.SUCCESS.status: if (form.diagnoseId): new_diagnose = Diagnose.getDiagnoseById(form.diagnoseId) else: new_diagnose = Diagnose.getNewDiagnoseByStatus( DiagnoseStatus.Draft, session['userId']) if (new_diagnose is None): new_diagnose = Diagnose() new_diagnose.status = DiagnoseStatus.Draft new_diagnose.doctorId = form.doctorId new_diagnose.uploadUserId = session['userId'] Diagnose.save(new_diagnose) form_result.data = {'formId': 2, 'diagnoseId': new_diagnose.id} return jsonify(form_result.__dict__) elif (int(formid) == 2): form = DiagnoseForm1(request.form) form_result = form.validate() if form_result.status == rs.SUCCESS.status: if form.diagnoseId is not None: new_diagnose = Diagnose.getDiagnoseById(form.diagnoseId) else: new_diagnose = Diagnose.getNewDiagnoseByStatus( DiagnoseStatus.Draft, int(session['userId'])) if (new_diagnose is not None): needcreateNewUserByHospitalUser = True # 去拿没有draft的用户 if (form.exist): #select exist patient , from list, when modify exist diagnose new_patient = Patient.get_patient_by_id(form.patientid) else: #update draft patient when modify exist diagnose new_patient = Patient.getPatientDraftByPatienId( new_diagnose.patientId) if new_patient: new_patient.realname = form.patientname new_patient.gender = form.patientsex new_patient.birthDate = datetime.strptime( form.birthdate, "%Y-%m-%d") new_patient.identityCode = form.identitynumber new_patient.locationId = form.locationId new_patient.identityPhone = form.phonenumber Patient.save(new_patient) needcreateNewUserByHospitalUser = False #create a new patient if new_patient is None: new_patient = Patient() new_patient.type = PatientStatus.diagnose new_patient.userID = session['userId'] new_patient.realname = form.patientname new_patient.gender = form.patientsex new_patient.birthDate = datetime.strptime( form.birthdate, "%Y-%m-%d") new_patient.identityCode = form.identitynumber new_patient.locationId = form.locationId new_patient.identityPhone = form.phonenumber new_patient.status = ModelStatus.Draft # new_patient.locationId = form.location Patient.save(new_patient) new_diagnose.patientId = new_patient.id Diagnose.save(new_diagnose) # Hospital User 注册用户 if form.isHospitalUser and ( not form.exist) and needcreateNewUserByHospitalUser: userQuery = User.getByPhone(form.phonenumber) if userQuery.count() <= 0: passwd = random.sample( 'zyxwvutsrqponmlkjihgfedcba1234567890', 6) passwd = ''.join(passwd) new_user = User(form.patientname, form.phonenumber, passwd, True) new_user.type = UserStatus.patent new_user.status = ModelStatus.Normal User.save(new_user) new_patient.userID = new_user.id Patient.save(new_patient) new_userrole = UserRole(new_user.id, RoleId.Patient) UserRole.save(new_userrole) sendRegisterMobileMessage(session.get('userId'), new_diagnose, new_user.phone, passwd) else: new_patient.userID = userQuery.first().id Patient.save(new_patient) form_result.data = { 'formId': 3, } else: form_result = ResultStatus(FAILURE.status, "找不到第一步草稿") return jsonify(form_result.__dict__) elif (int(formid) == 3): form = DiagnoseForm2(request.form) form_result = form.validate() if form_result.status == rs.SUCCESS.status: if form.diagnoseId is not None: new_diagnose = Diagnose.getDiagnoseById(form.diagnoseId) else: new_diagnose = Diagnose.getNewDiagnoseByStatus( DiagnoseStatus.Draft, int(session['userId'])) if new_diagnose is not None: #直接选择的病例,不是新建或者更改 isExistingPathology = False if form.exist: new_pathology = Pathology.getById(form.pathologyId) isExistingPathology = True elif new_diagnose.pathologyId: new_pathology = Pathology.getById(new_diagnose.pathologyId) else: new_pathology = Pathology.getByPatientStatus( session['userId'], ModelStatus.Draft) if new_pathology is None: new_pathology = Pathology(new_diagnose.patientId) if not isExistingPathology: new_pathology.diagnoseMethod = form.dicomtype new_pathology.status = ModelStatus.Draft new_pathology.save(new_pathology) PathologyPostion.deleteByPathologyId(new_pathology.id) for position in form.patientlocation: new_position_id = PathologyPostion( new_pathology.id, position) PathologyPostion.save(new_position_id) File.cleanDirtyFile(form.fileurl, new_pathology.id, FileType.Dicom) if form.fileurl and len(form.fileurl) > 0: for fileurl in form.fileurl: new_file = File.getFilebyId(int(fileurl)) new_file.pathologyId = new_pathology.id File.save(new_file) new_diagnose.pathologyId = new_pathology.id Diagnose.save(new_diagnose) form_result.data = {'formId': 4} else: form_result = ResultStatus(FAILURE.status, "找不到上步的草稿") return jsonify(form_result.__dict__) elif (int(formid) == 4): form = DiagnoseForm4(request.form) form_result = form.validate() if form_result.status == rs.SUCCESS.status: if form.diagnoseId is not None: new_diagnose = Diagnose.getDiagnoseById(form.diagnoseId) else: new_diagnose = Diagnose.getNewDiagnoseByStatus( DiagnoseStatus.Draft, int(session['userId'])) if (new_diagnose is not None): new_pathology = Pathology.getById(new_diagnose.pathologyId) if (new_pathology is not None): new_pathology.caseHistory = form.illnessHistory new_pathology.hospitalId = form.hospitalId new_pathology.status = ModelStatus.Normal Pathology.save(new_pathology) File.cleanDirtyFile(form.fileurl, new_pathology.id, FileType.FileAboutDiagnose) if form.fileurl and len(form.fileurl) > 0: for fileurl in form.fileurl: new_file = File.getFilebyId(int(fileurl)) new_file.pathologyId = new_pathology.id File.save(new_file) new_patient = Patient.get_patient_by_id( new_diagnose.patientId) new_patient.status = PatientStatus.diagnose #add for need update scenario if new_diagnose.status == constant.DiagnoseStatus.NeedUpdate: new_diagnoselog = DiagnoseLog( new_diagnose.uploadUserId, new_diagnose.id, DiagnoseLogAction.DiagnoseNeedUpateRecommitAction) DiagnoseLog.save(db_session, new_diagnoselog) new_diagnose.status = DiagnoseStatus.Triaging Diagnose.save(new_diagnose) #hospitalUser type=1 else: if form.type == '1' and not checkFilesExisting( new_diagnose): new_diagnoselog = DiagnoseLog( new_diagnose.uploadUserId, new_diagnose.id, DiagnoseLogAction.NewDiagnoseAction) DiagnoseLog.save(db_session, new_diagnoselog) #update by lichuan , save diagnose and change to needPay new_diagnose.status = DiagnoseStatus.HospitalUserDiagnoseNeedCommit Diagnose.save(new_diagnose) #end update else: #产生alipay,发送短消息 userId = session.get('userId') new_diagnose.ossUploaded = constant.DiagnoseUploaed.Uploaded new_diagnose.status = DiagnoseStatus.NeedPay Diagnose.save(new_diagnose) sendAllMessage(userId, new_diagnose) else: form_result = ResultStatus(FAILURE.status, "找不到上步的草稿1") else: form_result = ResultStatus(FAILURE.status, "找不到上步的草稿2") form_result.data = {'isFinal': True} return jsonify(form_result.__dict__) else: return jsonify(ResultStatus(FAILURE.status, "错误的表单号").__dict__)
def fileUpload(): userId = session.get('userId') if userId is None: return redirect(LOGIN_URL) userId = string.atoi(userId) type = request.form.get('type') diagnoseId = request.form.get("diagnoseId") if diagnoseId is None: return jsonify({'code': 1, 'message': "error", 'data': ''}) diagnoseId = string.atoi(diagnoseId) if type: type = string.atoi(type) else: type = constant.FileType.Dicom try: diagnose = Diagnose.getDiagnoseById(diagnoseId) if diagnose and diagnose.pathologyId: file_infos = [] files = request.files for key, file in files.iteritems(): if file and allowed_file(file.filename): filename = file.filename extension = getFileExtension(filename) # file_url = oss_util.uploadFile(diagnoseId, filename) from DoctorSpring.util.oss_util import uploadFileFromFileStorage, size, getFileName fileurl = uploadFileFromFileStorage( diagnoseId, filename, file, '', {}, extension) newFileName = getFileName(diagnoseId, filename, extension) size = size(newFileName) new_file = File(type, filename, size, fileurl, diagnose.pathologyId) File.save(new_file) if type == FileType.Dicom: filesAboutDiagnose = File.getFiles( diagnose.pathologyId, FileType.FileAboutDiagnose) if filesAboutDiagnose and len(filesAboutDiagnose) > 0: diagnoseChange = Diagnose() diagnoseChange.id = diagnoseId diagnoseChange.ossUploaded = constant.DiagnoseUploaed.Uploaded #diagnoseChange.status=constant.DiagnoseStatus.NeedPay diagnose.uploadUserId = userId Diagnose.update(diagnoseChange) #sendAllMessage(userId,diagnose)需要提交了才能发信息h new_diagnoselog = DiagnoseLog( diagnose.uploadUserId, diagnose.id, DiagnoseLogAction.NewDiagnoseAction) DiagnoseLog.save(db_session, new_diagnoselog) if type == FileType.FileAboutDiagnose: filesAboutDiagnose = File.getFiles( diagnose.pathologyId, FileType.Dicom) if filesAboutDiagnose and len(filesAboutDiagnose) > 0: diagnoseChange = Diagnose() diagnoseChange.id = diagnoseId diagnoseChange.ossUploaded = constant.DiagnoseUploaed.Uploaded #diagnoseChange.status=constant.DiagnoseStatus.NeedPay diagnose.uploadUserId = userId Diagnose.update(diagnoseChange) #sendAllMessage(userId,diagnose) new_diagnoselog = DiagnoseLog( diagnose.uploadUserId, diagnose.id, DiagnoseLogAction.NewDiagnoseAction) DiagnoseLog.save(db_session, new_diagnoselog) file_infos.append( dict(id=new_file.id, name=filename, size=size, url=fileurl)) else: return jsonify({'code': 1, 'message': "error", 'data': ''}) return jsonify(files=file_infos) except Exception, e: LOG.error(e.message) return jsonify({'code': 1, 'message': "上传出错", 'data': ''})
def getDiagnoseDetailInfoByPatient(session, diagnose): if diagnose is None: return diagDict = {} diagDict['id'] = diagnose.id if hasattr(diagnose, "patient") and diagnose.patient: if diagnose.patient.realname: diagDict['patientName'] = diagnose.patient.realname if diagnose.patient.gender: diagDict['gender'] = constant.Gender[diagnose.patient.gender] if diagnose.patient.birthDate: diagDict['birthDate'] = diagnose.patient.birthDate.strftime( '%Y-%m-%d') if diagnose.diagnoseSeriesNumber: diagDict['diagnosenumber'] = diagnose.diagnoseSeriesNumber #diagDict['type']=diagnose.type if hasattr(diagnose, "doctor") and diagnose.doctor and diagnose.doctor.username: diagDict['doctorName'] = diagnose.doctor.username diagDict['doctorUserId'] = diagnose.doctor.userId if diagnose.createDate: diagDict["applyTime"] = diagnose.createDate.strftime('%Y-%m-%d') if diagnose.status: diagDict['diagnoseStatus'] = diagnose.status # if hasattr(diagnose,"hospital") and diagnose.hospital: # diagDict['hospitalHistory']=diagnose.hospital.name # diagDict['hospitalId']=diagnose.hospitalId if diagnose.pathologyId: diagDict['dicomUrl'] = File.getDicomFileUrl(diagnose.pathologyId) if diagnose.pathologyId: diagDict['docUrl'] = File.getFilesUrl(diagnose.pathologyId) if hasattr(diagnose, "pathology") and diagnose.pathology: pathology = diagnose.pathology diagDict['caseHistory'] = pathology.caseHistory diagDict['diagnoseType'] = pathology.diagnoseMethod 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) diagDict['positionName'] = positions if hasattr(pathology, "hospital") and pathology.hospital: diagDict['hospitalHistory'] = pathology.hospital.name diagDict['hospitalId'] = pathology.hospitalId if hasattr(diagnose, 'report') and diagnose.report and diagnose.report.fileUrl: diagDict['reportId'] = diagnose.reportId diagDict['reportUrl'] = diagnose.report.fileUrl # diagDict['techDes']=diagnose.report.techDesc # diagDict['imageDes']=diagnose.report.imageDesc # diagDict['diagnoseResult']=diagnose.report.diagnoseDesc diagnoseLogs = DiagnoseLog.getDiagnoseLogByDiagnoseId(session, diagnose.id) diagnoseLogsDict = getDiagnoseLogsDict(diagnoseLogs) if diagnoseLogs and len(diagnoseLogs) > 0: diagDict['actions'] = diagnoseLogsDict isFeedback = Comment.existCommentBydiagnose( diagnose.id, type=constant.CommentType.DiagnoseComment) diagDict['isFeedback'] = str(isFeedback) return diagDict
def getDiagnoseListByKefu(diagnoses): if diagnoses is None or len(diagnoses) < 1: return result = [] for diagnose in diagnoses: diagDict = {} if hasattr( diagnose, "patient") and diagnose.patient and diagnose.patient.realname: diagDict['patientName'] = diagnose.patient.realname if hasattr(diagnose, "patient") and diagnose.patient: diagDict['mobile'] = diagnose.patient.identityPhone if hasattr(diagnose, "doctor") and diagnose.doctor and diagnose.doctor.username: diagDict['doctorName'] = diagnose.doctor.username if hasattr( diagnose.doctor, 'hospital' ) and diagnose.doctor.hospital and diagnose.doctor.hospital.name: diagDict['doctorHispital'] = diagnose.doctor.hospital.name if hasattr( diagnose, "hospital") and diagnose.hospital and diagnose.hospital.name: diagDict['hispital'] = diagnose.hospital.name if diagnose.createDate: diagDict["date"] = diagnose.createDate.strftime('%Y-%m-%d') if diagnose.id: diagDict['id'] = diagnose.id if diagnose.diagnoseSeriesNumber: diagDict['diagnosenumber'] = diagnose.diagnoseSeriesNumber if diagnose.status or diagnose.status == 0: diagDict['statusId'] = diagnose.status diagDict['status'] = constant.DiagnoseStatus.getStatusName( diagnose.status) if diagnose.pathologyId: dicomUrl = File.getDicomFileUrl(diagnose.pathologyId) if dicomUrl: diagDict['dicomUrl'] = dicomUrl otherUrls = File.getFilesUrl(diagnose.pathologyId) if otherUrls: diagDict['otherUrls'] = otherUrls if hasattr(diagnose, 'report') and diagnose.report and diagnose.report.fileUrl: diagDict['reportUrl'] = diagnose.report.fileUrl if hasattr(diagnose, "pathology") and diagnose.pathology: pathology = diagnose.pathology postionLen = 0 if hasattr(pathology, "pathologyPostions") and pathology.pathologyPostions: pathologyPositons = pathology.pathologyPostions postionLen = len(pathologyPositons) if pathologyPositons and len(pathologyPositons) > 0: positions = u'' for pathologyPositon in pathologyPositons: position = pathologyPositon.position positions += (u' ' + position.name) diagDict['positionName'] = positions #print diagDict['doctorName'],diagDict['positons'] if pathology.diagnoseMethod == constant.DiagnoseMethod.Mri: diagDict['payAmount'] = diagnose.getPayCount( constant.DiagnoseMethod.Mri, postionLen, diagnose.getUserDiscount(diagnose.patientId)) diagDict['diagnoseMethod'] = constant.DiagnoseMethod.Mri elif pathology.diagnoseMethod == constant.DiagnoseMethod.Ct: diagDict['payAmount'] = diagnose.getPayCount( constant.DiagnoseMethod.Ct, postionLen, diagnose.getUserDiscount(diagnose.patientId)) diagDict['diagnoseMethod'] = constant.DiagnoseMethod.Ct isFeedback = Comment.existCommentBydiagnose( diagnose.id, type=constant.CommentType.DiagnoseComment) diagDict['isFeedback'] = isFeedback result.append(diagDict) return result
def getDocomFileName(pathologyId): if pathologyId is None: return files = File.getFiles(pathologyId, constant.FileType.Dicom) if files and len(files): return files[0].name