medora-provider/lib/data/models/consultation_booking.dart
DhanshCOSQ 0f72ecf6ad feature/medora-55 (#10)
Added Splash screen, logo and some minor changes in the code

Co-authored-by: Jipson George <152465898+Jipson-cosq@users.noreply.github.com>
Reviewed-on: cosqnet/telemednet#10
Co-authored-by: DhanshCOSQ <dhanshas@cosq.net>
Co-committed-by: DhanshCOSQ <dhanshas@cosq.net>
2024-11-14 12:53:33 +00:00

105 lines
3.1 KiB
Dart

import 'package:cloud_firestore/cloud_firestore.dart';
enum PaymentStatus { pending, completed, failed, refunded }
class Booking {
final String id;
final String doctorId;
final String profileImageUrl;
final String doctorName;
final String patientId;
final String patientName;
final String location;
final DateTime appointmentDate;
final String appointmentTime;
final int consultationFee;
final PaymentStatus paymentStatus;
final DateTime createdAt;
final String specialization;
Booking({
required this.id,
required this.doctorId,
required this.profileImageUrl,
required this.doctorName,
required this.patientId,
required this.patientName,
required this.location,
required this.appointmentDate,
required this.appointmentTime,
required this.consultationFee,
required this.paymentStatus,
required this.createdAt,
required this.specialization,
});
Map<String, dynamic> toMap() {
return {
'id': id,
'doctorId': doctorId,
'profileImageUrl': profileImageUrl,
'doctorName': doctorName,
'patientId': patientId,
'patientName': patientName,
'location': location,
'appointmentDate': appointmentDate,
'appointmentTime': appointmentTime,
'consultationFee': consultationFee,
'paymentStatus': paymentStatus.toString().split('.').last,
'createdAt': createdAt,
'specialization': specialization,
};
}
factory Booking.fromMap(Map<String, dynamic> map) {
return Booking(
id: map['id'],
doctorId: map['doctorId'],
profileImageUrl: map['profileImageUrl'],
doctorName: map['doctorName'],
patientId: map['patientId'],
patientName: map['patientName'],
location: map['location'],
appointmentDate: (map['appointmentDate'] as Timestamp).toDate(),
appointmentTime: map['appointmentTime'],
consultationFee: map['consultationFee'],
paymentStatus: PaymentStatus.values.firstWhere(
(e) => e.toString().split('.').last == map['paymentStatus'],
),
createdAt: (map['createdAt'] as Timestamp).toDate(),
specialization: map['specialization'],
);
}
Booking copyWith({
String? id,
String? doctorId,
String? doctorName,
String? patientId,
String? patientName,
String? location,
DateTime? appointmentDate,
String? appointmentTime,
int? consultationFee,
PaymentStatus? paymentStatus,
DateTime? createdAt,
String? specialization,
}) {
return Booking(
id: id ?? this.id,
doctorId: doctorId ?? this.doctorId,
profileImageUrl: profileImageUrl,
doctorName: doctorName ?? this.doctorName,
patientId: patientId ?? this.patientId,
patientName: patientName ?? this.patientName,
location: location ?? this.location,
appointmentDate: appointmentDate ?? this.appointmentDate,
appointmentTime: appointmentTime ?? this.appointmentTime,
consultationFee: consultationFee!,
paymentStatus: paymentStatus ?? this.paymentStatus,
createdAt: createdAt ?? this.createdAt,
specialization: specialization ?? this.specialization,
);
}
}