|
|
|
|
@ -12,6 +12,7 @@ class DoctorMapper{
|
|
|
|
|
|
|
|
|
|
for (var element in doctorList) {
|
|
|
|
|
String? region = element.getRegionName(isArabic);
|
|
|
|
|
String? regionEng = element.getRegionName(false);
|
|
|
|
|
if (region == null) continue;
|
|
|
|
|
|
|
|
|
|
var regionDoctorList = regionList.registeredDoctorMap?.putIfAbsent(region, () => PatientDoctorAppointmentListByRegion());
|
|
|
|
|
@ -33,6 +34,8 @@ class DoctorMapper{
|
|
|
|
|
var newAppointment = PatientDoctorAppointmentList(
|
|
|
|
|
filterName:
|
|
|
|
|
element.getProjectCompleteNameWithLocale(isArabic: isArabic),
|
|
|
|
|
filterNameEng:
|
|
|
|
|
element.getProjectCompleteNameWithLocale(isArabic: false),
|
|
|
|
|
distanceInKMs: element.projectDistanceInKiloMeters.toString(),
|
|
|
|
|
projectTopName: element.projectTopName,
|
|
|
|
|
projectBottomName: element.projectBottomName,
|
|
|
|
|
@ -82,6 +85,7 @@ class DoctorMapper{
|
|
|
|
|
regionDoctorList?.hmgSize = regionDoctorList.hmgDoctorList?.length ?? 0;
|
|
|
|
|
|
|
|
|
|
regionList.registeredDoctorMap?[region] = regionDoctorList;
|
|
|
|
|
regionList.regionNameMap?[regionEng??""] = region;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return regionList;
|
|
|
|
|
@ -110,10 +114,19 @@ class DoctorMapper{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String>? keys = unsorted.registeredDoctorMap?.keys.toList();
|
|
|
|
|
keys?.sort();
|
|
|
|
|
final keys = unsorted.registeredDoctorMap?.keys.toList() ?? [];
|
|
|
|
|
if (keys.isEmpty) return unsorted;
|
|
|
|
|
|
|
|
|
|
keys.sort((a, b) {
|
|
|
|
|
final priorityA = _getRegionSortPriority(a);
|
|
|
|
|
final priorityB = _getRegionSortPriority(b);
|
|
|
|
|
if (priorityA != priorityB) return priorityA.compareTo(priorityB);
|
|
|
|
|
|
|
|
|
|
final aValue = a.toLowerCase();
|
|
|
|
|
final bValue = b.toLowerCase();
|
|
|
|
|
return aValue.compareTo(bValue);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (keys == null) return unsorted;
|
|
|
|
|
Map<String, PatientDoctorAppointmentListByRegion> sortedMap = {};
|
|
|
|
|
for (var key in keys) {
|
|
|
|
|
sortedMap[key] = unsorted.registeredDoctorMap![key]!;
|
|
|
|
|
@ -122,6 +135,25 @@ class DoctorMapper{
|
|
|
|
|
return unsorted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int _getRegionSortPriority(String regionKey) {
|
|
|
|
|
final key = regionKey.trim().toLowerCase();
|
|
|
|
|
if (key.isEmpty) return 999;
|
|
|
|
|
|
|
|
|
|
if (key.startsWith('c') || key.contains('وسط') || key.contains('الوسط') || key.contains('المنطقة الوسطى')) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if (key.startsWith('w') || key.contains('غرب') || key.contains('الغربي') || key.contains('الغربية')) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if (key.startsWith('e') || key.contains('شرق') || key.contains('الشرقي') || key.contains('الشرقية')) {
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
if (key.startsWith("u") || key.contains('الإمارات') || key.contains('امارات')) {
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
return 999;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Future<RegionList> getMappedHospitals(
|
|
|
|
|
List<HospitalsModel> hospitalList, {
|
|
|
|
|
bool isArabic = false, double lat = 0.0,double lng = 0.0
|
|
|
|
|
@ -129,6 +161,7 @@ class DoctorMapper{
|
|
|
|
|
final regionList = RegionList();
|
|
|
|
|
for (final hospital in hospitalList) {
|
|
|
|
|
final region = hospital.getRegionName(isArabic);
|
|
|
|
|
final regionEng = hospital.getRegionName(false);
|
|
|
|
|
if (region == null) continue;
|
|
|
|
|
|
|
|
|
|
final regionData = regionList.registeredDoctorMap?.putIfAbsent(
|
|
|
|
|
@ -152,6 +185,7 @@ class DoctorMapper{
|
|
|
|
|
} else {
|
|
|
|
|
final newEntry = PatientDoctorAppointmentList(
|
|
|
|
|
filterName: hospital.name,
|
|
|
|
|
filterNameEng: hospital.getName(false),
|
|
|
|
|
distanceInKMs: hospital.distanceInKilometers?.toString(),
|
|
|
|
|
projectTopName: hospital.name,
|
|
|
|
|
projectBottomName: hospital.name,
|
|
|
|
|
@ -196,6 +230,7 @@ class DoctorMapper{
|
|
|
|
|
regionData?.hmcSize = regionData.hmcDoctorList?.length ?? 0;
|
|
|
|
|
regionData?.hmgSize = regionData.hmgDoctorList?.length ?? 0;
|
|
|
|
|
regionList.registeredDoctorMap?[region] = regionData;
|
|
|
|
|
regionList.regionNameMap?[regionEng??""] = region;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return regionList;
|
|
|
|
|
|