修正了检查session的statsu
This commit is contained in:
parent
36c399c009
commit
7eff717256
@ -19,7 +19,7 @@ max_backups = 7
|
||||
path = D:/BodyCheck/file/
|
||||
|
||||
[CAMERA1]
|
||||
enabled = False
|
||||
enabled = True
|
||||
device_index = 0
|
||||
width = 1280
|
||||
height = 720
|
||||
|
||||
@ -232,7 +232,7 @@ class DatabaseManager:
|
||||
treatment_info TEXT, -- 处理信息
|
||||
remark_info TEXT, -- 备注信息
|
||||
detection_report TEXT, -- 生成检测报告的存储路径
|
||||
status TEXT DEFAULT 'checking', -- 会话状态(checking/checked/diagnosed/reported)
|
||||
status TEXT DEFAULT 'checking', -- 会话状态(checking/checked/completed/reported)
|
||||
data_ids TEXT, -- 关联的检测数据ID(逗号分隔)
|
||||
created_at TIMESTAMP, -- 记录创建时间
|
||||
FOREIGN KEY (patient_id) REFERENCES patients (id), -- 患者表外键约束
|
||||
@ -663,23 +663,28 @@ class DatabaseManager:
|
||||
# 构造更新语句
|
||||
update_fields = [
|
||||
'duration = ?',
|
||||
'end_time = ?',
|
||||
'status = ?'
|
||||
'end_time = ?'
|
||||
|
||||
]
|
||||
update_values = [duration_seconds, now_str, 'checked']
|
||||
update_values = [duration_seconds, now_str]
|
||||
|
||||
if diagnosis_info is not None:
|
||||
update_fields.append('diagnosis_info = ?')
|
||||
update_values.append(diagnosis_info)
|
||||
|
||||
if treatment_info is not None:
|
||||
update_fields.append('treatment_info = ?')
|
||||
update_values.append(treatment_info)
|
||||
|
||||
if suggestion_info is not None:
|
||||
update_fields.append('suggestion_info = ?')
|
||||
update_values.append(suggestion_info)
|
||||
|
||||
status='checked' #默认状态为checked:已完成检查
|
||||
if treatment_info is not None: #处理信息不为空时,状态设为completed:已诊断处理
|
||||
update_fields.append('treatment_info = ?')
|
||||
update_values.append(treatment_info)
|
||||
status='completed'
|
||||
|
||||
update_fields.append('status = ?')
|
||||
update_values.append(status)
|
||||
|
||||
# 添加会话ID到参数列表
|
||||
update_values.append(session_id)
|
||||
|
||||
@ -688,9 +693,9 @@ class DatabaseManager:
|
||||
|
||||
# 同步更新患者表的updated_at时间
|
||||
cursor.execute('''UPDATE patients SET updated_at = ? WHERE id = ?''', (now_str, patient_id))
|
||||
|
||||
self._sync_patient_medical_history_from_session(cursor, session_id)
|
||||
conn.commit()
|
||||
logger.info(f'结束检测并更新会话: {session_id}, duration={duration_seconds}s, status=checked')
|
||||
logger.info(f'结束检测并更新会话: {session_id}, duration={duration_seconds}s, status={status}')
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
@ -699,7 +704,7 @@ class DatabaseManager:
|
||||
return False
|
||||
|
||||
|
||||
def update_session_all_info(self, session_id: str, diagnosis_info: str = None, treatment_info: str = None, suggestion_info: str = None, status: str = None):
|
||||
def update_session_all_info(self, session_id: str, diagnosis_info: str = None, treatment_info: str = None, suggestion_info: str = None):
|
||||
"""同时更新会话的诊断信息、处理信息、建议信息和状态"""
|
||||
conn = self.get_connection()
|
||||
cursor = conn.cursor()
|
||||
@ -712,19 +717,16 @@ class DatabaseManager:
|
||||
if diagnosis_info is not None:
|
||||
update_fields.append('diagnosis_info = ?')
|
||||
update_values.append(diagnosis_info)
|
||||
|
||||
status='checked' #默认状态为checked:已完成检查
|
||||
if treatment_info is not None:
|
||||
update_fields.append('treatment_info = ?')
|
||||
update_values.append(treatment_info)
|
||||
status='completed' #处理信息不为空时,状态设为completed:已诊断处理
|
||||
|
||||
if suggestion_info is not None:
|
||||
update_fields.append('suggestion_info = ?')
|
||||
update_values.append(suggestion_info)
|
||||
|
||||
if status is not None:
|
||||
update_fields.append('status = ?')
|
||||
update_values.append(status)
|
||||
|
||||
if not update_fields:
|
||||
logger.warning(f'没有提供要更新的信息: {session_id}')
|
||||
return
|
||||
@ -807,7 +809,7 @@ class DatabaseManager:
|
||||
SELECT s.id, s.status, s.start_time, u.name as creator_name,s.detection_report as detection_report,s.data_ids as data_ids
|
||||
FROM detection_sessions s
|
||||
LEFT JOIN users u ON s.creator_id = u.id
|
||||
WHERE s.patient_id = ?
|
||||
WHERE s.patient_id = ? and s.status in ('checked','completed','reported')
|
||||
ORDER BY s.start_time DESC
|
||||
LIMIT ? OFFSET ?
|
||||
''', (patient_id, size, offset))
|
||||
@ -846,7 +848,7 @@ class DatabaseManager:
|
||||
conn = self.get_connection()
|
||||
cursor = conn.cursor()
|
||||
try:
|
||||
cursor.execute('SELECT COUNT(*) FROM detection_sessions WHERE patient_id = ?', (patient_id,))
|
||||
cursor.execute("SELECT COUNT(*) FROM detection_sessions WHERE status in ('checked','completed','reported') and patient_id = ?", (patient_id,))
|
||||
row = cursor.fetchone()
|
||||
return int(row[0]) if row else 0
|
||||
except Exception as e:
|
||||
|
||||
@ -1493,13 +1493,13 @@ class AppServer:
|
||||
diagnosis_info = data.get('diagnosis_info')
|
||||
treatment_info = data.get('treatment_info')
|
||||
suggestion_info = data.get('suggestion_info')
|
||||
status = data.get('status')
|
||||
|
||||
|
||||
# 验证至少提供一个要更新的字段
|
||||
if not any([diagnosis_info, treatment_info, suggestion_info, status]):
|
||||
if not any([diagnosis_info, treatment_info, suggestion_info]):
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': '至少需要提供一个要更新的字段(diagnosis_info, treatment_info, suggestion_info, status)'
|
||||
'error': '至少需要提供一个要更新的字段(diagnosis_info, treatment_info, suggestion_info)'
|
||||
}), 400
|
||||
|
||||
# 调用数据库管理器的批量更新方法
|
||||
@ -1507,8 +1507,7 @@ class AppServer:
|
||||
session_id=session_id,
|
||||
diagnosis_info=diagnosis_info,
|
||||
treatment_info=treatment_info,
|
||||
suggestion_info=suggestion_info,
|
||||
status=status
|
||||
suggestion_info=suggestion_info
|
||||
)
|
||||
|
||||
# 构建更新信息反馈
|
||||
|
||||
Loading…
Reference in New Issue
Block a user