DiscoverModule/lib/contacts_module/provider_class/hcp _provider.dart

159 lines
4.7 KiB
Dart
Raw Permalink Normal View History

2024-10-07 12:41:28 +00:00
// import 'package:discover_module/hive_fun.dart';
// import 'package:discover_module/service.dart/service.dart';
import 'package:discover_module/contacts_module/hive_fun.dart';
import 'package:discover_module/contacts_module/service.dart/service.dart';
2024-06-27 08:38:43 +00:00
import 'package:flutter/foundation.dart';
class hcpProvider extends ChangeNotifier {
final apicall = Callapi();
List _list = [];
2024-11-22 10:38:43 +00:00
List mulList = [];
2024-06-27 08:38:43 +00:00
List get list => _list;
getHCPProvider() async {
final jsondata = await apicall.getallhcpdata();
2024-10-07 12:41:28 +00:00
print("kkoollll_dataaaa: ${jsondata}");
2024-06-27 08:38:43 +00:00
_list = jsondata;
notifyListeners();
}
2024-07-19 08:45:14 +00:00
2024-08-30 12:24:54 +00:00
// getHCPHive() async {
// final jsondata = await apicall.getallhcpdata();
// _list = jsondata;
// notifyListeners();
// }
2024-11-22 10:38:43 +00:00
// List searchHCP(String query) {
// if (query.isEmpty) {
// return List.from(_list); // Return full list if query is empty
// } else {
// // return _list
// // .where(
// // (hcp) => hcp['name'].toLowerCase().contains(query.toLowerCase()))
// // .toList();
// print("JsonIssList: $_list");
// print("queryIssList: $query");
// return _list
// .where((hcp) =>
// hcp['name'].toLowerCase().contains(query.toLowerCase()) ||
// // (hcp['speciality'].toLowerCase().contains(query.toLowerCase()) ??
// // hcp['spl'].toLowerCase().contains(query.toLowerCase())) ||
// hcp['speciality'].toLowerCase().contains(query.toLowerCase()) ||
// hcp['addr'].toLowerCase().contains(query.toLowerCase()))
// .toList();
// // return _list.where((hcp) {
// // // Perform multiple checks using logical AND (&&)
// // return hcp['name'].toLowerCase().contains(query.toLowerCase()) &&
// // hcp['speciality'].toLowerCase().contains(query.toLowerCase()) &&
// // hcp['addr'].toLowerCase().contains(query.toLowerCase());
// // // Add more conditions as needed
// // }).toList();
// }
// }
2024-08-19 08:44:44 +00:00
List searchHCP(String query) {
2024-07-19 08:45:14 +00:00
if (query.isEmpty) {
return List.from(_list); // Return full list if query is empty
} else {
// return _list
// .where(
// (hcp) => hcp['name'].toLowerCase().contains(query.toLowerCase()))
// .toList();
2024-08-30 12:24:54 +00:00
print("JsonIssList: $_list");
print("queryIssList: $query");
2024-11-22 10:38:43 +00:00
List<String> selectedValuesList =
query.split(',').map((e) => e.trim()).toList();
return
// _list
// .where((hcp) =>
// hcp['name'].toLowerCase().contains(query.toLowerCase()) ||
// // (hcp['speciality'].toLowerCase().contains(query.toLowerCase()) ??
// // hcp['spl'].toLowerCase().contains(query.toLowerCase())) ||
// hcp['speciality'].toLowerCase().contains(query.toLowerCase()) ||
// hcp['addr'].toLowerCase().contains(query.toLowerCase()))
// .toList();
_list.where((hcp) {
// Check if the item matches any of the selected values
return selectedValuesList.any((selected) =>
hcp['name'].toLowerCase().contains(selected.toLowerCase())) ||
hcp['name'].toLowerCase().contains(query.toLowerCase());
}).toList();
2024-07-19 08:45:14 +00:00
}
}
2024-08-30 12:24:54 +00:00
getHCPProviderHive() async {
final jsondata = await HiveFunctions.gethcpdata();
print("JsonDtaa: ${jsondata}");
_list = jsondata;
print("JsonDtaaList: $_list");
notifyListeners();
//print("Get_hcp_dataaaL ${HiveFunctions.gethcpdata()}");
}
2024-10-07 12:41:28 +00:00
gethcpNamefilter(String? option) {
if (option == "HCP Name") {
return _list.map((e) => e["name"].toString()).toList();
} else {
return _list.map((e) => e["speciality"].toString()).toList();
}
}
getHCPProviderFilters(String? _selectedValue1, List<String> value) {
print("I_am Provider_filterr");
if (_selectedValue1 == "Profile Type") {
print("PPPP11");
return value = [
"All Profile",
'Full Profile',
'Basic Profile',
];
}
// else if (_selectedValue1 == "HCP Name") {
// print("FilterHcpNameee");
// fecthhcpbyname();
// } else if (_selectedValue1 == "Speciality") {
// print("kkk");
// fecthhcpbyspl();
// }
else if (_selectedValue1 == "Country") {
print("kkk");
return value = [
"United States",
"United States",
"United States",
];
} else if (_selectedValue1 == "State") {
print("kkk");
return value = [
"Karnataka",
'Karnataka',
'Karnataka',
];
} else if (_selectedValue1 == "City") {
print("kkk");
return value = [
"Hubli",
'Hubli',
'Hubli',
];
}
}
2024-06-27 08:38:43 +00:00
}