|
|
@@ -22,13 +22,14 @@ import utc from 'dayjs/plugin/utc';
|
|
|
import { View } from '@/API/patient/viewActions';
|
|
|
import BodyPositionFilter from './components/bodyPositionFilter';
|
|
|
import { omitAnimalSchemaMap } from '@/domain/animalSpecificInfo';
|
|
|
-import { RootState } from '@/states/store';
|
|
|
+import store, { RootState } from '@/states/store';
|
|
|
import { omitHumanSchemaMap } from '@/domain/humanSpecificInfo';
|
|
|
import { setBusinessFlow } from '@/states/BusinessFlowSlice';
|
|
|
import { selectRegisterInfo } from '@/states/patient/reregister/reregisterSlice';
|
|
|
import { clearReRegister } from '@/states/patient/reregister/reregisterSlice';
|
|
|
import useEffectiveBreakpoint from '../../hooks/useEffectiveBreakpoint';
|
|
|
import { QRCodeScanButton } from '@/components/QRCodeScanner';
|
|
|
+import { executeRegisterLogic } from '@/domain/patient/registerLogic';
|
|
|
dayjs.extend(utc);
|
|
|
|
|
|
const { Panel } = Collapse;
|
|
|
@@ -37,7 +38,7 @@ const RegisterPage: React.FC = () => {
|
|
|
const screens = useEffectiveBreakpoint();
|
|
|
const [form] = Form.useForm();
|
|
|
const dispatch = useDispatch();
|
|
|
- const { selectedViews, currentPatientType } = useRegisterState();
|
|
|
+ //const { selectedViews, currentPatientType } = useRegisterState();
|
|
|
const productName = useSelector(
|
|
|
(state: RootState) => state.product.productName
|
|
|
);
|
|
|
@@ -98,83 +99,15 @@ const RegisterPage: React.FC = () => {
|
|
|
data?: RegisterWorkResponseData;
|
|
|
views?: View[];
|
|
|
}> => {
|
|
|
- try {
|
|
|
- let values = form.getFieldsValue();
|
|
|
- // //转换年龄
|
|
|
- // console.log(`转换前的年龄值:${JSON.stringify(values.patient_age)}`)
|
|
|
- // const age=`${values.patient_age.number}${values.patient_age.unit}`;
|
|
|
- // console.log(`转换后的年龄和转换前的年龄:${age}---${values.patient_age}`)
|
|
|
- let formatDob = '';
|
|
|
- if (values.patient_dob) {
|
|
|
- try {
|
|
|
- const date = dayjs.utc(values.patient_dob);
|
|
|
- if (date.isValid()) {
|
|
|
- formatDob = date.format('YYYY-MM-DDTHH:mm:ss.SSS[Z]');
|
|
|
- } else {
|
|
|
- console.error('Invalid patient_dob date:', values.patient_dob);
|
|
|
- formatDob = '';
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('Error parsing patient_dob:', error);
|
|
|
- formatDob = '';
|
|
|
- }
|
|
|
- }
|
|
|
- console.log(`转换后的日期:${formatDob}`);
|
|
|
-
|
|
|
- values = { ...values, patient_dob: formatDob };
|
|
|
- console.log(`${JSON.stringify(values, null, 2)}`);
|
|
|
-
|
|
|
- let validateResult;
|
|
|
- if (productName === 'VETDROS') {
|
|
|
- const animalSchema = registerformSchema.omit(omitHumanSchemaMap);
|
|
|
- validateResult = animalSchema.safeParse(values);
|
|
|
- } else {
|
|
|
- const humanSchema = registerformSchema.omit(omitAnimalSchemaMap);
|
|
|
- validateResult = humanSchema.safeParse(values);
|
|
|
- }
|
|
|
- if (!validateResult.success) {
|
|
|
- message.error(`必填项未填写或者不合规则`);
|
|
|
- // todo 更详细和人性化的提示
|
|
|
- // message.error(JSON.stringify(validateResult.error, null, 2));
|
|
|
- console.log(JSON.stringify(validateResult.error, null, 2));
|
|
|
-
|
|
|
- return { success: false, views: [] as [] };
|
|
|
- }
|
|
|
- const registerInfo: RegisterInfo = {
|
|
|
- ...values,
|
|
|
- patient_type: currentPatientType?.patient_type_id,
|
|
|
- modality: 'DX',
|
|
|
- study_type: 'Normal',
|
|
|
- patient_age: `${values.patient_age.number.toString().padStart(3, '0')}${values.patient_age.unit}`, //发送前转换为字符串
|
|
|
- views: selectedViews.map((view) => ({
|
|
|
- view_id: view.view_id,
|
|
|
- procedure_id: view.procedure_id,
|
|
|
- })),
|
|
|
- };
|
|
|
- const response: RegisterWorkResponse = await registerWork(registerInfo);
|
|
|
- if (response.code !== '0x000000') {
|
|
|
- message.error(`注册失败: ${response.description}`);
|
|
|
- return { success: false, views: [] };
|
|
|
- }
|
|
|
- console.log('Work registered successfully:', response);
|
|
|
- message.info('Work registered successfully');
|
|
|
-
|
|
|
- // 清理时机1:注册成功后清理表单
|
|
|
- // 1. 清理 Redux formSlice
|
|
|
- dispatch(clearFormData());
|
|
|
- // 2. 清理 Ant Design Form
|
|
|
- form.resetFields();
|
|
|
- // 3. selectedViews 会在 Redux 中自动清空(已在 viewSelectionSlice 中实现)
|
|
|
- console.log('注册成功,表单已清空,可以开始新的注册');
|
|
|
-
|
|
|
- return { success: true, data: response.data, views: selectedViews };
|
|
|
- } catch (error) {
|
|
|
- console.error('Error registering work:', error);
|
|
|
- message.error(
|
|
|
- 'Error registering work, please check that console for details.'
|
|
|
- );
|
|
|
- return { success: false, views: [] };
|
|
|
- }
|
|
|
+ const result = await executeRegisterLogic({ getState: () => store.getState() });
|
|
|
+ // 清理时机1:注册成功后清理表单
|
|
|
+ // 1. 清理 Redux formSlice
|
|
|
+ dispatch(clearFormData());
|
|
|
+ // 2. 清理 Ant Design Form
|
|
|
+ form.resetFields();
|
|
|
+ // 3. selectedViews 会在 Redux 中自动清空(已在 viewSelectionSlice 中实现)
|
|
|
+ console.log('注册成功,表单已清空,可以开始新的注册');
|
|
|
+ return result;
|
|
|
};
|
|
|
|
|
|
return (
|