[bug]修改就诊时,就诊时间逻辑

This commit is contained in:
Auora
2025-10-31 16:23:12 +08:00
parent c07255fe5b
commit 2a7f1326b9
2 changed files with 38 additions and 20 deletions

View File

@@ -148,6 +148,7 @@
}
"
:visitType="visitType"
:firstVisitDate="firstVisitDate"
/>
</el-tab-pane>
<el-tab-pane label="诊断" name="diagnosis">
@@ -266,6 +267,7 @@ const waitCount = ref(0);
const loading = ref(false);
const { proxy } = getCurrentInstance();
const visitType = ref('');
const firstVisitDate = ref('');
const disabled = computed(() => {
return Object.keys(patientInfo.value).length === 0;
});
@@ -294,6 +296,7 @@ function setVisitType(type) {
function checkPatientHistory(patient) {
// 重置状态
visitTypeDisabled.value = false;
firstVisitDate.value = '';
// 如果患者没有身份证号,无法判断是否为初诊
if (!patient.idCard) {
@@ -320,20 +323,31 @@ function checkPatientHistory(patient) {
getEmrHistoryList(params).then(res => {
if (res.code === 200) {
const records = res.data?.records || [];
// 如果有历史记录,则为复诊
if (res.data && res.data.total > 0) {
visitType.value = 'FOLLOW_UP';
// 计算最早一次病历创建时间作为初诊日期
const earliest = records.reduce((min, cur) => {
const ct = new Date(cur.createTime).getTime();
return ct < min ? ct : min;
}, new Date(records[0].createTime).getTime());
// 使用统一格式化
firstVisitDate.value = formatDate(earliest);
} else {
// 如果没有历史记录,则为初诊
visitType.value = 'FIRST';
firstVisitDate.value = '';
}
} else {
// 请求失败,默认设置为初诊
visitType.value = 'FIRST';
firstVisitDate.value = '';
}
}).catch(() => {
// 异常情况,默认设置为初诊
visitType.value = 'FIRST';
firstVisitDate.value = '';
});
}
function getWaitPatient() {