修改BUG

This commit is contained in:
Flow 2025-06-27 16:17:34 +08:00
parent 16f3c90038
commit 20c16b7c5b
4 changed files with 327 additions and 138 deletions

View File

@ -55,5 +55,9 @@ export const PacsDataApi = {
//更新pacs抓取数据对应项的item
updatePacsDataitem: async (data: PacsDataVO) => {
return await request.put({ url: `/inspect/pacs-data/updatePacsDataitem`, data })
},
//根据体检编号获取PACS数据
getByMedicalSnAndType: async (medicalSn: string,type: string) => {
return await request.get({ url: `/inspect/pacs-data/getByMedicalSnAndType?medicalSn=${medicalSn}&type=${type}` })
}
}

View File

@ -65,6 +65,11 @@ export const PatientApi = {
return await request.put({ url: `/inspect/patient/update`, data })
},
//根据体检编号更新患者状态
updatePatientStatus: async (medicalSn: string, status: number) => {
return await request.put({ url: `/inspect/patient/updatePatientStatus?medicalSn=` + medicalSn + `&status=` + status })
},
// 删除患者信息
deletePatient: async (id: number) => {
return await request.delete({ url: `/inspect/patient/delete?id=` + id })
@ -193,4 +198,5 @@ export const PatientApi = {
url: `/inspect/patient/updateChiefinspector?medicalSn=${medicalSn}&chiefinspectorid=${chiefinspectorid}&chiefinspector=${chiefinspector}`
})
}
}

View File

@ -69,7 +69,7 @@ import { PatientApi, type PatientVO } from '@/api/inspect/inspectpatient'
import { ElMessage } from 'element-plus'
import Pagination from '@/components/Pagination/index.vue'
import dayjs from 'dayjs'
import { InspectOrgApi, InspectOrgVO } from '@/api/inspect/inspectorg/index'
import { InspectOrgApi } from '@/api/inspect/inspectorg/index'
import { getUserProfile } from '@/api/system/user/profile'
import { ElLoading } from 'element-plus'
import { PacsDataApi } from '@/api/inspect/inspectpacsdata'
@ -124,7 +124,9 @@ const handleQuery = async () => {
examhosname: examinfo.orgName,
status: 0
}
const data = await PatientApi.getPatientPage(params)
list.value = data.list || []
total.value = data.total || 0
}
@ -160,7 +162,6 @@ const handleBatchReview = async () => {
}
const currentTimestamp = Date.now()
const currentDate = formatDate(new Date())
//
for (const row of selectedRows.value) {
@ -172,163 +173,261 @@ const handleBatchReview = async () => {
//
const types = ['XCG', 'NCG', 'SHQX', 'ECG', 'YBJC']
//
const existingDataPromises = types.map((type) =>
//
const allCheckPromises = [
//
...types.map((type) =>
PacsDataApi.getPacsDataPage({
code: medicalSn,
type: type,
pageNo: 1,
pageSize: 1
}).catch((error) => {
console.warn(`检查${type}数据是否存在时出错:`, error)
return { list: [], type }
}).then(result => ({ ...result, type }))
),
//
PacsDataApi.getPacsDataPage({
code: medicalSn,
type: type,
type: 'US',
pageNo: 1,
pageSize: 1
}).catch((error) => {
console.warn(`检查${type}数据是否存在时出错:`, error)
return { list: [] }
})
)
console.warn('检查超声数据是否存在时出错:', error)
return { list: [], type: 'US' }
}).then(result => ({ ...result, type: 'US' })),
//
PacsDataApi.getPacsDataPage({
code: medicalSn,
type: 'ECG',
pageNo: 1,
pageSize: 1
}).catch((error) => {
console.warn('检查心电图数据是否存在时出错:', error)
return { list: [], type: 'ECG' }
}).then(result => ({ ...result, type: 'ECG' }))
]
//
const usExistingData = await PacsDataApi.getPacsDataPage({
code: medicalSn,
type: 'US',
pageNo: 1,
pageSize: 1
}).catch((error) => {
console.warn('检查超声数据是否存在时出错:', error)
return { list: [] }
})
//
const allExistingDataResults = await Promise.all(allCheckPromises)
//
const ecgExistingData = await PacsDataApi.getPacsDataPage({
code: medicalSn,
type: 'ECG',
pageNo: 1,
pageSize: 1
}).catch((error) => {
console.warn('检查心电图数据是否存在时出错:', error)
return { list: [] }
})
//
const existingDataResults = await Promise.all(existingDataPromises)
//
//
const typesToSync: string[] = []
existingDataResults.forEach((result, index) => {
const type = types[index]
//
const needsSync =
!result.list ||
let needsSyncECG = false
allExistingDataResults.forEach((result) => {
const needsSync = !result.list ||
result.list.length === 0 ||
(result.list[0] && (!result.list[0].data || result.list[0].data === ''))
if (needsSync) {
typesToSync.push(type)
} else {
console.log(`${type}数据已存在且不为空,跳过同步`)
if (result.type === 'US') {
// additionalPromises
} else if (result.type === 'ECG') {
needsSyncECG = needsSync
} else if (types.includes(result.type) && needsSync) {
typesToSync.push(result.type)
}
if (!needsSync) {
console.log(`${result.type}数据已存在且不为空,跳过同步`)
}
})
//
const needsSyncUS =
!usExistingData.list ||
usExistingData.list.length === 0 ||
(usExistingData.list[0] &&
(!usExistingData.list[0].data || usExistingData.list[0].data === ''))
//
const needsSyncECG =
!ecgExistingData.list ||
ecgExistingData.list.length === 0 ||
(ecgExistingData.list[0] &&
(!ecgExistingData.list[0].data || ecgExistingData.list[0].data === ''))
//
//
const syncPromises: Promise<any>[] = []
//
typesToSync.forEach((type) => {
syncPromises.push(
PatientApi.getReportTj(medicalSn, type).catch((error) => {
console.warn(`获取${type}报告失败:`, error)
return null
})
(async () => {
const startTime = Date.now()
try {
console.log(`${medicalSn} 开始获取${type}报告...`)
const result = await PatientApi.getReportTj(medicalSn, type)
const duration = Date.now() - startTime
console.log(`${medicalSn} 获取${type}报告完成,耗时: ${duration}ms`)
return result
} catch (error) {
const duration = Date.now() - startTime
console.warn(`${medicalSn} 获取${type}报告失败,耗时: ${duration}ms:`, error)
return null
}
})()
)
})
// ========== conclusions.ultrasound ==========
let usReport = null;
try {
usReport = await PatientApi.getUSTj(medicalSn);
console.log('usReport:', usReport); // 便
} catch (error) {
console.warn('获取超声报告失败:', error);
}
// ========== END ==========
// -
const usReportPromise = (async () => {
const startTime = Date.now()
try {
console.log(`${medicalSn} 开始获取超声报告...`)
const result = await PatientApi.getUSTj(medicalSn)
const duration = Date.now() - startTime
console.log(`${medicalSn} 获取超声报告完成,耗时: ${duration}ms`)
return result
} catch (error) {
const duration = Date.now() - startTime
console.warn(`${medicalSn} 获取超声报告失败,耗时: ${duration}ms:`, error)
return null
}
})()
//
if (needsSyncECG) {
syncPromises.push(
PatientApi.GetApiEcgInfo(medicalSn).catch((error) => {
console.warn('获取心电图报告失败:', error)
return null
})
(async () => {
const startTime = Date.now()
try {
console.log(`${medicalSn} 开始获取心电图报告...`)
const result = await PatientApi.GetApiEcgInfo(medicalSn)
const duration = Date.now() - startTime
console.log(`${medicalSn} 获取心电图报告完成,耗时: ${duration}ms`)
return result
} catch (error) {
const duration = Date.now() - startTime
console.warn(`${medicalSn} 获取心电图报告失败,耗时: ${duration}ms:`, error)
return null
}
})()
)
}
//
if (typesToSync.includes('YBJC')) {
syncPromises.push(
PatientApi.GetApiYbjcInfo(medicalSn, cardId).catch((error) => {
console.warn('获取一般检查报告失败:', error)
return null
})
(async () => {
const startTime = Date.now()
try {
console.log(`${medicalSn} 开始获取一般检查报告...`)
const result = await PatientApi.GetApiYbjcInfo(medicalSn, cardId)
const duration = Date.now() - startTime
console.log(`${medicalSn} 获取一般检查报告完成,耗时: ${duration}ms`)
return result
} catch (error) {
const duration = Date.now() - startTime
console.warn(`${medicalSn} 获取一般检查报告失败,耗时: ${duration}ms:`, error)
return null
}
})()
)
}
//
await PatientApi.getZytzInfo(medicalSn, cardId).catch((error) => {
console.warn('获取中医体质辨识报告失败:', error)
})
console.log(`${medicalSn} 开始并行执行 ${syncPromises.length} 个同步请求1个超声报告请求...`)
// getGwPatientInfo
// 🚀
const usStartTime = Date.now()
const usReport = await usReportPromise
const usDuration = Date.now() - usStartTime
console.log(`${medicalSn} 超声报告总耗时: ${usDuration}ms, 结果:`, usReport)
// 🔄
console.log(`${medicalSn} 超声报告获取完成,开始启动其他任务...`)
//
let syncResults: any[] = []
const syncPromise = syncPromises.length > 0 ? Promise.all(syncPromises) : Promise.resolve([])
//
const backgroundPromises: Promise<any>[] = []
if (cardId) {
try {
await PatientApi.getGwPatientInfo(cardId)
console.log(`${medicalSn} 公卫患者信息获取成功`)
} catch (error) {
console.warn(`${medicalSn} 获取公卫患者信息失败:`, error)
//
}
// updatePatientSupplement
try {
await PatientApi.updatePatientSupplement(medicalSn, cardId)
console.log(`${medicalSn} 补充信息更新成功`)
} catch (error) {
console.warn(`${medicalSn} 更新患者补充信息失败:`, error)
}
backgroundPromises.push(
(async () => {
const startTime = Date.now()
try {
console.log(`${medicalSn} 开始获取中医体质辨识报告...`)
const result = await PatientApi.getZytzInfo(medicalSn, cardId)
const duration = Date.now() - startTime
console.log(`${medicalSn} 获取中医体质辨识报告完成,耗时: ${duration}ms`)
return result
} catch (error) {
const duration = Date.now() - startTime
console.warn(`${medicalSn} 获取中医体质辨识报告失败,耗时: ${duration}ms:`, error)
return null
}
})()
)
backgroundPromises.push(
(async () => {
const startTime = Date.now()
try {
console.log(`${medicalSn} 开始获取公卫患者信息...`)
await PatientApi.getGwPatientInfo(cardId)
const duration = Date.now() - startTime
console.log(`${medicalSn} 获取公卫患者信息完成,耗时: ${duration}ms`)
return true
} catch (error) {
const duration = Date.now() - startTime
console.warn(`${medicalSn} 获取公卫患者信息失败,耗时: ${duration}ms:`, error)
return false
}
})()
)
backgroundPromises.push(
(async () => {
const startTime = Date.now()
try {
console.log(`${medicalSn} 开始更新患者补充信息...`)
await PatientApi.updatePatientSupplement(medicalSn, cardId)
const duration = Date.now() - startTime
console.log(`${medicalSn} 更新患者补充信息完成,耗时: ${duration}ms`)
return true
} catch (error) {
const duration = Date.now() - startTime
console.warn(`${medicalSn} 更新患者补充信息失败,耗时: ${duration}ms:`, error)
return false
}
})()
)
}
//
if (syncPromises.length === 0) {
console.log(`${medicalSn} 所有报告数据已存在,直接进行保存`)
} else {
const results = await Promise.all(syncPromises)
//
if (syncPromises.length > 0) {
console.log(`${medicalSn} 等待 ${syncPromises.length} 个同步请求完成...`)
const syncStartTime = Date.now()
syncResults = await syncPromise
const syncDuration = Date.now() - syncStartTime
console.log(`${medicalSn} 同步请求完成,总耗时: ${syncDuration}ms`)
}
//
const allFailed = results.every((result) => result === null)
//
if (backgroundPromises.length > 0) {
console.log(`${medicalSn} 后台执行 ${backgroundPromises.length} 个非关键请求...`)
Promise.all(backgroundPromises).then(() => {
console.log(`${medicalSn} 所有后台任务完成`)
}).catch(error => {
console.warn(`${medicalSn} 部分后台任务失败:`, error)
})
}
console.log(`${medicalSn} 关键请求执行完毕,开始处理结果...`)
//
if (syncPromises.length > 0) {
const allFailed = syncResults.every((result) => result === null)
if (allFailed) {
console.error(`${medicalSn} 所有报告同步失败`)
failCount++
continue
}
} else {
console.log(`${medicalSn} 所有报告数据已存在,直接进行保存`)
}
//
await new Promise((resolve) => setTimeout(resolve, 500))
// 200ms
await new Promise((resolve) => setTimeout(resolve, 200))
//
console.log(`${medicalSn} 开始检查检查项目数据...`)
// PACS
const checkDataStartTime = Date.now()
const pacsDataCheck = await checkPacsDataComplete(medicalSn)
const checkDataDuration = Date.now() - checkDataStartTime
console.log(`${medicalSn} 检查项目数据完整性完成,耗时: ${checkDataDuration}ms`)
if (!pacsDataCheck.isComplete) {
console.warn(`${medicalSn} 检查项目数据不完整,跳过保存:`, pacsDataCheck.missingItems)
failCount++
@ -339,12 +438,16 @@ const handleBatchReview = async () => {
try {
console.log(`${medicalSn} 开始保存检查结果...`)
// 1.
const itemsRes = await PatientitemsApi.getPatientitemsPage({
medicalSn: medicalSn,
pageNo: 1,
pageSize: 100
})
// 1.
const itemsStartTime = Date.now()
console.log(`${medicalSn} 开始获取患者检查项目...`)
const itemsRes = await PatientitemsApi.getPatientitemsPage({
medicalSn: medicalSn,
pageNo: 1,
pageSize: 100
})
const itemsDuration = Date.now() - itemsStartTime
console.log(`${medicalSn} 获取患者检查项目完成,耗时: ${itemsDuration}ms`)
if (itemsRes.list && itemsRes.list.length > 0) {
// 2. PACS
@ -407,7 +510,11 @@ const handleBatchReview = async () => {
// PACS
try {
const pacsStartTime = Date.now()
console.log(`${medicalSn} 开始获取PACS数据...`)
const pacsRes = await PacsDataApi.getPacsDataDetail(medicalSn)
const pacsDuration = Date.now() - pacsStartTime
console.log(`${medicalSn} 获取PACS数据完成耗时: ${pacsDuration}ms`)
if (pacsRes && pacsRes.length > 0) {
const typeGroups: Record<string, any[]> = {}
pacsRes.forEach((item) => {
@ -565,22 +672,36 @@ const handleBatchReview = async () => {
})
// 4.
const updateItemsStartTime = Date.now()
console.log(`${medicalSn} 开始批量更新检查项目...`)
await PatientitemsApi.updatePatientitemsBatch(allUpdatedItems)
const updateItemsDuration = Date.now() - updateItemsStartTime
console.log(`${medicalSn} 批量更新检查项目完成,耗时: ${updateItemsDuration}ms`)
// 5.
await PatientApi.updatePatient({
id: row.id,
status: 1
})
const updatePatientStartTime = Date.now()
console.log(`${medicalSn} 开始更新患者状态...`)
await PatientApi.updatePatientStatus(medicalSn, 1)
const updatePatientDuration = Date.now() - updatePatientStartTime
console.log(`${medicalSn} 更新患者状态完成,耗时: ${updatePatientDuration}ms`)
//
const doctorStartTime = Date.now()
console.log(`${medicalSn} 开始获取医生信息...`)
const res = await DoctorApi.getDoctorPage({
pageNo: 1,
pageSize: 100, //
orgid: userProfile.deptId
})
const doctor = res.list.find(doctor => doctor.doctorname === userProfile.nickname)
const doctorDuration = Date.now() - doctorStartTime
console.log(`${medicalSn} 获取医生信息完成,耗时: ${doctorDuration}ms`)
const updateDoctorStartTime = Date.now()
console.log(`${medicalSn} 开始更新总检医生...`)
await PatientApi.updateChiefinspector(medicalSn, doctor.doctorid, doctor.doctorname)
const updateDoctorDuration = Date.now() - updateDoctorStartTime
console.log(`${medicalSn} 更新总检医生完成,耗时: ${updateDoctorDuration}ms`)
// 6.
let summaryContent = ''
@ -608,25 +729,41 @@ const handleBatchReview = async () => {
// summaryResult
if (conclusions.general.summary && conclusions.general.summary.trim()) {
const updateSummaryStartTime = Date.now()
console.log(`${medicalSn} 开始更新一般检查结论...`)
await PatientApi.updatemedicalSn({
medicalSn: medicalSn,
summaryResult: conclusions.general.summary
} as any)
const updateSummaryDuration = Date.now() - updateSummaryStartTime
console.log(`${medicalSn} 更新一般检查结论完成,耗时: ${updateSummaryDuration}ms`)
}
//
if (summaryContent.trim()) {
const updateContentStartTime = Date.now()
console.log(`${medicalSn} 开始保存汇总内容...`)
await PatientApi.updatemedicalSn({
medicalSn: medicalSn,
summaryResult: summaryContent
} as any)
const updateContentDuration = Date.now() - updateContentStartTime
console.log(`${medicalSn} 保存汇总内容完成,耗时: ${updateContentDuration}ms`)
}
// 7.
const generateReportStartTime = Date.now()
console.log(`${medicalSn} 开始生成体检报告...`)
PatientApi.generateReport(medicalSn)
const generateReportDuration = Date.now() - generateReportStartTime
console.log(`${medicalSn} 生成体检报告完成,耗时: ${generateReportDuration}ms`)
// 8.
const pushInfoStartTime = Date.now()
console.log(`${medicalSn} 开始体检报告信息回传...`)
PatientApi.PushJYPatientInfo(medicalSn)
const pushInfoDuration = Date.now() - pushInfoStartTime
console.log(`${medicalSn} 体检报告信息回传完成,耗时: ${pushInfoDuration}ms`)
console.log(`${medicalSn} 保存完成`)
successCount++
@ -739,14 +876,6 @@ const checkPacsDataComplete = async (medicalSn: string) => {
}
}
//
const formatDate = (date: Date) => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
const handleSelectionChange = (rows: PatientVO[]) => {
selectedRows.value = rows
}

View File

@ -161,6 +161,20 @@
<span>{{ reportData.phoneNum }}</span>
</div>
</div>
<div class="info-row">
<div class="info-item" v-if="cbc">
<label style="color: red;">血常规</label>
<span>{{ cbc }}</span>
</div>
<div class="info-item" v-if="rt">
<label style="color: red;">尿常规</label>
<span>{{ rt }}</span>
</div>
<div class="info-item" v-if="bt">
<label style="color: red;">生化</label>
<span>{{ bt }}</span>
</div>
</div>
</div>
</div>
@ -946,6 +960,10 @@ const loadPatientData = async (patient) => {
} catch (error) {
console.error('获取PACS数据失败:', error)
}
// PACS
await fetchPacsStatus(patient.medicalSn)
} catch (error) {
console.error('加载患者数据失败:', error)
ElMessage.error('加载患者数据失败')
@ -974,6 +992,12 @@ const handlePatientSelect = async (patient) => {
biochemical: { summary: '' },
summary: { summary: '' }
}
// PACS
cbc.value = ''
rt.value = ''
bt.value = ''
//
selectedPatient.value = patient
@ -1483,7 +1507,36 @@ const checkEditPermission = () => {
return true
}
//
// 尿
const cbc = ref('')
const rt = ref('')
const bt = ref('')
// PACS
const fetchPacsStatus = async (medicalSn) => {
//
const typeMap = [
{ type: 'cbc', ref: cbc },
{ type: 'rt', ref: rt },
{ type: 'bt', ref: bt }
]
for (const item of typeMap) {
try {
const res = await PacsDataApi.getByMedicalSnAndType(medicalSn, item.type)
if (res && res.status) {
// status
item.ref.value = res.status || ''
} else {
item.ref.value = ''
}
} catch (e) {
console.error(`获取${item.type}状态失败:`, e)
item.ref.value = ''
}
}
}
// handleSyncfetchPacsStatus
const handleSync = async () => {
try {
const loading = ElLoading.service({
@ -1491,7 +1544,6 @@ const handleSync = async () => {
text: '同步中...',
background: 'rgba(255, 255, 255, 0.7)'
})
try {
if (!selectedPatient.value?.medicalSn) {
throw new Error('未选择患者或体检编号为空')
@ -1649,7 +1701,7 @@ const handleSync = async () => {
// BMI
processAutoFields()
loading.close()
ElMessage.success(`同步成功`)
} catch (error) {
@ -1718,6 +1770,11 @@ const handleRefresh = async (e) => {
biochemical: { summary: '' }
}
// PACS
cbc.value = ''
rt.value = ''
bt.value = ''
//
searchQuery.value = ''
dateRange.value = []
@ -2207,11 +2264,7 @@ const handleSaveAllResults = async () => {
// - API
if (selectedPatient.value) {
// status1
await PatientApi.updatePatient({
id: selectedPatient.value.id,
status: 1, //
})
await PatientApi.updatePatientStatus(selectedPatient.value.medicalSn, 1)
//
selectedPatient.value.status = 1
@ -2873,10 +2926,7 @@ const resetPatientStatus = async (patient) => {
try {
// status0
await PatientApi.updatePatient({
id: patient.id,
status: 0, //
})
await PatientApi.updatePatientStatus(patient.medicalSn, 0)
//
patient.status = 0