From 1a99cabf043de9302d579b988fd1fcb51614f718 Mon Sep 17 00:00:00 2001 From: Haroon Amjad <> Date: Thu, 23 Jan 2025 16:24:30 +0300 Subject: [PATCH] Vital Signs update --- .../inpatient_pending_advance_payment.dart | 1 + lib/pages/conference/zoom/call_screen.dart | 2 +- lib/pages/landing/home_page_2.dart | 257 ++++++++- lib/pages/landing/landing_page.dart | 28 +- lib/pages/landing/widgets/services_view.dart | 2 +- .../clinic_services/get_clinic_service.dart | 3 +- .../components/vital_sign_widget.dart | 535 +++++++++--------- lib/vital_signs/data/vitals_benchmark.dart | 8 +- lib/vital_signs/result_screen.dart | 507 ++++++++--------- lib/vital_signs/vital_sign.dart | 50 +- 10 files changed, 772 insertions(+), 621 deletions(-) diff --git a/lib/pages/InPatientServices/components/inpatient_pending_advance_payment.dart b/lib/pages/InPatientServices/components/inpatient_pending_advance_payment.dart index 690f1371..170895f8 100644 --- a/lib/pages/InPatientServices/components/inpatient_pending_advance_payment.dart +++ b/lib/pages/InPatientServices/components/inpatient_pending_advance_payment.dart @@ -255,6 +255,7 @@ class _InPatientPendingAdvancePaymentState extends State { ], ), ); - if (errorType == Errors.SessionJoinFailed || errorType == Errors.SessionDisconnecting) { + if (errorType == Errors.SessionJoinFailed || errorType == Errors.SessionDisconncting) { Timer( const Duration(milliseconds: 1000), () => Navigator.pop(context), diff --git a/lib/pages/landing/home_page_2.dart b/lib/pages/landing/home_page_2.dart index a5fff824..61eaafc9 100644 --- a/lib/pages/landing/home_page_2.dart +++ b/lib/pages/landing/home_page_2.dart @@ -9,13 +9,19 @@ import 'package:diplomaticquarterapp/pages/conference/zoom/call_screen.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/vital_signs/vital_sign.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher_string.dart'; +import 'package:vital_sign_camera/vital_sign_camera.dart'; import 'fragments/home_page_fragment2.dart'; import 'landing_page_pharmcy.dart'; @@ -34,6 +40,12 @@ class _HomePageState2 extends State { PharmacyModuleViewModel pharmacyModuleViewModel = locator(); late ProjectViewModel projectViewModel; + TextEditingController weightTextController = new TextEditingController(); + TextEditingController heightTextController = new TextEditingController(); + TextEditingController ageTextController = new TextEditingController(); + + String radioValue = ""; + @override void initState() { super.initState(); @@ -45,36 +57,145 @@ class _HomePageState2 extends State { return BaseView( onModelReady: (model) => model.getPatientRadOrders(), - builder: (_, model, wi) => Container( - color: CustomColors.backgroudGreyColor, + builder: (_, model, wi) => Scaffold( + resizeToAvoidBottomInset: true, + // color: CustomColors.backgroudGreyColor, // color: Colors.yellow, - child: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Column( - children: [ - HomePageFragment2( - model, - onLoginClick: () { - widget.onLoginClick!(); - // FirebaseCrashlytics.instance.crash(); - // Navigator.pushNamed( - // context, - // "zoom_call_page", - // arguments: CallArguments("h9qkpf02", "123", "Patient", "40", "1", false), - // ); - }, - onPharmacyClick: () { - // getPharmacyToken(model); - Uri uri = Uri.parse(PHARMACY_REDIRECT_URL); - launchUrl(uri, mode: LaunchMode.externalApplication); - }, - onMedicalFileClick: () { - widget.onMedicalFileClick!(); - }, - ) - ], + // child: + // SingleChildScrollView( + // physics: BouncingScrollPhysics(), + body: SingleChildScrollView( + child: Material( + color: CustomColors.backgroudGreyColor, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.asset( + 'assets/images/new/cloud_logo.svg', + width: 150, + height: 150, + ), + mHeight(16.0), + Text( + "Contact-Less Vitals", + style: TextStyle(color: Colors.black, fontSize: 22, letterSpacing: -0.68, fontWeight: FontWeight.bold), + ), + mHeight(16.0), + Text( + "Select Gender:", + textAlign: TextAlign.start, + style: TextStyle(color: Colors.black, fontSize: 14, letterSpacing: -0.68, fontWeight: FontWeight.bold), + ), + mHeight(8.0), + Container( + padding: EdgeInsets.only(left: 6, right: 6), + child: Row( + children: [ + Flexible( + child: Row( + children: [ + Radio( + value: TranslationBase.of(context).male, + groupValue: radioValue, + onChanged: (v) { + setState(() { + radioValue = v!; + }); + }, + ), + Text( + TranslationBase.of(context).male, + style: TextStyle( + fontSize: 12, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + Flexible( + child: Row( + children: [ + Radio( + value: TranslationBase.of(context).female, + groupValue: radioValue, + onChanged: (v) { + setState(() { + radioValue = v!; + }); + }, + ), + Text( + TranslationBase.of(context).female, + style: TextStyle( + fontSize: 12, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ], + ), + ), + mHeight(16.0), + inputWidget(TranslationBase.of(context).age, "0", ageTextController), + mHeight(16.0), + inputWidget(TranslationBase.of(context).weightAdd + " (kg)", "0", weightTextController), + mHeight(16.0), + inputWidget(TranslationBase.of(context).height + " (cm)", "0", heightTextController), + mHeight(16.0), + DefaultButton( + TranslationBase.of(context).start, + (ageTextController.text == "" || weightTextController.text == "" || heightTextController.text == "") + ? null + : () { + final UserInfo userInfo = UserInfo( + age: double.parse(ageTextController.text), + gender: radioValue == TranslationBase.of(context).male ? Gender.male : Gender.female, + weight: double.parse(weightTextController.text), + // kg, Optional + height: double.parse(heightTextController.text), + // cm, Optional + waistCircumference: 0, + // cm Optional + userId: 'dbd13e86-47f4-4a43-85f6-cf62fa750117'); + Navigator.push(context, FadePage(page: VitalSigns(userInfo: userInfo))); + }, + color: CustomColors.green, + disabledColor: CustomColors.grey, + ), + // HomePageFragment2( + // model, + // onLoginClick: () { + // widget.onLoginClick!(); + // // FirebaseCrashlytics.instance.crash(); + // // Navigator.pushNamed( + // // context, + // // "zoom_call_page", + // // arguments: CallArguments("h9qkpf02", "123", "Patient", "40", "1", false), + // // ); + // }, + // onPharmacyClick: () { + // // getPharmacyToken(model); + // Uri uri = Uri.parse(PHARMACY_REDIRECT_URL); + // launchUrl(uri, mode: LaunchMode.externalApplication); + // }, + // onMedicalFileClick: () { + // widget.onMedicalFileClick!(); + // }, + // ) + ], + ), + ), ), ), + // ), ), ); } @@ -101,4 +222,86 @@ class _HomePageState2 extends State { navigateToCovidDriveThru() { Navigator.push(context, FadePage(page: CovidDrivethruLocation())); } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String? prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); + } } diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 05d90571..618dc894 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -615,20 +615,22 @@ class _LandingPageState extends State with WidgetsBindingObserver { ), RobotIcon() ])), - bottomNavigationBar: BottomNavBar( - changeIndex: changeCurrentTab, - index: currentTab, - ), + // bottomNavigationBar: BottomNavBar( + // changeIndex: changeCurrentTab, + // index: currentTab, + // ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - floatingActionButton: (projectViewModel.havePrivilege(34) && currentTab == 0) - ? FloatingButton( - elevation: true, - onTap: () { - changeCurrentTab(2); - projectViewModel.analytics.appointment.book_appointment(); - }, - ) - : null); + floatingActionButton: + // (projectViewModel.havePrivilege(34) && currentTab == 0) + // ? FloatingButton( + // elevation: true, + // onTap: () { + // changeCurrentTab(2); + // projectViewModel.analytics.appointment.book_appointment(); + // }, + // ) + // : + null); } triggerRobot() { diff --git a/lib/pages/landing/widgets/services_view.dart b/lib/pages/landing/widgets/services_view.dart index f15cbbd6..8e475bc2 100644 --- a/lib/pages/landing/widgets/services_view.dart +++ b/lib/pages/landing/widgets/services_view.dart @@ -232,7 +232,7 @@ class ServicesView extends StatelessWidget { } else if (hmgServices.action == 1) { openLiveCare(context); } else if (hmgServices.action == 111) { - Navigator.push(context, FadePage(page: VitalSigns())); + // Navigator.push(context, FadePage(page: VitalSigns())); } else if (hmgServices.action == 2) { //todo for temporary basis // Navigator.push(context, FadePage(page: ResultScreen( diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index af2828cc..28ce572b 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -184,11 +184,12 @@ class ClinicListService extends BaseService { return Future.value(localRes); } - Future getInPatientPaymentLink(int projectID, int admissionNo, int orderID, String name, String email, num amount, String nationalID, int clinicID, context) async { + Future getInPatientPaymentLink(int paymentRequestID, int projectID, int admissionNo, int orderID, String name, String email, num amount, String nationalID, int clinicID, context) async { Map request; // request = {"ProjectID": projectID, "AdmissionReqNo": admissionReqNo, "AdmissionNo": admissionNo}; request = { + "PaymentRequestId": paymentRequestID, "ProjectID": projectID, "ClientOrderID": orderID, "OrderDescription": "InPatient Advance Payment", diff --git a/lib/vital_signs/components/vital_sign_widget.dart b/lib/vital_signs/components/vital_sign_widget.dart index a77c6ee7..4630ae26 100644 --- a/lib/vital_signs/components/vital_sign_widget.dart +++ b/lib/vital_signs/components/vital_sign_widget.dart @@ -11,7 +11,7 @@ class VitalSignWidget extends StatelessWidget { final String vectorUrl; final dynamic condition; final Map? lookupValues; - final Map? bloodPressureValues; + final Map? bloodPressureValues; final Color? textColor; const VitalSignWidget({ @@ -36,268 +36,256 @@ class VitalSignWidget extends StatelessWidget { shadowColor: CustomColors.lightGreyColor, child: Padding( padding: const EdgeInsets.all(12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, + child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ + Row( children: [ - Row( - children: [ - SvgPicture.asset(vectorUrl, width: 36.0, height: 36.0), - SizedBox( - width: 16, - ), - Text( - vitalSignName, - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - color: textColor ?? Colors.white, - ), - ), - ], - ), + SvgPicture.asset(vectorUrl, width: 36.0, height: 36.0), SizedBox( - height: 8, + width: 16, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "$vitalSignValue ${condition.unit}", - style: TextStyle( - fontSize: 14, - color: textColor ?? Colors.white, - fontWeight: FontWeight.w500, - ), - ), - SizedBox( - width: 8, - ), - 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( - // fontSize: 14, - // color: textColor ?? Colors.white, - // fontWeight: FontWeight.w500, - // ), - // ), - ], + Text( + vitalSignName, + textAlign: TextAlign.start, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: textColor ?? Colors.white, + ), + ), + ], + ), + SizedBox( + height: 8, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "$vitalSignValue ${condition.unit}", + style: TextStyle( + fontSize: 14, + color: textColor ?? Colors.white, + fontWeight: FontWeight.w500, + ), ), SizedBox( - height: 8, + width: 8, ), - // SizedBox( - // height: 30, - // child: Row(mainAxisSize: MainAxisSize.max, children: [ 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, - ), - ), + Status( + status: "${TranslationBase.of(context).getValue(condition.current?.interpretation ?? '')}", + originalData: condition.current?.interpretation ?? '', + ) + else if (condition is RangeConditionForBloodPressure) + Status( + status: "${TranslationBase.of(context).getValue(condition.systolic?.systolic.interpretation ?? '')}", + originalData: condition.systolic?.systolic.interpretation ?? '', + ) + // Text( + // "${TranslationBase.of(context).getValue(condition.current?.quantitativeInterpretation ?? '')}", + // style: TextStyle( + // fontSize: 14, + // color: textColor ?? Colors.white, + // fontWeight: FontWeight.w500, + // ), + // ), + ], + ), + SizedBox( + height: 8, + ), + // SizedBox( + // height: 30, + // child: Row(mainAxisSize: MainAxisSize.max, children: [ + 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, + originalData: condition.current?.interpretation ?? '', ), - ]), + ), ), - // 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, - // ); - // }), - // ), + ]), + ), + // 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 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, - ); - }), - ), - ]), + 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, + originalData: condition.systolic?.systolic.interpretation ?? '', + ); + }), ), - // 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, - ), - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // TranslationBase.of(context).getValue( - // condition.condition?.first.interpretation ?? ''), - // style: TextStyle( - // fontSize: 14, - // color: textColor ?? Colors.white, - // fontWeight: FontWeight.w500, - // ), - // ), - // Text( - // TranslationBase.of(context).getValue( - // condition.condition?.last.interpretation ?? ''), - // style: TextStyle( - // fontSize: 14, - // color: textColor ?? Colors.white, - // fontWeight: FontWeight.w500, - // ), - // ), - // ], - // ), - // SizedBox( - // height: 8, - // ), - ]), + ]), + ), + // 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, + ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // TranslationBase.of(context).getValue( + // condition.condition?.first.interpretation ?? ''), + // style: TextStyle( + // fontSize: 14, + // color: textColor ?? Colors.white, + // fontWeight: FontWeight.w500, + // ), + // ), + // Text( + // TranslationBase.of(context).getValue( + // condition.condition?.last.interpretation ?? ''), + // style: TextStyle( + // fontSize: 14, + // color: textColor ?? Colors.white, + // fontWeight: FontWeight.w500, + // ), + // ), + // ], + // ), + // SizedBox( + // height: 8, + // ), + ]), ), ); } @@ -306,8 +294,9 @@ class VitalSignWidget extends StatelessWidget { class RangeWidget extends StatelessWidget { final String title; final bool isSelected; + final String originalData; - const RangeWidget({super.key, required this.title, required this.isSelected}); + const RangeWidget({super.key, required this.title, required this.isSelected, required this.originalData}); @override Widget build(BuildContext context) { @@ -318,18 +307,14 @@ class RangeWidget extends StatelessWidget { borderRadius: BorderRadius.circular(3), ), // color: Color(0xFF359846), - color: (isSelected) - ? CustomColors.accentColor - : CustomColors.lightGreyColor, + color: (isSelected) ? getColor(originalData) : 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), + style: TextStyle(color: (isSelected) ? Colors.white : Colors.black, fontSize: 12), ), ), ), @@ -364,28 +349,28 @@ class Status extends StatelessWidget { borderRadius: BorderRadius.circular(3), ), // color: Color(0xFF359846), - color: (originalData.toLowerCase() == 'good' || - originalData.toLowerCase() == 'excellent' || - originalData.toLowerCase() == 'normal') - ? Color(0xFFD8E8DB) - : (originalData.toLowerCase() == 'poor' || originalData.toLowerCase() == 'low') - ? Color(0xFFD3D37E) - : Color(0x98d02127), + color: getColor(originalData), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), child: Text(status, style: TextStyle( - color: (originalData.toLowerCase() == 'good' || - originalData.toLowerCase() == 'excellent' || - originalData.toLowerCase() == 'normal') - ? Color(0xFF359846) - : (originalData.toLowerCase() == 'poor' || - originalData.toLowerCase() == 'low') - ? Colors.white - : Colors.white, - fontSize: 8, + color: Colors.white, + fontSize: 12, fontWeight: FontWeight.w600, )), )); } + + getColor(title) { + switch (title) { + case "excellent": + return Color(0xFF275b45); + case "good": + return Color(0xFF507a3d); + case "poor": + return Color(0xFFa86452); + case "atRisk": + return Color(0xFFa2494b); + } + } } diff --git a/lib/vital_signs/data/vitals_benchmark.dart b/lib/vital_signs/data/vitals_benchmark.dart index 0256d850..7ef98a74 100644 --- a/lib/vital_signs/data/vitals_benchmark.dart +++ b/lib/vital_signs/data/vitals_benchmark.dart @@ -103,7 +103,7 @@ var vital = { "unit": "mmHg", "values": [ { - "quotient": "(0-90) / (0-60)", + "quotient": "0-90", "systolic-lng": { "min": 0, "max": 90, @@ -122,7 +122,7 @@ var vital = { } }, { - "quotient": "(90-120) / (60-70)", + "quotient": "90-120", "systolic-lng": { "min": 90, "max": 120, @@ -141,7 +141,7 @@ var vital = { } }, { - "quotient": "(120-130) / (70-80)", + "quotient": "120-130", "systolic-lng": { "min": 120, "max": 130, @@ -160,7 +160,7 @@ var vital = { } }, { - "quotient": "(130-140) / (80-90)", + "quotient": "130-140", "systolic-lng": { "min": 130, "max": 140, diff --git a/lib/vital_signs/result_screen.dart b/lib/vital_signs/result_screen.dart index b5b37220..b5b17979 100644 --- a/lib/vital_signs/result_screen.dart +++ b/lib/vital_signs/result_screen.dart @@ -31,7 +31,6 @@ class ResultScreen extends StatelessWidget { final deviceSize = MediaQuery.of(context).size; const textColor = Color.fromARGB(255, 0, 0, 0); - print('the age is ${healthResult?.vitalSigns?.facialSkinAge}'); return AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).result, @@ -39,286 +38,258 @@ class ResultScreen extends StatelessWidget { showNewAppBarTitle: true, overrideUserLogin: true, backgroundColor: Color(0xffF8F8F8), + appBarIcons: [ + Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + "Scan Quality: ${_scanParameters!.signalQuality.toStringAsFixed(0)}%", + style: TextStyle(color: Colors.black, fontSize: 14, letterSpacing: -0.68, fontWeight: FontWeight.bold), + ), + ), + ), + ], body: Padding( padding: const EdgeInsets.all(15), child: ListView( shrinkWrap: true, children: [ Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (_holisticAnalysis != null && - _holisticAnalysis?.generalWellness != null) - VitalSignWidget( - textColor: textColor, - lookupValues: vitalValues['generalWellness']!, - vitalSignName: - TranslationBase.of(context).generalWellness, - condition: RangeConditionWithTitle.fromJson( - vital['generalWellness']!, - formatValueToTwoDp( - healthResult?.holisticHealth?.generalWellness)), - vitalSignValue: formatValueToTwoDp( - healthResult?.holisticHealth?.generalWellness), - vectorUrl: 'assets/images/svg/wellness.svg', - ),//wellness - if (_vitalSign?.stress != null) - VitalSignWidget( - textColor: textColor, - vitalSignName: TranslationBase.of(context).stress, - condition: RangeConditionWithTitle.fromJson( - vital['stressLevel']!, - formatValueToTwoDp( - healthResult?.vitalSigns.stress)), - lookupValues: vitalValues['stressLevel']!, - vitalSignValue: - formatValueToTwoDp(healthResult?.vitalSigns.stress), - vectorUrl: 'assets/images/svg/stress.svg', - ), - VitalSignWidget( - textColor: textColor, - vitalSignName: TranslationBase.of(context).pulseTitle, - condition: RangeConditionWithTitle.fromJson( - vital['HR']!, - formatValueToTwoDp( - healthResult?.vitalSigns.heartRate)), - lookupValues: vitalValues['HR']!, - vitalSignValue: formatValueToTwoDp( - healthResult?.vitalSigns.heartRate), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + if (_holisticAnalysis != null && _holisticAnalysis?.generalWellness != null) + VitalSignWidget( + textColor: textColor, + lookupValues: vitalValues['generalWellness']!, + vitalSignName: TranslationBase.of(context).generalWellness, + condition: RangeConditionWithTitle.fromJson(vital['generalWellness']!, formatValueToTwoDp(healthResult?.holisticHealth?.generalWellness)), + vitalSignValue: formatValueToTwoDp(healthResult?.holisticHealth?.generalWellness), + vectorUrl: 'assets/images/svg/wellness.svg', + ), //wellness + if (_vitalSign?.stress != null) + VitalSignWidget( + textColor: textColor, + vitalSignName: TranslationBase.of(context).stress, + condition: RangeConditionWithTitle.fromJson(vital['stressLevel']!, formatValueToTwoDp(healthResult?.vitalSigns.stress)), + lookupValues: vitalValues['stressLevel']!, + vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.stress), + vectorUrl: 'assets/images/svg/stress.svg', + ), + VitalSignWidget( + textColor: textColor, + vitalSignName: TranslationBase.of(context).pulseTitle, + condition: RangeConditionWithTitle.fromJson(vital['HR']!, formatValueToTwoDp(healthResult?.vitalSigns.heartRate)), + lookupValues: vitalValues['HR']!, + vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.heartRate), + vectorUrl: 'assets/images/svg/heartrate.svg', + ), + //heart rate + if (_vitalSign?.bloodPressure != null) + VitalSignWidget( + textColor: textColor, + vitalSignName: "Blood Pressure", + condition: RangeConditionForBloodPressure.fromJson(vital['blood_pressure']!, healthResult?.vitalSigns.bloodPressure ?? ""), + bloodPressureValues: vitalValues['blood_pressure']!, + vitalSignValue: healthResult?.vitalSigns.bloodPressure ?? "", + vectorUrl: 'assets/images/svg/bloodpressure.svg', + ), + if (_vitalSign?.hrvSdnn != null) + VitalSignWidget( vectorUrl: 'assets/images/svg/heartrate.svg', - ), - //heart rate - if (_vitalSign?.bloodPressure != null) - VitalSignWidget( - textColor: textColor, - vitalSignName: "Blood Pressure", - condition: RangeConditionForBloodPressure.fromJson( - vital['blood_pressure']!, - healthResult?.vitalSigns.bloodPressure ?? ""), - bloodPressureValues: vitalValues['blood_pressure']!, - vitalSignValue: - healthResult?.vitalSigns.bloodPressure ?? "", - vectorUrl: 'assets/images/svg/bloodpressure.svg', - ), - if (_vitalSign?.hrvSdnn != null) - VitalSignWidget( - vectorUrl: 'assets/images/svg/heartrate.svg', - textColor: textColor, - vitalSignName: "HRV SDNN", - lookupValues: vitalValues['hrvv']!, - condition: RangeConditionWithTitle.fromJson( - vital['hrvv']!, - formatValueToTwoDp( - healthResult?.vitalSigns.hrvSdnn)), - vitalSignValue: formatValueToTwoDp( - healthResult?.vitalSigns.hrvSdnn)), - - //oxygen - VitalSignWidget( textColor: textColor, - lookupValues: vitalValues['Sp02']!, - vitalSignName: - TranslationBase.of(context).oxygenSaturation, - condition: RangeConditionWithTitle.fromJson( - vital['Sp02']!, - formatValueToTwoDp(healthResult?.vitalSigns.spo2)), - vitalSignValue: - formatValueToTwoDp(healthResult?.vitalSigns.spo2), - vectorUrl: 'assets/images/svg/oxygen.svg', - ), - if (_vitalSign?.respiratoryRate != null) - VitalSignWidget( - textColor: textColor, - lookupValues: vitalValues['respiratoryRate']!, - vitalSignName: - TranslationBase.of(context).respiratoryRate, - condition: RangeConditionWithTitle.fromJson( - vital['respiratoryRate']!, - formatValueToTwoDp( - healthResult?.vitalSigns.respiratoryRate)), - vitalSignValue: formatValueToTwoDp( - healthResult?.vitalSigns.respiratoryRate), - vectorUrl: 'assets/images/svg/breathing.svg', - ), - if (_holisticAnalysis != null && - _holisticAnalysis?.bmi != null) - VitalSignWidget( - textColor: textColor, - lookupValues: vitalValues['bmi']!, - vitalSignName: TranslationBase.of(context).BMI, - condition: RangeConditionWithTitle.fromJson( - vital['bmi']!, - formatValueToTwoDp( - healthResult?.holisticHealth?.bmi)), - vitalSignValue: formatValueToTwoDp( - healthResult?.holisticHealth?.bmi), - vectorUrl: 'assets/images/svg/bmi.svg', - ), - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "IBI", - // condition: RangeConditionWithTitle.fromJson(vital['HR']!), - // vitalSignValue: - // formatValueToTwoDp(healthResult?.vitalSigns.ibi)), - + vitalSignName: "HRV SDNN", + lookupValues: vitalValues['hrvv']!, + condition: RangeConditionWithTitle.fromJson(vital['hrvv']!, formatValueToTwoDp(healthResult?.vitalSigns.hrvSdnn)), + vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.hrvSdnn)), - // if (_vitalSign?.hrvRmssd != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "HRV RMSSD", - // vitalSignValue: formatValueToTwoDp( - // healthResult?.vitalSigns.hrvRmssd)), + //oxygen + VitalSignWidget( + textColor: textColor, + lookupValues: vitalValues['Sp02']!, + vitalSignName: TranslationBase.of(context).oxygenSaturation, + condition: RangeConditionWithTitle.fromJson(vital['Sp02']!, formatValueToTwoDp(healthResult?.vitalSigns.spo2)), + vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.spo2), + vectorUrl: 'assets/images/svg/oxygen.svg', + ), + if (_vitalSign?.respiratoryRate != null) + VitalSignWidget( + textColor: textColor, + lookupValues: vitalValues['respiratoryRate']!, + vitalSignName: TranslationBase.of(context).respiratoryRate, + condition: RangeConditionWithTitle.fromJson(vital['respiratoryRate']!, formatValueToTwoDp(healthResult?.vitalSigns.respiratoryRate)), + vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.respiratoryRate), + vectorUrl: 'assets/images/svg/breathing.svg', + ), + if (_holisticAnalysis != null && _holisticAnalysis?.bmi != null) + VitalSignWidget( + textColor: textColor, + lookupValues: vitalValues['bmi']!, + vitalSignName: TranslationBase.of(context).BMI, + condition: RangeConditionWithTitle.fromJson(vital['bmi']!, formatValueToTwoDp(healthResult?.holisticHealth?.bmi)), + vitalSignValue: formatValueToTwoDp(healthResult?.holisticHealth?.bmi), + vectorUrl: 'assets/images/svg/bmi.svg', + ), + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "IBI", + // condition: RangeConditionWithTitle.fromJson(vital['HR']!), + // vitalSignValue: + // formatValueToTwoDp(healthResult?.vitalSigns.ibi)), - // if (_vitalSign?.temperature != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Temperature", - // vitalSignValue: formatValueToTwoDp( - // healthResult?.vitalSigns.temperature)), + // if (_vitalSign?.hrvRmssd != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "HRV RMSSD", + // vitalSignValue: formatValueToTwoDp( + // healthResult?.vitalSigns.hrvRmssd)), - // if (_vitalSign?.bloodPressureSystolic != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Blood Pressure Systolic", - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.vitalSigns.bloodPressureSystolic)), - // if (_vitalSign?.bloodPressureDiastolic != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Blood Pressure Diastolic", - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.vitalSigns.bloodPressureDiastolic)), - // if (_holisticAnalysis != null) - // Container( - // margin: const EdgeInsets.fromLTRB(0, 25, 0, 10), - // child: const Text( - // "Holistic Analysis", - // style: TextStyle( - // fontSize: 15, - // color: Colors.amber, - // fontWeight: FontWeight.bold, - // ), - // ), - // ), + // if (_vitalSign?.temperature != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Temperature", + // vitalSignValue: formatValueToTwoDp( + // healthResult?.vitalSigns.temperature)), + // if (_vitalSign?.bloodPressureSystolic != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Blood Pressure Systolic", + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.vitalSigns.bloodPressureSystolic)), + // if (_vitalSign?.bloodPressureDiastolic != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Blood Pressure Diastolic", + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.vitalSigns.bloodPressureDiastolic)), + // if (_holisticAnalysis != null) + // Container( + // margin: const EdgeInsets.fromLTRB(0, 25, 0, 10), + // child: const Text( + // "Holistic Analysis", + // style: TextStyle( + // fontSize: 15, + // color: Colors.amber, + // fontWeight: FontWeight.bold, + // ), + // ), + // ), - // if (_holisticAnalysis != null && - // _holisticAnalysis?.absi != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "ABSI", - // vitalSignValue: formatValueToTwoDp( - // healthResult?.holisticHealth?.absi)), - // if (_holisticAnalysis != null && - // _holisticAnalysis?.cardiacWorkload != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Cardiac Workload", - // vitalSignValue: formatValueToTwoDp( - // healthResult?.holisticHealth?.cardiacWorkload)), - // if (_holisticAnalysis != null && - // _holisticAnalysis?.pulseRespiratoryQuotient != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Pulse Respiratory Quotient", - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.holisticHealth?.pulseRespiratoryQuotient)), - // if (_holisticAnalysis != null && - // _holisticAnalysis?.waistToHeightRatio != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Waist to Height Ratio", - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.holisticHealth?.waistToHeightRatio)), - // if (_cardiovascularRisks != null) - // Container( - // margin: const EdgeInsets.fromLTRB(0, 25, 0, 10), - // child: const Text( - // "Cardiovascular Risks", - // style: TextStyle( - // fontSize: 15, - // color: Colors.amber, - // fontWeight: FontWeight.bold, - // ), - // ), - // ), - // if (_cardiovascularRisks != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: TranslationBase.of(context).cvd, - // condition: RangeConditionWithTitle.fromJson(vital['cvd']!, formatValueToTwoDp(healthResult - // ?.risks?.cardiovascularRisks?.generalRisk)), - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.risks?.cardiovascularRisks?.generalRisk), - // vectorUrl: 'assets/images/svg/heartrate.svg',), - // if (_cardiovascularRisks != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Congestive Heart Failure", - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.risks - // ?.cardiovascularRisks - // ?.congestiveHeartFailure)), - // if (_cardiovascularRisks != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Coronary Heart Disease", - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.risks - // ?.cardiovascularRisks - // ?.coronaryHeartDisease)), - // if (_cardiovascularRisks != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Intermittent Claudication", - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.risks - // ?.cardiovascularRisks - // ?.intermittentClaudication)), - // if (_cardiovascularRisks != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Stroke", - // vitalSignValue: formatValueToTwoDp(healthResult - // ?.risks?.cardiovascularRisks?.stroke)), - // if (_covidRisk != null) - // Container( - // margin: const EdgeInsets.fromLTRB(0, 25, 0, 10), - // child: const Text( - // "Covid Risks", - // style: TextStyle( - // fontSize: 15, - // color: Colors.amber, - // fontWeight: FontWeight.bold, - // ), - // ), - // ), - // if (_covidRisk != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Risk", - // vitalSignValue: formatValueToTwoDp( - // healthResult?.risks?.covidRisk?.covidRisk)), - // if (_scanParameters != null) - // Container( - // margin: const EdgeInsets.fromLTRB(0, 25, 0, 10), - // child: const Text( - // "Scan Parameters", - // style: TextStyle( - // fontSize: 15, - // color: Colors.amber, - // fontWeight: FontWeight.bold, - // ), - // ), - // ), - // if (_scanParameters != null) - // VitalSignWidget( - // textColor: textColor, - // vitalSignName: "Signal Quality", - // vitalSignValue: formatValueToTwoDp( - // healthResult?.scanParameters?.signalQuality)), - ]), + // if (_holisticAnalysis != null && + // _holisticAnalysis?.absi != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "ABSI", + // vitalSignValue: formatValueToTwoDp( + // healthResult?.holisticHealth?.absi)), + // if (_holisticAnalysis != null && + // _holisticAnalysis?.cardiacWorkload != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Cardiac Workload", + // vitalSignValue: formatValueToTwoDp( + // healthResult?.holisticHealth?.cardiacWorkload)), + // if (_holisticAnalysis != null && + // _holisticAnalysis?.pulseRespiratoryQuotient != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Pulse Respiratory Quotient", + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.holisticHealth?.pulseRespiratoryQuotient)), + // if (_holisticAnalysis != null && + // _holisticAnalysis?.waistToHeightRatio != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Waist to Height Ratio", + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.holisticHealth?.waistToHeightRatio)), + // if (_cardiovascularRisks != null) + // Container( + // margin: const EdgeInsets.fromLTRB(0, 25, 0, 10), + // child: const Text( + // "Cardiovascular Risks", + // style: TextStyle( + // fontSize: 15, + // color: Colors.amber, + // fontWeight: FontWeight.bold, + // ), + // ), + // ), + // if (_cardiovascularRisks != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: TranslationBase.of(context).cvd, + // condition: RangeConditionWithTitle.fromJson(vital['cvd']!, formatValueToTwoDp(healthResult + // ?.risks?.cardiovascularRisks?.generalRisk)), + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.risks?.cardiovascularRisks?.generalRisk), + // vectorUrl: 'assets/images/svg/heartrate.svg',), + // if (_cardiovascularRisks != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Congestive Heart Failure", + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.risks + // ?.cardiovascularRisks + // ?.congestiveHeartFailure)), + // if (_cardiovascularRisks != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Coronary Heart Disease", + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.risks + // ?.cardiovascularRisks + // ?.coronaryHeartDisease)), + // if (_cardiovascularRisks != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Intermittent Claudication", + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.risks + // ?.cardiovascularRisks + // ?.intermittentClaudication)), + // if (_cardiovascularRisks != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Stroke", + // vitalSignValue: formatValueToTwoDp(healthResult + // ?.risks?.cardiovascularRisks?.stroke)), + // if (_covidRisk != null) + // Container( + // margin: const EdgeInsets.fromLTRB(0, 25, 0, 10), + // child: const Text( + // "Covid Risks", + // style: TextStyle( + // fontSize: 15, + // color: Colors.amber, + // fontWeight: FontWeight.bold, + // ), + // ), + // ), + // if (_covidRisk != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Risk", + // vitalSignValue: formatValueToTwoDp( + // healthResult?.risks?.covidRisk?.covidRisk)), + // if (_scanParameters != null) + // Container( + // margin: const EdgeInsets.fromLTRB(0, 25, 0, 10), + // child: const Text( + // "Scan Parameters", + // style: TextStyle( + // fontSize: 15, + // color: Colors.amber, + // fontWeight: FontWeight.bold, + // ), + // ), + // ), + // if (_scanParameters != null) + // VitalSignWidget( + // textColor: textColor, + // vitalSignName: "Signal Quality", + // vitalSignValue: formatValueToTwoDp( + // healthResult?.scanParameters?.signalQuality)), + ]), ), ], ), diff --git a/lib/vital_signs/vital_sign.dart b/lib/vital_signs/vital_sign.dart index e297bd59..bb3fdbf9 100644 --- a/lib/vital_signs/vital_sign.dart +++ b/lib/vital_signs/vital_sign.dart @@ -16,17 +16,20 @@ import 'result_screen.dart'; final UserInfo userInfo = UserInfo( age: 30, gender: Gender.male, - weight: 75, // kg, Optional - height: 164, // cm, Optional - waistCircumference: 83, // cm Optional + weight: 75, + // kg, Optional + height: 164, + // cm, Optional + waistCircumference: 83, + // cm Optional userId: 'dbd13e86-47f4-4a43-85f6-cf62fa750117'); -final VitalSignCameraConfig config = VitalSignCameraConfig( - apiKey: 'nIsZO45woSXSfIxsL1t79MWeIpsnGQr6B941MSF2', - serverId: ServerId.awsEnterpriseProd); +final VitalSignCameraConfig config = VitalSignCameraConfig(apiKey: 'nIsZO45woSXSfIxsL1t79MWeIpsnGQr6B941MSF2', serverId: ServerId.awsEnterpriseProd); class VitalSigns extends StatefulWidget { - const VitalSigns({super.key}); + const VitalSigns({super.key, required this.userInfo}); + + final UserInfo userInfo; @override State createState() => _VitalSignsState(); @@ -50,10 +53,8 @@ class _VitalSignsState extends State with RouteAware { return queryCameraDevice(CameraPosition.front); } - bool startedScanning = - false; // set true when start button is pressed, set false when health result is tapped or error occurs - bool isAllConditionsMet = - false; // check for the 6 scan conditions before enabling the start button + bool startedScanning = false; // set true when start button is pressed, set false when health result is tapped or error occurs + bool isAllConditionsMet = false; // check for the 6 scan conditions before enabling the start button ScanConditions? _conditions; GetHealthStage? _scanningStage; @@ -106,31 +107,20 @@ class _VitalSignsState extends State with RouteAware { backgroundColor: Color(0xffF8F8F8), body: Column( children: [ - if (_conditions != null) - ScanConditionChecklist( - deviceSize: deviceSize, conditions: _conditions!), + if (_conditions != null) ScanConditionChecklist(deviceSize: deviceSize, conditions: _conditions!), Expanded( child: Stack( children: [ VitalSignCamera( - onCreated: _onVitalSignCameraCreated, - isActive: isCameraActive, - userInfo: userInfo, - config: config, - device: cameraDevice, - onVideoFrameProcessed: _onVideoFrameProcessed), + onCreated: _onVitalSignCameraCreated, isActive: isCameraActive, userInfo: widget.userInfo, config: config, device: cameraDevice, onVideoFrameProcessed: _onVideoFrameProcessed), Positioned.fill( child: CustomPaint( painter: OvalOverlayPainter(), ), ), - if (_scanningStage != - GetHealthStage - .idle) // show remaining time count down during scan - ScanStatus( - stage: _scanningStage, remainingTime: _remainingTime), - if (_scanningStage == GetHealthStage.idle && - isCameraActive) // show start button only when it is not scanning + if (_scanningStage != GetHealthStage.idle) // show remaining time count down during scan + ScanStatus(stage: _scanningStage, remainingTime: _remainingTime), + if (_scanningStage == GetHealthStage.idle && isCameraActive) // show start button only when it is not scanning StartButton( onPressed: () { setState(() { @@ -227,9 +217,7 @@ class _VitalSignsState extends State with RouteAware { } void _onVideoFrameProcessed(VideoFrameProcessedEvent event) { - if (!_showedHealthResult && - _healthResult == null && - event.healthResult?.health != null) { + if (!_showedHealthResult && _healthResult == null && event.healthResult?.health != null) { _showedHealthResult = true; Navigator.push( context, @@ -308,4 +296,4 @@ class OvalOverlayPainter extends CustomPainter { bool shouldRepaint(covariant CustomPainter oldDelegate) { return false; } -} \ No newline at end of file +}