Wd: Full portrait graph added.

merge-update-with-lab-changes
Syed Taha Alam 6 months ago
parent c09170b506
commit 656d8dd6b4

@ -2337,4 +2337,5 @@ const Map localizedValues = {
"liveCareTermsConditions48": {"en": "If you have any complaints or concerns about the Application and or the Website, Our Services, or how we handle your personal information please contact us on: EServices.HMG@drsulaimanalhabib.com or call 011 525 9553", "ar": "إذا كانت لديك أي شكاوى أو مخاوف بشأن التطبيق و/أو موقع الويب أو خدماتنا أو كيفية تعاملنا مع معلوماتك الشخصية، فيرجى التواصل معنا على: EServices.HMG@drsulaimanalhabib.com أو الاتصال على الرقم: 9553 525 011"}, "liveCareTermsConditions48": {"en": "If you have any complaints or concerns about the Application and or the Website, Our Services, or how we handle your personal information please contact us on: EServices.HMG@drsulaimanalhabib.com or call 011 525 9553", "ar": "إذا كانت لديك أي شكاوى أو مخاوف بشأن التطبيق و/أو موقع الويب أو خدماتنا أو كيفية تعاملنا مع معلوماتك الشخصية، فيرجى التواصل معنا على: EServices.HMG@drsulaimanalhabib.com أو الاتصال على الرقم: 9553 525 011"},
"clickPrivacyPolicy": {"en": "Please click here to view the privacy policy", "ar": "الرجاء الضغط هنا لعرض سياسة الخصوصية"}, "clickPrivacyPolicy": {"en": "Please click here to view the privacy policy", "ar": "الرجاء الضغط هنا لعرض سياسة الخصوصية"},
"thisResult" : {"en": "This Result", "ar": "هذه النتيجة"}, "thisResult" : {"en": "This Result", "ar": "هذه النتيجة"},
"seeAllGraphValues" : {"en": "See all values", "ar": "شاهد جميع القيم"},
}; };

@ -369,8 +369,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();
} }

@ -14,6 +14,7 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart';
import 'package:flutter/material.dart';
import 'package:open_filex/open_filex.dart'; import 'package:open_filex/open_filex.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.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;
@ -182,22 +186,50 @@ class LabsViewModel extends BaseViewModel {
// _labsService.adjustLabOrderResults(sortedResponse); // _labsService.adjustLabOrderResults(sortedResponse);
print("the recentThree list is ${mappedToThresholdValue}"); print("the recentThree list is ${mappedToThresholdValue}");
threshold = mappedToThresholdValue; threshold = mappedToThresholdValue;
List months = ['Jan','Feb','Mar','April','May','Jun','July','Aug','Sep','Oct','Nov','Dec'];
double counter = 1; double counter = 1;
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);

@ -4745,6 +4745,7 @@ class TranslationBase {
localizedValues["clickPrivacyPolicy"][locale.languageCode]; localizedValues["clickPrivacyPolicy"][locale.languageCode];
String get thisResult => localizedValues["thisResult"][locale.languageCode]; String get thisResult => localizedValues["thisResult"][locale.languageCode];
String get seeAllGraphValues => localizedValues["seeAllGraphValues"][locale.languageCode];
String getTranslation(String label) { String getTranslation(String label) {
switch (label) { switch (label) {

@ -3,10 +3,12 @@ import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/Loader/gif_loader_container.dart'; import 'package:diplomaticquarterapp/widgets/Loader/gif_loader_container.dart';
import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart'; import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/full_screen_lab_result_graph.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -25,16 +27,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),
@ -46,10 +45,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(
@ -103,9 +99,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(
@ -117,10 +139,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