diff --git a/lib/screens/patients/profile/lab_result/FlowChartPage.dart b/lib/screens/patients/profile/lab_result/FlowChartPage.dart index fcc9746a..be863b87 100644 --- a/lib/screens/patients/profile/lab_result/FlowChartPage.dart +++ b/lib/screens/patients/profile/lab_result/FlowChartPage.dart @@ -10,6 +10,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import 'lab_result_history_chart_and_detials.dart'; import 'lab_result_chart_and_detials.dart'; class FlowChartPage extends StatelessWidget { @@ -18,48 +19,57 @@ class FlowChartPage extends StatelessWidget { final PatiantInformtion patient; final bool isInpatient; - FlowChartPage({this.patientLabOrder, this.filterName, this.patient, this.isInpatient}); + FlowChartPage( + {this.patientLabOrder, this.filterName, this.patient, this.isInpatient}); @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => model.getPatientLabOrdersResults( + onModelReady: (model) => model.getPatientLabResultHistoryByDescription( patientLabOrder: patientLabOrder, - procedure: filterName, + procedureDescription: filterName, patient: patient), + // onModelReady: (model) => model.getPatientLabOrdersResults( + // patientLabOrder: patientLabOrder, + // procedure: filterName, + // patient: patient), builder: (context, model, w) => AppScaffold( isShowAppBar: true, appBarTitle: filterName, baseViewModel: model, - body: model.labOrdersResultsList.isNotEmpty + body: model.labOrdersResultHistoryList.isNotEmpty ? SingleChildScrollView( child: Container( - child: LabResultChartAndDetails( + child: LabResultHistoryChartAndDetails( name: filterName, - labResult: model.labOrdersResultsList, + labResultHistory: model.labOrdersResultHistoryList, ), + // child: LabResultChartAndDetails( + // name: filterName, + // labResult: model.labOrdersResultsList, + // ), ), ) : Container( - child: Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Image.asset('assets/images/no-data.png'), - Padding( - padding: const EdgeInsets.all(8.0), - child: AppText( - TranslationBase.of(context).noDataAvailable, - fontWeight: FontWeight.normal, - color: HexColor("#B8382B"), - fontSize: SizeConfig.textMultiplier * 2.5, - ), - ) - ], + child: Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset('assets/images/no-data.png'), + Padding( + padding: const EdgeInsets.all(8.0), + child: AppText( + TranslationBase.of(context).noDataAvailable, + fontWeight: FontWeight.normal, + color: HexColor("#B8382B"), + fontSize: SizeConfig.textMultiplier * 2.5, + ), + ) + ], + ), ), ), - ), ), ); } diff --git a/lib/screens/patients/profile/lab_result/LabResultHistoryPage.dart b/lib/screens/patients/profile/lab_result/LabResultHistoryPage.dart index 590c3e9a..118bc476 100644 --- a/lib/screens/patients/profile/lab_result/LabResultHistoryPage.dart +++ b/lib/screens/patients/profile/lab_result/LabResultHistoryPage.dart @@ -15,7 +15,7 @@ class LabResultHistoryPage extends StatelessWidget { final PatiantInformtion patient; LabResultHistoryPage({this.patientLabOrder, this.filterName, this.patient}); -// TODO mosa changes +// TODO mosa UI changes @override Widget build(BuildContext context) { return BaseView( @@ -34,6 +34,7 @@ class LabResultHistoryPage extends StatelessWidget { ...List.generate(model.labOrdersResultHistoryList.length, (index) { return Container( + margin: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), child: Column( children: [ Row( @@ -116,6 +117,14 @@ class LabResultHistoryPage extends StatelessWidget { ), ], ), + Divider( + color: Colors.grey, + height: 0.75, + thickness: 0.75, + ), + SizedBox( + height: 10, + ), ], ), ); diff --git a/lib/screens/patients/profile/lab_result/LabResultWidget.dart b/lib/screens/patients/profile/lab_result/LabResultWidget.dart index 47c9925b..ecbaa919 100644 --- a/lib/screens/patients/profile/lab_result/LabResultWidget.dart +++ b/lib/screens/patients/profile/lab_result/LabResultWidget.dart @@ -47,26 +47,26 @@ class LabResultWidget extends StatelessWidget { AppText(filterName), ], ), - InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: FlowChartPage( - filterName: filterName, - patientLabOrder: patientLabOrder, - patient: patient, - isInpatient: isInpatient, - ), - ), - ); - }, - child: AppText( - TranslationBase.of(context).showMoreBtn, - textDecoration: TextDecoration.underline, - color: Colors.blue, - ), - ), + // InkWell( + // onTap: () { + // Navigator.push( + // context, + // FadePage( + // page: FlowChartPage( + // filterName: filterName, + // patientLabOrder: patientLabOrder, + // patient: patient, + // isInpatient: isInpatient, + // ), + // ), + // ); + // }, + // // child: AppText( + // // TranslationBase.of(context).showMoreBtn, + // // textDecoration: TextDecoration.underline, + // // color: Colors.blue, + // // ), + // ), ], ), Row( @@ -119,25 +119,43 @@ class LabResultWidget extends StatelessWidget { ...List.generate( patientLabResultList.length, (index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ InkWell( - onTap: (){ + onTap: () { Navigator.push( context, FadePage( - page: LabResultHistoryPage( - filterName: patientLabResultList[index].description, + page: FlowChartPage( + filterName: + patientLabResultList[index].description, patientLabOrder: patientLabOrder, patient: patient, + isInpatient: isInpatient, ), + // page: LabResultHistoryPage( + // filterName: patientLabResultList[index].description, + // patientLabOrder: patientLabOrder, + // patient: patient, + // ), ), ); }, - child: AppText( - " (show details)", - color: Colors.blue, - fontSize: 12, + // child: AppText( + // " (show details)", + // color: Colors.blue, + // fontSize: 12, + // ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + AppText( + TranslationBase.of(context).showMoreBtn, + textDecoration: TextDecoration.underline, + color: Colors.blue, + fontSize: 12, + ), + ], ), ), Row( diff --git a/lib/screens/patients/profile/lab_result/Lab_Result_history_details_wideget.dart b/lib/screens/patients/profile/lab_result/Lab_Result_history_details_wideget.dart new file mode 100644 index 00000000..490d0ec4 --- /dev/null +++ b/lib/screens/patients/profile/lab_result/Lab_Result_history_details_wideget.dart @@ -0,0 +1,116 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/core/model/labs/LabResultHistory.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class LabResultHistoryDetailsWidget extends StatefulWidget { + final List labResultHistory; + + LabResultHistoryDetailsWidget({ + this.labResultHistory, + }); + + @override + _VitalSignDetailsWidgetState createState() => _VitalSignDetailsWidgetState(); +} + +class _VitalSignDetailsWidgetState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Container( + /* decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10.0), topRight: Radius.circular(10.0)), + border: Border.all(color: Colors.grey, width: 1), + ),*/ + margin: EdgeInsets.all(0), + child: Container( + color: Colors.transparent, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Container( + child: Container( + padding: EdgeInsets.all(8), + child: AppText( + TranslationBase.of(context).date, + fontSize: SizeConfig.textMultiplier * 1.6, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.all(8), + child: Container( + child: AppText( + TranslationBase.of(context).labResult, + fontSize: SizeConfig.textMultiplier * 1.6, + fontWeight: FontWeight.bold, + ), + // height: 60 + ), + ), + ) + ], + ), + const Divider( + height: 1, + thickness: 1, + color: Colors.black, + ), + Table( + border: TableBorder.symmetric( + inside: BorderSide(width: 1.0, color: Colors.grey[300]), + ), + children: fullData(projectViewModel), + ), + ], + ), + ), + ); + } + + List fullData(ProjectViewModel projectViewModel) { + List tableRow = []; + widget.labResultHistory.forEach((vital) { + var date = AppDateUtils.convertStringToDate(vital.verifiedOnDateTime); + tableRow.add(TableRow(children: [ + Container( + child: Container( + padding: EdgeInsets.all(8), + color: Colors.white, + child: AppText( + '${projectViewModel.isArabic ? AppDateUtils.getWeekDayArabic(date.weekday) : AppDateUtils.getWeekDay(date.weekday)} ,${date.day} ${projectViewModel.isArabic ? AppDateUtils.getMonthArabic(date.month) : AppDateUtils.getMonth(date.month)} ${date.year}', + fontSize: SizeConfig.textMultiplier * 1.8, + fontWeight: FontWeight.w600, + ), + ), + ), + Container( + child: Container( + padding: EdgeInsets.all(8), + color: Colors.white, + child: AppText( + '${vital.resultValue}', + fontSize: SizeConfig.textMultiplier * 1.8, + fontWeight: FontWeight.w600, + ), + ), + ), + ])); + }); + return tableRow; + } +} \ No newline at end of file diff --git a/lib/screens/patients/profile/lab_result/LineChartCurvedLabHistory.dart b/lib/screens/patients/profile/lab_result/LineChartCurvedLabHistory.dart new file mode 100644 index 00000000..ea9300d0 --- /dev/null +++ b/lib/screens/patients/profile/lab_result/LineChartCurvedLabHistory.dart @@ -0,0 +1,231 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/core/model/labs/LabResultHistory.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:fl_chart/fl_chart.dart'; +import 'package:flutter/material.dart'; + +class LineChartCurvedLabHistory extends StatefulWidget { + final String title; + final List labResultHistory; + + LineChartCurvedLabHistory({this.title, this.labResultHistory}); + + @override + State createState() => LineChartCurvedLabHistoryState(); +} + +class LineChartCurvedLabHistoryState extends State { + bool isShowingMainData; + List xAxixs = List(); + int indexes = 0; + + @override + void initState() { + super.initState(); + getXaxix(); + isShowingMainData = true; + } + + getXaxix() { + indexes = widget.labResultHistory.length ~/ 3.5; + for (int index = 0; index < widget.labResultHistory.length; index++) { + int mIndex = indexes * index; + if (mIndex < widget.labResultHistory.length) { + xAxixs.add(mIndex); + } + } + } + + @override + Widget build(BuildContext context) { + return AspectRatio( + aspectRatio: 1.23, + child: Container( + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(18)), + // color: Colors.white, + ), + child: Stack( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox( + height: 4, + ), + AppText( + widget.title, + fontSize: SizeConfig.textMultiplier * 2.1, + fontWeight: FontWeight.bold, + fontFamily: 'Poppins', + textAlign: TextAlign.center, + ), + const SizedBox( + height: 12, + ), + Expanded( + child: Padding( + padding: const EdgeInsets.only(right: 16.0, left: 8.0), + child: LineChart( + sampleData1(), + swapAnimationDuration: const Duration(milliseconds: 250), + ), + ), + ), + const SizedBox( + height: 10, + ), + ], + ), + ], + ), + ), + ); + } + + LineChartData sampleData1() { + return LineChartData( + lineTouchData: LineTouchData( + touchTooltipData: LineTouchTooltipData( + tooltipBgColor: Colors.white, + ), + touchCallback: (LineTouchResponse touchResponse) {}, + handleBuiltInTouches: true, + ), + gridData: FlGridData( + show: true, drawVerticalLine: true, drawHorizontalLine: true), + titlesData: FlTitlesData( + bottomTitles: SideTitles( + showTitles: true, + getTextStyles: (value) => const TextStyle( + color: Colors.black, + fontSize: 11, + ), + margin: 28, + rotateAngle: -65, + getTitles: (value) { + print(value); + DateTime date = AppDateUtils.convertStringToDate( + widget.labResultHistory[value.toInt()].verifiedOnDateTime); + if (widget.labResultHistory.length < 8) { + if (widget.labResultHistory.length > value.toInt()) { + return '${date.day}/ ${date.year}'; + } else + return ''; + } else { + if (value.toInt() == 0) return '${date.day}/ ${date.year}'; + if (value.toInt() == widget.labResultHistory.length - 1) + return '${date.day}/ ${date.year}'; + if (xAxixs.contains(value.toInt())) { + return '${date.day}/ ${date.year}'; + } + } + + return ''; + }, + ), + leftTitles: SideTitles( + showTitles: true, + getTextStyles: (value) => const TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 10, + ), + getTitles: (value) { + return '${value.toInt()}'; + }, + margin: 8, + //reservedSize: 30, + ), + ), + borderData: FlBorderData( + show: true, + border: const Border( + bottom: BorderSide( + color: Colors.black, + width: 0.5, + ), + left: BorderSide( + color: Colors.black, + ), + right: BorderSide( + color: Colors.black, + ), + top: BorderSide( + color: Colors.transparent, + ), + ), + ), + minX: 0, + maxX: (widget.labResultHistory.length - 1).toDouble(), + maxY: getMaxY() + 2, + minY: getMinY(), + lineBarsData: getData(), + ); + } + + double getMaxY() { + double max = 0; + widget.labResultHistory.forEach((element) { + try { + double resultValueDouble = double.parse(element.resultValue); + if (resultValueDouble > max) max = resultValueDouble; + } catch (e) { + print(e); + } + }); + + return max.roundToDouble(); + } + + double getMinY() { + double min = 0; + try { + min = double.parse(widget.labResultHistory[0].resultValue); + + widget.labResultHistory.forEach((element) { + double resultValueDouble = double.parse(element.resultValue); + if (resultValueDouble < min) min = resultValueDouble; + }); + } catch (e) { + print(e); + } + int value = min.toInt(); + + return value.toDouble(); + } + + List getData() { + List spots = List(); + for (int index = 0; index < widget.labResultHistory.length; index++) { + try { + var resultValueDouble = + double.parse(widget.labResultHistory[index].resultValue); + spots.add(FlSpot(index.toDouble(), resultValueDouble)); + } catch (e) { + print(e); + spots.add(FlSpot(index.toDouble(), 0.0)); + } + } + + final LineChartBarData lineChartBarData1 = LineChartBarData( + spots: spots, + isCurved: true, + colors: [Colors.red], + barWidth: 3, + isStrokeCapRound: true, + curveSmoothness: 0.12, + dotData: FlDotData( + show: false, + ), + belowBarData: BarAreaData( + show: false, + ), + ); + + return [ + lineChartBarData1, + ]; + } +} diff --git a/lib/screens/patients/profile/lab_result/lab_result_chart_and_detials.dart b/lib/screens/patients/profile/lab_result/lab_result_chart_and_detials.dart index 6026c9e9..49fee0f4 100644 --- a/lib/screens/patients/profile/lab_result/lab_result_chart_and_detials.dart +++ b/lib/screens/patients/profile/lab_result/lab_result_chart_and_detials.dart @@ -5,8 +5,8 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; -import 'Lab_Result_details_wideget.dart'; import 'LineChartCurved.dart'; +import 'Lab_Result_details_wideget.dart'; class LabResultChartAndDetails extends StatelessWidget { diff --git a/lib/screens/patients/profile/lab_result/lab_result_history_chart_and_detials.dart b/lib/screens/patients/profile/lab_result/lab_result_history_chart_and_detials.dart new file mode 100644 index 00000000..322eb817 --- /dev/null +++ b/lib/screens/patients/profile/lab_result/lab_result_history_chart_and_detials.dart @@ -0,0 +1,62 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/labs/LabResultHistory.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; + +import 'Lab_Result_history_details_wideget.dart'; +import 'LineChartCurvedLabHistory.dart'; + +class LabResultHistoryChartAndDetails extends StatelessWidget { + LabResultHistoryChartAndDetails({ + Key key, + @required this.labResultHistory, + @required this.name, + }) : super(key: key); + + final List labResultHistory; + final String name; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.symmetric(horizontal: 8), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(12)), + child: LineChartCurvedLabHistory( + title: name, + labResultHistory: labResultHistory, + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 8, vertical: 16), + padding: EdgeInsets.only(top: 16, right: 18.0, left: 16.0), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(12)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).graphDetails, + fontSize: SizeConfig.textMultiplier * 2.1, + fontWeight: FontWeight.bold, + ), + SizedBox( + height: 8, + ), + LabResultHistoryDetailsWidget( + labResultHistory: labResultHistory.reversed.toList(), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/patients/profile/lab_result/laboratory_result_page.dart b/lib/screens/patients/profile/lab_result/laboratory_result_page.dart index e58d4ef5..4ccd4379 100644 --- a/lib/screens/patients/profile/lab_result/laboratory_result_page.dart +++ b/lib/screens/patients/profile/lab_result/laboratory_result_page.dart @@ -49,20 +49,16 @@ class _LaboratoryResultPageState extends State { body: AppScaffold( isShowAppBar: false, body: SingleChildScrollView( - child: Column( - children: [ - LaboratoryResultWidget( - onTap: () async {}, - billNo: widget.patientLabOrders.invoiceNo, - details: model.patientLabSpecialResult.length > 0 - ? model.patientLabSpecialResult[0].resultDataHTML - : null, - orderNo: widget.patientLabOrders.orderNo, - patientLabOrder: widget.patientLabOrders, - patient: widget.patient, - isInpatient: widget.patientType == "1", - ), - ], + child: LaboratoryResultWidget( + onTap: () async {}, + billNo: widget.patientLabOrders.invoiceNo, + details: model.patientLabSpecialResult.length > 0 + ? model.patientLabSpecialResult[0].resultDataHTML + : null, + orderNo: widget.patientLabOrders.orderNo, + patientLabOrder: widget.patientLabOrders, + patient: widget.patient, + isInpatient: widget.patientType == "1", ), ), ), diff --git a/lib/widgets/patients/patient_card/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart index 286ce503..b86256fd 100644 --- a/lib/widgets/patients/patient_card/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -383,36 +383,20 @@ class PatientCard extends StatelessWidget { "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}", ), if (patientInfo.admissionDate != null) - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: - 2.0 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: TranslationBase.of(context) - .roomNo + - " : ", - style: TextStyle(fontSize: 12)), - new TextSpan( - text: - "${patientInfo.roomId}", - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 13)), - ]))), + CustomRow( + label: + TranslationBase.of(context).roomNo + " : ", + value: "${patientInfo.roomId}", + ), + if (isFromLiveCare) Column( children: [ - - CustomRow(label: TranslationBase.of(context) - .clinic + - " : ", - value: patientInfo.clinicName,), + CustomRow( + label: TranslationBase.of(context).clinic + + " : ", + value: patientInfo.clinicName, + ), ], ), ]))