diff --git a/lib/vital_signs/components/vital_sign_widget.dart b/lib/vital_signs/components/vital_sign_widget.dart index b7b85494..a77c6ee7 100644 --- a/lib/vital_signs/components/vital_sign_widget.dart +++ b/lib/vital_signs/components/vital_sign_widget.dart @@ -74,12 +74,20 @@ class VitalSignWidget extends StatelessWidget { SizedBox( width: 8, ), - if(lookupValues!= null) - Status( + if (condition is RangeConditionWithTitle) + Status( status: "${TranslationBase.of(context).getValue(condition.current?.quantitativeInterpretation ?? '')}", originalData: condition.current?.quantitativeInterpretation??'', - ) + ) + else if (condition is RangeConditionForBloodPressure) + Status( + status: + "${TranslationBase.of(context).getValue(condition.systolic?.systolic.quantitativeInterpretation ?? '')}", + originalData: condition + .systolic?.systolic.quantitativeInterpretation ?? + '', + ) // Text( // "${TranslationBase.of(context).getValue(condition.current?.quantitativeInterpretation ?? '')}", // style: TextStyle( @@ -96,87 +104,169 @@ class VitalSignWidget extends StatelessWidget { // SizedBox( // height: 30, // child: Row(mainAxisSize: MainAxisSize.max, children: [ - if (lookupValues != null) - Flexible( - flex: 1, - child: ListView.separated( - physics: NeverScrollableScrollPhysics(), - separatorBuilder: (_, __) => SizedBox( - width: 8, - ), - shrinkWrap: true, - itemCount: lookupValues?.length ?? 0, - itemBuilder: (_, index) { - var key = lookupValues?.keys.elementAt(index); - return RangeWidget( - title: key ?? '', - values: lookupValues?[key] ?? [], - isSelected: false, - ); - }), + if (condition is RangeConditionWithTitle) + SizedBox( + height: 30, + child: Row(mainAxisSize: MainAxisSize.max, children: [ + Expanded( + flex: 1, + child: ListView.separated( + separatorBuilder: (_, __) => SizedBox( + width: 8, + ), + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: condition.condition?.length ?? 0, + itemBuilder: (_, index) => RangeWidget( + title: condition.condition?[index].title ?? 'test', + isSelected: condition.condition?[index] + .isInRange(vitalSignValue) == + true, + ), + ), + ), + ]), ), + // Flexible( + // flex: 1, + // child: ListView.separated( + // physics: NeverScrollableScrollPhysics(), + // separatorBuilder: (_, __) => SizedBox( + // width: 8, + // ), + // shrinkWrap: true, + // itemCount: lookupValues?.length ?? 0, + // itemBuilder: (_, index) { + // var key = lookupValues?.keys.elementAt(index); + // return RangeWidget( + // title: key ?? '', + // values: lookupValues?[key] ?? [], + // isSelected: false, + // ); + // }), + // ), - if (bloodPressureValues != null) - Flexible( - flex: 1, - child: ListView.separated( - separatorBuilder: (_, __) => SizedBox( - width: 8, - ), - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: bloodPressureValues?.length ?? 0, - itemBuilder: (_, index) { - - var key = bloodPressureValues?.keys.elementAt(index); - print('the ssize is ${ (bloodPressureValues?[key]?.length??1)*40} '); - // return RangeWidget( - // title: key??'', - // values: lookupValues?[key]??[],isSelected: false, - // ); - return Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - TranslationBase.of(context).getValue(key ?? ''), - textAlign: TextAlign.center, - style: - TextStyle(color: Colors.black, fontSize: 16), - ), - - Status( - status: - "${TranslationBase.of(context).getValue(condition.getValue(key)?.quantitativeInterpretation ?? '')}", - originalData:condition.getValue(key)?.quantitativeInterpretation ?? '' , - ) - ], - ), - SizedBox(height: 8), - SizedBox( - height:220, - child: ListView.separated( - separatorBuilder: (_, __) => SizedBox( - width: 8, - ), - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: bloodPressureValues?[key]?.length ?? 0, - itemBuilder: (_, index) { - var title = bloodPressureValues?[key]?.keys.elementAt(index); - - return RangeWidget( - title: title ?? '', - values: bloodPressureValues?[key]?[title] ?? [], - isSelected: false, - ); - })) - ], - ); - }), + if (condition is RangeConditionForBloodPressure) + SizedBox( + height: 30, + child: Row(mainAxisSize: MainAxisSize.max, children: [ + Expanded( + flex: 1, + child: ListView.separated( + separatorBuilder: (_, __) => SizedBox( + width: 8, + ), + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: condition.condition?.length ?? 0, + itemBuilder: (_, currentIndex) { + var title = + condition.condition?[currentIndex].quotient ?? + ''; + return RangeWidget( + title: title, + isSelected: condition.condition?[currentIndex] + ?.getValue("systolic-lng") + ?.isSelected == + true, + ); + }), + ), + ]), ), - // ]), + // Flexible( + // flex: 1, + // child: ListView.separated( + // separatorBuilder: (_, __) => SizedBox( + // width: 8, + // ), + // physics: NeverScrollableScrollPhysics(), + // shrinkWrap: true, + // itemCount: bloodPressure.length ?? 0, + // itemBuilder: (_, index) { + // // return RangeWidget( + // // title: key??'', + // // values: lookupValues?[key]??[],isSelected: false, + // // ); + // return Column( + // children: [ + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // TranslationBase.of(context) + // .getValue(bloodPressure[index] ?? ''), + // textAlign: TextAlign.center, + // style: + // TextStyle(color: Colors.black, fontSize: 16), + // ), + // + // Status( + // status: + // "${TranslationBase.of(context).getValue(condition.getValue(bloodPressure[index])?.quantitativeInterpretation ?? '')}", + // originalData:condition.getValue(bloodPressure[index])?.quantitativeInterpretation ?? '' , + // ) + // ], + // ), + // SizedBox(height: 16), + // SizedBox( + // height: 30, + // child: Row( + // mainAxisSize: MainAxisSize.max, + // children: [ + // Expanded( + // flex: 1, + // child: ListView.separated( + // separatorBuilder: (_, __) => SizedBox( + // width: 8, + // ), + // scrollDirection: Axis.horizontal, + // shrinkWrap: true, + // itemCount: + // condition.condition?.length ?? 0, + // itemBuilder: (_, currentIndex) { + // var title = condition + // .condition?[currentIndex] + // .getValue( + // bloodPressure[index]).title ?? + // ''; + // return RangeWidget( + // title: title, + // isSelected: condition + // .condition?[currentIndex] + // ?.getValue( + // bloodPressure[index]) + // ?.isSelected == + // true, + // ); + // }), + // ), + // ]), + // ), + // SizedBox(height: 16), + // // SizedBox( + // // height:220, + // // child: ListView.separated( + // // separatorBuilder: (_, __) => SizedBox( + // // width: 8, + // // ), + // // physics: NeverScrollableScrollPhysics(), + // // shrinkWrap: true, + // // itemCount: bloodPressureValues?[key]?.length ?? 0, + // // itemBuilder: (_, index) { + // // var title = bloodPressureValues?[key]?.keys.elementAt(index); + // // + // // return RangeWidget( + // // title: title ?? '', + // // values: bloodPressureValues?[key]?[title] ?? [], + // // isSelected: false, + // // ); + // // })) + // ], + // ); + // }), + // ), + // ]), // ), SizedBox( height: 8, @@ -215,78 +305,34 @@ class VitalSignWidget extends StatelessWidget { class RangeWidget extends StatelessWidget { final String title; - final List values; final bool isSelected; - const RangeWidget( - {super.key, - required this.title, - required this.isSelected, - required this.values}); + const RangeWidget({super.key, required this.title, required this.isSelected}); @override Widget build(BuildContext context) { - - return Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: [ - SizedBox( - height: 30, - child: Material( - shape: RoundedRectangleBorder( - borderRadius: BorderRadiusDirectional.only( - topStart: Radius.circular(8), - bottomStart: Radius.circular(8), - ), - ), - // color: Color(0xFF359846), - color: CustomColors.lightGreyColor, - child: Padding( - padding: const EdgeInsets.only(top:4.0, bottom :4, right: 8, left: 8), - child: Text( - TranslationBase.of(context).getValue(title), - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black, fontSize: 12), - ), - ), + return SizedBox( + height: 30, + child: Material( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(3), + ), + // color: Color(0xFF359846), + color: (isSelected) + ? CustomColors.accentColor + : CustomColors.lightGreyColor, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + title, + textAlign: TextAlign.center, + style: TextStyle( + color: (isSelected) ? Colors.white : Colors.black, + fontSize: 12), ), ), - Expanded( - child: Material( - shape: RoundedRectangleBorder( - borderRadius: BorderRadiusDirectional.only( - topEnd: Radius.circular(8), - bottomEnd: Radius.circular(8), - ), - ), - // color: Color(0xFF359846), - color: getColor(title), - child: SizedBox( - height: 30, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: List.generate( - values.length, - (index) => Row( - children: [ - Text( - values[index], - textAlign: TextAlign.center, - style: TextStyle(color: Colors.white, fontSize: 12), - ), - SizedBox( - width: 8, - ) - ], - ), - ), - ), - ), - )), - ) - ], + ), ), ); } diff --git a/lib/vital_signs/data/vitals_benchmark.dart b/lib/vital_signs/data/vitals_benchmark.dart index 6d208932..0256d850 100644 --- a/lib/vital_signs/data/vitals_benchmark.dart +++ b/lib/vital_signs/data/vitals_benchmark.dart @@ -103,6 +103,7 @@ var vital = { "unit": "mmHg", "values": [ { + "quotient": "(0-90) / (0-60)", "systolic-lng": { "min": 0, "max": 90, @@ -121,6 +122,7 @@ var vital = { } }, { + "quotient": "(90-120) / (60-70)", "systolic-lng": { "min": 90, "max": 120, @@ -139,6 +141,7 @@ var vital = { } }, { + "quotient": "(120-130) / (70-80)", "systolic-lng": { "min": 120, "max": 130, @@ -157,6 +160,7 @@ var vital = { } }, { + "quotient": "(130-140) / (80-90)", "systolic-lng": { "min": 130, "max": 140, @@ -175,6 +179,7 @@ var vital = { } }, { + "quotient": "≥ 140 /90", "systolic-lng": { "min": 140, "max": 0, @@ -444,6 +449,7 @@ var vitalValues = { } }; +var bloodPressure = ["systolic-lng", "diastolic-lng"]; class RangeConditionWithTitle { String? unit; @@ -506,9 +512,22 @@ class BloodPressure { RangeCondition? systolic; RangeCondition? diastolic; + String? quotient; + BloodPressure.fromJson(Map json, String selectedValue) { systolic = RangeCondition.fromJson(json['systolic-lng'], selectedValue.split("/")[0]); diastolic = RangeCondition.fromJson(json['diastolic-lng'], selectedValue.split("/")[1]); + quotient = json['quotient'] ?? ''; + } + + RangeCondition? getValue(String key) { + switch (key) { + case 'systolic-lng': + return this.systolic; + + case 'diastolic-lng': + return this.diastolic; + } } } @@ -537,14 +556,7 @@ class RangeCondition { } 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); - } + num value = num.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!;