فهرست منبع

modify lvstudy calc

Melon 11 ماه پیش
والد
کامیت
6be72c21d4
2فایلهای تغییر یافته به همراه120 افزوده شده و 54 حذف شده
  1. 48 0
      lib/process/calcuators/formulas/cardiac.dart
  2. 72 54
      lib/process/calcuators/lv_study.dart

+ 48 - 0
lib/process/calcuators/formulas/cardiac.dart

@@ -1,5 +1,6 @@
 import 'dart:math' as math;
 
+import 'package:fis_measure/configs/cardiac.dart';
 import 'package:fis_measure/utils/number.dart';
 
 class CardiacFormulas {
@@ -87,4 +88,51 @@ class CardiacFormulas {
     // 计算公式相同,入参不同
     return edvCube(lvids);
   }
+
+  /// SV
+  static double sv(double edv, double esv) {
+    return edv - esv;
+  }
+
+  /// CO
+  static double co(
+    double sv, {
+    required int hr,
+  }) {
+    return (sv - hr) / 1000.0;
+  }
+
+  /// CI
+  static double ci(
+    double sv, {
+    required int hr,
+    required double bsa,
+  }) {
+    return ((sv - hr) / 1000.0) / bsa;
+  }
+
+  /// LVdMass
+  static double lvdMass(double ivsd, double lvidd, double lvpwd) {
+    const density = GlobalCardiacConfigs.density;
+    const correctionFactor = GlobalCardiacConfigs.correctionFactor;
+    double part1 = math.pow(ivsd + lvidd + lvpwd, 3).toDouble();
+    double part2 = math.pow(lvidd, 3).toDouble();
+    double value = ((density * part1 - part2) + correctionFactor) / 1000.0;
+    return value;
+  }
+
+  /// %FS
+  static double fsPercent(double lvidd, double lvids) {
+    return ((lvidd - lvids) / lvidd) * 100;
+  }
+
+  /// %IVS
+  static double ivsPercent(double ivss, double ivsd) {
+    return ((ivss - ivsd) / ivsd) * 100;
+  }
+
+  /// %LVPW
+  static double lvpwPercent(double lvpws, double lvpwd) {
+    return ((lvpws - lvpwd) / lvpwd) * 100;
+  }
 }

+ 72 - 54
lib/process/calcuators/lv_study.dart

@@ -33,7 +33,6 @@ class LvStudyDistanceGroupCal extends Calculator<StraightLineGroup, double> {
     if (ref.feature == null) return;
 
     final feature = ref.feature!;
-    // feature.updateStringValue(ref.meta.outputs.first, "");
 
     _v = _ValTemp();
     _v.ivsd = pickChildFloatValue(kidIVSd);
@@ -54,33 +53,35 @@ class LvStudyDistanceGroupCal extends Calculator<StraightLineGroup, double> {
         case MeasureTerms.LVESV:
           _updateLVESV();
           break;
+        case MeasureTerms.LVdMass:
+          _updateLVdMass();
+          break;
+        case MeasureTerms.PercentIVS:
+          _updatePercentIVS();
+          break;
+        case MeasureTerms.SV:
+          _updateSV();
+          break;
+        case MeasureTerms.EF:
+          _updateEF();
+          break;
+        case MeasureTerms.FS:
+          _updatePercentFS();
+          break;
+        case MeasureTerms.PercentLVPW:
+          _updatePercentLVPW();
+          break;
+        case MeasureTerms.CO:
+          _updateCO();
+          break;
+        case MeasureTerms.CI:
+          _updateCI();
+          break;
+        case MeasureTerms.SI:
+          _updateSI();
+          break;
       }
     }
-
-    // if (ivsd != null && ivss != null) {
-    //   _updatePercentIVS(ivss, ivsd);
-    // }
-
-    // if (lvidd != null && lvids != null) {
-    //   _updateSV();
-    //   _updateEF();
-
-    //   _updatePercentFS(lvidd, lvids);
-    // }
-
-    // if (lvpws != null && lvpwd != null) {
-    //   _updatePercentLVPW(lvpws, lvpwd);
-    // }
-
-    // if (ivsd != null && lvidd != null && lvpwd != null) {
-    //   _updateLVdMass(ivsd, ivsd, lvpwd);
-    // }
-
-    ref.feature!.values;
-    // ref.meta.outputs
-
-    // updateStringValue("");
-    // return;
   }
 
   void _updateLVEDV() {
@@ -119,13 +120,30 @@ class LvStudyDistanceGroupCal extends Calculator<StraightLineGroup, double> {
     _v.lvesv = value;
   }
 
+  void _updateLVdMass() {
+    if (_v.ivsd == null || _v.lvidd == null || _v.lvpwd == null) {
+      return;
+    }
+
+    double value = CardiacFormulas.lvdMass(_v.lvids!, _v.lvidd!, _v.lvpwd!);
+    _updateFloatValueByName(MeasureTerms.LVdMass, value);
+  }
+
+  void _updatePercentIVS() {
+    if (_v.ivsd == null || _v.ivss == null) {
+      return;
+    }
+    double value = CardiacFormulas.ivsPercent(_v.ivss!, _v.ivsd!);
+    _updateFloatValueByName(MeasureTerms.PercentIVS, value);
+  }
+
   void _updateSV() {
     if (_v.lvedv == null || _v.lvesv == null) {
       return;
     }
     final edv = _v.lvedv!;
     final esv = _v.lvesv!;
-    double value = edv - esv;
+    double value = CardiacFormulas.sv(edv, esv);
     _updateFloatValueByName(MeasureTerms.SV, value);
     _v.sv = value;
   }
@@ -136,44 +154,35 @@ class LvStudyDistanceGroupCal extends Calculator<StraightLineGroup, double> {
     }
     final edv = _v.lvedv!;
     final esv = _v.lvesv!;
-    double value = ((edv - esv) / edv) * 100;
+    double value = CardiacFormulas.ef(edv, esv);
     _updateFloatValueByName(MeasureTerms.EF, value);
-    _v.sv = value;
   }
 
-  void _updatePercentFS(double lvidd, double lvids) {
-    double value = ((lvidd - lvids) / lvidd) * 100;
+  void _updatePercentFS() {
+    if (_v.lvidd == null || _v.lvids == null) {
+      return;
+    }
+    final lvidd = _v.lvidd!;
+    final lvids = _v.lvids!;
+    double value = CardiacFormulas.fsPercent(lvidd, lvids);
     _updateFloatValueByName(MeasureTerms.FS, value);
-    _v.sv = value;
   }
 
-  void _updatePercentIVS(double ivss, double ivsd) {
-    double value = ((ivss - ivsd) / ivsd) * 100;
-    _updateFloatValueByName(MeasureTerms.PercentIVS, value);
-    _v.sv = value;
-  }
-
-  void _updatePercentLVPW(double lvpws, double lvpwd) {
-    double value = ((lvpws - lvpwd) / lvpwd) * 100;
+  void _updatePercentLVPW() {
+    if (_v.lvpws == null || _v.lvpwd == null) {
+      return;
+    }
+    final lvpws = _v.lvpws!;
+    final lvpwd = _v.lvpwd!;
+    double value = CardiacFormulas.lvpwPercent(lvpws, lvpwd);
     _updateFloatValueByName(MeasureTerms.PercentLVPW, value);
-    _v.sv = value;
-  }
-
-  void _updateLVdMass(double ivsd, double lvidd, double lvpwd) {
-    const density = GlobalCardiacConfigs.density;
-    const correctionFactor = GlobalCardiacConfigs.correctionFactor;
-    double part1 = math.pow(ivsd + lvidd + lvpwd, 3).toDouble();
-    double part2 = math.pow(lvidd, 3).toDouble();
-    double value = ((density * part1 - part2) + correctionFactor) / 1000.0;
-    _updateFloatValueByName(MeasureTerms.LVdMass, value);
-    _v.sv = value;
   }
 
   void _updateCO() {
     if (_v.sv == null || _v.hr == null) {
       return;
     }
-    double value = (_v.sv! - _v.hr!) / 1000.0;
+    double value = CardiacFormulas.co(_v.sv!, hr: _v.hr!);
     _updateFloatValueByName(MeasureTerms.CO, value);
   }
 
@@ -181,10 +190,19 @@ class LvStudyDistanceGroupCal extends Calculator<StraightLineGroup, double> {
     if (_v.sv == null || _v.hr == null) {
       return;
     }
-    double value = ((_v.sv! - _v.hr!) / 1000.0) / GlobalPatientConfig.BSA;
+    double value = CardiacFormulas.ci(
+      _v.sv!,
+      hr: _v.hr!,
+      bsa: GlobalPatientConfig.BSA,
+    );
     _updateFloatValueByName(MeasureTerms.CI, value);
   }
 
+  void _updateSI() {
+    //_updateSI
+    // TODO:
+  }
+
   void _updateFloatValueByName(
     String name,
     double value, {
@@ -208,5 +226,5 @@ class _ValTemp {
   double? lvedv = 0.0;
   double? lvesv = 0.0;
   double? sv = 0.0;
-  double? hr = 0.0;
+  int? hr = 72; // TODO: from vid ext
 }