var vital = { "HR": { "unit": "bpm", "values": [ { "min": 0, "max": 60, "interpretation": "atRisk", "quantitativeInterpretation": "low", "title": "< 60" }, { "min": 80, "max": 100, "interpretation": "poor", "quantitativeInterpretation": "normal", "title": "80-100" }, { "min": 60, "max": 80, "interpretation": "excellent", "quantitativeInterpretation": "normal", "title": "60-80" }, { "min": 100, "max": 0, "interpretation": "atRisk", "quantitativeInterpretation": "high", "title": "≥ 100" }, ] },"hrvv": { "unit": "ms", "values":[ { "min": 0, "max": 10.8, "interpretation": "atRisk", "quantitativeInterpretation": "low", "title": "< 10.8" }, { "min": 10.8, "max": 16.4, "interpretation": "poor", "quantitativeInterpretation": "low", "title": "10.8-16.4" }, { "min": 16.4, "max": 35.0, "interpretation": "poor", "quantitativeInterpretation": "low", "title": "16.4-35.0" }, { "min": 35.0, "max": 51.5, "interpretation": "good", "quantitativeInterpretation": "normal", "title": "35.0-51.5" }, { "min": 51.5, "max": 0, "interpretation": "excellent", "quantitativeInterpretation": "normal", "title": "≥ 51.5" } ] }, "Sp02": { "unit": "%", "values": [ { "min": 0, "max": 90, "interpretation": "atRisk", "quantitativeInterpretation": "low", "title": "≥ 90" }, { "min": 90, "max": 95, "interpretation": "poor", "quantitativeInterpretation": "possiblyLow", "title": "90-95" }, { "min": 95, "max": 97, "interpretation": "good", "quantitativeInterpretation": "normal", "title": "95-97" }, { "min": 97, "max": 100, "interpretation": "good", "quantitativeInterpretation": "normal", "isMaxIncluded": true, "title": "97-100" } ] }, "blood_pressure": { "unit": "mmHg", "values": [ { "min": 0, "max": (90 / 60), "interpretation": "atRisk", "quantitativeInterpretation": "low", "title": "< 90/60" }, { "min": (90 / 60), "max": (120 / 70), "interpretation": "excellent", "quantitativeInterpretation": "normal", "title": "90/60 - 120/70" }, { "min": (120 / 70), "max": (130 / 80), "interpretation": "good", "quantitativeInterpretation": "normal", "title": "120/70 - 130/80" }, { "min": (130 / 80), "max": (140 / 90), "interpretation": "poor", "quantitativeInterpretation": "slightlyHigh", "title": "130/80-140/90" }, { "min": (140 / 90), "max": 0, "interpretation": "atRisk", "quantitativeInterpretation": "high", "title": "≥ 140/90" } ] }, "bmi": { "unit": "", "values": [ { "min": 0, "max": 18.5, "interpretation": "poor", "quantitativeInterpretation": "normal", "title": "< 18.5" }, { "min": 18.5, "max": 25, "interpretation": "poor", "quantitativeInterpretation": "normal", "title": "25-30" },{ "min": 25, "max": 30, "interpretation": "poor", "quantitativeInterpretation": "normal", "title": "25-30" }, { "min": 30, "max": 40, "interpretation": "atRisk", "quantitativeInterpretation": "high", "title": "30-40" }, { "min": 40, "max": 0, "interpretation": "atRisk", "quantitativeInterpretation": "high", "title": "≥40" }, ] }, "respiratoryRate": { "unit": "bpm", "values": [ { "min": 0, "max": 12, "interpretation": "poor", "quantitativeInterpretation": "low", "title": "< 12" }, { "min": 12, "max": 20, "interpretation": "excellent", "quantitativeInterpretation": "normal", "title": "25-30" }, { "min": 20, "max": 0, "interpretation": "poor", "quantitativeInterpretation": "high", "title": "≥ 20" }, ] }, "cvd": { "unit": "%", "values": [ { "min": 0, "max": 1, "interpretation": "excellent", "quantitativeInterpretation": "normal", "title": "< 1" }, { "min": 1, "max": 10, "interpretation": "Average", "quantitativeInterpretation": "slightlyHigh", "title": "1-10" }, { "min": 10, "max": 20, "interpretation": "poor", "quantitativeInterpretation": "moderatelyHigh", "title": "10-20" }, { "min": 20, "max": 0, "interpretation": "atRisk", "quantitativeInterpretation": " high", "title": "≥ 20" }, ] }, "generalWellness": { "unit": "", "values": [ { "min": 0, "max": 40, "interpretation": "poor", "quantitativeInterpretation": "low", "title": "< 40" }, { "min": 40, "max": 80, "interpretation": "good", "quantitativeInterpretation": "normal", "title": "40-80" }, { "min": 80, "max": 100, "interpretation": "excellent", "quantitativeInterpretation": "normal", "title": "80-100", "isMaxIncluded": true }, ] }, "stressLevel": { "unit": "", "values": [ { "min": 0, "max": 2, "interpretation": "excellent", "quantitativeInterpretation": "normal", "title": "0-2" }, { "min": 2, "max": 3, "interpretation": "good", "quantitativeInterpretation": "normal", "title": "2-3" }, { "min": 3, "max": 0, "interpretation": "poor", "quantitativeInterpretation": "high", "title": "80-100", }, ] }, }; class RangeConditionWithTitle { String? unit; List? condition; RangeCondition? current; RangeConditionWithTitle({this.unit, this.condition}); RangeConditionWithTitle.fromJson(Map json, String formatValueToTwoDp) { this.unit = json['unit']; var conditions = json['values'] as List?; this.condition = conditions?.map((item) => RangeCondition.fromJson(item,formatValueToTwoDp)).toList(); print("the value is $formatValueToTwoDp"); current = condition?.where((element)=>element.isSelected == true).first; } } class RangeCondition { double? min; double? max; bool? isMaxIncluded; String? interpretation; String? quantitativeInterpretation; String? title; bool? isSelected; RangeCondition(this.min, this.max, this.interpretation, this.quantitativeInterpretation, this.isMaxIncluded); RangeCondition.fromJson(Map json, String selectedValue) { min = json['min'].toDouble(); max = json['max'].toDouble(); interpretation = json['interpretation']; quantitativeInterpretation = json['quantitativeInterpretation']; isMaxIncluded = json['isMaxIncluded']; title = json['title']; isSelected = isInRange(selectedValue); } bool isInRange(String data) { double value = 0.0; if(data.contains('/')){ value = double.parse(data.split("/")[0])/double.parse(data.split("/")[1]); print("the blood pressure is ${value}"); }else{ value = double.parse(data); } if (max == 0 && min != 0) return value >= min!; if (min == 0 && max != 0) return value < max!; if (isMaxIncluded == true) return value >= min! && value <= max!; return value >= min! && value < max!; } }