|
@@ -1,4 +1,4 @@
|
|
-import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
|
|
|
|
+import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
import { setCurrentPatientType } from '../../patientTypeSlice';
|
|
import { setCurrentPatientType } from '../../patientTypeSlice';
|
|
import { BodyPart } from '@/API/bodyPart';
|
|
import { BodyPart } from '@/API/bodyPart';
|
|
import { PatientType } from '@/API/patientType';
|
|
import { PatientType } from '@/API/patientType';
|
|
@@ -7,6 +7,9 @@ import {
|
|
setSelected,
|
|
setSelected,
|
|
} from '@/states/patient/register/SelectionTypeSlice';
|
|
} from '@/states/patient/register/SelectionTypeSlice';
|
|
import { setCurrentBodyPart } from '../../bodyPartSlice';
|
|
import { setCurrentBodyPart } from '../../bodyPartSlice';
|
|
|
|
+import { fetchProcedures, Procedure } from '@/API/patient/procedureActions';
|
|
|
|
+import { fetchViews } from '@/API/patient/viewActions';
|
|
|
|
+export type { Procedure };
|
|
|
|
|
|
// 体位类型
|
|
// 体位类型
|
|
export interface View {
|
|
export interface View {
|
|
@@ -35,32 +38,32 @@ export interface View {
|
|
}
|
|
}
|
|
|
|
|
|
// 协议类型
|
|
// 协议类型
|
|
-export interface Procedure {
|
|
|
|
- ProcedureID: string;
|
|
|
|
- ProcedureCode: string;
|
|
|
|
- ProcedureName: string;
|
|
|
|
- ProcedureOtherName: string;
|
|
|
|
- ProcedureDescription: string;
|
|
|
|
- PatientType: string;
|
|
|
|
- ProcedureGroupID: string;
|
|
|
|
- ProcedureType: string;
|
|
|
|
- FastSearch: boolean;
|
|
|
|
- Enable: boolean;
|
|
|
|
- Order: number;
|
|
|
|
- UserGroupID: string;
|
|
|
|
- ProcedureCategory: string;
|
|
|
|
- Modality: string;
|
|
|
|
- IsImplanted: boolean;
|
|
|
|
- MagFactor: number;
|
|
|
|
- // ProcedureViews: View[];
|
|
|
|
- // ProcedureViewRelations: any[];
|
|
|
|
- ClinicProtocol: boolean;
|
|
|
|
- IsFactoryDefault: boolean;
|
|
|
|
- MinBMI: number;
|
|
|
|
- MaxBMI: number;
|
|
|
|
- AutoDecompression: boolean;
|
|
|
|
- ConfigObjectValue: string;
|
|
|
|
-}
|
|
|
|
|
|
+// export interface Procedure {
|
|
|
|
+// ProcedureID: string;
|
|
|
|
+// ProcedureCode: string;
|
|
|
|
+// ProcedureName: string;
|
|
|
|
+// ProcedureOtherName: string;
|
|
|
|
+// ProcedureDescription: string;
|
|
|
|
+// PatientType: string;
|
|
|
|
+// ProcedureGroupID: string;
|
|
|
|
+// ProcedureType: string;
|
|
|
|
+// FastSearch: boolean;
|
|
|
|
+// Enable: boolean;
|
|
|
|
+// Order: number;
|
|
|
|
+// UserGroupID: string;
|
|
|
|
+// ProcedureCategory: string;
|
|
|
|
+// Modality: string;
|
|
|
|
+// IsImplanted: boolean;
|
|
|
|
+// MagFactor: number;
|
|
|
|
+// // ProcedureViews: View[];
|
|
|
|
+// // ProcedureViewRelations: any[];
|
|
|
|
+// ClinicProtocol: boolean;
|
|
|
|
+// IsFactoryDefault: boolean;
|
|
|
|
+// MinBMI: number;
|
|
|
|
+// MaxBMI: number;
|
|
|
|
+// AutoDecompression: boolean;
|
|
|
|
+// ConfigObjectValue: string;
|
|
|
|
+// }
|
|
|
|
|
|
interface ViewSelectionState {
|
|
interface ViewSelectionState {
|
|
selectedViews: View[]; // 已选择体位列表
|
|
selectedViews: View[]; // 已选择体位列表
|
|
@@ -127,6 +130,39 @@ const initialState: ViewSelectionState = {
|
|
currentSelectionType: { selected: 'protocol' },
|
|
currentSelectionType: { selected: 'protocol' },
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+export interface FilterCondition {
|
|
|
|
+ selection: string;
|
|
|
|
+ patientType: string | null;
|
|
|
|
+ bodyPart: string | null;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const fetchViewsOrProtocols = createAsyncThunk(
|
|
|
|
+ 'data/fetchData',
|
|
|
|
+ async (filter: FilterCondition, { rejectWithValue }) => {
|
|
|
|
+ try {
|
|
|
|
+ if (filter.selection === 'protocol') {
|
|
|
|
+ const response = await fetchProcedures(
|
|
|
|
+ filter.patientType,
|
|
|
|
+ filter.bodyPart,
|
|
|
|
+ true
|
|
|
|
+ );
|
|
|
|
+ return response.data.procedure_list;
|
|
|
|
+ }
|
|
|
|
+ if (filter.selection === 'view') {
|
|
|
|
+ const response = await fetchViews(
|
|
|
|
+ filter.patientType,
|
|
|
|
+ filter.bodyPart,
|
|
|
|
+ true,
|
|
|
|
+ null
|
|
|
|
+ );
|
|
|
|
+ return response.data.view_list;
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ return rejectWithValue(error.message);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+);
|
|
|
|
+
|
|
const viewSelectionSlice = createSlice({
|
|
const viewSelectionSlice = createSlice({
|
|
name: 'viewSelection',
|
|
name: 'viewSelection',
|
|
initialState,
|
|
initialState,
|
|
@@ -170,10 +206,33 @@ const viewSelectionSlice = createSlice({
|
|
}
|
|
}
|
|
})
|
|
})
|
|
.addCase(setSelected, (state, action) => {
|
|
.addCase(setSelected, (state, action) => {
|
|
- console.log(
|
|
|
|
- `在view section中感知到 currentSelectionType : ${action.payload}`
|
|
|
|
- );
|
|
|
|
|
|
+ console
|
|
|
|
+ .log
|
|
|
|
+ // `在view section中感知到 currentSelectionType : ${action.payload}`
|
|
|
|
+ ();
|
|
state.currentSelectionType.selected = action.payload;
|
|
state.currentSelectionType.selected = action.payload;
|
|
|
|
+ })
|
|
|
|
+ // eslint-disable-next-line
|
|
|
|
+ .addCase(fetchViewsOrProtocols.pending, (state, action) => {
|
|
|
|
+ console.log(`查询view或者protocals:pending`);
|
|
|
|
+ })
|
|
|
|
+ .addCase(fetchViewsOrProtocols.fulfilled, (state, action) => {
|
|
|
|
+ // console.log(`查询view或者protocals: fulfilled ${JSON.stringify(action.payload)}`);
|
|
|
|
+ if (action.meta.arg.selection === 'view') {
|
|
|
|
+ state.availableViews = action.payload as unknown as View[];
|
|
|
|
+ console.log(
|
|
|
|
+ `查询 Views : fulfilled ${JSON.stringify(state.availableViews)}`
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ state.protocols = action.payload as unknown as Procedure[];
|
|
|
|
+ console.log(
|
|
|
|
+ `查询protocals: fulfilled ${JSON.stringify(state.protocols)}`
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ // eslint-disable-next-line
|
|
|
|
+ .addCase(fetchViewsOrProtocols.rejected, (state, action) => {
|
|
|
|
+ console.log(`查询view或者protocals: rejected`);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
});
|
|
});
|