患者回话列表筛选

This commit is contained in:
xiaoxiao 2025-07-15 14:16:15 +08:00
parent b843007d7a
commit 63b13d7ccd
2 changed files with 51 additions and 13 deletions

View File

@ -300,6 +300,24 @@ export class PatientDao {
}
}
async getPatientTypeByUuid(uuid: string): Promise<number | null> {
this.checkDatabaseState();
if (!this.rdbStore) {
throw new Error('数据库连接为空');
}
const sql = 'SELECT type FROM patients WHERE LOWER(uuid) = LOWER(?)';
const resultSet = await this.rdbStore.querySql(sql, [uuid]);
if (resultSet.rowCount > 0) {
resultSet.goToFirstRow();
const typeIndex = resultSet.getColumnIndex('type');
const type = typeIndex >= 0 ? resultSet.getDouble(typeIndex) : null;
resultSet.close();
return type;
}
resultSet.close();
return null;
}
// 删除指定专家的所有患者数据
async deletePatientsByExpertUuid(expertUuid: string): Promise<void> {
try {
@ -855,6 +873,16 @@ export class PatientDatabaseManager {
async addPatient(patient: PatientData): Promise<boolean> {
return await this.addPatients(patient);
}
// 在 PatientDatabaseManager 类内添加
async getPatientTypeByUuid(uuid: string): Promise<number | null> {
if (!this.isDatabaseReady()) {
console.error('数据库未准备好无法获取患者type');
return null;
}
return await this.getPatientDao().getPatientTypeByUuid(uuid);
}
}
// 导出单例实例

View File

@ -236,21 +236,31 @@ export class LocalConversationViewModel {
}
this.offset = result.offset
this.isFinished = result.finished
let newConversation = result.conversationList
if (this.conversationList.length > 0 && newConversation.length > 0) {
this.conversationList =
this.conversationList.filter(conversation => !newConversation.find((m) => m.conversationId ===
conversation.conversationId))
}
this.conversationList?.push(...newConversation)
// let newConversation = result.conversationList
// if (this.conversationList.length > 0 && newConversation.length > 0) {
// this.conversationList =
// this.conversationList.filter(conversation => !newConversation.find((m) => m.conversationId ===
// conversation.conversationId))
// }
// this.conversationList?.push(...newConversation)
//异步有问题
if (this.conversationList.length > 0 ) {
const resultconversationList =await this.conversationList.filter(async conversation =>
await patientDbManager.getPatientByUuid(ChatKitClient.nim.conversationIdUtil.parseConversationTargetId(conversation.conversationId))!=null
)
this.conversationList =resultconversationList;
// if (this.conversationList.length > 0 ) {
// const resultconversationList =await this.conversationList.filter(async conversation =>
// await patientDbManager.getPatientByUuid(ChatKitClient.nim.conversationIdUtil.parseConversationTargetId(conversation.conversationId))!=null
// )
// this.conversationList =resultconversationList;
//
// }
const filteredConversations: V2NIMLocalConversation[] = [];
for (const conversation of result.conversationList) {
const uuid = ChatKitClient.nim.conversationIdUtil.parseConversationTargetId(conversation.conversationId);
// 假设 selectUserStyleWithModel 返回 "1" 表示 type=1
const style = await patientDbManager.getPatientTypeByUuid(uuid);
if (style == 1) {
filteredConversations.push(conversation);
}
}
this.conversationList = filteredConversations;
this.conversationList?.sort((a, b) => this.sortConversation(a, b))
this.isFinishedSyncLoad = true