import 'dart:convert';

class LabOrdersResponseByAi {
  Analysis? analysis;
  String? patientId;
  int? totalOrders;
  int? totalResults;

  LabOrdersResponseByAi({
    this.analysis,
    this.patientId,
    this.totalOrders,
    this.totalResults,
  });

  factory LabOrdersResponseByAi.fromRawJson(String str) => LabOrdersResponseByAi.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory LabOrdersResponseByAi.fromJson(Map<String, dynamic> json) => LabOrdersResponseByAi(
    analysis: json["analysis"] == null ? null : Analysis.fromJson(json["analysis"]),
    patientId: json["patient_id"],
    totalOrders: json["total_orders"],
    totalResults: json["total_results"],
  );

  Map<String, dynamic> toJson() => {
    "analysis": analysis?.toJson(),
    "patient_id": patientId,
    "total_orders": totalOrders,
    "total_results": totalResults,
  };
}

class Analysis {
  List<AiGeneratedAttribute>? aiGeneratedAttributes;
  List<String>? aiPredictions;
  List<AiRecommendation>? aiRecommendations;
  List<String>? prevention;
  String? rawMessage;
  List<RiskFactor>? riskFactors;
  List<dynamic>? suggestedDoctors;
  String? summary;

  Analysis({
    this.aiGeneratedAttributes,
    this.aiPredictions,
    this.aiRecommendations,
    this.prevention,
    this.rawMessage,
    this.riskFactors,
    this.suggestedDoctors,
    this.summary,
  });

  factory Analysis.fromRawJson(String str) => Analysis.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory Analysis.fromJson(Map<String, dynamic> json) => Analysis(
    aiGeneratedAttributes: json["ai_generated_attributes"] == null ? [] : List<AiGeneratedAttribute>.from(json["ai_generated_attributes"]!.map((x) => AiGeneratedAttribute.fromJson(x))),
    aiPredictions: json["ai_predictions"] == null ? [] : List<String>.from(json["ai_predictions"]!.map((x) => x)),
    aiRecommendations: json["ai_recommendations"] == null ? [] : List<AiRecommendation>.from(json["ai_recommendations"]!.map((x) => AiRecommendation.fromJson(x))),
    prevention: json["prevention"] == null ? [] : List<String>.from(json["prevention"]!.map((x) => x)),
    rawMessage: json["raw_message"],
    riskFactors: json["riskFactors"] == null ? [] : List<RiskFactor>.from(json["riskFactors"]!.map((x) => RiskFactor.fromJson(x))),
    suggestedDoctors: json["suggested_doctors"] == null ? [] : List<dynamic>.from(json["suggested_doctors"]!.map((x) => x)),
    summary: json["summary"],
  );

  Map<String, dynamic> toJson() => {
    "ai_generated_attributes": aiGeneratedAttributes == null ? [] : List<dynamic>.from(aiGeneratedAttributes!.map((x) => x.toJson())),
    "ai_predictions": aiPredictions == null ? [] : List<dynamic>.from(aiPredictions!.map((x) => x)),
    "ai_recommendations": aiRecommendations == null ? [] : List<dynamic>.from(aiRecommendations!.map((x) => x.toJson())),
    "prevention": prevention == null ? [] : List<dynamic>.from(prevention!.map((x) => x)),
    "raw_message": rawMessage,
    "riskFactors": riskFactors == null ? [] : List<dynamic>.from(riskFactors!.map((x) => x.toJson())),
    "suggested_doctors": suggestedDoctors == null ? [] : List<dynamic>.from(suggestedDoctors!.map((x) => x)),
    "summary": summary,
  };
}

class AiGeneratedAttribute {
  String? calculatedResultFlag;
  String? description;
  String? referanceRange;
  String? resultValue;
  String? testShortDescription;
  String? uom;
  String? calculationFormula;

  AiGeneratedAttribute({
    this.calculatedResultFlag,
    this.description,
    this.referanceRange,
    this.resultValue,
    this.testShortDescription,
    this.uom,
    this.calculationFormula,
  });

  factory AiGeneratedAttribute.fromRawJson(String str) => AiGeneratedAttribute.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory AiGeneratedAttribute.fromJson(Map<String, dynamic> json) => AiGeneratedAttribute(
    calculatedResultFlag: json["CalculatedResultFlag"],
    description: json["Description"],
    referanceRange: json["ReferanceRange"],
    resultValue: json["ResultValue"],
    testShortDescription: json["TestShortDescription"],
    uom: json["UOM"],
    calculationFormula: json["calculationFormula"],
  );

  Map<String, dynamic> toJson() => {
    "CalculatedResultFlag": calculatedResultFlag,
    "Description": description,
    "ReferanceRange": referanceRange,
    "ResultValue": resultValue,
    "TestShortDescription": testShortDescription,
    "UOM": uom,
    "calculationFormula": calculationFormula,
  };
}

class AiRecommendation {
  String? priority;
  String? recommendation;

  AiRecommendation({
    this.priority,
    this.recommendation,
  });

  factory AiRecommendation.fromRawJson(String str) => AiRecommendation.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory AiRecommendation.fromJson(Map<String, dynamic> json) => AiRecommendation(
    priority: json["priority"],
    recommendation: json["recommendation"],
  );

  Map<String, dynamic> toJson() => {
    "priority": priority,
    "recommendation": recommendation,
  };
}

class RiskFactor {
  String? description;
  String? factor;
  String? risk;

  RiskFactor({
    this.description,
    this.factor,
    this.risk,
  });

  factory RiskFactor.fromRawJson(String str) => RiskFactor.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory RiskFactor.fromJson(Map<String, dynamic> json) => RiskFactor(
    description: json["description"],
    factor: json["factor"],
    risk: json["risk"],
  );

  Map<String, dynamic> toJson() => {
    "description": description,
    "factor": factor,
    "risk": risk,
  };
}
