|
|
|
@ -7,10 +7,9 @@ import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/
|
|
|
|
|
|
|
|
|
|
|
|
class DoctorMapper{
|
|
|
|
class DoctorMapper{
|
|
|
|
static Future<RegionList> getMappedDoctor(List<DoctorList> doctorList,
|
|
|
|
static Future<RegionList> getMappedDoctor(List<DoctorList> doctorList,
|
|
|
|
{bool isArabic = false}) async {
|
|
|
|
{bool isArabic = false,double lat = 0.0,double long = 0.0}) async {
|
|
|
|
RegionList regionList = RegionList();
|
|
|
|
RegionList regionList = RegionList();
|
|
|
|
final lat = await Utils.getNumFromPrefs(CacheConst.userLat);
|
|
|
|
|
|
|
|
final long = await Utils.getNumFromPrefs(CacheConst.userLat);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var element in doctorList) {
|
|
|
|
for (var element in doctorList) {
|
|
|
|
String? region = element.getRegionName(isArabic);
|
|
|
|
String? region = element.getRegionName(isArabic);
|
|
|
|
@ -126,11 +125,9 @@ class DoctorMapper{
|
|
|
|
|
|
|
|
|
|
|
|
static Future<RegionList> getMappedHospitals(
|
|
|
|
static Future<RegionList> getMappedHospitals(
|
|
|
|
List<HospitalsModel> hospitalList, {
|
|
|
|
List<HospitalsModel> hospitalList, {
|
|
|
|
bool isArabic = false,
|
|
|
|
bool isArabic = false, double lat = 0.0,double lng = 0.0
|
|
|
|
}) async {
|
|
|
|
}) async {
|
|
|
|
final regionList = RegionList();
|
|
|
|
final regionList = RegionList();
|
|
|
|
final lat = await Utils.getNumFromPrefs(CacheConst.userLat);
|
|
|
|
|
|
|
|
final long = await Utils.getNumFromPrefs(CacheConst.userLat);
|
|
|
|
|
|
|
|
for (final hospital in hospitalList) {
|
|
|
|
for (final hospital in hospitalList) {
|
|
|
|
final region = hospital.getRegionName(isArabic);
|
|
|
|
final region = hospital.getRegionName(isArabic);
|
|
|
|
if (region == null) continue;
|
|
|
|
if (region == null) continue;
|
|
|
|
@ -173,13 +170,13 @@ class DoctorMapper{
|
|
|
|
} else if (distance < regionData.hmgDistance) {
|
|
|
|
} else if (distance < regionData.hmgDistance) {
|
|
|
|
regionData.hmgDistance = distance;
|
|
|
|
regionData.hmgDistance = distance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ( lat != 0&&
|
|
|
|
} else if ( lat != 0.0&&
|
|
|
|
long != 0 &&
|
|
|
|
lng != 0.0 &&
|
|
|
|
hospital.latitude != null &&
|
|
|
|
hospital.latitude != null &&
|
|
|
|
hospital.longitude != null) {
|
|
|
|
hospital.longitude != null) {
|
|
|
|
double calculatedDistance = calculateDistance(
|
|
|
|
double calculatedDistance = calculateDistance(
|
|
|
|
lat.toDouble(),
|
|
|
|
lat,
|
|
|
|
long.toDouble(),
|
|
|
|
lng,
|
|
|
|
double.parse(hospital.latitude!),
|
|
|
|
double.parse(hospital.latitude!),
|
|
|
|
double.parse(hospital.longitude!),
|
|
|
|
double.parse(hospital.longitude!),
|
|
|
|
).abs();
|
|
|
|
).abs();
|
|
|
|
|