
class ActivePrescriptionsResponseModel {
  String? itemId;
  String? itemDescription;
  String? route;
  String? frequency;
  int? frequencyNumber;
  int? doseDailyQuantity;
  int? days;
  String? startDate;
  String? endDate;
  String? orderDate;
  String? productImageString;
  bool isReminderOn;
  List<String?> selectedDoseTimes = [];

  ActivePrescriptionsResponseModel({
    this.itemId,
    this.itemDescription,
    this.route,
    this.frequency,
    this.frequencyNumber,
    this.doseDailyQuantity,
    this.days,
    this.startDate,
    this.endDate,
    this.orderDate,
    this.productImageString,
    this.isReminderOn = false,
    List<String?>? selectedDoseTimes,
  }) {
    this.selectedDoseTimes = selectedDoseTimes ?? [];
  }

  /// ========== JSON FROM ==========
  factory ActivePrescriptionsResponseModel.fromJson(Map<String, dynamic> json) {
    return ActivePrescriptionsResponseModel(
      itemId: json["ItemID"]?.toString() ?? "",
      itemDescription: json["ItemDescription"] ?? "",
      route: json["Route"] ?? "",
      frequency: json["Frequency"] ?? "",
      frequencyNumber: json["FrequencyNumber"],
      doseDailyQuantity: json["DoseDailyQuantity"] ?? 1,
      days: json["Days"] ?? 0,
      startDate: json["StartDate"] ?? "",
      endDate: json["EndDate"] ?? "",
      orderDate: json["OrderDate"] ?? "",
      productImageString: json["ProductImageString"] ?? "",
      isReminderOn: json["IsReminderOn"] == true,
      selectedDoseTimes:
      (json["SelectedDoseTimes"] as List<dynamic>?)
          ?.map((e) => e?.toString())
          .toList() ??
          [],
    );
  }



  /// ========== JSON TO ==========
  Map<String, dynamic> toJson() {
    return {
      "ItemID": itemId,
      "ItemDescription": itemDescription,
      "Route": route,
      "Frequency": frequency,
      "FrequencyNumber": frequencyNumber,
      "DoseDailyQuantity": doseDailyQuantity,
      "Days": days,
      "StartDate": startDate,
      "EndDate": endDate,
      "OrderDate": orderDate,
      "ProductImageString": productImageString,
      "IsReminderOn": isReminderOn,
      "SelectedDoseTimes": selectedDoseTimes,
    };
  }
}
