-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
2253 lines (2127 loc) · 74.6 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
import datetime
import torch
import pynvml
import psutil
import os
import random
import re
import shutil
from aliyunsdkcore.request import CommonRequest
import stat
import tempfile
import time
import zipfile
from io import BytesIO
from multiprocessing import Process
import numpy as np
from aliyunsdkcore.client import AcsClient
import cv2
import pydicom
# from datetime import datetime
import PIL.Image as Image
from flask import request as requ
from flask import session, redirect, url_for, flash, current_app, request, jsonify, make_response, \
send_file
from werkzeug.utils import secure_filename
import uuid
from Smooth.smooth import smooth
from All_hospital.bmp_to_nii import bmp_to_nii
from All_hospital.test import model_test
from domo.app import db
# ALLOWED_EXTENSIONS = set(['txt', 'dcm', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
from domo.app.load_dcm import get_pixeldata, setDicomWinWidthWinCenter
from domo.app.models import *
from domo.app.s3 import CephS3BOTO3, getInformation
from domo.manage import app
from vol_3d.vol2obj import obj_make
from volume.get_volume import liver_tumor_spleen
from . import main
ALLOWED_EXTENSIONS = set(['dcm', 'png', 'jpg', 'gif'])
conn = CephS3BOTO3()
join = os.path.join
# @main.before_request
# def create_db():
#
# db.drop_all()
# db.create_all()
# db.session.commit()
# def login_check():
# if session.get('user') is None:
# form = LoginForm()
# sign_form = Sign_inForm()
# return render_template('login.html', form=sign_form)
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
@main.route('/indexImage/<int:flag>', methods=['GET'])
def indexImage(flag):
"""
This is the image API
Call this 获取首页图片 api passing a flag and get back its features
---
tags:
- Private Cloud Platform API
parameters:
- name: flag
in: path
required: true
responses:
500:
description: 系统错误
200:
description: 首页图片获取
schema:
id: index_image
properties:
code:
type: integer
description: 0 成功, 其他值表示失败
data:
type: object
properties:
image:
type: object
properties:
background:
type: string
module:
type: object
properties:
name:
type: string
word:
type: array
items:
type: array
items:
type: string
msg:
type: string
"""
if flag == 1:
conn.get_list_object('private', 'image{}st'.format(flag))
return {"code": "0", "data": "", "msg": ""}
@main.route('/login', methods=['POST'])
def login():
"""
This is the login API
Call this 登录 api passing a 用户名或手机号 and 密码 and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: body
in: body
required: true
properties:
username:
type: string
description: 用户名
password:
type: string
description: 密码
responses:
500:
description: 系统错误
200:
description: 登录成功
schema:
id: login
properties:
code:
type: integer
description: 0 成功, 其他值表示失败
default:
data:
type: object
properties:
doctor_id:
type: string
description: 医生标识 doctor_id
doctor_name:
type: string
description: 医生姓名
doctor_dep:
type: string
description: 医生科室
msg:
type: string
description: 消息信息
"""
data = request.get_json()
username = data['username']
password = data['password']
if username and password:
if len(username) == 11:
user = Doctor.query.filter_by(phone_number=username).first()
if user is None:
user = Doctor.query.filter_by(username=username).first()
else:
user = Doctor.query.filter_by(username=username).first()
if user is not None:
if user.verify_password(password) is True:
# session['user'] = user.username
# session['doctor_id'] = user.doctor_id
result = {"code": 0, "data": {"doctor_id": user.doctor_id,
"doctor_name": user.name,
"doctor_dep": user.department
}, "msg": "登录成功"}
return result
return {"code": 10001, "data": "", "msg": "密码错误"}
return {"code": 10003, "data": "", "msg": "用户名不存在"}
return {"code": 10002, "data": "", "msg": "用户名或密码为空"}
@main.route('/department', methods=['GET'])
def get_department():
"""
This is the get_department API
Call this 科室 get back its features
---
tags:
- Liver Imaging Platform API READY
responses:
500:
description: 错误
200:
description: 医生所属科室信息
schema:
id: department
properties:
code:
type: integer
description: 0 成功,其他值表示失败
data:
type: array
items:
type: string
description: 获取科室
"""
result = {"code": 0, "data": ["内科", "消化内科"]}
return jsonify(result)
@main.route('/sign_in', methods=['POST'])
def sign_in():
"""
This is the sign_in API
Call this 注册 api passing 注册信息 and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: body
in: body
required: true
properties:
username:
type: string
required: true
description: The doctor username
name:
type: string
required: true
description: The doctor name
password:
type: string
required: true
description: The doctor password
department:
type: string
required: true
description: The doctor department
pre_phone_number:
type: string
required: true
description: The doctor pre_phone_number
phone_number:
type: string
required: true
description: The doctor phone_number
identify:
type: string
required: true
description: The doctor phone_number identify
responses:
500:
description: Error
200:
description: A doctor login information
schema:
id: sign_in
properties:
code:
type: integer
description: 0 成功, 其他值表示失败
data:
type: string
msg:
type: string
"""
global uuid
data = request.get_json()
department = data['department']
identify = data['identify']
name = data['name']
password = data['password']
phone_number = data['phone_number']
pre_phone_number = data['pre_phone_number']
username = data['username']
# if username != phone_number
# if (datetime.now().second - session['time'].second) > 300:
# return {
# "code": 10003,
# "data": "",
# "msg": "验证码超时"
# }
# if identify.lower() != session['identify']:
# if identify.lower() != '1234':
# return {
# "code": 10002,
# "data": "",
# "msg": "验证码错误"
# }
phone = Doctor.query.filter_by(phone_number=phone_number).first()
user = Doctor.query.filter_by(username=username).first()
if phone is None and user is None:
uid = uuid.uuid1().hex
doctor = Doctor(doctor_id=uid, username=username, password=password,
phone_number=phone_number,
department=department, name=name) # 与表单对应数据库
db.session.add(doctor)
try:
db.session.commit()
except Exception as e:
db.session.rollback()
return {"code": 10001, "data": "", "msg": "注册信息有误"}
session['user'] = doctor.username
session['doctor_id'] = doctor.doctor_id
result = {"code": 0, "data": "", "msg": "注册成功"}
return result
return {"code": 10002, "data": "", "msg": "该用户已注册"}
@main.route('/reset_password', methods=['POST'])
def reset_password():
"""
This is the reset_password API
Call this 重置密码 api passing phone number and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: data
in: body
required: true
properties:
password:
type: string
required: true
description: The doctor password
pre_phone_number:
type: string
required: true
description: The doctor pre_phone_number
phone_number:
type: string
required: true
description: The doctor phone_number
identify:
type: string
required: true
description: The doctor phone_number identify
responses:
500:
description: Error
200:
description: A doctor reset_password information
schema:
id: reset-password
properties:
code:
type: string
description: 0 成功, 其他值表示失败
default:
data:
type: string
msg:
type: string
"""
data = request.get_json()
phone_number = data['phone_number']
identify = data['identify']
if datetime.now().second - session['time'].second > 300:
return {
"code": 10003,
"data": "",
"msg": "验证码过期"
}
if identify.lower() != session['identify']:
return {
"code": 10002,
"data": "",
"msg": "验证码错误"
}
password = data['password']
doctor = Doctor.query.filter_by(phone_number=phone_number).first()
try:
doctor.hash_password = generate_password_hash(password)
db.session.commit()
except Exception as e:
print(repr(e))
db.session.rollback()
# flash('User reset password failed')
return {"code": 10001, "data": "", "msg": "重置密码失败"}
return {"code": 0, "data": "", "msg": "重置密码成功"}
@main.route('/identify', methods=['POST'])
def identify():
"""
This is the identify API
Call this 验证码api passing phone number and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: data
in: body
required: true
properties:
pre_phone_number:
type: string
required: true
description: The doctor pre_phone_number
phone_number:
type: string
required: true
description: The doctor phone_number
responses:
500:
description: Error
200:
description: A doctor phone number identify information
schema:
id: identify
properties:
code:
type: integer
description: 0 成功,其他值表示失败
data:
type: string
description: 验证码
"""
data = requ.get_json() # request被阿里云接口占用 此处用别名requ
phone_number = data['phone_number']
if len(phone_number) != 11:
return {
"code": 10001,
"data": "请输入正确手机号"
}
client = AcsClient('LTAI4GHR3opdFMbbGA5W6CoW', '5N3V2R5ZfIKZjrkBPn6B7RwB2YquuY', 'cn-hangzhou')
str = 'QWERTYUPASDFGHJKZXCVBNMqwertyupasdfghjkzxcvbnm987654321' # 由此产生四个随机数
code = '' # 先占位
for i in range(4):
ran = random.randint(0, len(str) - 1) # 因为下标从零开始,所以长度减一
code += str[ran]
request = CommonRequest()
request.set_accept_format('json')
request.set_domain('dysmsapi.aliyuncs.com')
request.set_method('POST')
request.set_protocol_type('https') # https | http
request.set_version('2017-05-25')
request.set_action_name('SendSms')
request.add_query_param('RegionId', "cn-hangzhou")
request.add_query_param('PhoneNumbers', phone_number)
request.add_query_param('SignName', "肝脏影像分析短信平台")
request.add_query_param('TemplateCode', "SMS_194635535")
identify = "{\"code\":\"" + code + "\"}"
request.add_query_param('TemplateParam', identify)
session['identify'] = code.lower()
session['time'] = datetime.now()
response = client.do_action_with_exception(request)
print(response)
return {
"code": 0,
"data": ""
}
@main.route('/patientInfo/patientFiles/<string:doctor_id>', methods=['GET'])
def patients_file(doctor_id):
"""
This is the patients_file API
Call this 查询患者档案 api passing doctor_id and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: doctor_id
in: path
required: true
- name: query
in: query
type: string
required: false
description: 查询关键字
- name: pagenum
in: query
type: integer
required: true
default: 1
description: The page number
- name: pagesize
in: query
type: integer
default: 10
required: true
description: The page size
responses:
500:
description: Error
200:
description: A doctor's patients_file information
schema:
id: doctor_patients
properties:
code:
type: integer
description: The doctor name
default:
data:
type: object
description: The doctor's patients
properties:
department:
type: string
name:
type: string
sum_pages:
type: integer
sum_patients:
type: integer
patients:
type: array
items:
type: object
properties:
identify_card:
type: string
description: 患者身份证号
name:
type: string
sex:
type: boolean
age:
type: string
msg:
type: string
"""
query = request.args.get('query')
doctor_id = doctor_id
pagenum = int(request.args.get('pagenum'))
pagesize = int(request.args.get('pagesize'))
doctor = Doctor.query.filter_by(doctor_id=doctor_id).first()
if doctor is None:
return {
"code": 10001,
"data": "",
"msg": "医生不存在"
}
doctor_name = doctor.name
department = doctor.department
patients = []
if query:
if len(query) < 15:
patient_num = Patient.query.filter(Patient.name.like(r'%{keyword}%'.format(keyword=query))).all()
# patient_num = Patient.query.filter_by(name=query).all()
else:
patient_num = Patient.query.filter_by(identify_card=query).all()
if patient_num:
sum_patients = int(len(patient_num))
sum_pages = sum_patients // pagesize
if sum_patients % pagesize > 0:
sum_pages += 1
if sum_pages < pagenum:
return {
"code": 10003,
"data": "",
"msg": "无效页码"
}
for patient in patient_num[pagesize * (pagenum - 1):(pagesize * (pagenum - 1) + pagesize)]:
patient_info = {}
patient_info['name'] = patient.name
patient_info['identify_card'] = patient.identify_card
sex, age = getInformation(patient_info['identify_card'])
if sex:
sex = '男'
else:
sex = '女'
patient_info['sex'] = sex
patient_info['age'] = age
patients.append(patient_info)
return {
"code": 0,
"data": {
"sum_pages": sum_pages,
"sum_patients": sum_patients,
"department": department,
"name": doctor_name,
"patients": patients
},
"msg": "成功"
}
return {
"code": 10002,
"data": "",
"msg": "医生未上传病人信息"
}
sum_patients = len(doctor.my_patients)
sum_pages = sum_patients // pagesize
if sum_patients % pagesize > 0:
sum_pages += 1
if sum_pages < pagenum:
return {
"code": 10003,
"data": "",
"msg": "无效页码"
}
if doctor.my_patients:
for patient in doctor.my_patients[pagesize * (pagenum - 1):(pagesize * (pagenum - 1) + pagesize)]:
patient_info = {}
patient_info['name'] = patient.name
patient_info['identify_card'] = patient.identify_card
sex, age = getInformation(patient_info['identify_card'])
if sex:
sex = '男'
else:
sex = '女'
patient_info['sex'] = sex
patient_info['age'] = age
patients.append(patient_info)
return {
"code": 0,
"data": {
"sum_pages": sum_pages,
"sum_patients": sum_patients,
"department": department,
"name": doctor_name,
"patients": patients
},
"msg": "ok"
}
return {
"code": 10002,
"data": {
"sum_pages": sum_pages,
"sum_patients": sum_patients,
"department": department,
"name": doctor_name,
"patients": patients
},
"msg": "医生未上传病人信息"
}
@main.route('/patientInfo/newPatientFiles/submission', methods=['POST'])
def new_patients():
"""
This is the new_patients API
Call this 新建患者档案 api passing a name and identify_card and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: body
in: body
required: true
properties:
doctor_id:
type: string
required: true
description: The doctor id
name:
type: string
required: true
description: The patient name
identify_card:
type: string
required: true
description: The patient identify_card
responses:
500:
description: Error The identify_card is not correct!
200:
description: 新建患者档案成功
schema:
id: new_patients
properties:
code:
type: integer
description: 0 成功,其他值表示失败
data:
type: string
description:
"""
data = request.get_json()
doctor_id = data.get('doctor_id')
identify_card = data.get('identify_card')
if len(identify_card) != 18:
return {
"code": 10001,
"data": "请输入正确身份证号"
}
if doctor_id is None:
return {
"code": 10001,
"data": "参数错误"
}
patient = Patient.query.filter_by(identify_card=identify_card).first()
if patient:
return {"code": 10001, "data": "身份证号已注册"}
name = data['name']
sex, age = getInformation(identify_card)
sex = bool(sex)
if age < 0:
return {"code": 10001, "data": "身份证信息不合法"}
age = str(age)
patient = Patient(name=name, identify_card=identify_card, doctor_id=doctor_id, sex=sex, age=age)
db.session.add(patient)
try:
db.session.commit()
flash('new patient created !')
except Exception as e:
db.session.rollback()
return {"code": 10001, "data": "身份证信息不合法"}
session['identify_card'] = identify_card
return {"code": 0, "data": ""}
@main.route('/patientInfo/newPatientCases/quality', methods=['POST'])
def quality():
"""
This is the new_case API
Call this 新增病例 api passing 身高,体重,dcm数据 and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: body
in: body
required: true
properties:
height:
type: string
required: true
description: The patient height
weight:
type: string
required: true
description: The patient weight
information:
type: string
identify_card:
type: string
required: true
description: The patient identify_card
responses:
500:
description: Error
200:
description: The patient new_cases
schema:
id: new_patient_case
properties:
code:
type: integer
data:
type: string
description: case_id
"""
data = request.get_json()
height = data.get('height')
weight = data.get('weight')
info = data.get('information')
identify_card = data.get('identify_card')
if len(height) > 2:
return {
"code": 10001,
"data": "请输入正确身高"
}
# if len(weight) > 10:
# return {
# "code": 10001,
# "data": "请输入正确体重"
# }
# if len(identify_card) != 18:
# return {
# "code": 10001,
# "data": "请输入正确身份证号"
# }
uid = uuid.uuid1().hex
# case = Case(case_id=uid, height=height, weight=weight, identify_card=identify_card, information=info)
# db.session.add(case)
# try:
# db.session.commit()
# flash('Case created !')
# except Exception as e:
# print(repr(e))
# db.session.rollback()
# flash('Case create failed')
# return {
# "code": 10001,
# "data": ""
# }
# case_id = case.case_id
return {
"code": 0,
"data": uid
}
# dcm文件上传
@main.route('/patientInfo/newPatientCases/submission', methods=['POST'])
def new_cases():
"""
This is the new_case API
Call this 新增病例 api passing 身高,体重,dcm数据 and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: body
in: body
required: true
properties:
height:
type: string
required: true
description: The patient height
weight:
type: string
required: true
description: The patient weight
information:
type: string
identify_card:
type: string
required: true
description: The patient identify_card
responses:
500:
description: Error
200:
description: The patient new_cases
schema:
id: new_patient_case
properties:
code:
type: integer
data:
type: string
description: case_id
"""
data = request.get_json()
height = data.get('height')
weight = data.get('weight')
info = data.get('information')
identify_card = data.get('identify_card')
if len(height) > 10:
return {
"code": 10001,
"data": "请输入正确身高"
}
if len(weight) > 10:
return {
"code": 10001,
"data": "请输入正确体重"
}
if len(identify_card) != 18:
return {
"code": 10001,
"data": "请输入正确身份证号"
}
uid = uuid.uuid1().hex
case = Case(case_id=uid, height=height, weight=weight, identify_card=identify_card, information=info)
db.session.add(case)
try:
db.session.commit()
flash('Case created !')
except Exception as e:
print(repr(e))
db.session.rollback()
flash('Case create failed')
return {
"code": 10001,
"data": ""
}
case_id = case.case_id
return {
"code": 0,
"data": case_id
}
@main.route('/patient/schedule/<string:case_id>', methods=['GET'])
def schedule(case_id):
"""
This is the schedule API
Call this 处理进度 api passing a name and case_id and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: case_id
in: path
type: string
required: true
description: 患者病历号
responses:
500:
description: Error The case_id is not correct!
200:
description: 查询处理进度
schema:
id: identify
properties:
code:
type: integer
description: 0 处理完成,其他值表示未完成
msg:
type: string
description:
"""
case = Case.query.filter_by(case_id=case_id).first()
# sm = case.real_liver_volume
if session[case_id]['volume'] == 1:
return {
"code": 0,
"msg": "结果处理完毕"
}
elif os.path.exists(os.path.join(os.getcwd(), '/data/bucket/{}/dcm/'.format(case.case_id))):
return {
"code": 10001,
"msg": "结果正在处理中"
}
return {
"code": 10002,
"msg": "未上传dcm文件"
}
@main.route('/patientInfo/del', methods=['POST'])
def delete():
"""
This is the patient_info delete API
Call this 删除患者档案 api passing identify_card and get back its features
---
tags:
- Liver Imaging Platform API READY
parameters:
- name: body
in: body
required: true
properties:
identify_card:
type: array
items:
type: string
required: true
description: The patient identify_card
responses:
500:
description: Error
200:
description: The patient deleted !
schema:
id: patient_del
properties:
code:
type: integer
description: 0表示成功,10001表示失败,删除失败的用户列表在data中
data:
type: array
items:
type: string
description: 删除失败的用户列表
"""
data = request.get_json()
data = data.get('identify_card')
result = []
for identify_card in data:
patient = Patient.query.filter_by(identify_card=identify_card).first()
if patient is None:
result.append(identify_card)
# return {"code": 10001, "data": ""} # 患者不存在
cases = patient.my_cases
filepath=os.getcwd()
# cases_list = []
for i in cases:
delete_file(os.path.join(filepath + app.config['STATIC'], i.case_id))
# conn.delete('bucket', i.case_id)
db.session.delete(patient)
try:
db.session.commit()
flash('Patient deleted !')
except Exception as e:
print(repr(e))
db.session.rollback()
flash('Patient delete failed')
return 10002 # 删除失败
if result:
return {"code": 10001, "data": result}
return {"code": 0, "data": ""}
@main.route('/patientInfo/patientCases/del', methods=['POST'])
def case_delete():