class ExplanationsResponseModel {
  final ExplanationsDataDetails? dataDetails;

  ExplanationsResponseModel({this.dataDetails});

  factory ExplanationsResponseModel.fromJson(Map<String, dynamic> json) {
    return ExplanationsResponseModel(
      dataDetails: json['dataDetails'] != null
          ? ExplanationsDataDetails.fromJson(json['dataDetails'])
          : null,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'dataDetails': dataDetails?.toJson(),
    };
  }
}

class ExplanationsDataDetails {
  final List<ExplanationEvidence>? supportingEvidence;
  final List<ExplanationEvidence>? conflictingEvidence;
  final List<ExplanationEvidence>? unconfirmedEvidence;
  final String? message;
  final List<String>? errorList;
  final int? id;
  final String? language;
  final String? generalId;
  final String? createDate;
  final String? lastEditDate;
  final String? createdBy;
  final String? lastEditBy;
  final bool? active;
  final int? sortOrder;
  final int? userType;
  final String? userId;

  ExplanationsDataDetails({
    this.supportingEvidence,
    this.conflictingEvidence,
    this.unconfirmedEvidence,
    this.message,
    this.errorList,
    this.id,
    this.language,
    this.generalId,
    this.createDate,
    this.lastEditDate,
    this.createdBy,
    this.lastEditBy,
    this.active,
    this.sortOrder,
    this.userType,
    this.userId,
  });

  factory ExplanationsDataDetails.fromJson(Map<String, dynamic> json) {
    return ExplanationsDataDetails(
      supportingEvidence: json['supporting_evidence'] != null
          ? (json['supporting_evidence'] as List)
              .map((item) => ExplanationEvidence.fromJson(item))
              .toList()
          : null,
      conflictingEvidence: json['conflicting_evidence'] != null
          ? (json['conflicting_evidence'] as List)
              .map((item) => ExplanationEvidence.fromJson(item))
              .toList()
          : null,
      unconfirmedEvidence: json['unconfirmed_evidence'] != null
          ? (json['unconfirmed_evidence'] as List)
              .map((item) => ExplanationEvidence.fromJson(item))
              .toList()
          : null,
      message: json['Message'],
      errorList: json['ErrorList'] != null
          ? List<String>.from(json['ErrorList'])
          : null,
      id: json['Id'],
      language: json['language'],
      generalId: json['generalId'],
      createDate: json['CreateDate'],
      lastEditDate: json['LastEditDate'],
      createdBy: json['CreatedBy'],
      lastEditBy: json['LastEditBy'],
      active: json['Active'],
      sortOrder: json['SortOrder'],
      userType: json['userType'],
      userId: json['userId'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'supporting_evidence': supportingEvidence?.map((item) => item.toJson()).toList(),
      'conflicting_evidence': conflictingEvidence?.map((item) => item.toJson()).toList(),
      'unconfirmed_evidence': unconfirmedEvidence?.map((item) => item.toJson()).toList(),
      'Message': message,
      'ErrorList': errorList,
      'Id': id,
      'language': language,
      'generalId': generalId,
      'CreateDate': createDate,
      'LastEditDate': lastEditDate,
      'CreatedBy': createdBy,
      'LastEditBy': lastEditBy,
      'Active': active,
      'SortOrder': sortOrder,
      'userType': userType,
      'userId': userId,
    };
  }
}

class ExplanationEvidence {
  final String? id;
  final String? name;
  final String? commonName;

  ExplanationEvidence({
    this.id,
    this.name,
    this.commonName,
  });

  factory ExplanationEvidence.fromJson(Map<String, dynamic> json) {
    return ExplanationEvidence(
      id: json['id'],
      name: json['name'],
      commonName: json['common_name'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'common_name': commonName,
    };
  }

  // Helper method to get display name
  String getDisplayName() {
    return commonName ?? name ?? '';
  }
}

