医嘱诊断和费用性质没有自动引入
This commit is contained in:
@@ -12,9 +12,17 @@
|
|||||||
<!-- 循环显示所有西药方 -->
|
<!-- 循环显示所有西药方 -->
|
||||||
<div v-for="(prescription, pIndex) in westernPrescriptions" :key="prescription.id" style="margin-bottom: 20px; border: 1px solid #e4e7ed; border-radius: 8px; padding: 10px; min-width: fit-content;">
|
<div v-for="(prescription, pIndex) in westernPrescriptions" :key="prescription.id" style="margin-bottom: 20px; border: 1px solid #e4e7ed; border-radius: 8px; padding: 10px; min-width: fit-content;">
|
||||||
<!-- 西药方标题栏 -->
|
<!-- 西药方标题栏 -->
|
||||||
<div style="margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; background: #f5f7fa; padding: 10px 12px; border-radius: 4px;">
|
<div class="prescription-header" style="margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; background: #f5f7fa; padding: 10px 12px; border-radius: 4px; min-height: 40px; width: 100%; box-sizing: border-box; position: relative;">
|
||||||
<span style="font-weight: 600; font-size: 14px; color: #409eff;">{{ prescription.name }}</span>
|
<span style="font-weight: 600; font-size: 14px; color: #409eff; flex-shrink: 0;">{{ prescription.name }}</span>
|
||||||
<el-button type="danger" plain size="small" @click="handleClosePrescription(prescription.id)">删除</el-button>
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
size="small"
|
||||||
|
@click="handleClosePrescription(prescription.id)"
|
||||||
|
style="flex-shrink: 0; min-width: 90px; z-index: 10; position: relative;"
|
||||||
|
title="删除整个西药方"
|
||||||
|
>
|
||||||
|
删除西药方
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 西药方操作区 -->
|
<!-- 西药方操作区 -->
|
||||||
@@ -977,7 +985,7 @@ import {
|
|||||||
getActivityBindDevice,
|
getActivityBindDevice,
|
||||||
} from '../api';
|
} from '../api';
|
||||||
import adviceBaseList from '../adviceBaseList.vue';
|
import adviceBaseList from '../adviceBaseList.vue';
|
||||||
import { computed, getCurrentInstance, nextTick, watch, unref } from 'vue';
|
import { computed, getCurrentInstance, nextTick, watch, unref, reactive } from 'vue';
|
||||||
import { calculateQuantityByDays, formatNumber } from '@/utils/his';
|
import { calculateQuantityByDays, formatNumber } from '@/utils/his';
|
||||||
import OrderGroupDrawer from './orderGroupDrawer';
|
import OrderGroupDrawer from './orderGroupDrawer';
|
||||||
import PrescriptionHistory from './prescriptionHistory';
|
import PrescriptionHistory from './prescriptionHistory';
|
||||||
@@ -1447,8 +1455,17 @@ function getListInfo(addNewRow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDiagnosisInfo() {
|
function getDiagnosisInfo() {
|
||||||
getEncounterDiagnosis(props.patientInfo.encounterId).then((res) => {
|
if (!props.patientInfo || !props.patientInfo.encounterId) {
|
||||||
diagnosisList.value = res.data;
|
console.warn('患者信息不完整,无法获取诊断信息');
|
||||||
|
return Promise.resolve({ data: [] });
|
||||||
|
}
|
||||||
|
|
||||||
|
return getEncounterDiagnosis(props.patientInfo.encounterId).then((res) => {
|
||||||
|
console.log('getDiagnosisInfo - API返回结果:', res);
|
||||||
|
const diagnosisData = res.data || res || [];
|
||||||
|
diagnosisList.value = Array.isArray(diagnosisData) ? diagnosisData : [];
|
||||||
|
console.log('getDiagnosisInfo - 诊断列表已更新:', diagnosisList.value);
|
||||||
|
|
||||||
let diagnosisInfo = diagnosisList.value.filter((item) => {
|
let diagnosisInfo = diagnosisList.value.filter((item) => {
|
||||||
return item.maindiseFlag == 1;
|
return item.maindiseFlag == 1;
|
||||||
});
|
});
|
||||||
@@ -1458,7 +1475,20 @@ function getDiagnosisInfo() {
|
|||||||
conditionId.value = diagnosisInfo[0].conditionId;
|
conditionId.value = diagnosisInfo[0].conditionId;
|
||||||
encounterDiagnosisId.value = diagnosisInfo[0].encounterDiagnosisId;
|
encounterDiagnosisId.value = diagnosisInfo[0].encounterDiagnosisId;
|
||||||
diagnosisName.value = diagnosisInfo[0].name;
|
diagnosisName.value = diagnosisInfo[0].name;
|
||||||
|
console.log('getDiagnosisInfo - 已设置主诊断:', diagnosisInfo[0]);
|
||||||
|
} else if (diagnosisList.value.length > 0) {
|
||||||
|
// 如果没有主诊断,使用第一个诊断
|
||||||
|
conditionDefinitionId.value = diagnosisList.value[0].definitionId;
|
||||||
|
conditionId.value = diagnosisList.value[0].conditionId;
|
||||||
|
encounterDiagnosisId.value = diagnosisList.value[0].encounterDiagnosisId;
|
||||||
|
diagnosisName.value = diagnosisList.value[0].name;
|
||||||
|
console.log('getDiagnosisInfo - 已设置第一个诊断:', diagnosisList.value[0]);
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error('获取诊断信息失败:', error);
|
||||||
|
diagnosisList.value = [];
|
||||||
|
return { data: [] };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3213,23 +3243,147 @@ function validateGroups(saveList) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增西药处方
|
* 新增西药处方
|
||||||
|
* 自动引入诊断和费用性质
|
||||||
*/
|
*/
|
||||||
function handleAddWesternPrescription() {
|
async function handleAddWesternPrescription() {
|
||||||
|
// 检查患者信息是否完整
|
||||||
|
if (!props.patientInfo || !props.patientInfo.encounterId) {
|
||||||
|
proxy.$modal.msgWarning('患者信息不完整,无法创建处方');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
prescriptionCounter.value++;
|
prescriptionCounter.value++;
|
||||||
const newPrescriptionId = `prescription_${Date.now()}_${prescriptionCounter.value}`;
|
const newPrescriptionId = `prescription_${Date.now()}_${prescriptionCounter.value}`;
|
||||||
const newPrescription = {
|
|
||||||
|
// 如果诊断列表为空,先加载诊断信息
|
||||||
|
if (!diagnosisList.value || diagnosisList.value.length === 0) {
|
||||||
|
try {
|
||||||
|
const diagnosisRes = await getDiagnosisInfo();
|
||||||
|
console.log('诊断信息加载完成:', diagnosisRes);
|
||||||
|
// 确保诊断列表已更新
|
||||||
|
if (diagnosisRes && diagnosisRes.data) {
|
||||||
|
diagnosisList.value = diagnosisRes.data || [];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载诊断信息失败:', error);
|
||||||
|
// 即使加载失败,也继续创建处方,只是不自动引入诊断
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果费用性质列表为空,先加载费用性质信息
|
||||||
|
if (!contractList.value || contractList.value.length === 0) {
|
||||||
|
try {
|
||||||
|
const res = await getContract({ encounterId: props.patientInfo.encounterId });
|
||||||
|
console.log('费用性质信息加载完成:', res);
|
||||||
|
if (res && res.data) {
|
||||||
|
contractList.value = res.data;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载费用性质失败:', error);
|
||||||
|
// 即使加载失败,也继续创建处方,只是不自动引入费用性质
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 再次确认数据已加载
|
||||||
|
console.log('数据加载检查 - 诊断列表:', diagnosisList.value?.length || 0, diagnosisList.value);
|
||||||
|
console.log('数据加载检查 - 费用性质列表:', contractList.value?.length || 0, contractList.value);
|
||||||
|
|
||||||
|
// 自动引入诊断:优先使用全局变量,否则从诊断列表中获取第一个主诊断,再否则获取第一个诊断
|
||||||
|
let autoConditionDefinitionId = conditionDefinitionId.value;
|
||||||
|
console.log('自动引入诊断 - 当前全局诊断ID:', autoConditionDefinitionId);
|
||||||
|
console.log('自动引入诊断 - 诊断列表:', diagnosisList.value);
|
||||||
|
|
||||||
|
if (!autoConditionDefinitionId && diagnosisList.value && diagnosisList.value.length > 0) {
|
||||||
|
// 优先获取主诊断
|
||||||
|
const mainDiagnosis = diagnosisList.value.find(item => item.maindiseFlag == 1);
|
||||||
|
if (mainDiagnosis) {
|
||||||
|
autoConditionDefinitionId = mainDiagnosis.definitionId;
|
||||||
|
console.log('自动引入诊断 - 找到主诊断:', mainDiagnosis);
|
||||||
|
// 同时更新全局变量
|
||||||
|
conditionDefinitionId.value = autoConditionDefinitionId;
|
||||||
|
conditionId.value = mainDiagnosis.conditionId;
|
||||||
|
encounterDiagnosisId.value = mainDiagnosis.encounterDiagnosisId;
|
||||||
|
diagnosisName.value = mainDiagnosis.name;
|
||||||
|
} else {
|
||||||
|
// 如果没有主诊断,使用第一个诊断
|
||||||
|
autoConditionDefinitionId = diagnosisList.value[0].definitionId;
|
||||||
|
console.log('自动引入诊断 - 使用第一个诊断:', diagnosisList.value[0]);
|
||||||
|
// 同时更新全局变量
|
||||||
|
conditionDefinitionId.value = autoConditionDefinitionId;
|
||||||
|
conditionId.value = diagnosisList.value[0].conditionId;
|
||||||
|
encounterDiagnosisId.value = diagnosisList.value[0].encounterDiagnosisId;
|
||||||
|
diagnosisName.value = diagnosisList.value[0].name;
|
||||||
|
}
|
||||||
|
} else if (!autoConditionDefinitionId) {
|
||||||
|
console.warn('自动引入诊断 - 无法自动引入:诊断列表为空或全局变量未设置');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自动引入费用性质:优先使用全局变量,否则从费用性质列表中获取第一个,再否则使用患者信息中的费用性质
|
||||||
|
let autoAccountId = accountId.value;
|
||||||
|
console.log('自动引入费用性质 - 当前全局费用性质ID:', autoAccountId);
|
||||||
|
console.log('自动引入费用性质 - 费用性质列表:', contractList.value);
|
||||||
|
console.log('自动引入费用性质 - 患者信息中的费用性质:', props.patientInfo?.accountId);
|
||||||
|
|
||||||
|
if (!autoAccountId) {
|
||||||
|
if (contractList.value && contractList.value.length > 0) {
|
||||||
|
autoAccountId = contractList.value[0].accountId;
|
||||||
|
console.log('自动引入费用性质 - 从列表获取:', contractList.value[0]);
|
||||||
|
// 同时更新全局变量
|
||||||
|
accountId.value = autoAccountId;
|
||||||
|
} else if (props.patientInfo && props.patientInfo.accountId) {
|
||||||
|
autoAccountId = props.patientInfo.accountId;
|
||||||
|
console.log('自动引入费用性质 - 从患者信息获取:', autoAccountId);
|
||||||
|
// 同时更新全局变量
|
||||||
|
accountId.value = autoAccountId;
|
||||||
|
} else {
|
||||||
|
console.warn('自动引入费用性质 - 无法自动引入:费用性质列表为空且患者信息中也没有');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建处方对象,确保诊断和费用性质被正确设置
|
||||||
|
const newPrescription = reactive({
|
||||||
id: newPrescriptionId,
|
id: newPrescriptionId,
|
||||||
name: `西药方${prescriptionCounter.value}`,
|
name: `西药方${prescriptionCounter.value}`,
|
||||||
prescriptionNo: '', // 处方单号码,保存时由后端生成
|
prescriptionNo: '', // 处方单号码,保存时由后端生成
|
||||||
conditionDefinitionId: conditionDefinitionId.value, // 诊断
|
conditionDefinitionId: autoConditionDefinitionId || undefined, // 诊断(自动引入)
|
||||||
accountId: accountId.value, // 费用性质
|
accountId: autoAccountId || undefined, // 费用性质(自动引入)
|
||||||
expandOrder: [], // 展开的行
|
expandOrder: [], // 展开的行
|
||||||
};
|
});
|
||||||
|
|
||||||
westernPrescriptions.value.push(newPrescription);
|
westernPrescriptions.value.push(newPrescription);
|
||||||
allPrescriptionsData.value[newPrescriptionId] = []; // 初始化空数据
|
allPrescriptionsData.value[newPrescriptionId] = []; // 初始化空数据
|
||||||
|
|
||||||
console.log('新增西药处方:', newPrescription);
|
console.log('新增西药处方完成:', {
|
||||||
|
prescriptionId: newPrescriptionId,
|
||||||
|
prescription: newPrescription,
|
||||||
|
autoConditionDefinitionId: autoConditionDefinitionId,
|
||||||
|
autoAccountId: autoAccountId,
|
||||||
|
diagnosisListLength: diagnosisList.value?.length || 0,
|
||||||
|
contractListLength: contractList.value?.length || 0,
|
||||||
|
diagnosisList: diagnosisList.value,
|
||||||
|
contractList: contractList.value
|
||||||
|
});
|
||||||
|
|
||||||
|
// 使用 nextTick 确保 Vue 响应式更新,然后再次检查并更新处方对象
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
// 确保处方对象中的诊断和费用性质已正确设置(使用响应式对象直接更新)
|
||||||
|
if (autoConditionDefinitionId) {
|
||||||
|
newPrescription.conditionDefinitionId = autoConditionDefinitionId;
|
||||||
|
console.log('已设置诊断ID到处方对象:', autoConditionDefinitionId);
|
||||||
|
}
|
||||||
|
if (autoAccountId) {
|
||||||
|
newPrescription.accountId = autoAccountId;
|
||||||
|
console.log('已设置费用性质ID到处方对象:', autoAccountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 再次等待一个tick,确保视图更新
|
||||||
|
await nextTick();
|
||||||
|
console.log('最终处方对象:', {
|
||||||
|
id: newPrescription.id,
|
||||||
|
conditionDefinitionId: newPrescription.conditionDefinitionId,
|
||||||
|
accountId: newPrescription.accountId
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3293,24 +3447,60 @@ function updateExpandOrder(keys) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭处方
|
* 关闭处方(删除西药方)
|
||||||
|
* 控制规则:
|
||||||
|
* 1. 西药方有已保存的数据不能删除
|
||||||
|
* 2. 西药方已签发和已收费不能删除
|
||||||
|
* 3. 西药方只有在待保存和无数据的情况才能删除
|
||||||
*/
|
*/
|
||||||
function handleClosePrescription(prescriptionId) {
|
function handleClosePrescription(prescriptionId) {
|
||||||
// 检查该处方是否有数据
|
// 检查该处方是否有数据
|
||||||
const prescriptionData = allPrescriptionsData.value[prescriptionId] || [];
|
const prescriptionData = allPrescriptionsData.value[prescriptionId] || [];
|
||||||
const hasData = prescriptionData.length > 0;
|
const hasData = prescriptionData.length > 0;
|
||||||
|
|
||||||
if (hasData) {
|
if (!hasData) {
|
||||||
// 如果有数据,提示用户确认
|
// 如果没有数据,直接删除
|
||||||
proxy.$modal.confirm('该处方包含数据,确定要关闭吗?').then(() => {
|
|
||||||
doClosePrescription(prescriptionId);
|
|
||||||
}).catch(() => {
|
|
||||||
console.log('取消关闭处方');
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// 如果没有数据,直接关闭
|
|
||||||
doClosePrescription(prescriptionId);
|
doClosePrescription(prescriptionId);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查是否有已保存的数据(statusEnum == 1 && (requestId || isSaved))
|
||||||
|
const hasSavedData = prescriptionData.some(item => {
|
||||||
|
return item.statusEnum == 1 && (item.requestId || item.isSaved);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasSavedData) {
|
||||||
|
proxy.$modal.msgWarning('西药方有已保存的数据,不能删除');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有已签发的数据(statusEnum == 2)
|
||||||
|
const hasIssuedData = prescriptionData.some(item => {
|
||||||
|
return item.statusEnum == 2;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasIssuedData) {
|
||||||
|
proxy.$modal.msgWarning('西药方已签发,不能删除');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有已收费的数据(chargeStatus == 5 表示已收费)
|
||||||
|
const hasChargedData = prescriptionData.some(item => {
|
||||||
|
return item.chargeStatus == 5;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasChargedData) {
|
||||||
|
proxy.$modal.msgWarning('西药方已收费,不能删除');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果所有数据都是待保存状态(statusEnum == 1 && !requestId && !isSaved)或无数据,可以删除
|
||||||
|
// 提示用户确认
|
||||||
|
proxy.$modal.confirm('确定要删除该西药方吗?').then(() => {
|
||||||
|
doClosePrescription(prescriptionId);
|
||||||
|
}).catch(() => {
|
||||||
|
console.log('取消删除西药方');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3480,4 +3670,18 @@ defineExpose({ getListInfo, getDiagnosisInfo, getSignedPrescriptionInfo });
|
|||||||
.prescription-scroll-container .el-table__body-wrapper {
|
.prescription-scroll-container .el-table__body-wrapper {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 确保标题栏删除按钮可见 */
|
||||||
|
.prescription-header {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prescription-header .el-button {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
visibility: visible !important;
|
||||||
|
display: inline-block !important;
|
||||||
|
opacity: 1 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user