修改了首页患者列表信息
This commit is contained in:
parent
5ec2adc833
commit
b74d9129fe
Binary file not shown.
Binary file not shown.
@ -404,7 +404,7 @@ class DatabaseManager:
|
|||||||
|
|
||||||
if keyword:
|
if keyword:
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
SELECT p.*, COALESCE(ds.session_count, 0) AS detection_count
|
SELECT p.*, COALESCE(ds.session_count, 0) AS num
|
||||||
FROM patients p
|
FROM patients p
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT patient_id, COUNT(*) AS session_count
|
SELECT patient_id, COUNT(*) AS session_count
|
||||||
@ -417,7 +417,7 @@ class DatabaseManager:
|
|||||||
''', (f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', size, offset))
|
''', (f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', size, offset))
|
||||||
else:
|
else:
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
SELECT p.*, COALESCE(ds.session_count, 0) AS detection_count
|
SELECT p.*, COALESCE(ds.session_count, 0) AS num
|
||||||
FROM patients p
|
FROM patients p
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT patient_id, COUNT(*) AS session_count
|
SELECT patient_id, COUNT(*) AS session_count
|
||||||
@ -738,6 +738,40 @@ class DatabaseManager:
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
cursor.execute(sql, update_values)
|
cursor.execute(sql, update_values)
|
||||||
|
cursor.execute('SELECT patient_id, creator_id, start_time, end_time, status FROM detection_sessions WHERE id = ?', (session_id,))
|
||||||
|
srow = cursor.fetchone()
|
||||||
|
if srow:
|
||||||
|
patient_id = srow['patient_id']
|
||||||
|
creator_id = srow['creator_id']
|
||||||
|
session_status = srow['status']
|
||||||
|
start_time = srow['start_time']
|
||||||
|
end_time = srow['end_time']
|
||||||
|
doctor_name = ''
|
||||||
|
if creator_id:
|
||||||
|
cursor.execute('SELECT name FROM users WHERE id = ?', (creator_id,))
|
||||||
|
urow = cursor.fetchone()
|
||||||
|
if urow:
|
||||||
|
try:
|
||||||
|
doctor_name = dict(urow).get('name') or ''
|
||||||
|
except Exception:
|
||||||
|
doctor_name = urow[0] if urow and len(urow) > 0 else ''
|
||||||
|
check_time = end_time or start_time or self.get_china_time()
|
||||||
|
mh_obj = {}
|
||||||
|
try:
|
||||||
|
cursor.execute('SELECT medical_history FROM patients WHERE id = ?', (patient_id,))
|
||||||
|
prow = cursor.fetchone()
|
||||||
|
if prow and prow[0]:
|
||||||
|
try:
|
||||||
|
mh_obj = json.loads(prow[0]) if isinstance(prow[0], str) else {}
|
||||||
|
except Exception:
|
||||||
|
mh_obj = {}
|
||||||
|
except Exception:
|
||||||
|
mh_obj = {}
|
||||||
|
mh_obj['doctor'] = doctor_name
|
||||||
|
mh_obj['status'] = session_status or ''
|
||||||
|
mh_obj['lastcheck_time'] = str(check_time) if check_time is not None else self.get_china_time()
|
||||||
|
now_str = self.get_china_time()
|
||||||
|
cursor.execute('UPDATE patients SET medical_history = ?, updated_at = ? WHERE id = ?', (json.dumps(mh_obj, ensure_ascii=False), now_str, patient_id))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
updated_info = []
|
updated_info = []
|
||||||
|
|||||||
@ -28,16 +28,17 @@
|
|||||||
<el-table-column prop="id" label="患者ID" min-width="120" align="center" />
|
<el-table-column prop="id" label="患者ID" min-width="120" align="center" />
|
||||||
<el-table-column prop="name" label="患者姓名" width="100" align="center" />
|
<el-table-column prop="name" label="患者姓名" width="100" align="center" />
|
||||||
<el-table-column prop="gender" label="性别" width="120" align="center" />
|
<el-table-column prop="gender" label="性别" width="120" align="center" />
|
||||||
<el-table-column prop="num" label="测试次数" width="100" align="center" />
|
<el-table-column prop="num" label="检测次数" width="100" align="center" />
|
||||||
<el-table-column prop="updated_at" label="最近测试时间" min-width="100" align="center" />
|
<el-table-column prop="updated_at" label="最近检测时间" min-width="100" align="center" />
|
||||||
<el-table-column prop="status" label="状态" align="center" width="100">
|
<el-table-column prop="status" label="状态" align="center" width="120">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div v-if="!scope.row.status"
|
<div v-if="!scope.row.status" class="unprocessed-status">未处理</div>
|
||||||
class="unprocessed-status">未处理</div>
|
<div v-else-if="scope.row.status === 'completed' || scope.row.status === 'checked'" class="processed-status">检测已完成</div>
|
||||||
<div v-else class="processed-status">已处理</div>
|
<div v-else-if="scope.row.status === 'reported'" class="processed-status">报告已生成</div>
|
||||||
|
<div v-else class="processed-status">{{ scope.row.status }}</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="doctor" label="测试医生" min-width="80" align="center" />
|
<el-table-column prop="doctor" label="检测医生" min-width="80" align="center" />
|
||||||
<el-table-column label="操作" width="100">
|
<el-table-column label="操作" width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
|
|
||||||
@ -453,10 +454,28 @@ const loadPatients = async () => {
|
|||||||
if (response.success) {
|
if (response.success) {
|
||||||
// 如果返回的是分页数据对象,提取patients数组
|
// 如果返回的是分页数据对象,提取patients数组
|
||||||
if (response.data && Array.isArray(response.data.patients)) {
|
if (response.data && Array.isArray(response.data.patients)) {
|
||||||
patients.value = response.data.patients
|
patients.value = (response.data.patients || []).map(p => {
|
||||||
|
let mh = {}
|
||||||
|
try {
|
||||||
|
mh = typeof p.medical_history === 'string' ? JSON.parse(p.medical_history) : (p.medical_history || {})
|
||||||
|
} catch {}
|
||||||
|
const doctor = mh && mh.doctor ? mh.doctor : ''
|
||||||
|
const status = mh && mh.status ? mh.status : ''
|
||||||
|
const lastcheck = mh && mh.lastcheck_time ? mh.lastcheck_time : ''
|
||||||
|
return { ...p, doctor, status, updated_at: lastcheck || p.updated_at }
|
||||||
|
})
|
||||||
patienttotal.value =response.data.total
|
patienttotal.value =response.data.total
|
||||||
} else if (Array.isArray(response.data)) {
|
} else if (Array.isArray(response.data)) {
|
||||||
patients.value = response.data
|
patients.value = (response.data || []).map(p => {
|
||||||
|
let mh = {}
|
||||||
|
try {
|
||||||
|
mh = typeof p.medical_history === 'string' ? JSON.parse(p.medical_history) : (p.medical_history || {})
|
||||||
|
} catch {}
|
||||||
|
const doctor = mh && mh.doctor ? mh.doctor : ''
|
||||||
|
const status = mh && mh.status ? mh.status : ''
|
||||||
|
const lastcheck = mh && mh.lastcheck_time ? mh.lastcheck_time : ''
|
||||||
|
return { ...p, doctor, status, updated_at: lastcheck || p.updated_at }
|
||||||
|
})
|
||||||
patienttotal.value =response.total
|
patienttotal.value =response.total
|
||||||
} else {
|
} else {
|
||||||
patients.value = []
|
patients.value = []
|
||||||
@ -1124,7 +1143,7 @@ function editClick(){
|
|||||||
|
|
||||||
.unprocessed-status{
|
.unprocessed-status{
|
||||||
margin: auto;
|
margin: auto;
|
||||||
width: 72px;
|
width: 100px;
|
||||||
height: 31px;
|
height: 31px;
|
||||||
line-height: 31px;
|
line-height: 31px;
|
||||||
background-color: rgba(228, 74, 74, 0.3);
|
background-color: rgba(228, 74, 74, 0.3);
|
||||||
@ -1137,7 +1156,7 @@ function editClick(){
|
|||||||
}
|
}
|
||||||
.processed-status{
|
.processed-status{
|
||||||
margin: auto;
|
margin: auto;
|
||||||
width: 72px;
|
width: 100px;
|
||||||
height: 31px;
|
height: 31px;
|
||||||
line-height: 31px;
|
line-height: 31px;
|
||||||
background-color: rgba(59, 242, 198, 0.1);
|
background-color: rgba(59, 242, 198, 0.1);
|
||||||
|
|||||||
@ -1157,15 +1157,15 @@ function disconnectWebSocket() {
|
|||||||
if (devicesSocket) {
|
if (devicesSocket) {
|
||||||
if (devicesSocket.connected) {
|
if (devicesSocket.connected) {
|
||||||
// 取消订阅所有设备
|
// 取消订阅所有设备
|
||||||
try {
|
// try {
|
||||||
devicesSocket.emit('unsubscribe_device', { device_type: 'camera1' })
|
// devicesSocket.emit('unsubscribe_device', { device_type: 'camera1' })
|
||||||
devicesSocket.emit('unsubscribe_device', { device_type: 'camera2' })
|
// devicesSocket.emit('unsubscribe_device', { device_type: 'camera2' })
|
||||||
devicesSocket.emit('unsubscribe_device', { device_type: 'femtobolt' })
|
// devicesSocket.emit('unsubscribe_device', { device_type: 'femtobolt' })
|
||||||
devicesSocket.emit('unsubscribe_device', { device_type: 'imu' })
|
// devicesSocket.emit('unsubscribe_device', { device_type: 'imu' })
|
||||||
devicesSocket.emit('unsubscribe_device', { device_type: 'pressure' })
|
// devicesSocket.emit('unsubscribe_device', { device_type: 'pressure' })
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
console.warn('取消设备订阅时出错:', e)
|
// console.warn('取消设备订阅时出错:', e)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 移除所有事件监听器
|
// 移除所有事件监听器
|
||||||
devicesSocket.removeAllListeners()
|
devicesSocket.removeAllListeners()
|
||||||
@ -1572,7 +1572,7 @@ async function handleDiagnosticInfo(status) {
|
|||||||
async function saveDetectionData() {
|
async function saveDetectionData() {
|
||||||
console.log(tempInfo.value)
|
console.log(tempInfo.value)
|
||||||
if (screenshotLoading.value) return
|
if (screenshotLoading.value) return
|
||||||
|
let titile_height = 24
|
||||||
try {
|
try {
|
||||||
screenshotLoading.value = true
|
screenshotLoading.value = true
|
||||||
// 显示保存进度
|
// 显示保存进度
|
||||||
@ -1623,7 +1623,7 @@ async function saveDetectionData() {
|
|||||||
|
|
||||||
session_id: patientInfo.value.sessionId,
|
session_id: patientInfo.value.sessionId,
|
||||||
patient_id: patientInfo.value.id,
|
patient_id: patientInfo.value.id,
|
||||||
screen_location:screen_location,
|
screen_location:[Math.round(screen_location.x), Math.round(screen_location.y) + titile_height, Math.round(screen_location.width), Math.round(screen_location.height)],
|
||||||
head_pose:head_pose,
|
head_pose:head_pose,
|
||||||
body_pose:null,
|
body_pose:null,
|
||||||
body_image: body_image,
|
body_image: body_image,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user