瀏覽代碼

feat(report): populate baseinfo in report with basic information from study list

sw 3 周之前
父節點
當前提交
dae1bea489

+ 47 - 5
src/pages/patient/DiagnosticReport/components/BaseInfo.tsx

@@ -8,12 +8,51 @@ import {
 } from '@/states/patient/DiagnosticReport/baseInfoSlice';
 import dayjs from 'dayjs';
 import { useSelector } from 'react-redux';
+import { useEffect } from 'react';
+import { Task } from '@/domain/work';
 
 const { Option } = Select;
 
 export const BaseInfo: React.FC = () => {
   const data = useSelector((s: RootState) => s.baseInfo);
   const dispatch = useAppDispatch();
+  const selectedIds = useSelector(
+    (s: RootState) => s.workSelection.selectedIds
+  );
+  const workEntities = useSelector((s: RootState) => s.workEntities.data);
+
+  const selectedStudy: Task =
+    selectedIds.length > 0 ? workEntities[selectedIds[0]] : null;
+
+  useEffect(() => {
+    console.log(`【诊断报告】:selectedStudy是空吗?${selectedStudy === null}`);
+    if (selectedStudy) {
+      dispatch(
+        updateField({ key: 'patientName', value: selectedStudy.PatientName })
+      );
+      dispatch(
+        updateField({ key: 'englishName', value: selectedStudy.PatientName })
+      );
+      dispatch(
+        updateField({ key: 'patientNo', value: selectedStudy.PatientID })
+      );
+      dispatch(updateField({ key: 'gender', value: selectedStudy.PatientSex }));
+      dispatch(updateField({ key: 'age', value: selectedStudy.PatientAge }));
+      // dispatch(updateField({ key: 'visitType', value: selectedStudy.visitType }));// 就诊类型
+      // dispatch(updateField({ key: 'clinicNo', value: selectedStudy.clinicNo }));
+      // dispatch(updateField({ key: 'department', value: selectedStudy.department }));//科室
+      dispatch(
+        updateField({
+          key: 'examTime',
+          value: selectedStudy.StudyStartDatetime,
+        })
+      );
+      // dispatch(updateField({ key: 'bodyPart', value: selectedStudy. }));
+      // dispatch(updateField({ key: 'examDesc', value: selectedStudy.examDesc }));
+      // dispatch(updateField({ key: 'examPosition', value: selectedStudy.examPosition }));
+      // dispatch(updateField({ key: 'clinicalDiag', value: selectedStudy.clinicalDiag }));
+    }
+  }, [dispatch]);
   // eslint-disable-next-line @typescript-eslint/no-explicit-any
   const onChange = (key: keyof BaseInfoState, val: any) => {
     dispatch(updateField({ key, value: val }));
@@ -26,6 +65,14 @@ export const BaseInfo: React.FC = () => {
   return (
     <Form layout="vertical">
       <Row gutter={12}>
+        <Col span={6}>
+          <Form.Item label="患者姓名">
+            <Input
+              value={data.patientName}
+              onChange={(e) => onChange('patientName', e.target.value)}
+            />
+          </Form.Item>
+        </Col>
         <Col span={6}>
           <Form.Item label="曾用名">
             <Input
@@ -47,11 +94,6 @@ export const BaseInfo: React.FC = () => {
             <Input disabled value={data.patientNo} />
           </Form.Item>
         </Col>
-        <Col span={6}>
-          <Form.Item label="检查单号">
-            <Input disabled value={data.examNo} />
-          </Form.Item>
-        </Col>
 
         <Col span={4}>
           <Form.Item label="性别">

+ 18 - 3
src/states/patient/DiagnosticReport/baseInfoSlice.ts

@@ -9,24 +9,37 @@ export interface BaseInfoState {
   usedName: string;
   englishName: string;
   patientNo: string;
-  examNo: string;
+  // examNo: string;
   gender: Gender;
   age: string;
   visitType: VisitType;
+  /**
+   * 门诊/住院号
+   */
   clinicNo: string;
+  /**
+   * 科室
+   */
   department: string;
   examTime: string;
   bodyPart: BodyPart;
   examDesc: string;
+  /**
+   * 检查部位
+   */
   examPosition: string;
+  /**
+   * 临床诊断
+   */
   clinicalDiag: string;
+  patientName: string;
 }
 
 const initialState: BaseInfoState = {
   usedName: '',
   englishName: '',
-  patientNo: 'ER_202508251654111',
-  examNo: 'ER_202508251654111',
+  patientNo: '',
+  // examNo: '',
   gender: '女',
   age: '',
   visitType: '门诊',
@@ -37,6 +50,7 @@ const initialState: BaseInfoState = {
   examDesc: '',
   examPosition: '',
   clinicalDiag: '',
+  patientName: '', 
 };
 
 const baseInfoSlice = createSlice({
@@ -47,6 +61,7 @@ const baseInfoSlice = createSlice({
       state,
       action: PayloadAction<{ key: keyof BaseInfoState; value: any }>
     ) {
+      console.log(`【诊断报告】:设置字段 ${action.payload.key}==${action.payload.value}`)
       if (action.payload.key === 'gender') {
         state.gender = action.payload.value as Gender;
       } else if (action.payload.key === 'visitType') {

+ 1 - 1
src/states/patient/DiagnosticReport/saveReportThunk.ts

@@ -16,7 +16,7 @@ export const saveReportThunk = createAsyncThunk(
         hospitalization_number: state.baseInfo.clinicNo,
         bed_number: state.baseInfo.department,
         requesting_department: state.baseInfo.department,
-        inspection_number: state.baseInfo.examNo,
+        inspection_number: state.baseInfo.patientNo, //todo 暂时使用患者编号
         inspection_method: state.baseInfo.examDesc,
       },
       findings: state.diagnosis.diagnosisDescription,