Эх сурвалжийг харах

1、支持实验小鼠的心脏测量公式切换

guanxinyi 10 сар өмнө
parent
commit
dfb75e8403

+ 1 - 1
lib/configs/patient.dart

@@ -26,7 +26,7 @@ abstract class GlobalPatientConfig {
   static int? hr;
 
   /// 物种类型
-  static SpeciesType speciesType = SpeciesType.general;
+  static SpeciesType speciesType = SpeciesType.mouseGeneral;
 
   /// 切换物种
   static switchSpecies(SpeciesType type) {

+ 3 - 2
lib/interfaces/enums/species.dart

@@ -1,4 +1,5 @@
 enum SpeciesType {
-  general,
-  mouse,
+  mouseGeneral,
+
+  animals,
 }

+ 3 - 3
lib/process/calcuators/formulas/Urology.dart

@@ -6,9 +6,9 @@ import 'package:fis_measure/interfaces/enums/species.dart';
 class UrologyFormulas {
   UrologyFormulas._();
   static final IUrologyFormulaStrategy _singleton =
-      GlobalPatientConfig.speciesType != SpeciesType.general
+      GlobalPatientConfig.speciesType != SpeciesType.mouseGeneral
           ? BaseUrologyFormulas()
-          : MouseUrologyFormulas();
+          : AnimalsUrologyFormulas();
 
   static double calcRUV(double d1, double d2) {
     return _singleton.calcRUV(d1, d2);
@@ -28,4 +28,4 @@ class BaseUrologyFormulas implements IUrologyFormulaStrategy {
   }
 }
 
-class MouseUrologyFormulas extends BaseUrologyFormulas {}
+class AnimalsUrologyFormulas extends BaseUrologyFormulas {}

+ 78 - 23
lib/process/calcuators/formulas/cardiac.dart

@@ -8,9 +8,9 @@ import 'package:fis_measure/utils/number.dart';
 
 class CardiacFormulas {
   static final ICardiacFormulaStrategy _singleton =
-      GlobalPatientConfig.speciesType != SpeciesType.general
+      GlobalPatientConfig.speciesType == SpeciesType.mouseGeneral
           ? BaseCardiacFormulas()
-          : MouseCardiacFormulas();
+          : AnimalsCardiacFormulas();
 
   static double teiIndex(double co, double et) => _singleton.teiIndex(co, et);
   static double ef(double edv, double esv) => _singleton.ef(edv, esv);
@@ -78,6 +78,7 @@ abstract class ICardiacFormulaStrategy {
       [int num = 20]);
 }
 
+/// 实验室小鼠公式
 class BaseCardiacFormulas implements ICardiacFormulaStrategy {
   /// IMP
   ///
@@ -205,6 +206,7 @@ class BaseCardiacFormulas implements ICardiacFormulaStrategy {
   }
 
   /// LVdMass
+  /// LVd Mass(2D)
   @override
   double lvdMass(double ivsd, double lvidd, double lvpwd) {
     const density = GlobalCardiacConfigs.density;
@@ -340,38 +342,91 @@ class BaseCardiacFormulas implements ICardiacFormulaStrategy {
   }
 }
 
-class MouseCardiacFormulas extends BaseCardiacFormulas {
-  MouseCardiacFormulas() : super();
+/// 人用普通公式
+class AnimalsCardiacFormulas extends BaseCardiacFormulas {
+  AnimalsCardiacFormulas() : super();
 
   @override
-  double teiIndex(double co, double et) {
-    double imp = 0.0;
-    if (et != 0.0) {
-      imp = (((co).abs() - (et).abs()) / et).abs();
+  double edvTeichholz(double lvidd) {
+    double edv = double.nan;
+    lvidd = lvidd / 10;
+    if (!NumUtil.almostEquals(lvidd, 0)) {
+      edv = 7.0 * math.pow(lvidd, 3) / (2.4 + lvidd);
     }
-    return imp;
+    return edv;
   }
 
-  /// SV
+  /// CO
   @override
-  double sv(double edv, double esv) {
-    return 0;
+  double co(
+    double sv, {
+    required int hr,
+  }) {
+    return (sv - hr);
   }
 
-  /// EF
-  /// Formula: `(EDV - ESV )/EDV`
+  /// CI
+  @override
+  double ci(
+    double sv, {
+    required int hr,
+    required double bsa,
+  }) {
+    return ((sv - hr)) / bsa;
+  }
+
+  /// ESV (Teichholz)
   ///
-  /// [edv] Unit: `cm³`
+  ///  Formula: `[7.0/(2.4 + LVIDs)] x LVIDs^3`
   ///
-  /// [esv] Unit: `cm³`
+  /// [lvids] Unit: `cm`
   ///
-  /// Result Unit: `None`
+  /// Result Unit: `cm³`
   @override
-  double ef(double edv, double esv) {
-    // 这行判断暂时注释掉是为了使实际表现与旧版一致
-    // if (edv < esv) {
-    //   return double.nan;
-    // }
-    return 0.5;
+  double esvTeichholz(double lvids) {
+    // 计算公式相同,入参不同
+    return edvTeichholz(lvids);
+  }
+
+  /// LVdMass
+  /// LVd Mass(2D)
+  @override
+  double lvdMass(double ivsd, double lvidd, double lvpwd) {
+    ivsd = ivsd / 10;
+    lvidd = lvidd / 10;
+    lvpwd = lvpwd / 10;
+    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;
+  }
+
+  /// <summary>
+  /// <para>MVA VTI = 1/4 x π x (LVOT Diam)^2 x LVOT VTI/MV VTI </para>
+  /// <para>AVA VTI = 1/4 x π x (LVOT Diam)^2 x LVOT VTI/AV VTI</para>
+  /// <para>TVA VTI = 1/4 x π x (RVOT Diam)^2 x RVOT VTI/TV VTI</para>
+  /// <para>PVA VTI = 1/4 x π x (RVOT Diam)^2 x RVOT VTI/PV VTI</para>
+  /// </summary>
+  /// <param name="otDiam">cm</param>
+  /// <param name="otvti">cm</param>
+  /// <param name="vti">cm</param>
+  /// <returns>cm^2</returns>
+  /// SV(LVOT)|CO
+  @override
+  double flowAreaByVTI(double otDiam, double otvti, double vti) {
+    otDiam = otDiam / 10;
+    otvti = otvti / 10;
+    vti = vti / 10;
+    double sv = 0.25 * math.pi * math.pow(otDiam, 2) * otvti / vti;
+    return sv;
+  }
+
+  /// LVd Mass Index
+  @override
+  double lvdMassIndex(double lvdmass, double bsa) {
+    lvdmass = lvdmass / 10;
+    return lvdmass / bsa * 1000;
   }
 }

+ 3 - 3
lib/process/calcuators/formulas/general.dart

@@ -11,9 +11,9 @@ class GeneralFormulas {
   static const double VolumeCofficient = math.pi / 6.0;
 
   static final IGeneralFormulaStrategy _singleton =
-      GlobalPatientConfig.speciesType != SpeciesType.general
+      GlobalPatientConfig.speciesType != SpeciesType.mouseGeneral
           ? BaseGeneralFormulas()
-          : MouseGeneralFormulas();
+          : AnimalsGeneralFormulas();
 
   static double volumeTwoLine(double d1, double d2,
           [bool useBigValue = true]) =>
@@ -427,4 +427,4 @@ class BaseGeneralFormulas implements IGeneralFormulaStrategy {
   }
 }
 
-class MouseGeneralFormulas extends BaseGeneralFormulas {}
+class AnimalsGeneralFormulas extends BaseGeneralFormulas {}

+ 3 - 3
lib/process/calcuators/formulas/obstetrics.dart

@@ -6,9 +6,9 @@ import 'package:fis_measure/utils/number.dart';
 class ObstetricsFormulas {
   ObstetricsFormulas._();
   static final IObstetricsFormulaStrategy _singleton =
-      GlobalPatientConfig.speciesType != SpeciesType.general
+      GlobalPatientConfig.speciesType != SpeciesType.mouseGeneral
           ? BaseObstetricsFormulas()
-          : MouseObstetricsFormulas();
+          : AnimalsObstetricsFormulas();
 
   static double gsMean(double d1, double d2, double d3) =>
       _singleton.gsMean(d1, d2, d3);
@@ -55,4 +55,4 @@ class BaseObstetricsFormulas implements IObstetricsFormulaStrategy {
   }
 }
 
-class MouseObstetricsFormulas extends BaseObstetricsFormulas {}
+class AnimalsObstetricsFormulas extends BaseObstetricsFormulas {}

+ 36 - 5
lib/process/items/item_feature.dart

@@ -1,5 +1,7 @@
 import 'package:fis_common/logger/logger.dart';
+import 'package:fis_measure/configs/patient.dart';
 import 'package:fis_measure/interfaces/date_types/point.dart';
+import 'package:fis_measure/interfaces/enums/species.dart';
 import 'package:fis_measure/interfaces/process/calculators/values.dart';
 import 'package:fis_measure/interfaces/process/items/item.dart';
 import 'package:fis_measure/interfaces/process/items/item_feature.dart';
@@ -124,7 +126,9 @@ abstract class MeasureItemFeature implements IMeasureItemFeature {
     VidUsUnit unit,
   ) {
     int index = values.indexWhere((e) => e.meta.name == outputMeta.name);
+    VidUsUnit currentUnit = updateUnitBySpeciesType(unit);
     if (index < 0) {
+      unit = currentUnit;
       final floatValue = FloatValue(outputMeta, value, unit);
       values.add(floatValue);
       return floatValue;
@@ -133,16 +137,41 @@ abstract class MeasureItemFeature implements IMeasureItemFeature {
       if (valueBase is FloatValue) {
         final floatValue = valueBase;
         floatValue.value = value;
-        floatValue.unit = unit;
+        outputMeta.unit = currentUnit;
         return floatValue;
       } else {
-        final newValue = FloatValue(outputMeta, value, unit);
+        final newValue = FloatValue(outputMeta, value, currentUnit);
         values[index] = newValue;
         return newValue;
       }
     }
   }
 
+  VidUsUnit updateUnitBySpeciesType(VidUsUnit unit) {
+    if (GlobalPatientConfig.speciesType != SpeciesType.mouseGeneral) {
+      return unit;
+    }
+    if (unit == VidUsUnit.cm3) {
+      return VidUsUnit.mm3;
+    } else if (unit == VidUsUnit.cm) {
+      return VidUsUnit.mm;
+    } else if (unit == VidUsUnit.cm2) {
+      return VidUsUnit.mm2;
+    } else if (unit == VidUsUnit.Lmin) {
+      return VidUsUnit.mlmin;
+    } else if (unit == VidUsUnit.Lminm2) {
+      return VidUsUnit.mlmincm2;
+    } else if (unit == VidUsUnit.ml) {
+      return VidUsUnit.mil;
+    } else if (unit == VidUsUnit.g) {
+      return VidUsUnit.mg;
+    } else if (unit == VidUsUnit.kg) {
+      return VidUsUnit.mg;
+    } else {
+      return unit;
+    }
+  }
+
   /// 更新字符串结果值
   StringValue updateStringValue(
     ItemOutputMeta outputMeta,
@@ -150,8 +179,10 @@ abstract class MeasureItemFeature implements IMeasureItemFeature {
     VidUsUnit unit = VidUsUnit.None,
   ]) {
     int index = values.indexWhere((e) => e.meta.name == outputMeta.name);
+    VidUsUnit currentUnit = updateUnitBySpeciesType(unit);
+
     if (index < 0) {
-      final stringValue = StringValue(outputMeta, value, unit);
+      final stringValue = StringValue(outputMeta, value, currentUnit);
       values.add(stringValue);
       return stringValue;
     } else {
@@ -159,10 +190,10 @@ abstract class MeasureItemFeature implements IMeasureItemFeature {
       if (valueBase is StringValue) {
         final floatValue = valueBase;
         floatValue.value = value;
-        floatValue.unit = unit;
+        floatValue.unit = currentUnit;
         return floatValue;
       } else {
-        final newValue = StringValue(outputMeta, value, unit);
+        final newValue = StringValue(outputMeta, value, currentUnit);
         values[index] = newValue;
         return newValue;
       }

+ 9 - 7
lib/values/unit_desc.dart

@@ -61,10 +61,10 @@ class UnitDescriptionMap {
     _add(VidUsUnit.degree, '° ');
     _add(VidUsUnit.radian, 'rad');
     //Weight
-    _add(VidUsUnit.g);
-    _add(VidUsUnit.mg);
-    _add(VidUsUnit.ng);
-    _add(VidUsUnit.kg);
+    _add(VidUsUnit.g, 'g');
+    _add(VidUsUnit.mg, 'mg');
+    _add(VidUsUnit.ng, 'ng');
+    _add(VidUsUnit.kg, 'kg');
     _add(VidUsUnit.oz);
     _add(VidUsUnit.lb);
     //Area
@@ -73,9 +73,10 @@ class UnitDescriptionMap {
     _add(VidUsUnit.m2, 'm²');
     //Volumn
     _add(VidUsUnit.cm3, 'cm³');
-    _add(VidUsUnit.mm3, 'cm³');
-    _add(VidUsUnit.ml);
-    _add(VidUsUnit.L);
+    _add(VidUsUnit.mm3, 'mm³');
+    _add(VidUsUnit.ml, 'ml');
+    _add(VidUsUnit.L, 'L');
+    _add(VidUsUnit.mil, 'μl');
     //Velocity
     _add(VidUsUnit.cms, 'cm/s');
     _add(VidUsUnit.mms, 'mm/s');
@@ -109,6 +110,7 @@ class UnitDescriptionMap {
     _add(VidUsUnit.cm3minm2, 'cm³/min/m²');
     _add(VidUsUnit.mlminm2, 'ml/min/m²');
     _add(VidUsUnit.Lminm2, 'L/min.m²');
+    _add(VidUsUnit.mlmincm2, 'ml/min.cm²');
     _add(VidUsUnit.circs, 'circ/s');
     //CO
     _add(VidUsUnit.mlbeat, 'ml/beat');

+ 1 - 1
pubspec.yaml

@@ -87,7 +87,7 @@ dependency_overrides:
   vid:
     git:
       url: http://git.ius.plus:88/Project-Wing/flutter_vid.git
-      ref: b38bb1b5a4
+      ref: 1a076e5
   fis_vid:
     git:
       url: http://git.ius.plus:88/Project-Wing/fis_lib_vid.git