|
@@ -1,4 +1,12 @@
|
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
|
|
+import { setCurrentPatientType } from '../../patientTypeSlice';
|
|
|
|
+import { BodyPart } from '@/API/bodyPart';
|
|
|
|
+import { PatientType } from '@/API/patientType';
|
|
|
|
+import {
|
|
|
|
+ SelectionState,
|
|
|
|
+ setSelected,
|
|
|
|
+} from '@/states/patient/register/SelectionTypeSlice';
|
|
|
|
+import { setCurrentBodyPart } from '../../bodyPartSlice';
|
|
|
|
|
|
// 体位类型
|
|
// 体位类型
|
|
export interface View {
|
|
export interface View {
|
|
@@ -58,15 +66,9 @@ interface ViewSelectionState {
|
|
selectedViews: View[]; // 已选择体位列表
|
|
selectedViews: View[]; // 已选择体位列表
|
|
availableViews: View[]; // 待选择体位列表
|
|
availableViews: View[]; // 待选择体位列表
|
|
protocols: Procedure[]; // 协议列表(只会出现在待选择列表)
|
|
protocols: Procedure[]; // 协议列表(只会出现在待选择列表)
|
|
-}
|
|
|
|
-
|
|
|
|
-//type SelectionType = 'protocol' | 'view';
|
|
|
|
-
|
|
|
|
-interface ViewSelectionState {
|
|
|
|
- selectedViews: View[]; // 已选择体位列表
|
|
|
|
- availableViews: View[]; // 待选择体位列表
|
|
|
|
- protocols: Procedure[]; // 协议列表(只会出现在待选择列表)
|
|
|
|
- //selectionType: SelectionType; // 可选择值为 'protocol' | 'view'
|
|
|
|
|
|
+ currentBodyPart: BodyPart | null;
|
|
|
|
+ currentPatientType: PatientType | null;
|
|
|
|
+ currentSelectionType: SelectionState;
|
|
}
|
|
}
|
|
|
|
|
|
const initialState: ViewSelectionState = {
|
|
const initialState: ViewSelectionState = {
|
|
@@ -120,7 +122,9 @@ const initialState: ViewSelectionState = {
|
|
},
|
|
},
|
|
],
|
|
],
|
|
protocols: [],
|
|
protocols: [],
|
|
- //selectionType: 'protocol',
|
|
|
|
|
|
+ currentBodyPart: null,
|
|
|
|
+ currentPatientType: null,
|
|
|
|
+ currentSelectionType: { selected: 'protocol' },
|
|
};
|
|
};
|
|
|
|
|
|
const viewSelectionSlice = createSlice({
|
|
const viewSelectionSlice = createSlice({
|
|
@@ -133,7 +137,7 @@ const viewSelectionSlice = createSlice({
|
|
},
|
|
},
|
|
// 添加协议中的所有体位到已选择体位列表
|
|
// 添加协议中的所有体位到已选择体位列表
|
|
// eslint-disable-next-line
|
|
// eslint-disable-next-line
|
|
- addProtocolViews(state, action: PayloadAction<Procedure>) {
|
|
|
|
|
|
+ addProtocolViews(state, action: PayloadAction<Procedure>) {
|
|
// 假设协议中包含 ProcedureViews 属性,存储体位数组
|
|
// 假设协议中包含 ProcedureViews 属性,存储体位数组
|
|
// todo 这里涉及到基于协议查询其名下的体位,然后再添加
|
|
// todo 这里涉及到基于协议查询其名下的体位,然后再添加
|
|
// if (Array.isArray(action.payload.ProcedureViews)) {
|
|
// if (Array.isArray(action.payload.ProcedureViews)) {
|
|
@@ -148,6 +152,30 @@ const viewSelectionSlice = createSlice({
|
|
state.protocols = action.payload;
|
|
state.protocols = action.payload;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ extraReducers: (builder) => {
|
|
|
|
+ builder
|
|
|
|
+ .addCase(setCurrentPatientType, (state, action) => {
|
|
|
|
+ const currentPatientType = action.payload;
|
|
|
|
+ if (currentPatientType) {
|
|
|
|
+ // console.log(`在view section中感知到 current patient type 变化: ${currentPatientType.patient_type_name}`);
|
|
|
|
+ // 基于过滤条件查询协议或者体位
|
|
|
|
+ state.currentPatientType = currentPatientType;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .addCase(setCurrentBodyPart, (state, action) => {
|
|
|
|
+ const currentBodyPart = action.payload;
|
|
|
|
+ if (currentBodyPart) {
|
|
|
|
+ state.currentBodyPart = currentBodyPart;
|
|
|
|
+ // console.log(`在view section中感知到 currentBodyPart 变化: ${JSON.stringify(currentBodyPart, null, 2)}`);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .addCase(setSelected, (state, action) => {
|
|
|
|
+ console.log(
|
|
|
|
+ `在view section中感知到 currentSelectionType : ${action.payload}`
|
|
|
|
+ );
|
|
|
|
+ state.currentSelectionType.selected = action.payload;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
});
|
|
});
|
|
|
|
|
|
export const {
|
|
export const {
|