Merge branch 'master' into haroon_dev

pull/75/head
haroon amjad 4 weeks ago
commit 9d48a00b21

@ -485,3 +485,11 @@ class DateUtil {
return ""; return "";
} }
} }
extension OnlyDate on DateTime{
DateTime provideDateOnly(){
return DateTime(this.year, month, day);
}
}

@ -22,6 +22,8 @@ class LabViewModel extends ChangeNotifier {
bool isLabResultsLoading = false; bool isLabResultsLoading = false;
bool isLabResultByHospitalLoading = false; bool isLabResultByHospitalLoading = false;
bool isSpecialResultsLoading = false; bool isSpecialResultsLoading = false;
bool isGraphVisible = true;
bool shouldShowGraph = true;
LabRepo labRepo; LabRepo labRepo;
ErrorHandlerService errorHandlerService; ErrorHandlerService errorHandlerService;
@ -225,6 +227,7 @@ class LabViewModel extends ChangeNotifier {
} catch (e) {} } catch (e) {}
}); });
LabResult recentResult = recentThree.first; LabResult recentResult = recentThree.first;
checkIfGraphShouldBeDisplayed(recentResult);
recentResult.verifiedOn = resultDate(DateUtil.convertStringToDate(recentResult.verifiedOnDateTime!)); recentResult.verifiedOn = resultDate(DateUtil.convertStringToDate(recentResult.verifiedOnDateTime!));
// filteredGraphValues = [filteredGraphValues.first]; // filteredGraphValues = [filteredGraphValues.first];
navigationService.push(MaterialPageRoute( navigationService.push(MaterialPageRoute(
@ -237,6 +240,12 @@ class LabViewModel extends ChangeNotifier {
); );
} }
void checkIfGraphShouldBeDisplayed(LabResult recentResult){
shouldShowGraph = recentResult.checkIfGraphShouldBeDisplayed();
isGraphVisible = shouldShowGraph;
notifyListeners();
}
Future<void> getPatientSpecialResult( Future<void> getPatientSpecialResult(
PatientLabOrdersResponseModel laborder) async { PatientLabOrdersResponseModel laborder) async {
isSpecialResultsLoading = true; isSpecialResultsLoading = true;
@ -551,4 +560,9 @@ class LabViewModel extends ChangeNotifier {
return "normal"; return "normal";
} }
} }
alterGraphVisibility(){
isGraphVisible = !isGraphVisible;
notifyListeners();
}
} }

@ -24,6 +24,7 @@ class LabResult {
String? referenceHigh; String? referenceHigh;
String? criticalLow; String? criticalLow;
String? referenceLow; String? referenceLow;
num? resultTypeID;
String? packageShortDescription; String? packageShortDescription;
LabResult( LabResult(
@ -80,6 +81,7 @@ class LabResult {
criticalLow = json['CriticalLow']; criticalLow = json['CriticalLow'];
referenceLow = json['ReferenceLow']; referenceLow = json['ReferenceLow'];
packageShortDescription = json['PackageShortDescription']; packageShortDescription = json['PackageShortDescription'];
resultTypeID = json['ResultTypeID'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -111,6 +113,21 @@ class LabResult {
return data; return data;
} }
bool checkIfGraphShouldBeDisplayed(){
if (resultTypeID == null) return false;
if (resultTypeID == 6) return false;
if (referanceRange == null || referanceRange == "" || referanceRange == "\n") return false;
bool isDigit = RegExp(r"\\d+").hasMatch("$resultValue");
if(isDigit) return true;
try {
num.parse(resultValue ?? "");
} catch (e) {
return false;
}
return true;
}
@override @override
String toString() { String toString() {
return 'LabOrderResult(flag: $calculatedResultFlag, value: $resultValue, verifiedOn: $verifiedOnDateTime)'; return 'LabOrderResult(flag: $calculatedResultFlag, value: $resultValue, verifiedOn: $verifiedOnDateTime)';

@ -50,6 +50,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
void onTabChange(int index) { void onTabChange(int index) {
previouslySelectedTab = selectedTabIndex; previouslySelectedTab = selectedTabIndex;
selectedTabIndex = index; selectedTabIndex = index;
start = null;
end = null;
notifyListeners(); notifyListeners();
} }
@ -452,12 +454,12 @@ class MyAppointmentsViewModel extends ChangeNotifier {
filteredAppointmentList.add(element); filteredAppointmentList.add(element);
} }
}); });
filteredAppointmentList.addAll(sourceList);
} else { } else {
filteredAppointmentList.clear(); filteredAppointmentList.clear();
sourceList.forEach((element) { sourceList.forEach((element) {
try { try {
var dateTime = DateUtil.convertStringToDate(element.appointmentDate); var dateTime = DateUtil.convertStringToDate(element.appointmentDate).provideDateOnly();
if (start != null && end == null) { if (start != null && end == null) {
if (dateTime.isAtSameMomentAs(start)) { if (dateTime.isAtSameMomentAs(start)) {
if (isUnderFilter(element)) { if (isUnderFilter(element)) {
@ -465,7 +467,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
} }
} }
} else if (start != null && end != null) { } else if (start != null && end != null) {
if ((dateTime.isAfter(start)) && (dateTime.isBefore(end))) { if ((dateTime.isAfter(start)) && ((dateTime.isBefore(end))||((dateTime.isAtSameMomentAs(end))))) {
if (isUnderFilter(element)) { if (isUnderFilter(element)) {
filteredAppointmentList.add(element); filteredAppointmentList.add(element);
} }

@ -4,7 +4,7 @@ import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/lab/lab_view_model.dart'; import 'package:hmg_patient_app_new/features/lab/lab_view_model.dart';
import 'package:hmg_patient_app_new/features/lab/models/resp_models/lab_result.dart'; import 'package:hmg_patient_app_new/features/lab/models/resp_models/lab_result.dart';
import 'package:hmg_patient_app_new/presentation/lab/lab_result_via_hospital/lab_order_result_item.dart'; import 'package:hmg_patient_app_new/presentation/lab/lab_result_via_hospital/lab_order_result_item.dart';
import 'package:provider/provider.dart' show Selector, Provider; import 'package:provider/provider.dart' show Selector, Provider, ReadContext;
class LabResultList extends StatelessWidget { class LabResultList extends StatelessWidget {
late LabViewModel model; late LabViewModel model;
@ -15,7 +15,7 @@ class LabResultList extends StatelessWidget {
return Selector<LabViewModel, List<LabResult>>( return Selector<LabViewModel, List<LabResult>>(
selector: (_, model) => model.mainLabResultsByHospitals, selector: (_, model) => model.mainLabResultsByHospitals,
builder: (__, list, ___) { builder: (__, list, ___) {
if (list.isEmpty) { if (list.isEmpty && context.read<LabViewModel>().labSpecialResult.isEmpty) {
return Utils.getNoDataWidget(context, return Utils.getNoDataWidget(context,
noDataText: "You don't have any lab results yet." noDataText: "You don't have any lab results yet."
.needTranslation); .needTranslation);

@ -7,6 +7,7 @@ import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/lab/lab_view_model.dart' show LabViewModel;
import 'package:hmg_patient_app_new/features/lab/models/resp_models/lab_result.dart'; import 'package:hmg_patient_app_new/features/lab/models/resp_models/lab_result.dart';
import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_orders_response_model.dart'; import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_orders_response_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
@ -14,6 +15,7 @@ import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart'; import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
import 'package:hmg_patient_app_new/widgets/chip/custom_chip_widget.dart'; import 'package:hmg_patient_app_new/widgets/chip/custom_chip_widget.dart';
import 'package:provider/provider.dart';
class LabOrderResultItem extends StatelessWidget { class LabOrderResultItem extends StatelessWidget {
final VoidCallback onTap; final VoidCallback onTap;
@ -45,8 +47,49 @@ class LabOrderResultItem extends StatelessWidget {
child: '${tests!.description}'.toText14(weight: FontWeight.w500), child: '${tests!.description}'.toText14(weight: FontWeight.w500),
), ),
'${tests!.packageShortDescription}'.toText12(fontWeight: FontWeight.w500, color: AppColors.textColorLight), '${tests!.packageShortDescription}'.toText12(fontWeight: FontWeight.w500, color: AppColors.textColorLight),
// SizedBox(height: 12.h),
SizedBox(height: 24.h), Row(
mainAxisSize: MainAxisSize.max,
children: [
Flexible(
child: Text(
tests?.resultValue ?? "",
style: TextStyle(
fontSize: 24.fSize,
fontWeight: FontWeight.w600,
fontFamily: 'Poppins',
color: context.read<LabViewModel>().getColor(
tests?.calculatedResultFlag ?? "",
),
letterSpacing: -2,
),
overflow: TextOverflow.ellipsis, // prevent overflow
maxLines: 1,
softWrap: false,
),
),
SizedBox(width: 4.h,),
Expanded(
flex: 2,
child: Visibility(
visible: tests?.referanceRange != null,
child: Text(
"(Reference range ${tests?.referanceRange})".needTranslation,
style: TextStyle(
fontSize: 12.fSize,
fontWeight: FontWeight.w500,
fontFamily: 'Poppins',
color: AppColors.greyTextColor,
),
// overflow: TextOverflow.ellipsis,
// maxLines: 2,
softWrap: true,
),
),
),
],
),
SizedBox(height: 12.h),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [

@ -15,35 +15,38 @@ import 'package:hmg_patient_app_new/presentation/lab/lab_results/lab_result_list
import 'package:hmg_patient_app_new/theme/colors.dart' show AppColors; import 'package:hmg_patient_app_new/theme/colors.dart' show AppColors;
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
import 'package:hmg_patient_app_new/widgets/graph/custom_graph.dart'; import 'package:hmg_patient_app_new/widgets/graph/custom_graph.dart';
import 'package:provider/provider.dart' show Consumer, Provider; import 'package:provider/provider.dart' show Consumer, Provider, ReadContext;
import '../../../widgets/common_bottom_sheet.dart' import '../../../widgets/common_bottom_sheet.dart'
show showCommonBottomSheetWithoutHeight; show showCommonBottomSheetWithoutHeight;
class LabResultDetails extends StatelessWidget { class LabResultDetails extends StatelessWidget {
final LabResult recentLabResult; final LabResult recentLabResult;
final String? testDescription;
// final List<DataPoint> graphPoint; const LabResultDetails(
late LabViewModel model; {super.key,
String? testDescription; required this.recentLabResult,
required this.testDescription});
LabResultDetails({super.key, required this.recentLabResult, required this.testDescription});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
model = Provider.of<LabViewModel>(context, listen: false);
return CollapsingListView( return CollapsingListView(
title: 'Lab Result Details'.needTranslation, title: 'Lab Result Details'.needTranslation,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
spacing: 16.h, spacing: 16.h,
children: [LabNameAndStatus, LabGraph(context)], children: [
LabNameAndStatus(context),
getLabDescription(context),
LabGraph(context)
],
).paddingAll(24.h), ).paddingAll(24.h),
), ),
); );
} }
Widget get LabNameAndStatus => Container( Widget LabNameAndStatus(BuildContext context) => Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration( decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor, color: AppColors.whiteColor,
borderRadius: 24.h, borderRadius: 24.h,
@ -80,11 +83,12 @@ class LabResultDetails extends StatelessWidget {
//todo change the text color according to the provided test values //todo change the text color according to the provided test values
Row( Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Expanded( Expanded(
child: Row( child: Row(
spacing: 4.h,
mainAxisSize: MainAxisSize.max,
children: [ children: [
Flexible( Flexible(
child: Text( child: Text(
@ -93,7 +97,7 @@ class LabResultDetails extends StatelessWidget {
fontSize: 24.fSize, fontSize: 24.fSize,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontFamily: 'Poppins', fontFamily: 'Poppins',
color: model.getColor( color: context.read<LabViewModel>().getColor(
recentLabResult.calculatedResultFlag ?? "", recentLabResult.calculatedResultFlag ?? "",
), ),
letterSpacing: -2, letterSpacing: -2,
@ -103,7 +107,10 @@ class LabResultDetails extends StatelessWidget {
softWrap: false, softWrap: false,
), ),
), ),
Visibility( SizedBox(width: 4.h,),
Expanded(
flex: 2,
child: Visibility(
visible: recentLabResult.referanceRange != null, visible: recentLabResult.referanceRange != null,
child: Text( child: Text(
"(Reference range ${recentLabResult.referanceRange})".needTranslation, "(Reference range ${recentLabResult.referanceRange})".needTranslation,
@ -113,37 +120,44 @@ class LabResultDetails extends StatelessWidget {
fontFamily: 'Poppins', fontFamily: 'Poppins',
color: AppColors.greyTextColor, color: AppColors.greyTextColor,
), ),
overflow: TextOverflow.ellipsis, // overflow: TextOverflow.ellipsis,
maxLines: 1, // maxLines: 2,
softWrap: false, softWrap: true,
),
), ),
), ),
], ],
), ),
), ),
Utils.buildSvgWithAssets( SizedBox(
width: 21,
child: Utils.buildSvgWithAssets(
icon: AppAssets.lab_result_indicator, icon: AppAssets.lab_result_indicator,
width: 21, width: 21,
height: 23, height: 23,
iconColor: model.getColor( iconColor: context.read<LabViewModel>().getColor(
recentLabResult.calculatedResultFlag ?? "", recentLabResult.calculatedResultFlag ?? "",
), ),
), ),
),
], ],
) )
], ],
)); ));
Widget LabGraph(BuildContext context) => Consumer<DateRangeSelectorRangeViewModel>( Widget LabGraph(BuildContext context) => Consumer<LabViewModel>(
builder: (_, model, ___) => Consumer<LabViewModel>(
builder: (_, labmodel, ___) => Container( builder: (_, labmodel, ___) => Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration( decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor, color: AppColors.whiteColor,
borderRadius: 24.h, borderRadius: 24.h,
hasShadow: true, hasShadow: true,
), ),
height: model.isGraphVisible?260.h:(labmodel.filteredGraphValues.length<3)?(labmodel.filteredGraphValues.length*64)+80.h:260.h, height: labmodel.isGraphVisible
? 260.h
: (labmodel.filteredGraphValues.length < 3)
? (labmodel.filteredGraphValues.length * 64) + 80.h
: 260.h,
padding: EdgeInsets.all(16.h), padding: EdgeInsets.all(16.h),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -153,11 +167,12 @@ class LabResultDetails extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
model.isGraphVisible?LocaleKeys.historyFlowchart.tr(): LocaleKeys.history.tr(), labmodel.isGraphVisible
? LocaleKeys.historyFlowchart.tr()
: LocaleKeys.history.tr(),
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontFamily: 'Poppins', fontFamily: 'Poppins',
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: AppColors.textColor, color: AppColors.textColor,
), ),
@ -167,11 +182,15 @@ class LabResultDetails extends StatelessWidget {
children: [ children: [
//todo handle when the graph icon is being displayed //todo handle when the graph icon is being displayed
Utils.buildSvgWithAssets( Utils.buildSvgWithAssets(
icon: model.isGraphVisible?AppAssets.ic_list:AppAssets.ic_graph, icon: labmodel.isGraphVisible
? AppAssets.ic_list
: AppAssets.ic_graph,
width: 24.h, width: 24.h,
height: 24.h) height: 24.h)
.onPress(() { .onPress(() {
model.alterGraphVisibility(); if (labmodel.shouldShowGraph) {
labmodel.alterGraphVisibility();
}
}), }),
Utils.buildSvgWithAssets( Utils.buildSvgWithAssets(
icon: AppAssets.ic_date_filter, icon: AppAssets.ic_date_filter,
@ -183,7 +202,6 @@ class LabResultDetails extends StatelessWidget {
context, context,
child: DateRangeSelector( child: DateRangeSelector(
onRangeSelected: (start, end) { onRangeSelected: (start, end) {
// if (start != null) { // if (start != null) {
labmodel.getSelectedDateRange(start, end); labmodel.getSelectedDateRange(start, end);
// } // }
@ -197,11 +215,11 @@ class LabResultDetails extends StatelessWidget {
], ],
) )
], ],
).paddingOnly(bottom: model.isGraphVisible? 16.h :24.h), ).paddingOnly(bottom: labmodel.isGraphVisible ? 16.h : 24.h),
historyBody(model, labmodel) historyBody(labmodel)
], ],
)), )),
)); );
Widget leftLabels(String value) { Widget leftLabels(String value) {
return Text( return Text(
@ -229,17 +247,15 @@ class LabResultDetails extends StatelessWidget {
); );
} }
Widget historyBody(DateRangeSelectorRangeViewModel model, LabViewModel labmodel) { Widget historyBody(LabViewModel labmodel) {
if(model.isGraphVisible){ if (labmodel.isGraphVisible && labmodel.shouldShowGraph) {
var graphColor = labmodel.getColor(recentLabResult.calculatedResultFlag??"N"); var graphColor = labmodel.getColor(recentLabResult.calculatedResultFlag??"N");
return CustomGraph( return CustomGraph(
dataPoints: labmodel.filteredGraphValues, dataPoints: labmodel.filteredGraphValues,
// maxY: 100,
makeGraphBasedOnActualValue: true, makeGraphBasedOnActualValue: true,
leftLabelReservedSize: 40, leftLabelReservedSize: 40,
leftLabelInterval: getInterval(labmodel), leftLabelInterval: getInterval(labmodel),
maxY: (labmodel.maxY)+(getInterval(labmodel)??0)/5, maxY: (labmodel.maxY)+(getInterval(labmodel)??0)/2,
maxX: labmodel.filteredGraphValues.length.toDouble()-.75, maxX: labmodel.filteredGraphValues.length.toDouble()-.75,
leftLabelFormatter: (value) { leftLabelFormatter: (value) {
return leftLabels(value.toStringAsFixed(2).tr()); return leftLabels(value.toStringAsFixed(2).tr());
@ -279,11 +295,11 @@ class LabResultDetails extends StatelessWidget {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
height: 180.h); height: 180.h);
}else { }else {
return labHistoryList(model, labmodel); return labHistoryList(labmodel);
} }
} }
Widget labHistoryList(DateRangeSelectorRangeViewModel model, LabViewModel labmodel) { Widget labHistoryList(LabViewModel labmodel) {
return SizedBox( return SizedBox(
height: labmodel.filteredGraphValues.length<3?labmodel.filteredGraphValues.length*64:180.h, height: labmodel.filteredGraphValues.length<3?labmodel.filteredGraphValues.length*64:180.h,
child: ListView.separated( child: ListView.separated(
@ -315,4 +331,27 @@ class LabResultDetails extends StatelessWidget {
if(maxX >100 && maxX < 200) return 30; if(maxX >100 && maxX < 200) return 30;
return 50; return 50;
} }
Widget getLabDescription(BuildContext context) {
return Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 24.h,
hasShadow: true,
),
height: 98.h,
padding: EdgeInsets.all(16.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8.h,
children: [
"What is this result?"
.needTranslation
.toText16(weight: FontWeight.w600, color: AppColors.textColor),
testDescription?.toText12(
fontWeight: FontWeight.w500, color: AppColors.textColorLight) ??
SizedBox.shrink()
],
));
}
} }

@ -1,5 +1,6 @@
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/features/lab/models/Range.dart'; import 'package:hmg_patient_app_new/features/lab/models/Range.dart';
class DateRangeSelectorRangeViewModel extends ChangeNotifier { class DateRangeSelectorRangeViewModel extends ChangeNotifier {
@ -17,7 +18,7 @@ class DateRangeSelectorRangeViewModel extends ChangeNotifier {
'Nov', 'Nov',
'Dec' 'Dec'
]; ];
bool isGraphVisible = true;
Range? _currentlySelectedRange; Range? _currentlySelectedRange;
Range? get currentlySelectedRange => _currentlySelectedRange; Range? get currentlySelectedRange => _currentlySelectedRange;
@ -50,7 +51,7 @@ class DateRangeSelectorRangeViewModel extends ChangeNotifier {
get getCurrentYear => DateTime.now().year; get getCurrentYear => DateTime.now().year;
calculateDatesFromRange() { calculateDatesFromRange() {
_toDate = DateTime.now(); _toDate = DateTime.now().provideDateOnly();
switch (_currentlySelectedRange) { switch (_currentlySelectedRange) {
case Range.WEEKLY: case Range.WEEKLY:
_fromDate = _toDate!.subtract(Duration(days: 7)); _fromDate = _toDate!.subtract(Duration(days: 7));
@ -77,7 +78,6 @@ class DateRangeSelectorRangeViewModel extends ChangeNotifier {
toDate = null; toDate = null;
fromDate = null; fromDate = null;
currentlySelectedRange = null; currentlySelectedRange = null;
isGraphVisible = true;
notifyListeners(); notifyListeners();
} }
@ -86,8 +86,4 @@ class DateRangeSelectorRangeViewModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
alterGraphVisibility(){
isGraphVisible = !isGraphVisible;
notifyListeners();
}
} }

Loading…
Cancel
Save