class SubmitRefundResponseModel {
  final String? message;
  final String? refundType;
  final String? patientId;
  final String? refNo;

  SubmitRefundResponseModel({
    this.message,
    this.refundType,
    this.patientId,
    this.refNo,
  });

  factory SubmitRefundResponseModel.fromJson(Map<String, dynamic> json) {
    return SubmitRefundResponseModel(
      message: (json['Message'] ?? json['message']) as String?,
      refundType: (json['Refund_RefundTypeDisplay'] ?? json['refundType'])?.toString(),
      patientId: (json['Refund_PatientIdDisplay'] ?? json['patientId'])?.toString(),
      refNo: (json['Refund_RefNo'] ?? json['ReferenceNumber'] ?? json['refNo'])?.toString(),
    );
  }
}

class RefundStatusModel {
  final String? errorMessage;
  final String? lastUpdated;
  final bool? pendingVerification;
  final String? referenceNumber;
  final String? requestStatusName;
  final String? status;
  final bool? verified;

  RefundStatusModel({
    this.errorMessage,
    this.lastUpdated,
    this.pendingVerification,
    this.referenceNumber,
    this.requestStatusName,
    this.status,
    this.verified,
  });

  factory RefundStatusModel.fromJson(Map<String, dynamic> json) {
    return RefundStatusModel(
      errorMessage: json['ErrorMessage'] as String?,
      lastUpdated: json['LastUpdated'] as String?,
      pendingVerification: json['PendingVerification'] as bool?,
      referenceNumber: json['ReferenceNumber'] as String?,
      requestStatusName: json['RequestStatusName'] as String?,
      status: json['Status'] as String?,
      verified: json['Verified'] as bool?,
    );
  }
}

class WalletAdvanceItem {
  final String? advanceDate;
  final String? advanceNo;
  final double? balanceAmount;
  final double? paidAmount;

  WalletAdvanceItem({
    this.advanceDate,
    this.advanceNo,
    this.balanceAmount,
    this.paidAmount,
  });

  factory WalletAdvanceItem.fromJson(Map<String, dynamic> json) {
    return WalletAdvanceItem(
      advanceDate: json['AdvanceDate'] as String?,
      advanceNo: json['AdvanceNo'] as String?,
      balanceAmount: (json['BalanceAmount'] as num?)?.toDouble(),
      paidAmount: (json['PaidAmount'] as num?)?.toDouble(),
    );
  }
}

class WalletRequestPayload {
  final List<WalletAdvanceItem>? advancesList;
  final int? doctorId;
  final String? doctorName;
  final String? iban;
  final String? nationalId;
  final String? patientId;
  final String? patientName;
  final String? project;
  final int? projectId;
  final String? refundAmountTypeName;
  final String? refundDestination;
  final String? refundDestinationName;
  final String? refundType;
  final String? refundTypeName;
  final String? remarks;
  final double? totalRefundAmount;

  WalletRequestPayload({
    this.advancesList,
    this.doctorId,
    this.doctorName,
    this.iban,
    this.nationalId,
    this.patientId,
    this.patientName,
    this.project,
    this.projectId,
    this.refundAmountTypeName,
    this.refundDestination,
    this.refundDestinationName,
    this.refundType,
    this.refundTypeName,
    this.remarks,
    this.totalRefundAmount,
  });

  factory WalletRequestPayload.fromJson(Map<String, dynamic> json) {
    return WalletRequestPayload(
      advancesList: (json['AdvancesList'] as List<dynamic>?)?.map((e) => WalletAdvanceItem.fromJson(e as Map<String, dynamic>)).toList(),
      doctorId: (json['DoctorId'] as num?)?.toInt(),
      doctorName: json['DoctorName'] as String?,
      iban: json['IBAN'] as String?,
      nationalId: json['NationalId'] as String?,
      patientId: json['PatientId'] as String?,
      patientName: json['PatientName'] as String?,
      project: json['Project'] as String?,
      projectId: (json['ProjectId'] as num?)?.toInt(),
      refundAmountTypeName: json['RefundAmountTypeName'] as String?,
      refundDestination: json['RefundDestination'] as String?,
      refundDestinationName: json['RefundDestinationName'] as String?,
      refundType: json['RefundType'] as String?,
      refundTypeName: json['RefundTypeName'] as String?,
      remarks: json['Remarks'] as String?,
      totalRefundAmount: (json['TotalRefundAmount'] as num?)?.toDouble(),
    );
  }
}

class InvoiceRefundProcedure {
  final bool? isLocked;
  final int? lineItemNo;
  final double? patientPaidAmount;
  final String? procedureId;
  final String? procedureName;
  final String? refundReason;

  InvoiceRefundProcedure({
    this.isLocked,
    this.lineItemNo,
    this.patientPaidAmount,
    this.procedureId,
    this.procedureName,
    this.refundReason,
  });

  factory InvoiceRefundProcedure.fromJson(Map<String, dynamic> json) {
    return InvoiceRefundProcedure(
      isLocked: json['IsLocked'] as bool?,
      lineItemNo: (json['LineItemNo'] as num?)?.toInt(),
      patientPaidAmount: (json['PatientPaidAmount'] as num?)?.toDouble(),
      procedureId: json['ProcedureID'] as String?,
      procedureName: json['ProcedureName'] as String?,
      refundReason: json['RefundReason'] as String?,
    );
  }
}

class InvoiceRequestPayload {
  final List<WalletAdvanceItem>? advancesList;
  final String? appointmentNo;
  final int? clinicId;
  final String? clinicName;
  final int? doctorId;
  final String? doctorName;
  final String? iban;
  final String? invoiceDate;
  final String? invoiceNo;
  final bool? isFastTrack;
  final String? nationalId;
  final String? patientId;
  final String? patientName;
  final List<InvoiceRefundProcedure>? proceduresList;
  final String? project;
  final int? projectId;
  final String? refundAmountType;
  final String? refundAmountTypeName;
  final String? refundDestination;
  final String? refundDestinationName;
  final double? refundTaxAmount;
  final String? refundType;
  final String? refundTypeName;
  final String? remarks;
  final double? totalRefundAmount;

  InvoiceRequestPayload({
    this.advancesList,
    this.appointmentNo,
    this.clinicId,
    this.clinicName,
    this.doctorId,
    this.doctorName,
    this.iban,
    this.invoiceDate,
    this.invoiceNo,
    this.isFastTrack,
    this.nationalId,
    this.patientId,
    this.patientName,
    this.proceduresList,
    this.project,
    this.projectId,
    this.refundAmountType,
    this.refundAmountTypeName,
    this.refundDestination,
    this.refundDestinationName,
    this.refundTaxAmount,
    this.refundType,
    this.refundTypeName,
    this.remarks,
    this.totalRefundAmount,
  });

  factory InvoiceRequestPayload.fromJson(Map<String, dynamic> json) {
    return InvoiceRequestPayload(
      advancesList: (json['AdvancesList'] as List<dynamic>?)?.map((e) => WalletAdvanceItem.fromJson(e as Map<String, dynamic>)).toList(),
      appointmentNo: json['AppointmentNo']?.toString(),
      clinicId: (json['ClinicId'] as num?)?.toInt(),
      clinicName: json['ClinicName'] as String?,
      doctorId: (json['DoctorId'] as num?)?.toInt(),
      doctorName: json['DoctorName'] as String?,
      iban: json['IBAN'] as String?,
      invoiceDate: json['InvoiceDate'] as String?,
      invoiceNo: json['InvoiceNo'] as String?,
      isFastTrack: json['IsFastTrack'] as bool?,
      nationalId: json['NationalId'] as String?,
      patientId: json['PatientId'] as String?,
      patientName: json['PatientName'] as String?,
      proceduresList: (json['ProceduresList'] as List<dynamic>?)?.map((e) => InvoiceRefundProcedure.fromJson(e as Map<String, dynamic>)).toList(),
      project: json['Project'] as String?,
      projectId: (json['ProjectId'] as num?)?.toInt(),
      refundAmountType: json['RefundAmountType'] as String?,
      refundAmountTypeName: json['RefundAmountTypeName'] as String?,
      refundDestination: json['RefundDestination'] as String?,
      refundDestinationName: json['RefundDestinationName'] as String?,
      refundTaxAmount: (json['RefundTaxAmount'] as num?)?.toDouble(),
      refundType: json['RefundType'] as String?,
      refundTypeName: json['RefundTypeName'] as String?,
      remarks: json['Remarks'] as String?,
      totalRefundAmount: (json['TotalRefundAmount'] as num?)?.toDouble(),
    );
  }
}

class RefundInvoiceModel {
  final String? invoiceNumber;
  final String? lastUpdated;
  final String? patientId;
  final bool? pendingVerification;
  final String? referenceNumber;
  final String? refundDestination;
  final int? refundDestinationId;
  final String? refundType;
  final int? refundTypeId;
  final String? requestStatusName;
  final int? requestStatusId;
  final String? verificationInitiatedAt;
  final bool? verified;
  final String? errorMessage;
  final WalletRequestPayload? walletRequestPayload;
  final InvoiceRequestPayload? invoiceRequestPayload;

  RefundInvoiceModel({
    this.invoiceNumber,
    this.lastUpdated,
    this.patientId,
    this.pendingVerification,
    this.referenceNumber,
    this.refundDestination,
    this.refundDestinationId,
    this.refundType,
    this.refundTypeId,
    this.requestStatusName,
    this.requestStatusId,
    this.verificationInitiatedAt,
    this.verified,
    this.errorMessage,
    this.walletRequestPayload,
    this.invoiceRequestPayload,
  });

  factory RefundInvoiceModel.fromJson(Map<String, dynamic> json) {
    return RefundInvoiceModel(
      invoiceNumber: json['InvoiceNumber'] as String?,
      lastUpdated: json['LastUpdated'] as String?,
      patientId: json['PatientID'] as String?,
      pendingVerification: json['PendingVerification'] as bool?,
      referenceNumber: json['ReferenceNumber'] as String?,
      refundDestination: json['RefundDestination'] as String?,
      refundDestinationId: json['RefundDestinationId'] as int?,
      refundType: json['RefundType'] as String?,
      refundTypeId: json['RefundTypeId'] as int?,
      requestStatusName: json['StatusName'] as String?,
      requestStatusId: json['StatusId'] as int?,
      verificationInitiatedAt: json['VerificationInitiatedAt'] as String?,
      verified: json['Verified'] as bool?,
      errorMessage: json['ErrorMessage'] as String?,
      walletRequestPayload:
          json['WalletRequestPayload'] != null ? WalletRequestPayload.fromJson(json['WalletRequestPayload'] as Map<String, dynamic>) : null,
      invoiceRequestPayload:
          json['InvoiceRequestPayload'] != null ? InvoiceRequestPayload.fromJson(json['InvoiceRequestPayload'] as Map<String, dynamic>) : null,
    );
  }
}
