Browse Source

因和后端交互的接口变化,修改API实现,及受API影响的更上层实现

dengdx 2 months ago
parent
commit
025937081c

+ 9 - 2
src/API/patient/procedureActions.ts

@@ -27,20 +27,27 @@ interface ProcedureResponse {
   description: string;
   description: string;
   solution: string;
   solution: string;
   data: {
   data: {
-    procedure_list: Procedure[];
+    procedures: Procedure[];
+    count: number;
   };
   };
 }
 }
 
 
 export const fetchProcedures = async (
 export const fetchProcedures = async (
   patientType: string | null,
   patientType: string | null,
   bodyPart: string | null,
   bodyPart: string | null,
-  isEnabled: boolean
+  isEnabled: boolean,
+  procedure_type: 'NORMAL' | 'EMERGENCY' = 'NORMAL',
+  page = 1,
+  page_size = 9999
 ): Promise<ProcedureResponse> => {
 ): Promise<ProcedureResponse> => {
   const response = await axiosInstance.get('/auth/protocol/procedure', {
   const response = await axiosInstance.get('/auth/protocol/procedure', {
     params: {
     params: {
       patient_type: patientType,
       patient_type: patientType,
       body_part: bodyPart,
       body_part: bodyPart,
       is_enabled: isEnabled,
       is_enabled: isEnabled,
+      procedure_type: procedure_type,
+      page: page,
+      page_size: page_size,
     },
     },
   });
   });
   return response.data;
   return response.data;

+ 7 - 2
src/API/patient/viewActions.ts

@@ -33,7 +33,8 @@ interface FetchViewsResponse {
   solution: string;
   solution: string;
   data: {
   data: {
     '@type': string;
     '@type': string;
-    view_list: View[];
+    views: View[];
+    count: number;
   };
   };
 }
 }
 
 
@@ -41,7 +42,9 @@ export const fetchViews = async (
   patient_type: string | null,
   patient_type: string | null,
   body_part: string | null,
   body_part: string | null,
   is_enabled: boolean,
   is_enabled: boolean,
-  procedure_id: string | null | undefined
+  procedure_id: string | null | undefined,
+  page = 1,
+  page_size = 9999
 ): Promise<FetchViewsResponse> => {
 ): Promise<FetchViewsResponse> => {
   const response = await axiosInstance.get('/auth/protocol/view', {
   const response = await axiosInstance.get('/auth/protocol/view', {
     params: {
     params: {
@@ -49,6 +52,8 @@ export const fetchViews = async (
       body_part,
       body_part,
       is_enabled,
       is_enabled,
       procedure_id,
       procedure_id,
+      page: page,
+      page_size: page_size,
     },
     },
   });
   });
 
 

+ 77 - 0
src/domain/patient/registrationGenerator.ts

@@ -0,0 +1,77 @@
+import { v4 as uuidv4 } from 'uuid';
+import { RegisterInfo } from '../../API/patient/workActions';
+
+interface ExtendedRegisterInfo extends RegisterInfo {
+  performed_protocol_code_value: string;
+  performed_protocol_code_meaning: string;
+  study_description: string;
+  reg_source: string;
+}
+
+enum RegisterSource {
+  Local = 'local',
+}
+
+const emergencyPrefix = 'emergency';
+const maxNumber = uuidv4();
+const userName = 'defaultUser'; // Placeholder for actual user name from user_info slice
+
+const generateRegistrationInfo = (): RegisterInfo => {
+  const work: ExtendedRegisterInfo = {
+    patient_id: `${emergencyPrefix}_${maxNumber}`,
+    patient_name: `${emergencyPrefix}_${maxNumber}^^^^`,
+    reg_source: RegisterSource.Local.toString(),
+    operator_id: userName,
+    study_type: 'Emergency',
+    accession_number: maxNumber,
+    performed_protocol_code_value: '',
+    performed_protocol_code_meaning: '',
+    study_description: '',
+    views: [],
+    patient_size: '',
+    patient_age: '',
+    patient_dob: '',
+    patient_sex: '',
+    sex_neutered: '',
+    pregnancy_status: '',
+    chip_number: '',
+    variety: '',
+    patient_type: '',
+    ref_physician: '',
+    modality: '',
+    weight: 0,
+    thickness: 0,
+    length: 0,
+    comment: '',
+  };
+
+  // 获取用于急诊的所有procudure
+  const procedures = [
+    {
+      ProcedureCode: 'P123',
+      ProcedureDescription: 'Sample Procedure',
+      ProcedureName: 'Sample Procedure Name',
+    },
+  ];
+  // 得到急诊procedure下的所有view
+
+  if (procedures.length > 0) {
+    const lastProcedure = procedures[procedures.length - 1];
+    work.performed_protocol_code_value = lastProcedure.ProcedureCode;
+    work.performed_protocol_code_meaning = lastProcedure.ProcedureCode;
+    work.study_description =
+      lastProcedure.ProcedureDescription || lastProcedure.ProcedureName;
+
+    // Placeholder for querying views based on ProcedureCode
+    work.views = [
+      {
+        view_id: 'V123',
+        procedure_id: 'P123',
+      },
+    ];
+  }
+
+  return work;
+};
+
+export default generateRegistrationInfo;

+ 3 - 3
src/states/patient/viewSelection/index.ts

@@ -102,7 +102,7 @@ export const fetchViewsOrProtocols = createAsyncThunk(
           filter.bodyPart,
           filter.bodyPart,
           true
           true
         );
         );
-        return response.data.procedure_list;
+        return response.data.procedures;
       }
       }
       if (filter.selection === 'view') {
       if (filter.selection === 'view') {
         const response = await fetchViews(
         const response = await fetchViews(
@@ -111,7 +111,7 @@ export const fetchViewsOrProtocols = createAsyncThunk(
           true,
           true,
           filter.procedureId
           filter.procedureId
         );
         );
-        return response.data.view_list;
+        return response.data.views;
       }
       }
     } catch (error) {
     } catch (error) {
       return rejectWithValue(error.message);
       return rejectWithValue(error.message);
@@ -124,7 +124,7 @@ export const fetchViewsByProcedureId = createAsyncThunk(
   async (procedureId: string, { rejectWithValue }) => {
   async (procedureId: string, { rejectWithValue }) => {
     try {
     try {
       const response = await fetchViews(null, null, true, procedureId);
       const response = await fetchViews(null, null, true, procedureId);
-      return response.data.view_list;
+      return response.data.views;
     } catch (error) {
     } catch (error) {
       return rejectWithValue(error.message);
       return rejectWithValue(error.message);
     }
     }