diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index bf7dc5b7..732e4bc1 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -187,7 +187,7 @@ class BaseAppClient { // body['IdentificationNo'] = 1023854217; // body['MobileNo'] = "531940021"; //0560717232 - // body['PatientID'] = 53320; //4609100 + // body['PatientID'] = 3628599; //4609100 // body['TokenID'] = "@dm!n"; // Patient ID: 3027574 diff --git a/lib/core/viewModels/medical/labs_view_model.dart b/lib/core/viewModels/medical/labs_view_model.dart index 313f82c6..7a90e45b 100644 --- a/lib/core/viewModels/medical/labs_view_model.dart +++ b/lib/core/viewModels/medical/labs_view_model.dart @@ -32,7 +32,6 @@ class LabsViewModel extends BaseViewModel { List threshold = []; double maxYForThreeDots = 0.0; double maxYForCompleteGraph = 0.0; - List months = ['Jan', 'Feb', 'Mar', 'April', 'May', 'Jun', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; String get labReportPDF => _labsService.labReportPDF; @@ -200,13 +199,7 @@ class LabsViewModel extends BaseViewModel { maxYForThreeDots = double.parse(element.resultValue!); } // threePointGraphValue.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime)); - threePointGraphValue.add(DataPoint( - labelValue: counter, - value: double.parse(element.resultValue!), - actualValue: element.resultValue!, - label: "${months[dateTime.month - 1]} ${dateTime.year}", - date: dateTime, - referenceRangeValue: element.calculatedResultFlag ?? "IRR")); + threePointGraphValue.add(DataPoint( labelValue: counter,value : double.parse(element.resultValue!), actualValue: element.resultValue!,label: formatDateAsMMYY(dateTime), date: dateTime, referenceRangeValue:element.calculatedResultFlag ??"IRR")); counter++; } catch (e) {} }); @@ -224,21 +217,15 @@ class LabsViewModel extends BaseViewModel { completeeGraphValues.clear(); setState(ViewState.Busy); double counter = 1; - threshold = _labsService.getThresholdValue(); + threshold = _labsService.getThresholdValue(); _labsService.labOrdersResultsList.reversed.forEach((element) { try { var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!); - if (double.parse(element.resultValue!) > maxYForCompleteGraph) { + if(double.parse(element.resultValue!)> maxYForCompleteGraph){ maxYForCompleteGraph = double.parse(element.resultValue!); } // completeeGraphValues.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime)); - completeeGraphValues.add(DataPoint( - labelValue: counter, - value: double.parse(element.resultValue!), - label: "${months[dateTime.month - 1]} ${dateTime.year}", - date: dateTime, - actualValue: element.resultValue!, - referenceRangeValue: element.calculatedResultFlag ?? "IRR")); + completeeGraphValues.add(DataPoint( labelValue: counter,value : double.parse(element.resultValue!), label: formatDateAsMMYY(dateTime), date: dateTime,actualValue: element.resultValue!, referenceRangeValue:element.calculatedResultFlag??"IRR" )); } catch (e) { print("the mapping is having exception $e"); } @@ -250,6 +237,11 @@ class LabsViewModel extends BaseViewModel { onComplete(); } + String formatDateAsMMYY(DateTime date) { + String month = date.month.toString().padLeft(2, '0'); + String year = date.year.toString().substring(2); + return '$month/$year'; + } sendLabReportEmail({PatientLabOrders? patientLabOrder, String? mes, AuthenticatedUser? userObj, required bool isVidaPlus, bool isDownload = false}) async { setState(ViewState.Busy); diff --git a/lib/widgets/data_display/medical/LabResult/full_screen_lab_result_graph.dart b/lib/widgets/data_display/medical/LabResult/full_screen_lab_result_graph.dart index 5720891d..65412e14 100644 --- a/lib/widgets/data_display/medical/LabResult/full_screen_lab_result_graph.dart +++ b/lib/widgets/data_display/medical/LabResult/full_screen_lab_result_graph.dart @@ -12,8 +12,11 @@ class FullScreenGraph extends StatelessWidget { final double maxY; - const FullScreenGraph({super.key, required this.completeeGraphValues, required this.threshold, required this.maxY}); - + const FullScreenGraph( + {super.key, + required this.completeeGraphValues, + required this.threshold, + required this.maxY}); @override Widget build(BuildContext context) { return AppScaffold( @@ -21,8 +24,7 @@ class FullScreenGraph extends StatelessWidget { appBarTitle: TranslationBase.of(context).labResult, showNewAppBar: true, showNewAppBarTitle: true, - showHomeAppBarIcon: false, - backgroundColor: Color(0xffF8F8F8), + showHomeAppBarIcon: false,backgroundColor: Color(0xffF8F8F8), body: RotatedBox( quarterTurns: 1, child: SizedBox( @@ -32,34 +34,39 @@ class FullScreenGraph extends StatelessWidget { color: Colors.white, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18), - child: DynamicResultChart( - dataPoints: completeeGraphValues, - thresholds: threshold, - maxY: maxY, - // width:((completeeGraphValues.length <=2)? MediaQuery.sizeOf(context).height : (MediaQuery.sizeOf(context).height* ( - // completeeGraphValues.length <= 3 - // ? 1 - // : (completeeGraphValues.length/3)) - // ) )-77, - width: MediaQuery.sizeOf(context).height - 100, + child: SingleChildScrollView( scrollDirection: Axis.horizontal, - height: MediaQuery.sizeOf(context).width, - isFullScreenGraph: true, + child: DynamicResultChart( + dataPoints: completeeGraphValues, + thresholds: threshold, + maxY: maxY, + width:((completeeGraphValues.length <=2)? MediaQuery.sizeOf(context).height : (MediaQuery.sizeOf(context).height* ( + completeeGraphValues.length <= 15 + ? 1 + : (completeeGraphValues.length/15)) + ) )-100, + maxX: completeeGraphValues.length+1, + // width: MediaQuery.sizeOf(context).height - 100, + scrollDirection: Axis.horizontal, + height: MediaQuery.sizeOf(context).width, + showBottomTitleDates: true, + isFullScreeGraph: true, // isFullScreenGraph: false, ), ), ), ), ), + ), ); } -// double getMax(List dataPoints) { -// double max = double.negativeInfinity; -// for (var point in dataPoints) { -// if (point.value > max) { -// max = point.y; -// } -// } -// return max; -// } + // double getMax(List dataPoints) { + // double max = double.negativeInfinity; + // for (var point in dataPoints) { + // if (point.value > max) { + // max = point.y; + // } + // } + // return max; + // } } diff --git a/lib/widgets/data_display/medical/LabResult/lab_result_graph.dart b/lib/widgets/data_display/medical/LabResult/lab_result_graph.dart index 3510ee78..1177c912 100644 --- a/lib/widgets/data_display/medical/LabResult/lab_result_graph.dart +++ b/lib/widgets/data_display/medical/LabResult/lab_result_graph.dart @@ -9,12 +9,14 @@ class DynamicResultChart extends StatelessWidget { final double? width; final double height; final double? maxY; + final double? maxX; final Axis scrollDirection; - final bool isFullScreenGraph; + final bool showBottomTitleDates; + final bool isFullScreeGraph; DynamicResultChart( - {super.key, required this.dataPoints, required this.thresholds, required this.width, required this.scrollDirection, required this.height, this.maxY, this.isFullScreenGraph = false}); + {super.key, required this.dataPoints, required this.thresholds, this.width, required this.scrollDirection, required this.height, this.maxY,this.maxX, this.showBottomTitleDates = true, this.isFullScreeGraph = false}); @override Widget build(BuildContext context) { @@ -52,7 +54,7 @@ class DynamicResultChart extends StatelessWidget { minY: 0, maxY: ((maxY?.ceilToDouble()??0.0)+interval ).floorToDouble(), // minX: dataPoints.first.labelValue - 1, - // maxX: maxX, + maxX: maxX, lineTouchData: LineTouchData(touchTooltipData: LineTouchTooltipData(getTooltipItems: (touchedSpots) { if (touchedSpots.isEmpty) return []; @@ -128,7 +130,7 @@ class DynamicResultChart extends StatelessWidget { bottomTitles: AxisTitles( axisNameSize: 60, sideTitles: SideTitles( - showTitles: !isFullScreenGraph, + showTitles: showBottomTitleDates, reservedSize: 50, getTitlesWidget: (value, _) { if (value.toInt() >= 0 && value.toInt() < dataPoints.length) { @@ -254,7 +256,7 @@ class DynamicResultChart extends StatelessWidget { isCurved: true, isStrokeCapRound: true, isStrokeJoinRound: true, - barWidth: 2, // invisible line + barWidth: 2, gradient: LinearGradient( colors: [Color(0xFF5dc36b), Color(0xFF5dc36b)], begin: Alignment.centerLeft, diff --git a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart index fe93d2be..fae3c671 100644 --- a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart +++ b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart @@ -40,7 +40,6 @@ class _LaboratoryResultWidgetState extends State { super.initState(); this.model = widget.labmodel; - print("the details are ${widget.details}"); labSpecialResult = widget.details; } @@ -48,13 +47,11 @@ class _LaboratoryResultWidgetState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - print("did change dependency is called"); var oldStateTablateScreenState = isTabletScreen; isTabletScreen = isTablet(context); if(isTabletScreen != oldStateTablateScreenState); { - print("the screen width is changed"); model?.recalculatePercentage(isTabletScreen); }