import 'package:hmg_patient_app/core/model/hospitals/hospitals_model.dart';

class DoctorList {
  int? clinicID;
  dynamic appointmentNo;
  String? clinicName;
  String? doctorTitle;
  num? iD;
  String? name;
  int? projectID;
  String? projectName;
  int? actualDoctorRate;
  num? clinicRoomNo;
  dynamic date;
  dynamic appointmentDate;
  dynamic dayName;
  int? doctorID;
  String? doctorImageURL;
  dynamic doctorProfile;
  dynamic doctorProfileInfo;
  int? doctorRate;
  num? gender;
  String? genderDescription;
  bool? isAppointmentAllowed;
  bool? isDoctorAllowVedioCall;
  bool? isDoctorDummy;
  bool? isLiveCare;
  bool? isLiveCareClinic;
  bool? isDoctorHasPrePostImages;
  String? latitude;
  String? longitude;
  String? nationalityFlagURL;
  String? nationalityID;
  String? nationalityName;
  dynamic nearestFreeSlot;
  int? noOfPatientsRate;
  num? originalClinicID;
  num? personRate;
  dynamic projectDistanceInKiloMeters;
  String? qR;
  dynamic qRString;
  num? rateNumber;
  dynamic serviceID;
  String? setupID;
  List<String>? speciality;
  List<String>? specialityN;
  dynamic workingHours;
  dynamic decimalDoctorRate;
  String? projectBottomName;
  String? projectTopName;
  bool? isHMC;
  String? region;
  String? regionArabic;
  String? regionEnglish;
  String? regionID;

  DoctorList(
      {this.clinicID,
      this.appointmentNo,
      this.clinicName,
      this.doctorTitle,
      this.iD,
      this.name,
      this.projectID,
      this.projectName,
      this.actualDoctorRate,
      this.clinicRoomNo,
      this.date,
      this.appointmentDate,
      this.dayName,
      this.doctorID,
      this.doctorImageURL,
      this.doctorProfile,
      this.doctorProfileInfo,
      this.doctorRate,
      this.gender,
      this.genderDescription,
      this.isAppointmentAllowed,
      this.isDoctorAllowVedioCall,
      this.isDoctorDummy,
      this.isLiveCare,
      this.isLiveCareClinic,
      this.isDoctorHasPrePostImages,
      this.latitude,
      this.longitude,
      this.nationalityFlagURL,
      this.nationalityID,
      this.nationalityName,
      this.nearestFreeSlot,
      this.noOfPatientsRate,
      this.originalClinicID,
      this.personRate,
      this.projectDistanceInKiloMeters,
      this.qR,
      this.qRString,
      this.rateNumber,
      this.serviceID,
      this.setupID,
      this.speciality,
      this.specialityN,
      this.workingHours,
      this.decimalDoctorRate,
      this.projectBottomName,
      this.projectTopName,
      this.isHMC,
      this.region,
    this.regionArabic,
    this.regionEnglish,
    this.regionID,
      });

  DoctorList.fromJson(
    Map<String, dynamic> json,
  ) {
    clinicID = json['ClinicID'];
    appointmentNo = json['AppointmentNo'];
    clinicName = json['ClinicName'];
    doctorTitle = json['DoctorTitle'];
    iD = json['ID'];
    name = json['DoctorName'] ?? json['Name'];
    projectID = json['ProjectID'];
    projectName = json['ProjectName'];
    actualDoctorRate = json['ActualDoctorRate'];
    clinicRoomNo = json['ClinicRoomNo'];
    date = json['Date'];
    appointmentDate = json['AppointmentDate'];
    dayName = json['DayName'];
    doctorID = json['DoctorID'];
    doctorImageURL = json['DoctorImageURL'];
    doctorProfile = json['DoctorProfile'];
    doctorProfileInfo = json['DoctorProfileInfo'];
    doctorRate = json['DoctorRate'];
    gender = json['Gender'];
    genderDescription = json['GenderDescription'];
    isAppointmentAllowed = json['IsAppointmentAllowed'];
    isDoctorAllowVedioCall = json['IsDoctorAllowVedioCall'];
    isDoctorDummy = json['IsDoctorDummy'];
    isLiveCare = json['IsLiveCare'];
    isLiveCareClinic = json['IsLiveCareClinic'];
    isDoctorHasPrePostImages = json['IsDoctorHasPrePostImages'];
    latitude = json['Latitude'];
    longitude = json['Longitude'];
    nationalityFlagURL = json['NationalityFlagURL'];
    nationalityID = json['NationalityID'];
    nationalityName = json['NationalityName'];
    nearestFreeSlot = json['NearestFreeSlot'];
    noOfPatientsRate = json['NoOfPatientsRate'];
    originalClinicID = json['OriginalClinicID'];
    personRate = json['PersonRate'];
    projectDistanceInKiloMeters = json['ProjectDistanceInKiloMeters'];
    qR = json['QR'];
    qRString = json['QRString'];
    rateNumber = json['RateNumber'];
    serviceID = json['ServiceID'];
    setupID = json['SetupID'];
    if (json.containsKey('Speciality') && json['Speciality'] != null) speciality = json['Speciality'].cast<String>();
    if (json.containsKey('SpecialityN') && json['SpecialityN'] != null) specialityN = json['SpecialityN'].cast<String>();
    workingHours = json['WorkingHours'];
    decimalDoctorRate = json['DecimalDoctorRate'];
    projectBottomName = json['ProjectNameBottom'];
    projectTopName = json['ProjectNameTop'];
    this.isHMC = json["IsHMC"];
    this.regionArabic = json['RegionNameN'];
    this.regionEnglish = json['RegionName'];
  }

  String? getRegionName(bool isArabic) {
    if (isArabic) {
      return regionArabic;
    }
    return regionEnglish;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['ClinicID'] = this.clinicID;
    data['AppointmentNo'] = this.appointmentNo;
    data['ClinicName'] = this.clinicName;
    data['DoctorTitle'] = this.doctorTitle;
    data['ID'] = this.iD;
    data['Name'] = this.name;
    data['ProjectID'] = this.projectID;
    data['ProjectName'] = this.projectName;
    data['ActualDoctorRate'] = this.actualDoctorRate;
    data['ClinicRoomNo'] = this.clinicRoomNo;
    data['Date'] = this.date;
    data['DayName'] = this.dayName;
    data['DoctorID'] = this.doctorID;
    data['DoctorImageURL'] = this.doctorImageURL;
    data['DoctorProfile'] = this.doctorProfile;
    data['DoctorProfileInfo'] = this.doctorProfileInfo;
    data['DoctorRate'] = this.doctorRate;
    data['Gender'] = this.gender;
    data['GenderDescription'] = this.genderDescription;
    data['IsAppointmentAllowed'] = this.isAppointmentAllowed;
    data['IsDoctorAllowVedioCall'] = this.isDoctorAllowVedioCall;
    data['IsDoctorDummy'] = this.isDoctorDummy;
    data['IsLiveCare'] = this.isLiveCare;
    data['IsLiveCareClinic'] = this.isLiveCareClinic;
    data['IsDoctorHasPrePostImages'] = this.isDoctorHasPrePostImages;
    data['Latitude'] = this.latitude;
    data['Longitude'] = this.longitude;
    data['NationalityFlagURL'] = this.nationalityFlagURL;
    data['NationalityID'] = this.nationalityID;
    data['NationalityName'] = this.nationalityName;
    data['NearestFreeSlot'] = this.nearestFreeSlot;
    data['NoOfPatientsRate'] = this.noOfPatientsRate;
    data['OriginalClinicID'] = this.originalClinicID;
    data['PersonRate'] = this.personRate;
    data['ProjectDistanceInKiloMeters'] = this.projectDistanceInKiloMeters;
    data['QR'] = this.qR;
    data['QRString'] = this.qRString;
    data['RateNumber'] = this.rateNumber;
    data['ServiceID'] = this.serviceID;
    data['SetupID'] = this.setupID;
    data['Speciality'] = this.speciality;
    data['SpecialityN'] = this.specialityN;
    data['WorkingHours'] = this.workingHours;
    data['DecimalDoctorRate'] = this.decimalDoctorRate;
    return data;
  }

  String getProjectCompleteName(){
    return "${this.projectTopName} ${this.projectBottomName}";
  }

  String getProjectCompleteNameWithLocale({bool isArabic = false}) {
    if (isArabic) {
      return "${this.projectBottomName} ${this.projectTopName}";
    }
    return "${this.projectTopName} ${this.projectBottomName}";
  }
}

class PatientDoctorAppointmentList {
  String? filterName = "";
  String? distanceInKMs = "";
  List<DoctorList>? patientDoctorAppointmentList = [];
  String? projectTopName = "";
  String? projectBottomName = "";
  bool? isHMC;
  List<HospitalsModel> hospitalList = [];

  PatientDoctorAppointmentList(
      {this.filterName,
      this.distanceInKMs,
      this.projectTopName,
      this.projectBottomName,
      DoctorList? patientDoctorAppointment,
      HospitalsModel? model,
      this.isHMC = false}) {
    if (model != null) {
      hospitalList.add(model);
    }
    if (patientDoctorAppointment != null) {
      patientDoctorAppointmentList!.add(patientDoctorAppointment!);
    }
  }
}

// class PatientDoctorAppointmentListByRegion {
//   String? filterName = "";
//   String? distanceInKMs = "";
//   List<DoctorList>? hmgDoctorList = [];
//   List<DoctorList>? hmcDoctorList = [];
//   String? projectTopName = "";
//   String? projectBottomName = "";
//
//   PatientDoctorAppointmentListByRegion({this.filterName, this.distanceInKMs, this.projectTopName, this.projectBottomName, DoctorList? hmcPatientDoctorAppointment, DoctorList? hmgPatientDoctorAppointment}) {
//     hmcDoctorList!.add(hmcPatientDoctorAppointment!);
//     hmgDoctorList!.add(hmgPatientDoctorAppointment!);
//   }
// }

class PatientDoctorAppointmentListByRegion {
  List<PatientDoctorAppointmentList>? hmgDoctorList = [];
  List<PatientDoctorAppointmentList>? hmcDoctorList = [];
  int hmcSize = 0;
  int hmgSize = 0;
  num distance = double.infinity;
  num hmgDistance = double.infinity;
  num hmcDistance = double.infinity;
}

class RegionList {
  Map<String, PatientDoctorAppointmentListByRegion?>? registeredDoctorMap = {};
}

/// dummy data
///
///

DoctorList doctor1 = DoctorList(
  clinicID: 101,
  appointmentNo: 12345,
  clinicName: "Downtown Clinic",
  doctorTitle: "Dr.",
  iD: 1,
  name: "John Doe",
  projectID: 301,
  projectName: "HealthCare Network",
  actualDoctorRate: 500,
  clinicRoomNo: 2,
  date: "2025-01-10",
  appointmentDate: "2025-01-15T10:00:00",
  dayName: "Monday",
  doctorID: 11,
  doctorImageURL: "https://example.com/images/johndoe.jpg",
  doctorProfile: null,
  doctorProfileInfo: null,
  doctorRate: 4,
  gender: 1,
  genderDescription: "Male",
  isAppointmentAllowed: true,
  isDoctorAllowVedioCall: false,
  isDoctorDummy: false,
  isLiveCare: true,
  isLiveCareClinic: false,
  isDoctorHasPrePostImages: true,
  latitude: "24.7136",
  longitude: "46.6753",
  nationalityFlagURL: "https://example.com/images/flags/sa.png",
  nationalityID: "SA",
  nationalityName: "Saudi Arabia",
  nearestFreeSlot: "2025-01-15T10:00:00",
  noOfPatientsRate: 50,
  originalClinicID: 102,
  personRate: 4.5,
  projectDistanceInKiloMeters: 5.0,
  qR: "QR123",
  qRString: "abcd1234",
  rateNumber: 120,
  serviceID: null,
  setupID: "Setup001",
  speciality: ["Cardiology", "Internal Medicine"],
  specialityN: ["Cardiology"],
  workingHours: "8 AM - 5 PM",
  decimalDoctorRate: 4.5,
  projectBottomName: "HealthCare Bottom",
  projectTopName: "HealthCare Top",
  isHMC: false,
  region: "Riyadh",
);

DoctorList doctor2 = DoctorList(
  clinicID: 102,
  appointmentNo: 67890,
  clinicName: "City Medical Center",
  doctorTitle: "Dr.",
  iD: 2,
  name: "Jane Smith",
  projectID: 302,
  projectName: "MedicalGroup Network",
  actualDoctorRate: 450,
  clinicRoomNo: 5,
  date: "2025-01-12",
  appointmentDate: "2025-01-16T09:00:00",
  dayName: "Wednesday",
  doctorID: 12,
  doctorImageURL: "https://example.com/images/janesmith.jpg",
  doctorProfile: null,
  doctorProfileInfo: null,
  doctorRate: 5,
  gender: 2,
  genderDescription: "Female",
  isAppointmentAllowed: true,
  isDoctorAllowVedioCall: true,
  isDoctorDummy: false,
  isLiveCare: false,
  isLiveCareClinic: true,
  isDoctorHasPrePostImages: false,
  latitude: "24.7742",
  longitude: "46.7387",
  nationalityFlagURL: "https://example.com/images/flags/us.png",
  nationalityID: "US",
  nationalityName: "United States",
  nearestFreeSlot: "2025-01-16T09:00:00",
  noOfPatientsRate: 70,
  originalClinicID: 103,
  personRate: 4.8,
  projectDistanceInKiloMeters: 8.0,
  qR: "QR567",
  qRString: "efgh5678",
  rateNumber: 200,
  serviceID: null,
  setupID: "Setup002",
  speciality: ["Dermatology", "Cosmetic Surgery"],
  specialityN: ["Dermatology"],
  workingHours: "9 AM - 6 PM",
  decimalDoctorRate: 4.8,
  projectBottomName: "MedicalGroup Bottom",
  projectTopName: "MedicalGroup Top",
  isHMC: true,
  region: "Riyadh",
);

// Dummy data for PatientDoctorAppointmentList
PatientDoctorAppointmentList patientList1 = PatientDoctorAppointmentList(
  filterName: "Aryan",
  distanceInKMs: "0",
  projectTopName: "HealthCare",
  projectBottomName: "Center",
  patientDoctorAppointment: doctor1,
);

PatientDoctorAppointmentList patientList2 = PatientDoctorAppointmentList(
  filterName: "Aryan",
  distanceInKMs: "0",
  projectTopName: "MedicalGroup",
  projectBottomName: "Clinic",
  patientDoctorAppointment: doctor2,
);

// Dummy data for PatientDoctorAppointmentListByRegion
PatientDoctorAppointmentListByRegion region1 =
    PatientDoctorAppointmentListByRegion()
      ..hmgDoctorList = [patientList1]
      ..hmcDoctorList = [patientList2];

// Dummy data for RegionList
RegionList regionList = RegionList()
  ..registeredDoctorMap = {
    "Region1": region1,
    "Region2": region1,
  };