Bladeren bron

feat(report): auto-populate patient information when entering diagnostic report

sw 3 weken geleden
bovenliggende
commit
894796f5a5
1 gewijzigde bestanden met toevoegingen van 9 en 5 verwijderingen
  1. 9 5
      src/pages/patient/DiagnosticReport/components/BaseInfo.tsx

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

@@ -20,12 +20,16 @@ export const BaseInfo: React.FC = () => {
     (s: RootState) => s.workSelection.selectedIds
   );
   const workEntities = useSelector((s: RootState) => s.workEntities.data);
-
-  const selectedStudy: Task =
-    selectedIds.length > 0 ? workEntities[selectedIds[0]] : null;
+  console.log(`【诊断报告】:选中的study id :${selectedIds[0]}`);
+  const selectedStudy: Task | null =
+    selectedIds.length > 0
+      ? (workEntities.find((t) => t.StudyID === selectedIds[0]) ?? null)
+      : null;
 
   useEffect(() => {
-    console.log(`【诊断报告】:selectedStudy是空吗?${selectedStudy === null}`);
+    console.log(
+      `【诊断报告】:selectedStudy是空吗?${selectedStudy === null} ${selectedStudy}`
+    );
     if (selectedStudy) {
       dispatch(
         updateField({ key: 'patientName', value: selectedStudy.PatientName })
@@ -52,7 +56,7 @@ export const BaseInfo: React.FC = () => {
       // dispatch(updateField({ key: 'examPosition', value: selectedStudy.examPosition }));
       // dispatch(updateField({ key: 'clinicalDiag', value: selectedStudy.clinicalDiag }));
     }
-  }, [dispatch]);
+  }, [selectedIds]);
   // eslint-disable-next-line @typescript-eslint/no-explicit-any
   const onChange = (key: keyof BaseInfoState, val: any) => {
     dispatch(updateField({ key, value: val }));