search lab order updated.

pull/14/head
Sultan khan 2 months ago
parent 3cafc16d50
commit ac17202b7a

@ -11,7 +11,8 @@ class LabViewModel extends ChangeNotifier {
ErrorHandlerService errorHandlerService; ErrorHandlerService errorHandlerService;
List<PatientLabOrdersResponseModel> patientLabOrders = []; List<PatientLabOrdersResponseModel> patientLabOrders = [];
List<PatientLabOrdersResponseModel> filteredLabOrders = [];
List<PatientLabOrdersResponseModel> tempLabOrdersList = [];
late List<String> _labSuggestionsList = []; late List<String> _labSuggestionsList = [];
List<String> get labSuggestions => _labSuggestionsList; List<String> get labSuggestions => _labSuggestionsList;
@ -20,6 +21,7 @@ class LabViewModel extends ChangeNotifier {
initLabProvider() { initLabProvider() {
patientLabOrders.clear(); patientLabOrders.clear();
filteredLabOrders.clear();
isLabOrdersLoading = true; isLabOrdersLoading = true;
isLabResultsLoading = true; isLabResultsLoading = true;
getPatientLabOrders(); getPatientLabOrders();
@ -36,6 +38,8 @@ class LabViewModel extends ChangeNotifier {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) { } else if (apiResponse.messageStatus == 1) {
patientLabOrders = apiResponse.data!; patientLabOrders = apiResponse.data!;
filteredLabOrders = List.from(patientLabOrders);
tempLabOrdersList = apiResponse.data!;
isLabOrdersLoading = false; isLabOrdersLoading = false;
isLabResultsLoading = false; isLabResultsLoading = false;
filterSuggestions(); filterSuggestions();
@ -50,12 +54,25 @@ class LabViewModel extends ChangeNotifier {
filterSuggestions() { filterSuggestions() {
final List<String> labels = patientLabOrders final List<String> labels = patientLabOrders
.expand((order) => order.testDetails!) // flatten testDetails .expand((order) => order.testDetails!)
.map((detail) => detail.description) // pick description .map((detail) => detail.description)
.whereType<String>() // remove nulls if any .whereType<String>()
.toList(); .toList();
_labSuggestionsList = labels.toSet().toList(); // remove duplicates by converting to a set and back to a list _labSuggestionsList = labels.toSet().toList();
notifyListeners(); notifyListeners();
} }
filterLabReports(String query) {
if (query.isEmpty) {
filteredLabOrders = List.from(patientLabOrders); // reset
} else {
filteredLabOrders = patientLabOrders.where((order) {
final descriptions = order.testDetails?.map((d) => d.description?.toLowerCase()).toList() ?? [];
return descriptions.any((desc) => desc != null && desc.contains(query.toLowerCase()));
}).toList();
patientLabOrders = filteredLabOrders;
}
notifyListeners();
}
} }

@ -63,7 +63,7 @@ class _InsuranceHomePageState extends State<InsuranceHomePage> {
onPressed: () { onPressed: () {
insuranceVM.setIsInsuranceHistoryLoading(true); insuranceVM.setIsInsuranceHistoryLoading(true);
showCommonBottomSheet(context, showCommonBottomSheet(context,
child: InsuranceHistory(), callBackFunc: () {}, title: "", height: ResponsiveExtension.screenHeight * 0.5, isCloseButtonVisible: false, isFullScreen: false); child: InsuranceHistory(), title: "", height: ResponsiveExtension.screenHeight * 0.5, isCloseButtonVisible: false, isFullScreen: false);
}, },
backgroundColor: AppColors.primaryRedColor.withOpacity(0.1), backgroundColor: AppColors.primaryRedColor.withOpacity(0.1),
borderColor: AppColors.primaryRedColor.withOpacity(0.0), borderColor: AppColors.primaryRedColor.withOpacity(0.0),

@ -4,6 +4,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart'; import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
@ -15,6 +16,7 @@ import 'package:hmg_patient_app_new/features/lab/lab_view_model.dart';
import 'package:hmg_patient_app_new/presentation/lab/search_lab_report.dart'; import 'package:hmg_patient_app_new/presentation/lab/search_lab_report.dart';
import 'package:hmg_patient_app_new/theme/colors.dart'; 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/custom_chip_widget.dart';
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
import 'package:hmg_patient_app_new/widgets/shimmer/movies_shimmer_widget.dart'; import 'package:hmg_patient_app_new/widgets/shimmer/movies_shimmer_widget.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -30,7 +32,7 @@ class _LabOrdersPageState extends State<LabOrdersPage> {
late LabViewModel labProvider; late LabViewModel labProvider;
List<List<TestDetails>?> labSuggestions = []; List<List<TestDetails>?> labSuggestions = [];
int? expandedIndex; int? expandedIndex;
String? selectedFilterText='';
@override @override
void initState() { void initState() {
scheduleMicrotask(() { scheduleMicrotask(() {
@ -66,7 +68,10 @@ class _LabOrdersPageState extends State<LabOrdersPage> {
}else { }else {
showCommonBottomSheet(context, child: SearchLabResultsContent(labSuggestionsList: model.labSuggestions), showCommonBottomSheet(context, child: SearchLabResultsContent(labSuggestionsList: model.labSuggestions),
callBackFunc: () {}, callBackFunc: (value) {
selectedFilterText = value;
model.filterLabReports(value!);
},
title: LocaleKeys.searchLabReport.tr(), title: LocaleKeys.searchLabReport.tr(),
height: ResponsiveExtension.screenHeight, height: ResponsiveExtension.screenHeight,
isCloseButtonVisible: true); isCloseButtonVisible: true);
@ -77,6 +82,8 @@ class _LabOrdersPageState extends State<LabOrdersPage> {
// Build Tab Bar // Build Tab Bar
SizedBox(height: 16.h), SizedBox(height: 16.h),
// Expandable list // Expandable list
selectedFilterText!.isNotEmpty ? CustomChipWidget(chipText: selectedFilterText!, chipType: ChipTypeEnum.alert, isSelected: true, ) : SizedBox(),
ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
@ -275,13 +282,6 @@ class _LabOrdersPageState extends State<LabOrdersPage> {
return ""; return "";
} }
} }
getLabSuggestions(LabViewModel model) {
if(model.patientLabOrders.isEmpty){
return [];
}
return model.patientLabOrders.map((m) => m.testDetails).toList();
}
} }

@ -7,7 +7,7 @@ import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/theme/colors.dart';
void showCommonBottomSheet(BuildContext context, void showCommonBottomSheet(BuildContext context,
{required Widget child, required VoidCallback callBackFunc, String? title, required double height, bool isCloseButtonVisible = true, bool isFullScreen = true}) { {required Widget child, Function(String?)? callBackFunc, String? title, required double height, bool isCloseButtonVisible = true, bool isFullScreen = true}) {
showModalBottomSheet<String>( showModalBottomSheet<String>(
sheetAnimationStyle: AnimationStyle( sheetAnimationStyle: AnimationStyle(
duration: Duration(milliseconds: 500), // Custom animation duration duration: Duration(milliseconds: 500), // Custom animation duration
@ -29,7 +29,9 @@ void showCommonBottomSheet(BuildContext context,
), ),
); );
}).then((value) { }).then((value) {
callBackFunc(); if(value != null) {
callBackFunc!(value);
}
}); });
} }
@ -63,12 +65,14 @@ class ButtonSheetContent extends StatelessWidget {
// Close button // Close button
isCloseButtonVisible && isFullScreen isCloseButtonVisible && isFullScreen
? Padding( ? Column(children: [
padding: EdgeInsets.symmetric(horizontal: 16), SizedBox(height: 40.h,),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16,),
child: Utils.buildSvgWithAssets(icon: AppAssets.closeBottomNav, width: 32, height: 32).onPress(() { child: Utils.buildSvgWithAssets(icon: AppAssets.closeBottomNav, width: 32, height: 32).onPress(() {
Navigator.of(context).pop(); Navigator.of(context).pop();
}), }),
) )])
: SizedBox(), : SizedBox(),
isFullScreen isFullScreen

Loading…
Cancel
Save