getAllDiseases method

Future<List<Disease>> getAllDiseases(
  1. String languageCode
)

Retrieves all diseases for a specific language.

Returns a list of diseases with their localized information and associated mosquito vectors for the specified language.

@param languageCode The language code (e.g., 'en', 'es') @return A Future that completes with a list of Disease objects

Implementation

Future<List<Disease>> getAllDiseases(String languageCode) async {
  final db = await database;
  final List<Map<String, dynamic>> maps = await db.rawQuery('''
    SELECT
      d.id, d.image_url,
      t.name, t.description, t.symptoms, t.treatment, t.prevention, t.prevalence
    FROM diseases d
    LEFT JOIN disease_translations t ON d.id = t.disease_id
    WHERE t.language_code = ?
  ''', [languageCode]);

  return Future.wait(maps.map((map) async {
    final vectorNames = await _getVectorNamesForDisease(db, map['id']);
    return Disease(
      id: map['id'],
      name: map['name'],
      description: map['description'],
      symptoms: map['symptoms'],
      treatment: map['treatment'],
      prevention: map['prevention'],
      vectors: vectorNames,
      prevalence: map['prevalence'],
      imageUrl: map['image_url'],
    );
  }).toList());
}