class GeminiDiagnosisResponse {
  String plantSpecies;
  String diseaseName;
  String confidenceLevel;
  String scientificName;
  String symptoms;
  List<String> preventionMeasures;
  String organicTreatment;
  String chemicalTreatment;

  GeminiDiagnosisResponse({
    required this.plantSpecies,
    required this.diseaseName,
    required this.confidenceLevel,
    required this.scientificName,
    required this.symptoms,
    required this.preventionMeasures,
    required this.organicTreatment,
    required this.chemicalTreatment,
  });

  factory GeminiDiagnosisResponse.fromMap(Map<String, dynamic> map) {
    return GeminiDiagnosisResponse(
      plantSpecies: map['plantSpecies'] ?? map['plant_species'] ?? 'Unknown',
      diseaseName: map['diseaseName'] ?? map['disease_name'] ?? 'Unknown',
      confidenceLevel: map['confidenceLevel'] ?? map['confidence_level'] ?? 'possible',
      scientificName: map['scientificName'] ?? map['scientific_name'] ?? 'Unknown',
      symptoms: map['symptoms'] ?? 'No symptoms description available',
      preventionMeasures: _parseStringList(map['preventionMeasures'] ?? map['prevention_measures'] ?? []),
      organicTreatment: map['organicTreatment'] ?? map['organic_treatment'] ?? 'No organic treatment available',
      chemicalTreatment: map['chemicalTreatment'] ?? map['chemical_treatment'] ?? 'No chemical treatment available',
    );
  }

  static List<String> _parseStringList(dynamic value) {
    if (value is List) {
      return value.map((e) => e.toString()).toList();
    } else if (value is String) {
      return [value];
    }
    return [];
  }

  bool get isHealthy => diseaseName.toLowerCase().contains('healthy');
} 