index.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React from 'react';
  2. import { useAppDispatch, useAppSelector } from '@/states/store';
  3. import { ReportHeader } from './components/ReportHeader';
  4. import { ReportMain } from './components/ReportMain';
  5. import { ReportFooter } from './components/ReportFooter';
  6. import PdfPreviewModal from '@/states/patient/DiagnosticReport/PdfPreviewModal';
  7. import { updateField } from '@/states/patient/DiagnosticReport/baseInfoSlice';
  8. const DiagnosticReport: React.FC = () => {
  9. const dispatch = useAppDispatch();
  10. const currentWork = useAppSelector(
  11. (state) => state.diagnosticReport.currentWork
  12. );
  13. const reportData = {}; // Define reportData here or fetch it from state or props
  14. const currentTheme = useAppSelector((state) => state.theme.currentTheme);
  15. // 初始化报告数据
  16. React.useEffect(() => {
  17. if (currentWork) {
  18. // 初始化 baseInfo slice
  19. dispatch(updateField({ key: 'studyId', value: currentWork.StudyID }));
  20. dispatch(
  21. updateField({
  22. key: 'patientName',
  23. value: currentWork.PatientName || currentWork.DisplayPatientName,
  24. })
  25. );
  26. dispatch(updateField({ key: 'patientNo', value: currentWork.PatientID }));
  27. dispatch(
  28. updateField({
  29. key: 'examTime',
  30. value: currentWork.StudyStartDatetime || '',
  31. })
  32. );
  33. dispatch(
  34. updateField({ key: 'examDesc', value: currentWork.StudyDescription })
  35. );
  36. dispatch(updateField({ key: 'age', value: currentWork.PatientAge }));
  37. dispatch(
  38. updateField({
  39. key: 'gender',
  40. value: currentWork.PatientSex === 'M' ? '男' : '女',
  41. })
  42. );
  43. // 暂时注释掉没有的字段,后续根据实际需要添加
  44. // dispatch(updateField({ key: 'department', value: currentWork.department || '' }));
  45. // dispatch(updateField({ key: 'examPosition', value: currentWork.body_part || '' }));
  46. // 初始化动物信息(如果适用)
  47. if (currentWork.owner_name) {
  48. // 这里可以添加动物信息的初始化
  49. }
  50. }
  51. }, [currentWork, dispatch]);
  52. return (
  53. <div
  54. className="flex flex-col h-full"
  55. style={{ backgroundColor: currentTheme.token.colorBgContainer }}
  56. >
  57. <ReportHeader />
  58. <ReportMain className="flex-1 overflow-scroll" />
  59. <ReportFooter reportData={reportData} />
  60. <PdfPreviewModal></PdfPreviewModal>
  61. </div>
  62. );
  63. };
  64. export default React.memo(DiagnosticReport);