class TriageLevelResponseModel {
  final TriageLevelDataDetails? dataDetails;

  TriageLevelResponseModel({this.dataDetails});

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

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

class TriageLevelDataDetails {
  final String? triageLevel;
  final List<SeriousEvidence>? serious;
  final String? rootCause;
  final bool? teleconsultationApplicable;
  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;

  TriageLevelDataDetails({
    this.triageLevel,
    this.serious,
    this.rootCause,
    this.teleconsultationApplicable,
    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 TriageLevelDataDetails.fromJson(Map<String, dynamic> json) {
    return TriageLevelDataDetails(
      triageLevel: json['triage_level'],
      serious: json['serious'] != null
          ? (json['serious'] as List)
              .map((item) => SeriousEvidence.fromJson(item))
              .toList()
          : null,
      rootCause: json['root_cause'],
      teleconsultationApplicable: json['teleconsultation_applicable'],
      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 {
      'triage_level': triageLevel,
      'serious': serious?.map((item) => item.toJson()).toList(),
      'root_cause': rootCause,
      'teleconsultation_applicable': teleconsultationApplicable,
      '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 SeriousEvidence {
  final String? id;
  final String? name;
  final String? commonName;
  final String? seriousness;
  final bool? isEmergency;

  SeriousEvidence({
    this.id,
    this.name,
    this.commonName,
    this.seriousness,
    this.isEmergency,
  });

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

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

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

