import 'package:hmg_patient_app_new/features/symptoms_checker/models/triage_question_model.dart';

class TriageQuestionsData {
  static List<TriageQuestionModel> getSampleTriageQuestions() {
    return [
      // Question 1: Pain Location
      TriageQuestionModel(
        id: 'q1',
        question: 'Where do you feel the chest pain, and where does the pain spread or move to?',
        options: [
          TriageOptionModel(
            id: 'q1_opt1',
            text: 'It is all over',
            severityScore: 3,
          ),
          TriageOptionModel(
            id: 'q1_opt2',
            text: 'It is behind the breast bone',
            severityScore: 5,
          ),
          TriageOptionModel(
            id: 'q1_opt3',
            text: 'Moves or spread to the upper limb; for example the shoulder, arm, or fingers',
            severityScore: 7,
          ),
          TriageOptionModel(
            id: 'q1_opt4',
            text: 'Moves or spread to the upper back; between the shoulder blades',
            severityScore: 6,
          ),
          TriageOptionModel(
            id: 'q1_opt5',
            text: 'Moves or spread to the neck or jaw',
            severityScore: 8,
          ),
        ],
      ),

      // Question 2: Pain Intensity
      TriageQuestionModel(
        id: 'q2',
        question: 'How would you describe the intensity of your chest pain?',
        options: [
          TriageOptionModel(
            id: 'q2_opt1',
            text: 'Mild - Barely noticeable, does not interfere with daily activities',
            severityScore: 2,
          ),
          TriageOptionModel(
            id: 'q2_opt2',
            text: 'Moderate - Noticeable but manageable, some interference with activities',
            severityScore: 4,
          ),
          TriageOptionModel(
            id: 'q2_opt3',
            text: 'Severe - Significantly interferes with activities, difficult to ignore',
            severityScore: 7,
          ),
          TriageOptionModel(
            id: 'q2_opt4',
            text: 'Very severe - Unbearable, cannot perform any activities',
            severityScore: 9,
          ),
        ],
      ),

      // Question 3: Pain Duration
      TriageQuestionModel(
        id: 'q3',
        question: 'How long have you been experiencing this chest pain?',
        options: [
          TriageOptionModel(
            id: 'q3_opt1',
            text: 'Less than 5 minutes',
            severityScore: 3,
          ),
          TriageOptionModel(
            id: 'q3_opt2',
            text: 'Between 5 to 15 minutes',
            severityScore: 5,
          ),
          TriageOptionModel(
            id: 'q3_opt3',
            text: 'Between 15 to 30 minutes',
            severityScore: 7,
          ),
          TriageOptionModel(
            id: 'q3_opt4',
            text: 'More than 30 minutes',
            severityScore: 8,
          ),
          TriageOptionModel(
            id: 'q3_opt5',
            text: 'Comes and goes (intermittent)',
            severityScore: 4,
          ),
        ],
      ),

      // Question 4: Associated Symptoms
      TriageQuestionModel(
        id: 'q4',
        question: 'Are you experiencing any of these symptoms along with chest pain?',
        options: [
          TriageOptionModel(
            id: 'q4_opt1',
            text: 'Shortness of breath or difficulty breathing',
            severityScore: 8,
          ),
          TriageOptionModel(
            id: 'q4_opt2',
            text: 'Sweating, nausea, or vomiting',
            severityScore: 7,
          ),
          TriageOptionModel(
            id: 'q4_opt3',
            text: 'Dizziness or lightheadedness',
            severityScore: 7,
          ),
          TriageOptionModel(
            id: 'q4_opt4',
            text: 'Rapid or irregular heartbeat',
            severityScore: 6,
          ),
          TriageOptionModel(
            id: 'q4_opt5',
            text: 'None of the above',
            severityScore: 2,
          ),
        ],
      ),

      // Question 5: Triggering Factors
      TriageQuestionModel(
        id: 'q5',
        question: 'What triggers or worsens your chest pain?',
        options: [
          TriageOptionModel(
            id: 'q5_opt1',
            text: 'Physical activity or exertion',
            severityScore: 6,
          ),
          TriageOptionModel(
            id: 'q5_opt2',
            text: 'Emotional stress or anxiety',
            severityScore: 4,
          ),
          TriageOptionModel(
            id: 'q5_opt3',
            text: 'Deep breathing or coughing',
            severityScore: 3,
          ),
          TriageOptionModel(
            id: 'q5_opt4',
            text: 'Eating or lying down',
            severityScore: 3,
          ),
          TriageOptionModel(
            id: 'q5_opt5',
            text: 'Nothing specific, pain is constant',
            severityScore: 7,
          ),
        ],
      ),
    ];
  }

  /// Calculate total severity score from answered questions
  static int calculateTotalScore(List<TriageQuestionModel> questions) {
    int totalScore = 0;
    int answeredCount = 0;

    for (var question in questions) {
      if (question.isConfirmed && question.confirmedOption != null) {
        totalScore += question.confirmedOption!.severityScore ?? 0;
        answeredCount++;
      }
    }

    // Return average score or 0 if no questions answered
    return answeredCount > 0 ? (totalScore / answeredCount * 10).round() : 0;
  }

  /// Get risk level based on score
  static String getRiskLevel(int score) {
    if (score >= 70) {
      return 'High Risk - Seek immediate medical attention';
    } else if (score >= 50) {
      return 'Moderate Risk - Consult a doctor soon';
    } else if (score >= 30) {
      return 'Low to Moderate Risk - Monitor symptoms';
    } else {
      return 'Low Risk - Self-care may be sufficient';
    }
  }

  /// Get suggested condition based on score
  static String getSuggestedCondition(int score) {
    if (score >= 70) {
      return 'Acute Coronary Syndrome';
    } else if (score >= 50) {
      return 'Angina or Cardiac concern';
    } else if (score >= 30) {
      return 'Non-cardiac chest pain';
    } else {
      return 'Musculoskeletal chest pain';
    }
  }
}
