From 0d30fd62122dda8f58db42a4f68b0990694fbdf8 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 2 Jun 2020 17:13:41 +0300 Subject: [PATCH] vitalsign details --- lib/lookups/patient_lookup.dart | 11 + .../vital_sign/body_measurements_screen.dart | 188 ++++++++++++---- .../vital_ding_chart_and_detials.dart | 39 ++++ .../vital_sign/vital_sign_details_screen.dart | 206 +++++++++++++++--- .../shared/charts/app_time_series_chart.dart | 110 +++++++--- 5 files changed, 440 insertions(+), 114 deletions(-) create mode 100644 lib/screens/patients/profile/vital_sign/vital_ding_chart_and_detials.dart diff --git a/lib/lookups/patient_lookup.dart b/lib/lookups/patient_lookup.dart index fbb382c2..451e694b 100644 --- a/lib/lookups/patient_lookup.dart +++ b/lib/lookups/patient_lookup.dart @@ -20,3 +20,14 @@ {"text": "Out Sudia Arabia", "val": "2"}, ]; + + +enum vitalSignDetails { + bodyMeasurements, + temperature, + pulse, + pespiration, + bloodPressure, + oxygenation, + painScale +} \ No newline at end of file diff --git a/lib/screens/patients/profile/vital_sign/body_measurements_screen.dart b/lib/screens/patients/profile/vital_sign/body_measurements_screen.dart index 769b40f9..f0133e84 100644 --- a/lib/screens/patients/profile/vital_sign/body_measurements_screen.dart +++ b/lib/screens/patients/profile/vital_sign/body_measurements_screen.dart @@ -1,10 +1,8 @@ -import 'package:charts_flutter/flutter.dart' as charts; -import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/lookups/patient_lookup.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign_res_model.dart'; import 'package:doctor_app_flutter/providers/patients_provider.dart'; -import 'package:doctor_app_flutter/widgets/patients/vital_sign_details_wideget.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/vital_sign/vital_ding_chart_and_detials.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -13,61 +11,157 @@ class BodyMeasurementsScreen extends StatelessWidget { // ; PatientsProvider patientsProv; List vitalList = []; + String pageTitle; @override Widget build(BuildContext context) { patientsProv = Provider.of(context); - List seriesList = generateData(); + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + pageTitle = routeArgs['title']; + var pageKey = routeArgs['key']; + List VSchart; + vitalList = patientsProv.patientVitalSignOrderdSubList; + switch (pageKey) { + case vitalSignDetails.bodyMeasurements: + VSchart = [ + { + 'name': 'Highet', + 'title1': 'Date', + 'title2': 'Cm', + 'viewKey': 'HeightCm', + }, + { + 'name': 'Weight Kg', + 'title1': 'Date', + 'title2': 'Kg', + 'viewKey': 'WeightKg', + }, + { + 'name': 'BodyMassIndex', + 'title1': 'Date', + 'title2': 'BodyMass', + 'viewKey': 'BodyMassIndex', + }, + { + 'name': 'HeadCircumCm', + 'title1': 'Date', + 'title2': 'Cm', + 'viewKey': 'HeadCircumCm', + }, + { + 'name': 'Ideal Body Weight (Lbs)', + 'title1': 'Date', + 'title2': 'Ideal Weight', + 'viewKey': 'IdealBodyWeightLbs', + }, + { + 'name': 'LeanBodyWeightLbs (Lbs)', + 'title1': 'Date', + 'title2': 'Lean Weight', + 'viewKey': 'LeanBodyWeightLbs', + } + ]; + + break; + + case vitalSignDetails.temperature: + VSchart = [ + { + 'name': 'Temperature In Celcius', + 'title1': 'Date', + 'title2': 'C', + 'viewKey': 'TemperatureCelcius', + }, + ]; + + break; + case vitalSignDetails.pulse: + VSchart = [ + { + 'name': 'Pulse Beat Per Minute', + 'title1': 'Date', + 'title2': 'Minute', + 'viewKey': 'PulseBeatPerMinute', + }, + ]; + + break; + case vitalSignDetails.pespiration: + VSchart = [ + { + 'name': 'Respiration Beat Per Minute', + 'title1': 'Date', + 'title2': 'Beat Per Minute', + 'viewKey': 'RespirationBeatPerMinute', + }, + ]; + + break; + case vitalSignDetails.bloodPressure: + VSchart = [ + { + 'name': 'Blood Pressure Higher', + 'title1': 'Date', + 'title2': 'Minute', + 'viewKey': 'BloodPressureHigher', + }, + { + 'name': 'Blood Pressure Lower', + 'title1': 'Date', + 'title2': 'Minute', + 'viewKey': 'BloodPressureLower', + } + ]; + + break; + case vitalSignDetails.oxygenation: + VSchart = [ + { + 'name': 'FIO2', + 'title1': 'Date', + 'title2': 'Cm', + 'viewKey': 'FIO2', + }, + { + 'name': 'SAO2', + 'title1': 'Date', + 'title2': 'Cm', + 'viewKey': 'SAO2', + }, + ]; + + break; + case vitalSignDetails.painScale: + VSchart = [ + { + 'name': 'PainScore', + 'title1': 'Date', + 'title2': 'Cm', + 'viewKey': 'PainScore', + }, + ]; + break; + + default: + } // generateData(); return AppScaffold( - appBarTitle: 'Body Measurements', + appBarTitle: pageTitle, body: ListView( - children: [ - Column( - children: [ - TimeSeriesChart(seriesList: seriesList, vitalList: vitalList), - VitalSignDetailsWidget( - vitalList: vitalList.reversed.toList(), - title1: 'Date', - title2: 'Kg', - viewKey: 'HeightCm', - ), - ], - ), - ], + children: VSchart.map((chartInfo) { + var vitalListTemp = vitalList.where((element) => element.toJson()[chartInfo['viewKey']] != null,); + return vitalListTemp.length !=0 ? VitalSingChartAndDetials( + vitalList: vitalList, + name: chartInfo['name'], + title1: chartInfo['title1'], + title2: chartInfo['title2'], + viewKey: chartInfo['viewKey']) : Container(); + }).toList(), ), ); } - - generateData() { - final List data = []; - - vitalList = patientsProv.patientVitalSignOrderdSubList; - if (vitalList.length > 0) { - vitalList.forEach( - (element) { - data.add( - TimeSeriesSales( - new DateTime(element.vitalSignDate.year, - element.vitalSignDate.month, element.vitalSignDate.day), - element.bodyMassIndex.toInt(), - ), - ); - }, - ); - } - return [ - new charts.Series( - id: 'Sales', - domainFn: (TimeSeriesSales sales, _) => sales.time, - measureFn: (TimeSeriesSales sales, _) => sales.sales, - data: data, - ) - ]; - } } - class LinearSales { final int year; final int sales; diff --git a/lib/screens/patients/profile/vital_sign/vital_ding_chart_and_detials.dart b/lib/screens/patients/profile/vital_sign/vital_ding_chart_and_detials.dart new file mode 100644 index 00000000..e01290c1 --- /dev/null +++ b/lib/screens/patients/profile/vital_sign/vital_ding_chart_and_detials.dart @@ -0,0 +1,39 @@ +import 'package:doctor_app_flutter/models/patient/vital_sign_res_model.dart'; +import 'package:doctor_app_flutter/widgets/patients/vital_sign_details_wideget.dart'; +import 'package:doctor_app_flutter/widgets/shared/charts/app_time_series_chart.dart'; +import 'package:flutter/material.dart'; +class VitalSingChartAndDetials extends StatelessWidget { + VitalSingChartAndDetials({ + Key key, + @required this.vitalList, + @required this.name, + @required this.viewKey, + @required this.title1, + @required this.title2, + }) : super(key: key); + + final List vitalList ; + final String name; + final String viewKey; + final String title1; + final String title2; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + AppTimeSeriesChart( + vitalList: vitalList, + chartName: name, + viewKey: viewKey, + ), + VitalSignDetailsWidget( + vitalList: vitalList.reversed.toList(), + title1: '${title1}', + title2: '${title2}', + viewKey: '${viewKey}', + ), + ], + ); + } +} diff --git a/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart b/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart index 9547c1ce..fc25928a 100644 --- a/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart +++ b/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart @@ -1,16 +1,18 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/lookups/patient_lookup.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign_req_model.dart'; import 'package:doctor_app_flutter/providers/patients_provider.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../../config/size_config.dart'; import '../../../../models/patient/vital_sign_res_model.dart'; -import '../../../../widgets/patients/profile/profile_medical_info_widget.dart'; import '../../../../widgets/shared/app_scaffold_widget.dart'; + DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class VitalSignDetailsScreen extends StatefulWidget { @@ -74,54 +76,192 @@ class _VitalSignDetailsScreenState extends State { return AppScaffold( appBarTitle: "vital Sing ", isloading: patientsProv.isLoading, - body: CustomScrollView( - primary: false, - slivers: [ - SliverPadding( - padding: const EdgeInsets.all(10), - sliver: SliverGrid.count( - childAspectRatio: 0.7, - crossAxisSpacing: 10, - mainAxisSpacing: 0, - crossAxisCount: 3, + body: Container( + child: Column( + children: [ + Row( children: [ InkWell( - onTap: (){ - Navigator.of(context).pushNamed(BODY_MEASUREMENTS); + onTap: () { + Navigator.of(context).pushNamed(BODY_MEASUREMENTS, + arguments: { + 'title': 'Body Measurements', + 'key': vitalSignDetails.bodyMeasurements + }); }, - child: CircleAvatarWidget( + child: VitalSignItem( des: 'Body Measurements', url: url + 'heartbeat.png', + lastVal: patientsProv + .patientVitalSignOrderdSubList[0].heightCm + .toString(), + unit: 'Cm', ), ), - CircleAvatarWidget( - des: 'Temperature', - url: url + 'heartbeat.png', + InkWell( + onTap: () { + Navigator.of(context).pushNamed(BODY_MEASUREMENTS, + arguments: { + 'title': 'Temperature', + 'key': vitalSignDetails.temperature + }); + }, + child: VitalSignItem( + des: 'Temperature', + url: url + 'heartbeat.png', + ), ), - CircleAvatarWidget( - des: 'Pulse', - url: url + 'heartbeat.png', + ], + ), + Row( + children: [ + InkWell( + onTap: () { + Navigator.of(context).pushNamed(BODY_MEASUREMENTS, + arguments: { + 'title': 'pulse', + 'key': vitalSignDetails.pulse + }); + }, + child: VitalSignItem( + des: 'Pulse', + url: url + 'heartbeat.png', + ), ), - CircleAvatarWidget( - des: 'Respiration', - url: url + 'heartbeat.png', + InkWell( + onTap: () { + Navigator.of(context).pushNamed(BODY_MEASUREMENTS, + arguments: { + 'title': 'pespiration', + 'key': vitalSignDetails.pespiration + }); + }, + child: VitalSignItem( + des: 'Respiration', + url: url + 'heartbeat.png', + ), ), - CircleAvatarWidget( - des: 'Blood Pressure', - url: url + 'heartbeat.png', + ], + ), + Row( + children: [ + InkWell( + onTap: () { + Navigator.of(context).pushNamed(BODY_MEASUREMENTS, + arguments: { + 'title': 'Blood Pressure', + 'key': vitalSignDetails.bloodPressure + }); + }, + child: VitalSignItem( + des: 'Blood Pressure', + url: url + 'heartbeat.png', + ), ), - CircleAvatarWidget( - des: 'Oxygenation', - url: url + 'heartbeat.png', + InkWell( + onTap: () { + Navigator.of(context).pushNamed(BODY_MEASUREMENTS, + arguments: { + 'title': 'Oxygenation', + 'key': vitalSignDetails.oxygenation + }); + }, + child: VitalSignItem( + des: 'Oxygenation', + url: url + 'heartbeat.png', + ), ), - CircleAvatarWidget( - des: 'Pain Scale', - url: url + 'heartbeat.png', + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + onTap: () { + Navigator.of(context).pushNamed(BODY_MEASUREMENTS, + arguments: { + 'title': 'Pain Scale', + 'key': vitalSignDetails.painScale + }); + }, + child: VitalSignItem( + des: 'Pain Scale', + url: url + 'heartbeat.png', + ), ), ], ), + ], + ), + )); + } +} + +class VitalSignItem extends StatelessWidget { + const VitalSignItem( + {Key key, + @required this.url, + @required this.des, + this.lastVal = 'N/A', + this.unit = '', + this.height, + this.width}) + : super(key: key); + + final String url; + final String des; + final String lastVal; + final String unit; + + final double height; + final double width; + + @override + Widget build(BuildContext context) { + return RoundedContainer( + height: 0.14 * SizeConfig.realScreenHeight, + width: 0.45 * SizeConfig.realScreenWidth, + child: Container( + padding: EdgeInsets.all(5), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + des, + style: TextStyle( + fontSize: 1.7 * SizeConfig.textMultiplier, + color: Theme.of(context).primaryColor, + fontWeight: FontWeight.bold), ), + Column( + // mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Image.asset( + url, + height: SizeConfig.heightMultiplier * 7, + ), + ), + Expanded( + child: RichText( + text: TextSpan( + style: TextStyle(color: Colors.black), + children: [ + new TextSpan(text: lastVal), + new TextSpan( + text: ' ${unit}', + style: + TextStyle(color: Theme.of(context).primaryColor)), + ], + ), + )) + ], + ) ], - )); + ), + ), + ); } } diff --git a/lib/widgets/shared/charts/app_time_series_chart.dart b/lib/widgets/shared/charts/app_time_series_chart.dart index 128c81cd..d22fb951 100644 --- a/lib/widgets/shared/charts/app_time_series_chart.dart +++ b/lib/widgets/shared/charts/app_time_series_chart.dart @@ -1,51 +1,93 @@ +import 'package:charts_flutter/flutter.dart' as charts; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign_res_model.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/vital_sign/body_measurements_screen.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; -import 'package:charts_flutter/flutter.dart' as charts; -class TimeSeriesChart extends StatelessWidget { - const TimeSeriesChart({ - Key key, - @required this.seriesList, - @required this.vitalList, - }) : super(key: key); +class AppTimeSeriesChart extends StatelessWidget { + AppTimeSeriesChart( + {Key key, + @required this.vitalList, + @required this.viewKey, + this.chartName = ''}); - final List seriesList; final List vitalList; + final String chartName; + final String viewKey; + List seriesList; @override Widget build(BuildContext context) { + seriesList = generateData(); return RoundedContainer( - height: SizeConfig.realScreenHeight * 0.4, - child: Center( - child: Expanded( - child: charts.TimeSeriesChart( - seriesList, - animate: true, - behaviors: [ - new charts.RangeAnnotation( - [ - new charts.RangeAnnotationSegment( - DateTime( - vitalList[vitalList.length - 1] - .vitalSignDate - .year, - vitalList[vitalList.length - 1] - .vitalSignDate - .month + - 3, - vitalList[vitalList.length - 1] - .vitalSignDate - .day), - vitalList[0].vitalSignDate, - charts.RangeAnnotationAxisType.domain), - ], + height: SizeConfig.realScreenHeight * 0.47, + child: Column( + children: [ + Text( + chartName, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 3), + ), + Container( + height: SizeConfig.realScreenHeight * 0.37, + child: Center( + child: Expanded( + child: charts.TimeSeriesChart( + seriesList, + animate: true, + behaviors: [ + new charts.RangeAnnotation( + [ + new charts.RangeAnnotationSegment( + DateTime( + vitalList[vitalList.length - 1] + .vitalSignDate + .year, + vitalList[vitalList.length - 1] + .vitalSignDate + .month + + 3, + vitalList[vitalList.length - 1] + .vitalSignDate + .day), + vitalList[0].vitalSignDate, + charts.RangeAnnotationAxisType.domain), + ], + ), + ], + ), ), - ], + ), ), - ), + ], ), ); } + + generateData() { + final List data = []; + if (vitalList.length > 0) { + vitalList.forEach( + (element) { + data.add( + TimeSeriesSales( + new DateTime(element.vitalSignDate.year, + element.vitalSignDate.month, element.vitalSignDate.day), + element.toJson()[viewKey].toInt(), + ), + ); + }, + ); + } + return [ + new charts.Series( + id: 'Sales', + domainFn: (TimeSeriesSales sales, _) => sales.time, + measureFn: (TimeSeriesSales sales, _) => sales.sales, + data: data, + ) + ]; + } }