Merge branch 'dev_v3.13.6_CR_7211_Lab_report_changes' into merge-update-with-lab-changes

# Conflicts:
#	lib/config/localized_values.dart
#	lib/core/viewModels/medical/labs_view_model.dart
#	lib/uitl/translations_delegate_base.dart
#	lib/widgets/data_display/medical/LabResult/FlowChartPage.dart
merge-update-with-lab-changes
haroon amjad 7 months ago
commit 7b6395cc49

@ -2371,4 +2371,6 @@ const Map localizedValues = {
"thisResult" : {"en": "This Result", "ar": "هذه النتيجة"},
"seeAllGraphValues" : {"en": "See all values", "ar": "شاهد جميع القيم"},
}; };

@ -323,8 +323,9 @@ class LabsService extends BaseService {
if (bDate == null) return -1; if (bDate == null) return -1;
return bDate.compareTo(aDate); // descending return bDate.compareTo(aDate); // descending
}); });
print("the copied item are $copy");
print("the copied item are $copy");
labOrdersResultsList = copy;
return copy.take(3).toList(); return copy.take(3).toList();
} }

@ -1,6 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui';
import 'package:hmg_patient_app/core/enum/filter_type.dart'; import 'package:hmg_patient_app/core/enum/filter_type.dart';
import 'package:hmg_patient_app/core/enum/viewstate.dart'; import 'package:hmg_patient_app/core/enum/viewstate.dart';
@ -25,8 +26,11 @@ class LabsViewModel extends BaseViewModel {
LabsService _labsService = locator<LabsService>(); LabsService _labsService = locator<LabsService>();
List<LabOrderResult> get labOrdersResultsList => _labsService.labOrdersResultsList; List<LabOrderResult> get labOrdersResultsList => _labsService.labOrdersResultsList;
List<DataPoint> timeSeries = []; List<DataPoint> threePointGraphValue = [];
List<DataPoint> completeeGraphValues = [];
List<ThresholdRange> threshold = []; List<ThresholdRange> threshold = [];
List months = ['Jan','Feb','Mar','April','May','Jun','July','Aug','Sep','Oct','Nov','Dec'];
String get labReportPDF => _labsService.labReportPDF; String get labReportPDF => _labsService.labReportPDF;
@ -188,16 +192,46 @@ class LabsViewModel extends BaseViewModel {
recentThree.reversed.forEach((element) { recentThree.reversed.forEach((element) {
try { try {
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!); var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
timeSeries.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month]} ${dateTime.year}", date: dateTime)); threePointGraphValue.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime));
counter++; counter++;
} catch (e) {} } catch (e) {}
}); });
timeSeries.last.label = "thisResult"; threePointGraphValue.last.label = "thisResult";
timeSeries.last.isStringResource = true; threePointGraphValue.last.isStringResource = true;
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
/// This function is used to create a full graph data points for the lab results.
/// @param onComplete: A callback function that is called when the data points are created.
createFullGraphDatPoints(
VoidCallback onComplete
){
completeeGraphValues.clear();
setState(ViewState.Busy);
double counter = 1;
threshold = _labsService.getThresholdValue();
_labsService.labOrdersResultsList.reversed.forEach((element) {
try {
print("the mapping is being done");
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
completeeGraphValues.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime));
} catch (e) {
print("the mapping is having exception $e");
}
++counter;
});
print("the label values are $counter");
print("the completeeGraphValues length are ${completeeGraphValues.length}");
print("the completeeGraphValues last value of label ias ${completeeGraphValues.last.labelValue}");
completeeGraphValues.last.label = "thisResult";
completeeGraphValues.last.isStringResource = true;
setState(ViewState.Idle);
onComplete();
}
sendLabReportEmail({PatientLabOrders? patientLabOrder, String? mes, AuthenticatedUser? userObj, required bool isVidaPlus, bool isDownload = false}) async { sendLabReportEmail({PatientLabOrders? patientLabOrder, String? mes, AuthenticatedUser? userObj, required bool isVidaPlus, bool isDownload = false}) async {
setState(ViewState.Busy); setState(ViewState.Busy);

@ -3526,6 +3526,7 @@ class TranslationBase {
String get criticalLow => localizedValues["criticalLow"][locale.languageCode]; String get criticalLow => localizedValues["criticalLow"][locale.languageCode];
String get high => localizedValues["high"][locale.languageCode]; String get high => localizedValues["high"][locale.languageCode];
String get thisResult => localizedValues["thisResult"][locale.languageCode]; String get thisResult => localizedValues["thisResult"][locale.languageCode];
String get seeAllGraphValues => localizedValues["seeAllGraphValues"][locale.languageCode];
String get normal => localizedValues["normal"][locale.languageCode]; String get normal => localizedValues["normal"][locale.languageCode];
String get low => localizedValues["low"][locale.languageCode]; String get low => localizedValues["low"][locale.languageCode];

@ -29,16 +29,13 @@ class FlowChartPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectViewModel = Provider.of(context); projectViewModel = Provider.of(context);
return BaseView<LabsViewModel>( return BaseView<LabsViewModel>(
onModelReady: (model) => onModelReady: (model) => model.getPatientLabOrdersResults(
model.getPatientLabOrdersResults(patientLabOrder: patientLabOrder, patientLabOrder: patientLabOrder,
procedure: filterName, procedure: filterName,
isVidaPlus: Utils.isVidaPlusProject( isVidaPlus: Utils.isVidaPlusProject(
projectViewModel!, int.parse(patientLabOrder!.projectID!))), projectViewModel!, int.parse(patientLabOrder!.projectID!))),
builder: (context, model, w) => builder: (context, model, w) => SizedBox(
SizedBox( height: MediaQuery.sizeOf(context).height * .75,
height: MediaQuery
.sizeOf(context)
.height * .75,
child: (model.state == ViewState.Busy) child: (model.state == ViewState.Busy)
? Material( ? Material(
color: Colors.grey.withOpacity(0.6), color: Colors.grey.withOpacity(0.6),
@ -50,10 +47,7 @@ class FlowChartPage extends StatelessWidget {
child: Container( child: Container(
child: GifLoaderContainer(), child: GifLoaderContainer(),
margin: EdgeInsets.only( margin: EdgeInsets.only(
bottom: MediaQuery bottom: MediaQuery.of(context).size.height * 0.09)),
.of(context)
.size
.height * 0.09)),
), ),
) )
: SingleChildScrollView( : SingleChildScrollView(
@ -107,9 +101,35 @@ class FlowChartPage extends StatelessWidget {
// timeSeries: model.timeSeries, // timeSeries: model.timeSeries,
// indexes: model.timeSeries.length ~/ 5.5 ?? 0, // indexes: model.timeSeries.length ~/ 5.5 ?? 0,
// ), // ),
child: Column(
children: [
SizedBox(
height: MediaQuery.sizeOf(context).height / 4,
child: DynamicResultChart( child: DynamicResultChart(
dataPoints: model.timeSeries, dataPoints: model.threePointGraphValue,
thresholds: model.threshold, thresholds: model.threshold,
width: MediaQuery.sizeOf(context).width - 77,
scrollDirection: Axis.horizontal,
height: MediaQuery.sizeOf(context).height / 4,
),
),
InkWell(
onTap: () {
model.createFullGraphDatPoints(() {
Navigator.push(context,
MaterialPageRoute(builder: (_) {
return FullScreenGraph(
completeeGraphValues: model.completeeGraphValues,
threshold: model.threshold,
);
}));
});
},
child: Text(TranslationBase.of(context)
.seeAllGraphValues),
)
],
), ),
), ),
LabResultChartAndDetails( LabResultChartAndDetails(
@ -121,10 +141,7 @@ class FlowChartPage extends StatelessWidget {
: Center( : Center(
child: Container( child: Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: MediaQuery top: MediaQuery.of(context).size.height * 0.32),
.of(context)
.size
.height * 0.32),
child: Center( child: Center(
child: getNoDataWidget(context), child: getNoDataWidget(context),
), ),

@ -0,0 +1,59 @@
import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
class FullScreenGraph extends StatelessWidget {
final List<DataPoint> completeeGraphValues ;
final List<ThresholdRange> threshold ;
const FullScreenGraph({super.key, required this.completeeGraphValues, required this.threshold});
@override
Widget build(BuildContext context) {
return AppScaffold(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).labResult,
showNewAppBar: true,
showNewAppBarTitle: true,
backgroundColor: Color(0xffF8F8F8),
body: RotatedBox(
quarterTurns: 1,
child: SizedBox(
// width: MediaQuery.sizeOf(context).height,
height: MediaQuery.sizeOf(context).width,
child: Material(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18),
child: DynamicResultChart(
dataPoints: completeeGraphValues,
thresholds: threshold,
// 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,
maxX: completeeGraphValues.length.toDouble(),
scrollDirection: Axis.horizontal,
height: MediaQuery.sizeOf(context).width,
isFullScreenGraph: true,
),
),
),
),
),
);
}
// double getMax(List<DataPoint> dataPoints) {
// double max = double.negativeInfinity;
// for (var point in dataPoints) {
// if (point.value > max) {
// max = point.y;
// }
// }
// return max;
// }
}

@ -6,14 +6,26 @@ import 'package:intl/intl.dart';
class DynamicResultChart extends StatelessWidget { class DynamicResultChart extends StatelessWidget {
final List<DataPoint> dataPoints; final List<DataPoint> dataPoints;
final List<ThresholdRange> thresholds; final List<ThresholdRange> thresholds;
final double? width;
final double height;
final double? maxX;
final Axis scrollDirection;
final bool isFullScreenGraph;
const DynamicResultChart( const DynamicResultChart(
{super.key, required this.dataPoints, required this.thresholds}); {super.key, required this.dataPoints, required this.thresholds,required this.width,required this.scrollDirection, required this.height, this.maxX, this.isFullScreenGraph = false});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final minY = thresholds.first.value; var minY = 0.0;
final maxY = thresholds.last.value + 1; var maxY = 0.0;
if(thresholds.isNotEmpty) {
print("the thresholds are $thresholds");
minY = thresholds.first.value;
maxY = thresholds.last.value + 1;
}else{
return SizedBox.shrink();
}
final spots = dataPoints.asMap().entries.map((entry) { final spots = dataPoints.asMap().entries.map((entry) {
return FlSpot(entry.key.toDouble(), entry.value.value); return FlSpot(entry.key.toDouble(), entry.value.value);
@ -24,19 +36,16 @@ class DynamicResultChart extends StatelessWidget {
return Material( return Material(
color: Colors.white, color: Colors.white,
child: SizedBox( child: SizedBox(
height: MediaQuery.sizeOf(context).height / 4, width: width,
child: SingleChildScrollView( height: height,
scrollDirection: Axis.horizontal,
child: SizedBox(
width: MediaQuery.sizeOf(context).width - 77,
child: Padding( child: Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8), padding: const EdgeInsets.only(top: 8.0, bottom: 8),
child: LineChart( child: LineChart(
LineChartData( LineChartData(
minY: minY, minY: minY,
maxY: maxY, maxY: maxY,
minX: dataPoints.first.labelValue - 1, minX: dataPoints.first.labelValue-1,
maxX: dataPoints.first.labelValue + 1, maxX: maxX,
lineTouchData: lineTouchData:
LineTouchData(touchTooltipData: LineTouchTooltipData( LineTouchData(touchTooltipData: LineTouchTooltipData(
getTooltipItems: (touchedSpots) { getTooltipItems: (touchedSpots) {
@ -45,8 +54,9 @@ class DynamicResultChart extends StatelessWidget {
// Only show tooltip for the first touched spot, hide others // Only show tooltip for the first touched spot, hide others
return touchedSpots.map((spot) { return touchedSpots.map((spot) {
if (spot == touchedSpots.first) { if (spot == touchedSpots.first) {
final dataPoint = dataPoints[spot.x.toInt()];
return LineTooltipItem( return LineTooltipItem(
'${spot.y}', '${dataPoint.label} ${spot.y.toStringAsFixed(2)}',
const TextStyle(color: Colors.white), const TextStyle(color: Colors.white),
); );
} }
@ -92,7 +102,7 @@ class DynamicResultChart extends StatelessWidget {
bottomTitles: AxisTitles( bottomTitles: AxisTitles(
axisNameSize: 60, axisNameSize: 60,
sideTitles: SideTitles( sideTitles: SideTitles(
showTitles: true, showTitles: !isFullScreenGraph,
reservedSize: 50, reservedSize: 50,
getTitlesWidget: (value, _) { getTitlesWidget: (value, _) {
if (value.toInt() >= 0 && if (value.toInt() >= 0 &&
@ -104,8 +114,9 @@ class DynamicResultChart extends StatelessWidget {
dataPoints[value.toInt()].label); dataPoints[value.toInt()].label);
} }
return Padding( return Padding(
padding: const EdgeInsets.only(top: 8.0), padding: EdgeInsetsDirectional.only(top: 8.0,),
child: Text( child: Text(
label, label,
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
@ -145,8 +156,6 @@ class DynamicResultChart extends StatelessWidget {
), ),
), ),
), ),
),
),
)); ));
} }
@ -186,12 +195,13 @@ class DynamicResultChart extends StatelessWidget {
} }
// Add dot markers separately so they are on top // Add dot markers separately so they are on top
final List<FlSpot> allSpots = dataPoints.asMap().entries.map((entry) { final List<FlSpot> allSpots = dataPoints.asMap().entries.map((entry) {
return FlSpot(entry.key.toDouble(), entry.value.value); return FlSpot(entry.key.toDouble(), entry.value.value);
}).toList(); }).toList();
print("the spots are $allSpots"); print("the spots are $allSpots");
return [ var data = [
...segments, ...segments,
LineChartBarData( LineChartBarData(
spots: allSpots, spots: allSpots,
@ -212,6 +222,10 @@ class DynamicResultChart extends StatelessWidget {
), ),
) )
]; ];
var max = LineChartHelper.calculateMaxAxisValues(data).maxX;
print("the maxX is the -------> $max");
return data;
} }
List<HorizontalRangeAnnotation> _buildRangeShades( List<HorizontalRangeAnnotation> _buildRangeShades(
@ -226,6 +240,8 @@ class DynamicResultChart extends StatelessWidget {
} }
return ranges; return ranges;
} }
} }
final List<DataPoint> sampleData = [ final List<DataPoint> sampleData = [

Loading…
Cancel
Save