import 'dart:convert';

class SearchEReferralResponseModel {
  dynamic acceptedBrachCode;
  dynamic acceptedBranchName;
  dynamic acceptedBranchNameAr;
  dynamic channel;
  dynamic identityCardAttachment;
  String? identityNumber;
  dynamic insuranceCardAttachment;
  bool? isInsuredPatient;
  List<MedicalReportAttachment>? medicalReportAttachment;
  String? otherRelationship;
  String? patientContactNo;
  int? patientId;
  String? patientName;
  dynamic preferredBranchCode;
  dynamic preferredBranchName;
  String? referralDate;
  int? referralNumber;
  RelationshipType? relationshipType;
  String? requesterContactNo;
  String? requesterName;
  String? status;
  String? statusAr;

  SearchEReferralResponseModel({
    this.acceptedBrachCode,
    this.acceptedBranchName,
    this.acceptedBranchNameAr,
    this.channel,
    this.identityCardAttachment,
    this.identityNumber,
    this.insuranceCardAttachment,
    this.isInsuredPatient,
    this.medicalReportAttachment,
    this.otherRelationship,
    this.patientContactNo,
    this.patientId,
    this.patientName,
    this.preferredBranchCode,
    this.preferredBranchName,
    this.referralDate,
    this.referralNumber,
    this.relationshipType,
    this.requesterContactNo,
    this.requesterName,
    this.status,
    this.statusAr,
  });

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

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

  factory SearchEReferralResponseModel.fromJson(Map<String, dynamic> json) => SearchEReferralResponseModel(
    acceptedBrachCode: json["AcceptedBrachCode"],
    acceptedBranchName: json["AcceptedBranchName"],
    acceptedBranchNameAr: json["AcceptedBranchNameAr"],
    channel: json["Channel"],
    identityCardAttachment: json["IdentityCardAttachment"],
    identityNumber: json["IdentityNumber"],
    insuranceCardAttachment: json["InsuranceCardAttachment"],
    isInsuredPatient: json["IsInsuredPatient"],
    medicalReportAttachment: json["MedicalReportAttachment"] == null ? [] : List<MedicalReportAttachment>.from(json["MedicalReportAttachment"]!.map((x) => MedicalReportAttachment.fromJson(x))),
    otherRelationship: json["OtherRelationship"],
    patientContactNo: json["PatientContactNo"],
    patientId: json["PatientId"],
    patientName: json["PatientName"],
    preferredBranchCode: json["PreferredBranchCode"],
    preferredBranchName: json["PreferredBranchName"],
    referralDate: json["ReferralDate"],
    referralNumber: json["ReferralNumber"],
    relationshipType: json["RelationshipType"] == null ? null : RelationshipType.fromJson(json["RelationshipType"]),
    requesterContactNo: json["RequesterContactNo"],
    requesterName: json["RequesterName"],
    status: json["Status"],
    statusAr: json["StatusAr"],
  );

  Map<String, dynamic> toJson() => {
    "AcceptedBrachCode": acceptedBrachCode,
    "AcceptedBranchName": acceptedBranchName,
    "AcceptedBranchNameAr": acceptedBranchNameAr,
    "Channel": channel,
    "IdentityCardAttachment": identityCardAttachment,
    "IdentityNumber": identityNumber,
    "InsuranceCardAttachment": insuranceCardAttachment,
    "IsInsuredPatient": isInsuredPatient,
    "MedicalReportAttachment": medicalReportAttachment == null ? [] : List<dynamic>.from(medicalReportAttachment!.map((x) => x.toJson())),
    "OtherRelationship": otherRelationship,
    "PatientContactNo": patientContactNo,
    "PatientId": patientId,
    "PatientName": patientName,
    "PreferredBranchCode": preferredBranchCode,
    "PreferredBranchName": preferredBranchName,
    "ReferralDate": referralDate,
    "ReferralNumber": referralNumber,
    "RelationshipType": relationshipType?.toJson(),
    "RequesterContactNo": requesterContactNo,
    "RequesterName": requesterName,
    "Status": status,
    "StatusAr": statusAr,
  };
}

class MedicalReportAttachment {
  String? base64String;
  String? fileName;

  MedicalReportAttachment({
    this.base64String,
    this.fileName,
  });

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

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

  factory MedicalReportAttachment.fromJson(Map<String, dynamic> json) => MedicalReportAttachment(
    base64String: json["Base64String"],
    fileName: json["FileName"],
  );

  Map<String, dynamic> toJson() => {
    "Base64String": base64String,
    "FileName": fileName,
  };
}

class RelationshipType {
  int? id;
  String? text;
  String? textAr;
  String? textEn;

  RelationshipType({
    this.id,
    this.text,
    this.textAr,
    this.textEn,
  });

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

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

  factory RelationshipType.fromJson(Map<String, dynamic> json) => RelationshipType(
    id: json["ID"],
    text: json["Text"],
    textAr: json["Text_Ar"],
    textEn: json["Text_En"],
  );

  Map<String, dynamic> toJson() => {
    "ID": id,
    "Text": text,
    "Text_Ar": textAr,
    "Text_En": textEn,
  };
}
