|
@@ -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;
|
|
|
}
|