增加同步接口以及功能

This commit is contained in:
Euni4U 2025-03-11 14:52:07 +08:00
parent ec21ddbaf8
commit 851b555172
3 changed files with 520 additions and 289 deletions

View File

@ -18,6 +18,7 @@ export interface PatientitemsVO {
itemStatus: string // 0未检 1已检 2放弃 3挂起择日检(待查) itemStatus: string // 0未检 1已检 2放弃 3挂起择日检(待查)
createTime: Date // 创建时间 createTime: Date // 创建时间
positive: string // 是否阳性 1阳性 positive: string // 是否阳性 1阳性
analyse: string // 检查结果分析
inspectdoctor: string // 检查医生 inspectdoctor: string // 检查医生
inspecttime: Date // 检查时间 inspecttime: Date // 检查时间
groupname: string // 模块名称 groupname: string // 模块名称
@ -70,4 +71,9 @@ export const PatientitemsApi = {
exportPatientitems: async (params) => { exportPatientitems: async (params) => {
return await request.download({ url: `/Inspect/patientitems/export-excel`, params }) return await request.download({ url: `/Inspect/patientitems/export-excel`, params })
}, },
//同步患者数据和检查项
createPatientapiInfo: async () => {
return await request.get({ url: `/Inspect/patientitems/apiPatientInfo` })
}
} }

View File

@ -108,7 +108,7 @@ const getImageUrls = async () => {
'ultrasound': ['ultrasound', 'us', '超声', '彩超', 'b超', 'doppler'], 'ultrasound': ['ultrasound', 'us', '超声', '彩超', 'b超', 'doppler'],
'ecg': ['ecg', 'ekg', '心电图', 'electrocardiogram'], 'ecg': ['ecg', 'ekg', '心电图', 'electrocardiogram'],
'blood': ['blood', 'cbc', '血常规', '血液', 'bloodtest'], 'blood': ['blood', 'cbc', '血常规', '血液', 'bloodtest'],
'urine': ['urine', 'ua', '尿常规', '尿液', 'urinalysis'] 'urine': ['urine', 'ua', '尿常规', '尿液', 'urinalysis','RT','rt']
} }
// //

View File

@ -5,15 +5,15 @@
<div class="list-header"> <div class="list-header">
<div class="filter-options"> <div class="filter-options">
<div class="header-title"> <div class="header-title">
人员列表 <span>患者列表</span>
<el-button <el-button
class="refresh-btn"
:icon="Refresh"
circle
type="success" type="success"
@click="handleRefresh"
size="small" size="small"
/> @click="handleRefresh"
:icon="Refresh"
>
刷新
</el-button>
</div> </div>
</div> </div>
@ -130,7 +130,7 @@
<div class="info-row"> <div class="info-row">
<div class="info-item"> <div class="info-item">
<label>性别</label> <label>性别</label>
<span>{{ reportData.gender }}</span> <span>{{ gender }}</span>
</div> </div>
<div class="info-item"> <div class="info-item">
<label>年龄</label> <label>年龄</label>
@ -303,18 +303,16 @@
<div class="action-footer"> <div class="action-footer">
<div class="left-section"> <div class="left-section">
<span>检查医生</span> <span>检查医生</span>
<span>{{ user?.nickname || '暂无' }}</span> <span>{{ selectedPatient?.status === '1' || selectedPatient?.status === 1 ? (inspectDoctor || ' ') : ' ' }}</span>
<span style="margin-left: 100px;">检查日期{{ formattedMedicalDateTime }}</span> <span style="margin-left: 100px;">检查日期{{ selectedPatient?.status === '1' || selectedPatient?.status === 1 ? (inspectTime || ' ') : ' ' }}</span>
</div> </div>
<div class="right-section"> <div class="right-section">
<div class="action-buttons"> <div class="action-buttons">
<button class="action-btn" @click="checkEditPermission">同步结果</button> <button class="action-btn" @click="checkEditPermission" :disabled="isDisabled">弃检</button>
<button class="action-btn">报告预览</button>
<button class="action-btn" @click="checkEditPermission">弃检</button>
<button <button
v-if="!isReadOnly"
class="action-btn primary" class="action-btn primary"
@click="handleSaveAllResults" @click="handleSaveAllResults"
:disabled="isDisabled"
> >
保存所有结果 保存所有结果
</button> </button>
@ -529,6 +527,13 @@ const getPatientList = async () => {
pageSize: pageSize.value pageSize: pageSize.value
} }
const res = await PatientApi.getPatientPage(params) const res = await PatientApi.getPatientPage(params)
//
if (res.list && res.list.length > 0) {
//
//
}
patients.value = res.list patients.value = res.list
originalPatients.value = res.list // originalPatients.value = res.list //
filteredPatients.value = res.list // filteredPatients.value = res.list //
@ -588,7 +593,7 @@ try {
} }
} }
// // loadPatientData
const loadPatientData = async (patient) => { const loadPatientData = async (patient) => {
try { try {
// //
@ -597,7 +602,10 @@ const loadPatientData = async (patient) => {
const cachedData = patientDataCache.value.get(cacheKey) const cachedData = patientDataCache.value.get(cacheKey)
reportData.value = cachedData.reportData reportData.value = cachedData.reportData
examItems.value = cachedData.examItems examItems.value = cachedData.examItems
conclusionData.value = cachedData.conclusionData
currentTab.value = cachedData.currentTab currentTab.value = cachedData.currentTab
inspectDoctor.value = cachedData.inspectDoctor || ''
inspectTime.value = cachedData.inspectTime || ''
return return
} }
@ -609,79 +617,41 @@ const loadPatientData = async (patient) => {
try { try {
// ID // ID
const [userProfile, patientData, itemsRes] = await Promise.all([ const userProfile = await getUserProfile()
getUserProfile(), user.value = userProfile
PatientApi.getPatient(patient.id),
PatientitemsApi.getPatientitemsPage({ //
const patientData = await PatientApi.getPatient(patient.id)
reportData.value = patientData
//
const hasItems = await checkPatientHasItems(patient.medicalSn)
//
if (!hasItems) {
console.log('患者没有检查项目,自动同步')
try {
await PatientitemsApi.createPatientapiInfo({
medicalSn: patient.medicalSn
})
console.log('自动同步成功')
} catch (syncError) {
console.error('自动同步失败:', syncError)
//
}
}
//
const itemsRes = await PatientitemsApi.getPatientitemsPage({
medicalSn: patient.medicalSn, medicalSn: patient.medicalSn,
pageNo: 1, pageNo: 1,
pageSize: 100 pageSize: 100
}) })
])
user.value = userProfile //
//
isImageDepartment.value = checkIsImageDepartment(userProfile.deptId)
reportData.value = patientData
//
if (!isImageDepartment.value && !isBloodTest.value) {
if (itemsRes.list && itemsRes.list.length > 0) { if (itemsRes.list && itemsRes.list.length > 0) {
const itemsByCategory = { //
general: [], const groupedItems = {}
ultrasound: [],
ecg: [],
blood: [],
urine: []
}
//
if (itemsRes.list.length > 0) {
examConclusion.value = itemsRes.list[0].analyse || ''
}
//
itemsRes.list.forEach(item => {
const itemName = (item.itemName || '').toLowerCase()
let category = 'general' //
if (itemName.includes('彩超') || itemName.includes('超声') || itemName.includes('b超')) {
category = 'ultrasound'
} else if (itemName.includes('心电图') || itemName.includes('ecg') || itemName.includes('ekg')) {
category = 'ecg'
} else if (itemName.includes('血常规') || itemName.includes('血细胞') || itemName.includes('血红蛋白')) {
category = 'blood'
} else if (itemName.includes('尿常规') || itemName.includes('尿液分析')) {
category = 'urine'
}
const processedItem = {
id: item.id,
name: item.itemName,
value: item.itemResult || '',
unit: item.unit,
reference: `${item.lowValue}-${item.highValue}`,
note: getStatusNote(item),
risk: getRiskLevel(item),
status: getRowStatus(item),
positive: item.positive === '1' ? '阳性' : '阴性',
itemStatus: item.itemStatus,
examDescription: item.examDescription || '',
analyse: item.analyse || '',
sectionID: item.sectionID
}
itemsByCategory[category].push(processedItem)
})
examItems.value = itemsByCategory
// ""
currentTab.value = 'all'
}
}
// //
const conclusions = { const conclusions = {
@ -692,23 +662,117 @@ const loadPatientData = async (patient) => {
urine: { summary: '' } urine: { summary: '' }
} }
itemsRes.list.forEach(item => { //
const itemName = (item.itemName || '').toLowerCase() inspectDoctor.value = ''
let category = 'general' inspectTime.value = ''
if (itemName.includes('彩超') || itemName.includes('超声')) { //
category = 'ultrasound' const checkedItems = itemsRes.list.filter(item =>
} else if (itemName.includes('心电图')) { item.itemStatus === '1' &&
category = 'ecg' item.sectionID === user.value.deptId
} else if (itemName.includes('血常规')) { )
category = 'blood'
} else if (itemName.includes('尿常规')) { if (checkedItems.length > 0) {
category = 'urine' // 使
const firstCheckedItem = checkedItems[0]
inspectDoctor.value = firstCheckedItem.inspectdoctor || ''
//
if (firstCheckedItem.inspecttime) {
const inspectDate = new Date(Number(firstCheckedItem.inspecttime))
inspectTime.value = formatDate(inspectDate)
}
} }
itemsRes.list.forEach(item => {
//
const category = getCategoryByItemName(item.itemName || '')
if (!groupedItems[category]) {
groupedItems[category] = []
}
//
const processedItem = processItemData(item)
groupedItems[category].push(processedItem)
//
processConclusion(item, category, conclusions)
})
examItems.value = groupedItems
conclusionData.value = conclusions
//
patientDataCache.value.set(cacheKey, {
reportData: { ...reportData.value },
examItems: { ...examItems.value },
conclusionData: { ...conclusionData.value },
currentTab: currentTab.value,
inspectDoctor: inspectDoctor.value,
inspectTime: inspectTime.value
})
}
} catch (error) {
console.error('加载患者数据失败:', error)
ElMessage.error('加载患者数据失败')
} finally {
loading.close()
}
} catch (error) {
console.error('加载患者数据失败:', error)
ElMessage.error('加载患者数据失败')
}
}
//
const getCategoryByItemName = (itemName) => {
itemName = itemName.toLowerCase()
if (itemName.includes('超声') || itemName.includes('彩超') || itemName.includes('b超')) {
return 'ultrasound'
} else if (itemName.includes('心电图') || itemName.includes('ecg') || itemName.includes('ekg')) {
return 'ecg'
} else if (itemName.includes('血常规') || itemName.includes('血细胞') || itemName.includes('血红蛋白')) {
return 'blood'
} else if (itemName.includes('尿常规') || itemName.includes('尿液分析')) {
return 'urine'
} else {
return 'general'
}
}
//
const processItemData = (item) => {
return {
id: item.id,
name: item.itemName,
code: item.itemCode,
value: item.itemResult,
originalValue: item.itemResult,
unit: item.unit,
reference: item.lowValue !== null && item.highValue !== null ?
`${item.lowValue}-${item.highValue}` : 'null-null',
status: getRowStatus(item),
risk: getRiskLevel(item),
note: getStatusNote(item),
itemStatus: item.itemStatus || '0',
sectionID: item.sectionID
}
}
//
const processConclusion = (item, category, conclusions) => {
if (category === 'ultrasound' || category === 'ecg') {
//
if (item.examDescription) {
conclusions[category].finding = item.examDescription
}
if (item.itemResult) {
conclusions[category].diagnosis = item.itemResult
}
// analyse
if (item.analyse) { if (item.analyse) {
if (['ultrasound', 'ecg'].includes(category)) {
//
const parts = item.analyse.split('\n') const parts = item.analyse.split('\n')
parts.forEach(part => { parts.forEach(part => {
if (part.startsWith('检查所见:')) { if (part.startsWith('检查所见:')) {
@ -717,28 +781,13 @@ const loadPatientData = async (patient) => {
conclusions[category].diagnosis = part.replace('检查结果:', '') conclusions[category].diagnosis = part.replace('检查结果:', '')
} }
}) })
}
} else { } else {
// - 使analyse
if (item.analyse) {
conclusions[category].summary = item.analyse conclusions[category].summary = item.analyse
} }
} }
})
conclusionData.value = conclusions
patientDataCache.value.set(cacheKey, {
reportData: { ...reportData.value },
examItems: { ...examItems.value },
currentTab: currentTab.value
})
} finally {
loading.close()
}
} catch (error) {
console.error('获取患者详细信息出错:', error)
ElMessage.error('获取患者详细信息失败')
}
} }
// //
@ -864,6 +913,44 @@ try {
// //
if (patient.medicalSn) { if (patient.medicalSn) {
await getpatientitemData(patient.medicalSn) await getpatientitemData(patient.medicalSn)
//
try {
const params = {
medicalSn: patient.medicalSn,
pageNo: 1,
pageSize: 100
}
const itemsRes = await PatientitemsApi.getPatientitemsPage(params)
if (itemsRes.list && itemsRes.list.length > 0) {
//
const checkedItems = itemsRes.list.filter(item =>
item.itemStatus === '1' &&
(item.sectionID === user.value.deptId || item.sectionID == user.value.deptId)
)
if (checkedItems.length > 0) {
// 使
const firstCheckedItem = checkedItems[0]
inspectDoctor.value = firstCheckedItem.inspectdoctor || ''
//
if (firstCheckedItem.inspecttime) {
const inspectDate = new Date(Number(firstCheckedItem.inspecttime))
inspectTime.value = formatDate(inspectDate)
}
} else {
//
inspectDoctor.value = ''
inspectTime.value = ''
}
}
} catch (error) {
console.error('获取检查医生和检查日期失败:', error)
inspectDoctor.value = ''
inspectTime.value = ''
}
} }
// //
@ -877,14 +964,6 @@ try {
} }
} }
//
const isSpecialExam = computed(() => {
if (!selectedPatient.value || !currentTab.value) return false
//
return ['ultrasound', 'ecg', 'blood', 'urine'].includes(currentTab.value)
})
onMounted(async () => { onMounted(async () => {
// //
patients.value = [] patients.value = []
@ -1062,10 +1141,18 @@ return date.toLocaleDateString('zh-CN', {
// //
const age = computed(() => { const age = computed(() => {
if (!reportData.value.birthday) return '' if (!reportData.value.cardId) return ''
// YYYY-MM-DD //
const birthDate = new Date(reportData.value.birthday) const idCard = reportData.value.cardId
if (idCard.length !== 18) return '' // 18
// ( YYYYMMDD)
const birthYear = idCard.substring(6, 10)
const birthMonth = idCard.substring(10, 12)
const birthDay = idCard.substring(12, 14)
const birthDate = new Date(`${birthYear}-${birthMonth}-${birthDay}`)
if (isNaN(birthDate.getTime())) return '' // if (isNaN(birthDate.getTime())) return '' //
const today = new Date() const today = new Date()
@ -1080,17 +1167,25 @@ if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate()))
return age return age
}) })
//
const gender = computed(() => {
if (!reportData.value.cardId) return reportData.value.gender || ''
//
const idCard = reportData.value.cardId
if (idCard.length !== 18) return reportData.value.gender || '' // 18
// 17
const genderCode = parseInt(idCard.charAt(16))
return genderCode % 2 === 1 ? '男' : '女'
})
// //
const selectedPatient = ref(null) const selectedPatient = ref(null)
// //
const user = ref(null) const user = ref(null)
//
const loadData = async () => {
reportData.value = await PatientApi.getPatient(1)
}
// //
const isAllItemsChecked = computed(() => { const isAllItemsChecked = computed(() => {
if (!sortedExamItems.value || sortedExamItems.value.length === 0) return false if (!sortedExamItems.value || sortedExamItems.value.length === 0) return false
@ -1099,13 +1194,159 @@ return sortedExamItems.value.every(item => item.itemStatus === '1')
// //
const checkEditPermission = () => { const checkEditPermission = () => {
if (isAllItemsChecked.value) { //
if (selectedPatient.value && (selectedPatient.value.status === '1' || selectedPatient.value.status === 1)) {
ElMessage.warning('该患者检查已完成,不可进行编辑')
return false
}
//
const currentDeptItems = Object.values(examItems.value)
.flat()
.filter(item => item.sectionID === user.value?.deptId)
if (currentDeptItems.length > 0 && currentDeptItems.every(item => item.itemStatus === '1')) {
ElMessage.warning('所有检查项目已完成,不可进行编辑') ElMessage.warning('所有检查项目已完成,不可进行编辑')
return false return false
} }
return true return true
} }
//
const handleSyncResults = async () => {
if (!selectedPatient.value?.medicalSn) {
console.warn('未选择患者,无法同步')
ElMessage.warning('请先选择患者')
return
}
try {
console.log('开始同步患者数据, 体检编号:', selectedPatient.value.medicalSn)
const loading = ElLoading.service({
lock: true,
text: '同步中...',
background: 'rgba(255, 255, 255, 0.7)'
})
//
const existingItems = await PatientitemsApi.getPatientitemsPage({
medicalSn: selectedPatient.value.medicalSn,
pageNo: 1,
pageSize: 1
})
//
if (existingItems.list && existingItems.list.length > 0) {
console.log('该患者已有检查项目,无需再次同步')
loading.close()
ElMessage.info('该患者已有检查项目,无需再次同步')
//
await loadPatientData(selectedPatient.value)
return
}
//
const syncResult = await PatientitemsApi.createPatientapiInfo({
medicalSn: selectedPatient.value.medicalSn
})
console.log('同步接口调用成功:', syncResult)
//
console.log('重新加载患者数据')
await loadPatientData(selectedPatient.value)
console.log('患者数据加载完成')
loading.close()
console.log('同步操作完成')
ElMessage.success('同步成功')
} catch (error) {
console.error('同步失败:', error)
ElMessage.error('同步失败,请稍后重试')
}
}
//
const handleRefresh = async () => {
try {
const loading = ElLoading.service({
lock: true,
text: '刷新中...',
background: 'rgba(255, 255, 255, 0.7)'
})
//
selectedPeriod.value = 'reset'
showDatePicker.value = false
customDateRange.value = []
//
searchQuery.value = ''
//
try {
//
const existingPatients = await PatientApi.getPatientPage({
pageNo: 1,
pageSize: 100,
examDate: formatDate(new Date())
})
const existingMedicalSns = new Set()
if (existingPatients.list && existingPatients.list.length > 0) {
existingPatients.list.forEach(patient => {
if (patient.medicalSn) {
existingMedicalSns.add(patient.medicalSn)
}
})
}
//
if (existingMedicalSns.size < 5) {
//
await PatientitemsApi.createPatientapiInfo({})
} else {
ElMessage.info('已有足够的患者数据,跳过全量同步')
}
} catch (syncError) {
console.error('同步数据失败:', syncError)
//
}
//
selectedPatient.value = null
//
pageNo.value = 1
//
await getPatientList()
loading.close()
ElMessage.success('刷新成功')
} catch (error) {
console.error('刷新失败:', error)
ElMessage.error('刷新失败')
}
}
//
const checkPatientHasItems = async (medicalSn) => {
try {
const existingItems = await PatientitemsApi.getPatientitemsPage({
medicalSn: medicalSn,
pageNo: 1,
pageSize: 1
})
return existingItems.list && existingItems.list.length > 0
} catch (error) {
console.error('检查患者检查项目失败:', error)
return false
}
}
// //
const handleResultChange = (item) => { const handleResultChange = (item) => {
if (!checkEditPermission()) { if (!checkEditPermission()) {
@ -1172,14 +1413,26 @@ switch (type) {
} }
} }
// //
const isDisabled = computed(() => { const isDisabled = computed(() => {
return isAllItemsChecked.value //
if (selectedPatient.value?.status === '1' || selectedPatient.value?.status === 1) return true
//
const currentDeptItems = Object.values(examItems.value)
.flat()
.filter(item => item.sectionID === user.value?.deptId)
if (currentDeptItems.length > 0 && currentDeptItems.every(item => item.itemStatus === '1')) {
return true
}
return false
}) })
// //
const isReadOnly = computed(() => { const isReadOnly = computed(() => {
return isAllItemsChecked.value return isDisabled.value
}) })
// //
@ -1241,20 +1494,10 @@ return allChecked ? '1' : '0'
// //
const getStatusText = (patient) => { const getStatusText = (patient) => {
if (patient.examStatus === '1') { // 使 status
if (patient.status === '1' || patient.status === 1) {
return '已检查' return '已检查'
} }
if (selectedPatient.value?.id === patient.id) {
const currentDeptItems = Object.values(examItems.value)
.flat()
.filter(item => item.sectionID === user.value?.deptId)
if (currentDeptItems.length > 0 && currentDeptItems.every(item => item.itemStatus === '1')) {
return '已检查'
}
}
return '待检查' return '待检查'
} }
@ -1307,32 +1550,6 @@ const formatDate = (date) => {
return `${year}-${month}-${day}` return `${year}-${month}-${day}`
} }
//
const handleRefresh = async () => {
try {
//
selectedPeriod.value = 'reset'
showDatePicker.value = false
customDateRange.value = []
//
searchQuery.value = ''
//
selectedPatient.value = null
//
pageNo.value = 1
//
await getPatientList()
ElMessage.success('刷新成功')
} catch (error) {
console.error('刷新失败:', error)
ElMessage.error('刷新失败')
}
}
// //
const validateAllResults = () => { const validateAllResults = () => {
const errors = [] const errors = []
@ -1385,7 +1602,7 @@ const validateAllResults = () => {
return true return true
} }
// //
const handleSaveAllResults = async () => { const handleSaveAllResults = async () => {
if (!checkEditPermission()) return if (!checkEditPermission()) return
@ -1400,62 +1617,68 @@ const handleSaveAllResults = async () => {
// //
let allUpdatedItems = [] let allUpdatedItems = []
//
console.log('当前标签页:', currentTab.value)
console.log('结论数据:', conclusionData.value)
console.log('当前检查项目:', currentExamItems.value)
// //
Object.keys(examItems.value).forEach(tabKey => { Object.keys(examItems.value).forEach(tabKey => {
const items = examItems.value[tabKey] || [] const items = examItems.value[tabKey] || []
items.forEach(item => { items.forEach(item => {
const itemName = (item.name || '').toLowerCase() const itemName = (item.name || '').toLowerCase()
console.log('处理项目:', item.name, '项目ID:', item.id, '标签页:', tabKey)
// //
const baseFields = { const baseFields = {
id: item.id, id: item.id,
medicalSn: selectedPatient.value?.medicalSn, medicalSn: selectedPatient.value?.medicalSn,
itemStatus: item.itemStatus || '1', itemStatus: '1', //
inspectdoctor: user.value?.nickname || '', inspectdoctor: user.value?.nickname || '',
inspecttime: currentTimestamp, inspecttime: currentTimestamp,
sectionID: user.value?.deptId sectionID: user.value?.deptId
} }
// //
if (itemName.includes('超声') || itemName.includes('彩超')) { if (itemName.includes('超声') || itemName.includes('彩超') || itemName.includes('b超')) {
console.log('超声项目:', item.name, '所见:', conclusionData.value.ultrasound?.finding, '结果:', conclusionData.value.ultrasound?.diagnosis) const finding = conclusionData.value.ultrasound?.finding?.trim() || ''
const diagnosis = conclusionData.value.ultrasound?.diagnosis?.trim() || ''
// analyse
const analyseContent = `检查所见:${finding}\n检查结果${diagnosis}`
allUpdatedItems.push({ allUpdatedItems.push({
...baseFields, ...baseFields,
examDescription: conclusionData.value.ultrasound?.finding?.trim() || '', examDescription: finding,
itemResult: conclusionData.value.ultrasound?.diagnosis?.trim() || '' itemResult: diagnosis,
analyse: analyseContent
}) })
} else if (itemName.includes('心电图')) { } else if (itemName.includes('心电图') || itemName.includes('ecg') || itemName.includes('ekg')) {
console.log('心电图项目:', item.name, '所见:', conclusionData.value.ecg?.finding, '结果:', conclusionData.value.ecg?.diagnosis) const finding = conclusionData.value.ecg?.finding?.trim() || ''
const diagnosis = conclusionData.value.ecg?.diagnosis?.trim() || ''
// analyse
const analyseContent = `检查所见:${finding}\n检查结果${diagnosis}`
allUpdatedItems.push({ allUpdatedItems.push({
...baseFields, ...baseFields,
examDescription: conclusionData.value.ecg?.finding?.trim() || '', examDescription: finding,
itemResult: conclusionData.value.ecg?.diagnosis?.trim() || '' itemResult: diagnosis,
analyse: analyseContent
}) })
} else if (itemName.includes('血常规')) { } else if (itemName.includes('血常规') || itemName.includes('血细胞') || itemName.includes('血红蛋白')) {
console.log('血常规项目:', item.name, '小结:', conclusionData.value.blood?.summary)
allUpdatedItems.push({ allUpdatedItems.push({
...baseFields, ...baseFields,
itemResult: conclusionData.value.blood?.summary?.trim() || '' analyse: conclusionData.value.blood?.summary?.trim() || '' // analyse
}) })
} else if (itemName.includes('尿常规')) { } else if (itemName.includes('尿常规') || itemName.includes('尿液分析')) {
console.log('尿常规项目:', item.name, '小结:', conclusionData.value.urine?.summary)
allUpdatedItems.push({ allUpdatedItems.push({
...baseFields, ...baseFields,
itemResult: conclusionData.value.urine?.summary?.trim() || '' analyse: conclusionData.value.urine?.summary?.trim() || '' // analyse
})
} else {
//
allUpdatedItems.push({
...baseFields,
analyse: conclusionData.value.general?.summary?.trim() || '' // analyse
}) })
} }
}) })
}) })
console.log('最终要更新的项目:', allUpdatedItems)
if (allUpdatedItems.length === 0) { if (allUpdatedItems.length === 0) {
ElMessage.warning('没有需要保存的检查项目') ElMessage.warning('没有需要保存的检查项目')
return return
@ -1463,20 +1686,70 @@ const handleSaveAllResults = async () => {
// //
await PatientitemsApi.updatePatientitemsBatch(allUpdatedItems) await PatientitemsApi.updatePatientitemsBatch(allUpdatedItems)
//
inspectDoctor.value = user.value?.nickname || ''
inspectTime.value = formatDate(new Date())
// - API
if (selectedPatient.value) {
// status1
await PatientApi.updatePatient({
id: selectedPatient.value.id,
status: 1 //
})
//
selectedPatient.value.status = 1
//
const patientIndex = patients.value.findIndex(p => p.id === selectedPatient.value.id)
if (patientIndex !== -1) {
patients.value[patientIndex].status = 1
}
//
const filteredIndex = filteredPatients.value.findIndex(p => p.id === selectedPatient.value.id)
if (filteredIndex !== -1) {
filteredPatients.value[filteredIndex].status = 1
}
}
ElMessage.success('所有检查结果保存成功') ElMessage.success('所有检查结果保存成功')
// //
await refreshExamData() await refreshExamData()
} catch (error) { } catch (error) {
console.error('保存失败:', error)
ElMessage.error(`保存失败: ${error.message || '请检查数据是否完整'}`) ElMessage.error(`保存失败: ${error.message || '请检查数据是否完整'}`)
} }
} }
// //
const refreshExamData = async () => { const refreshExamData = async () => {
try { try {
//
if (selectedPatient.value) {
const updatedPatient = await PatientApi.getPatient(selectedPatient.value.id)
if (updatedPatient) {
//
selectedPatient.value = updatedPatient
//
const patientIndex = patients.value.findIndex(p => p.id === selectedPatient.value.id)
if (patientIndex !== -1) {
patients.value[patientIndex] = updatedPatient
}
//
const filteredIndex = filteredPatients.value.findIndex(p => p.id === selectedPatient.value.id)
if (filteredIndex !== -1) {
filteredPatients.value[filteredIndex] = updatedPatient
}
}
}
//
const params = { const params = {
medicalSn: selectedPatient.value?.medicalSn, medicalSn: selectedPatient.value?.medicalSn,
pageNo: 1, pageNo: 1,
@ -1487,35 +1760,17 @@ const refreshExamData = async () => {
if (itemsRes.list && itemsRes.list.length > 0) { if (itemsRes.list && itemsRes.list.length > 0) {
// //
const currentDeptItems = itemsRes.list.filter(item => // ... ...
item.sectionID === user.value?.deptId
)
//
currentDeptItems.forEach(item => {
if (['ultrasound', 'ecg'].includes(currentTab.value)) {
conclusionData.value[currentTab.value] = {
finding: item.examDescription || '',
diagnosis: item.itemResult || ''
}
} else {
conclusionData.value[currentTab.value] = {
summary: item.itemResult || ''
}
}
})
//
if (selectedPatient.value) {
const allChecked = currentDeptItems.every(item => item.itemStatus === '1')
selectedPatient.value.examStatus = allChecked ? '1' : '0'
}
} }
} catch (error) { } catch (error) {
console.error('刷新数据失败:', error) console.error('刷新数据失败:', error)
} }
} }
//
const inspectDoctor = ref('')
const inspectTime = ref('')
</script> </script>
<style scoped> <style scoped>
@ -2314,44 +2569,14 @@ background-color: transparent;
cursor: not-allowed; cursor: not-allowed;
} }
/* 保持按钮样式正常 */
.action-btn {
padding: 6px 16px;
border: none;
border-radius: 4px;
background: #40B6FF;
color: white;
cursor: pointer;
font-size: 14px;
transition: all 0.3s;
}
.action-btn:hover {
opacity: 0.9;
}
.action-btn.primary {
background: #40B6FF;
}
/* 只读状态的输入框样式 */
.cell-input[readonly] {
background-color: transparent;
cursor: not-allowed;
}
/* 只读状态的文本框样式 */ /* 只读状态的文本框样式 */
.summary-textarea[readonly] { .summary-textarea[readonly],
.findings-textarea[readonly],
.diagnosis-textarea[readonly] {
background-color: #f5f7fa; background-color: #f5f7fa;
cursor: not-allowed; cursor: not-allowed;
} }
/* 只读状态下的按钮样式 */
.view-only {
opacity: 0.7;
cursor: not-allowed;
}
.right-content { .right-content {
flex: 1; flex: 1;
display: flex; display: flex;