|
@@ -31,48 +31,53 @@ const RegisterPage: React.FC = () => {
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
const { selectedViews, currentPatientType } = useRegisterState();
|
|
const { selectedViews, currentPatientType } = useRegisterState();
|
|
|
|
|
|
-const handleRegister = async (): Promise<{ success: boolean; data?: any; views?: View[] }> => {
|
|
|
|
- try {
|
|
|
|
- let values = form.getFieldsValue();
|
|
|
|
- const formatDob = values.patient_dob
|
|
|
|
- ? dayjs.utc(values.patient_dob).format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') //values.patient_dob.toString('YYYY-MM-DD[T00:00:00.000000Z]')
|
|
|
|
- : '';
|
|
|
|
- console.log(`转换后的日期:${formatDob}`);
|
|
|
|
|
|
+ const handleRegister = async (): Promise<{
|
|
|
|
+ success: boolean;
|
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
+ data?: any;
|
|
|
|
+ views?: View[];
|
|
|
|
+ }> => {
|
|
|
|
+ try {
|
|
|
|
+ let values = form.getFieldsValue();
|
|
|
|
+ const formatDob = values.patient_dob
|
|
|
|
+ ? dayjs.utc(values.patient_dob).format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') //values.patient_dob.toString('YYYY-MM-DD[T00:00:00.000000Z]')
|
|
|
|
+ : '';
|
|
|
|
+ console.log(`转换后的日期:${formatDob}`);
|
|
|
|
|
|
- values = { ...values, patient_dob: formatDob };
|
|
|
|
- console.log(`${JSON.stringify(values, null, 2)}`);
|
|
|
|
|
|
+ values = { ...values, patient_dob: formatDob };
|
|
|
|
+ console.log(`${JSON.stringify(values, null, 2)}`);
|
|
|
|
|
|
- const validateResult = registerformSchema.safeParse(values);
|
|
|
|
- if (!validateResult.success) {
|
|
|
|
- message.error(`必填项未填写或者不合规则`);
|
|
|
|
- // todo 更详细和人性化的提示
|
|
|
|
- // message.error(JSON.stringify(validateResult.error, null, 2));
|
|
|
|
- console.log(JSON.stringify(validateResult.error, null, 2));
|
|
|
|
|
|
+ const validateResult = registerformSchema.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 [] };
|
|
|
|
|
|
+ return { success: false, views: [] as [] };
|
|
|
|
+ }
|
|
|
|
+ const registerInfo: RegisterInfo = {
|
|
|
|
+ ...values,
|
|
|
|
+ patient_type: currentPatientType?.patient_type_id,
|
|
|
|
+ modality: 'dx',
|
|
|
|
+ study_type: 'Normal',
|
|
|
|
+ views: selectedViews.map((view) => ({
|
|
|
|
+ view_id: view.view_id,
|
|
|
|
+ procedure_id: view.procedure_id,
|
|
|
|
+ })),
|
|
|
|
+ };
|
|
|
|
+ const response = await registerWork(registerInfo);
|
|
|
|
+ console.log('Work registered successfully:', response);
|
|
|
|
+ message.info('Work registered successfully');
|
|
|
|
+ return { success: true, data: response.data, views: selectedViews };
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('Error registering work:', error);
|
|
|
|
+ message.error(
|
|
|
|
+ 'Error registering work, please check the console for details.'
|
|
|
|
+ );
|
|
|
|
+ return { success: false, views: [] };
|
|
}
|
|
}
|
|
- const registerInfo: RegisterInfo = {
|
|
|
|
- ...values,
|
|
|
|
- patient_type: currentPatientType?.patient_type_id,
|
|
|
|
- modality: 'dx',
|
|
|
|
- study_type: 'Normal',
|
|
|
|
- views: selectedViews.map((view) => ({
|
|
|
|
- view_id: view.view_id,
|
|
|
|
- procedure_id: view.procedure_id,
|
|
|
|
- })),
|
|
|
|
- };
|
|
|
|
- const response = await registerWork(registerInfo);
|
|
|
|
- console.log('Work registered successfully:', response);
|
|
|
|
- message.info('Work registered successfully');
|
|
|
|
- return { success: true, data: response.data, views: selectedViews };
|
|
|
|
- } catch (error) {
|
|
|
|
- console.error('Error registering work:', error);
|
|
|
|
- message.error(
|
|
|
|
- 'Error registering work, please check the console for details.'
|
|
|
|
- );
|
|
|
|
- return { success: false, views: [] };
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
@@ -89,7 +94,7 @@ const handleRegister = async (): Promise<{ success: boolean; data?: any; views?:
|
|
display: 'flex',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
flexDirection: 'column',
|
|
}}
|
|
}}
|
|
- className="h-full"
|
|
|
|
|
|
+ className="h-full px-4"
|
|
>
|
|
>
|
|
<BasicInfoForm form={form} style={{ overflow: 'auto' }} />
|
|
<BasicInfoForm form={form} style={{ overflow: 'auto' }} />
|
|
</Col>
|
|
</Col>
|
|
@@ -178,12 +183,17 @@ const handleRegister = async (): Promise<{ success: boolean; data?: any; views?:
|
|
<Button type="primary" onClick={handleRegister}>
|
|
<Button type="primary" onClick={handleRegister}>
|
|
注册
|
|
注册
|
|
</Button>
|
|
</Button>
|
|
- <Button type="default" onClick={async () => {
|
|
|
|
- const registerResult = await handleRegister();
|
|
|
|
- if (registerResult.success) {
|
|
|
|
- await registerToExam(registerResult.data,registerResult.views);
|
|
|
|
- }
|
|
|
|
- }}>检查</Button>
|
|
|
|
|
|
+ <Button
|
|
|
|
+ type="default"
|
|
|
|
+ onClick={async () => {
|
|
|
|
+ const registerResult = await handleRegister();
|
|
|
|
+ if (registerResult.success) {
|
|
|
|
+ await registerToExam(registerResult.data, registerResult.views);
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ 检查
|
|
|
|
+ </Button>
|
|
</Space>
|
|
</Space>
|
|
</>
|
|
</>
|
|
);
|
|
);
|