class TriageQuestionModel {
  final String id;
  final String question;
  final List<TriageOptionModel> options;
  int? selectedOptionIndex;
  int? confirmedOptionIndex; // Confirmed answer when user presses Next

  TriageQuestionModel({
    required this.id,
    required this.question,
    required this.options,
    this.selectedOptionIndex,
    this.confirmedOptionIndex,
  });

  bool get isAnswered => selectedOptionIndex != null;

  bool get isConfirmed => confirmedOptionIndex != null;

  void selectOption(int index) {
    selectedOptionIndex = index;
  }

  void confirmSelection() {
    confirmedOptionIndex = selectedOptionIndex;
  }

  void clearSelection() {
    selectedOptionIndex = null;
  }

  TriageOptionModel? get selectedOption {
    if (selectedOptionIndex != null && selectedOptionIndex! < options.length) {
      return options[selectedOptionIndex!];
    }
    return null;
  }

  TriageOptionModel? get confirmedOption {
    if (confirmedOptionIndex != null && confirmedOptionIndex! < options.length) {
      return options[confirmedOptionIndex!];
    }
    return null;
  }

  TriageQuestionModel copyWith({
    String? id,
    String? question,
    List<TriageOptionModel>? options,
    int? selectedOptionIndex,
    int? confirmedOptionIndex,
  }) {
    return TriageQuestionModel(
      id: id ?? this.id,
      question: question ?? this.question,
      options: options ?? this.options,
      selectedOptionIndex: selectedOptionIndex ?? this.selectedOptionIndex,
      confirmedOptionIndex: confirmedOptionIndex ?? this.confirmedOptionIndex,
    );
  }
}

class TriageOptionModel {
  final String id;
  final String text;
  final int? severityScore; // Optional: for calculating risk scores

  TriageOptionModel({
    required this.id,
    required this.text,
    this.severityScore,
  });

  TriageOptionModel copyWith({
    String? id,
    String? text,
    int? severityScore,
  }) {
    return TriageOptionModel(
      id: id ?? this.id,
      text: text ?? this.text,
      severityScore: severityScore ?? this.severityScore,
    );
  }
}
