Ver Fonte

feat (1.46.2 -> 1.47.0): 实现患者注册重复检查功能

- 在workActions.ts中添加检查患者检查的API接口和响应类型
- 在registerLogic.ts中集成重复检查逻辑,注册时检查重复并弹出确认对话框
- 新增duplicateCheck.ts文件,实现患者重复检查的核心逻辑

改动文件:
- src/API/patient/workActions.ts
- src/domain/patient/registerLogic.ts
- src/domain/patient/duplicateCheck.ts
dengdx há 1 semana atrás
pai
commit
4ee1ac59bc

+ 14 - 0
CHANGELOG.md

@@ -2,6 +2,20 @@
 
 本项目的所有重要变更都将记录在此文件中。
 
+## [1.47.0] - 2026-01-03 19:42
+
+### 新增 (Added)
+
+- **实现患者注册重复检查功能** - 在患者注册时添加重复检查机制,如果发现已有检查记录则弹出确认对话框
+  - 在workActions.ts中添加检查患者检查的API接口和响应类型
+  - 在registerLogic.ts中集成重复检查逻辑,注册时检查重复并弹出确认对话框
+  - 新增duplicateCheck.ts文件,实现患者重复检查的核心逻辑
+
+**改动文件:**
+- src/API/patient/workActions.ts
+- src/domain/patient/registerLogic.ts
+- src/domain/patient/duplicateCheck.ts
+
 ## [1.46.2] - 2026-01-03 19:24
 
 ### 重构 (Refactored)

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "zsis",
-  "version": "1.46.2",
+  "version": "1.47.0",
   "private": true,
   "description": "医学成像系统",
   "main": "main.js",

+ 34 - 0
src/API/patient/workActions.ts

@@ -314,6 +314,20 @@ export interface StudyListData {
   studies: RegisterWorkResponseData[];
 }
 
+/**
+ * 患者检查查询响应类型
+ */
+export interface StudyListResponse {
+  /** 响应码 */
+  code: string;
+  /** 描述信息 */
+  description: string;
+  /** 解决方案 */
+  solution: string;
+  /** 数据内容 */
+  data: StudyListData;
+}
+
 /**
  * fetchTaskList 专用的数据结构
  */
@@ -583,3 +597,23 @@ export const lockStudy = async (
     throw error;
   }
 };
+
+/**
+ * 检查患者是否有已存在的检查
+ * @param patientId 患者ID
+ * @returns 检查列表响应
+ */
+export const checkPatientStudy = async (
+  patientId: string
+): Promise<StudyListResponse> => {
+  try {
+    const response = await axiosInstance.get(
+      `/auth/patient/${patientId}/study`
+    );
+    console.log('Patient study check response:', response.data);
+    return response.data;
+  } catch (error) {
+    console.error('Error checking patient studies:', error);
+    throw error;
+  }
+};

+ 27 - 0
src/domain/patient/duplicateCheck.ts

@@ -0,0 +1,27 @@
+import { checkPatientStudy, StudyListResponse } from '@/API/patient/workActions';
+
+/**
+ * 检查患者是否有重复检查
+ * @param patientId 患者ID
+ * @returns 如果有重复返回true,否则返回false
+ */
+export const checkPatientDuplicate = async (patientId: string): Promise<boolean> => {
+  try {
+    const response: StudyListResponse = await checkPatientStudy(patientId);
+
+    if (response.code !== '0x000000') {
+      console.warn('检查患者检查失败:', response.description);
+      // 如果API调用失败,为了安全起见,认为没有重复
+      return false;
+    }
+
+    const hasDuplicate = response.data.count > 0;
+    console.log(`患者 ${patientId} 检查重复状态: ${hasDuplicate} (count: ${response.data.count})`);
+
+    return hasDuplicate;
+  } catch (error) {
+    console.error('检查患者重复失败:', error);
+    // 如果发生错误,为了安全起见,认为没有重复
+    return false;
+  }
+};

+ 24 - 1
src/domain/patient/registerLogic.ts

@@ -1,4 +1,4 @@
-import { message } from 'antd';
+import { message, Modal } from 'antd';
 import dayjs from 'dayjs';
 import utc from 'dayjs/plugin/utc';
 import {
@@ -12,6 +12,7 @@ import { omitAnimalSchemaMap } from '@/domain/animalSpecificInfo';
 import { omitHumanSchemaMap } from '@/domain/humanSpecificInfo';
 import { RootState } from '@/states/store';
 import { View } from '@/API/patient/viewActions';
+import { checkPatientDuplicate } from './duplicateCheck';
 
 dayjs.extend(utc);
 
@@ -61,6 +62,28 @@ export async function executeRegisterLogic(store: {
       return { success: false, views: [] };
     }
 
+    // 检查患者是否有重复检查
+    const hasDuplicate = await checkPatientDuplicate(values.patient_id);
+    if (hasDuplicate) {
+      // 弹出确认对话框
+      const confirmed = await new Promise<boolean>((resolve) => {
+        Modal.confirm({
+          title: '确认继续注册',
+          content: '患者已被登记,确认要继续登记吗?',
+          okText: '确定',
+          cancelText: '取消',
+          centered: true,
+          onOk: () => resolve(true),
+          onCancel: () => resolve(false),
+        });
+      });
+
+      if (!confirmed) {
+        // 用户选择取消,不继续注册
+        return { success: false, views: [] };
+      }
+    }
+
     // 构建注册信息 - 与原代码相同的逻辑
     const registerInfo: RegisterInfo = {
       ...values,