diff --git a/lib/features/medical_file/medical_file_view_model.dart b/lib/features/medical_file/medical_file_view_model.dart index b93bb62d..05f82208 100644 --- a/lib/features/medical_file/medical_file_view_model.dart +++ b/lib/features/medical_file/medical_file_view_model.dart @@ -215,27 +215,40 @@ class MedicalFileViewModel extends ChangeNotifier { final result = await medicalFileRepo.getPatientVaccinesList(); result.fold( - // (failure) async => await errorHandlerService.handleError( - // failure: failure, - // onOkPressed: () { - // onError!(failure.message); - // }, - // ), (failure) async { - // onError!(failure.message); + print("❌ Vaccine API Failure: ${failure.message}"); isPatientVaccineListLoading = false; notifyListeners(); + if (onError != null) { + onError(failure.message); + } }, (apiResponse) { + print("📦 Vaccine API Response - Status: ${apiResponse.messageStatus}, Data: ${apiResponse.data}"); + if (apiResponse.messageStatus == 2) { - // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + print("⚠️ Vaccine API Error: ${apiResponse.errorMessage}"); + isPatientVaccineListLoading = false; + notifyListeners(); + if (onError != null) { + onError(apiResponse.errorMessage ?? "Unknown error"); + } } else if (apiResponse.messageStatus == 1) { - patientVaccineList = apiResponse.data!; + if (apiResponse.data != null) { + patientVaccineList = apiResponse.data!; + print("✅ Vaccine data loaded: ${patientVaccineList.length} items"); + } else { + print("⚠️ Vaccine API returned success but data is null"); + } isPatientVaccineListLoading = false; notifyListeners(); if (onSuccess != null) { onSuccess(apiResponse); } + } else { + print("⚠️ Unexpected messageStatus: ${apiResponse.messageStatus}"); + isPatientVaccineListLoading = false; + notifyListeners(); } }, ); diff --git a/lib/features/medical_file/models/patient_vaccine_response_model.dart b/lib/features/medical_file/models/patient_vaccine_response_model.dart index ff27b063..255a7198 100644 --- a/lib/features/medical_file/models/patient_vaccine_response_model.dart +++ b/lib/features/medical_file/models/patient_vaccine_response_model.dart @@ -1,160 +1,169 @@ +import 'dart:convert'; + class PatientVaccineResponseModel { - String? setupID; - int? projectID; - int? patientID; + String? setupId; + int? projectId; + int? patientId; int? invoiceNo; - String? procedureID; + String? procedureId; String? vaccineName; - Null? vaccineNameN; + dynamic vaccineNameN; String? invoiceDate; - int? doctorID; - int? clinicID; + int? doctorId; + int? clinicId; String? firstName; String? middleName; String? lastName; - Null? firstNameN; - Null? middleNameN; - Null? lastNameN; + dynamic firstNameN; + dynamic middleNameN; + dynamic lastNameN; String? dateofBirth; int? actualDoctorRate; String? age; String? clinicName; - Null? decimalDoctorRate; - Null? doctorImageURL; + double? decimalDoctorRate; + dynamic doctorImageUrl; String? doctorName; int? doctorRate; - int? doctorStarsRate; + double? doctorStarsRate; String? doctorTitle; int? gender; - Null? genderDescription; - Null? invoiceNoVP; + dynamic genderDescription; + dynamic invoiceNoVp; bool? isActiveDoctorProfile; bool? isDoctorAllowVedioCall; bool? isExecludeDoctor; int? noOfPatientsRate; String? patientName; String? projectName; - String? qR; + String? qr; + List? speciality; String? vaccinationDate; - PatientVaccineResponseModel( - {this.setupID, - this.projectID, - this.patientID, - this.invoiceNo, - this.procedureID, - this.vaccineName, - this.vaccineNameN, - this.invoiceDate, - this.doctorID, - this.clinicID, - this.firstName, - this.middleName, - this.lastName, - this.firstNameN, - this.middleNameN, - this.lastNameN, - this.dateofBirth, - this.actualDoctorRate, - this.age, - this.clinicName, - this.decimalDoctorRate, - this.doctorImageURL, - this.doctorName, - this.doctorRate, - this.doctorStarsRate, - this.doctorTitle, - this.gender, - this.genderDescription, - this.invoiceNoVP, - this.isActiveDoctorProfile, - this.isDoctorAllowVedioCall, - this.isExecludeDoctor, - this.noOfPatientsRate, - this.patientName, - this.projectName, - this.qR, - this.vaccinationDate}); + PatientVaccineResponseModel({ + this.setupId, + this.projectId, + this.patientId, + this.invoiceNo, + this.procedureId, + this.vaccineName, + this.vaccineNameN, + this.invoiceDate, + this.doctorId, + this.clinicId, + this.firstName, + this.middleName, + this.lastName, + this.firstNameN, + this.middleNameN, + this.lastNameN, + this.dateofBirth, + this.actualDoctorRate, + this.age, + this.clinicName, + this.decimalDoctorRate, + this.doctorImageUrl, + this.doctorName, + this.doctorRate, + this.doctorStarsRate, + this.doctorTitle, + this.gender, + this.genderDescription, + this.invoiceNoVp, + this.isActiveDoctorProfile, + this.isDoctorAllowVedioCall, + this.isExecludeDoctor, + this.noOfPatientsRate, + this.patientName, + this.projectName, + this.qr, + this.speciality, + this.vaccinationDate, + }); + + factory PatientVaccineResponseModel.fromRawJson(String str) => PatientVaccineResponseModel.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); - PatientVaccineResponseModel.fromJson(Map json) { - setupID = json['SetupID']; - projectID = json['ProjectID']; - patientID = json['PatientID']; - invoiceNo = json['InvoiceNo']; - procedureID = json['ProcedureID']; - vaccineName = json['VaccineName']; - vaccineNameN = json['VaccineNameN']; - invoiceDate = json['InvoiceDate']; - doctorID = json['DoctorID']; - clinicID = json['ClinicID']; - firstName = json['FirstName']; - middleName = json['MiddleName']; - lastName = json['LastName']; - firstNameN = json['FirstNameN']; - middleNameN = json['MiddleNameN']; - lastNameN = json['LastNameN']; - dateofBirth = json['DateofBirth']; - actualDoctorRate = json['ActualDoctorRate']; - age = json['Age']; - clinicName = json['ClinicName']; - decimalDoctorRate = json['DecimalDoctorRate']; - doctorImageURL = json['DoctorImageURL']; - doctorName = json['DoctorName']; - doctorRate = json['DoctorRate']; - doctorStarsRate = json['DoctorStarsRate']; - doctorTitle = json['DoctorTitle']; - gender = json['Gender']; - genderDescription = json['GenderDescription']; - invoiceNoVP = json['InvoiceNo_VP']; - isActiveDoctorProfile = json['IsActiveDoctorProfile']; - isDoctorAllowVedioCall = json['IsDoctorAllowVedioCall']; - isExecludeDoctor = json['IsExecludeDoctor']; - noOfPatientsRate = json['NoOfPatientsRate']; - patientName = json['PatientName']; - projectName = json['ProjectName']; - qR = json['QR']; - vaccinationDate = json['VaccinationDate']; - } + factory PatientVaccineResponseModel.fromJson(Map json) => PatientVaccineResponseModel( + setupId: json["SetupID"], + projectId: json["ProjectID"], + patientId: json["PatientID"], + invoiceNo: json["InvoiceNo"], + procedureId: json["ProcedureID"], + vaccineName: json["VaccineName"], + vaccineNameN: json["VaccineNameN"], + invoiceDate: json["InvoiceDate"], + doctorId: json["DoctorID"], + clinicId: json["ClinicID"], + firstName: json["FirstName"], + middleName: json["MiddleName"], + lastName: json["LastName"], + firstNameN: json["FirstNameN"], + middleNameN: json["MiddleNameN"], + lastNameN: json["LastNameN"], + dateofBirth: json["DateofBirth"], + actualDoctorRate: json["ActualDoctorRate"], + age: json["Age"], + clinicName: json["ClinicName"], + decimalDoctorRate: json["DecimalDoctorRate"]?.toDouble(), + doctorImageUrl: json["DoctorImageURL"], + doctorName: json["DoctorName"], + doctorRate: json["DoctorRate"], + doctorStarsRate: json["DoctorStarsRate"]?.toDouble(), + doctorTitle: json["DoctorTitle"], + gender: json["Gender"], + genderDescription: json["GenderDescription"], + invoiceNoVp: json["InvoiceNo_VP"], + isActiveDoctorProfile: json["IsActiveDoctorProfile"], + isDoctorAllowVedioCall: json["IsDoctorAllowVedioCall"], + isExecludeDoctor: json["IsExecludeDoctor"], + noOfPatientsRate: json["NoOfPatientsRate"], + patientName: json["PatientName"], + projectName: json["ProjectName"], + qr: json["QR"], + speciality: json["Speciality"] == null ? [] : List.from(json["Speciality"]!.map((x) => x)), + vaccinationDate: json["VaccinationDate"], + ); - Map toJson() { - final Map data = new Map(); - data['SetupID'] = this.setupID; - data['ProjectID'] = this.projectID; - data['PatientID'] = this.patientID; - data['InvoiceNo'] = this.invoiceNo; - data['ProcedureID'] = this.procedureID; - data['VaccineName'] = this.vaccineName; - data['VaccineNameN'] = this.vaccineNameN; - data['InvoiceDate'] = this.invoiceDate; - data['DoctorID'] = this.doctorID; - data['ClinicID'] = this.clinicID; - data['FirstName'] = this.firstName; - data['MiddleName'] = this.middleName; - data['LastName'] = this.lastName; - data['FirstNameN'] = this.firstNameN; - data['MiddleNameN'] = this.middleNameN; - data['LastNameN'] = this.lastNameN; - data['DateofBirth'] = this.dateofBirth; - data['ActualDoctorRate'] = this.actualDoctorRate; - data['Age'] = this.age; - data['ClinicName'] = this.clinicName; - data['DecimalDoctorRate'] = this.decimalDoctorRate; - data['DoctorImageURL'] = this.doctorImageURL; - data['DoctorName'] = this.doctorName; - data['DoctorRate'] = this.doctorRate; - data['DoctorStarsRate'] = this.doctorStarsRate; - data['DoctorTitle'] = this.doctorTitle; - data['Gender'] = this.gender; - data['GenderDescription'] = this.genderDescription; - data['InvoiceNo_VP'] = this.invoiceNoVP; - data['IsActiveDoctorProfile'] = this.isActiveDoctorProfile; - data['IsDoctorAllowVedioCall'] = this.isDoctorAllowVedioCall; - data['IsExecludeDoctor'] = this.isExecludeDoctor; - data['NoOfPatientsRate'] = this.noOfPatientsRate; - data['PatientName'] = this.patientName; - data['ProjectName'] = this.projectName; - data['QR'] = this.qR; - data['VaccinationDate'] = this.vaccinationDate; - return data; - } + Map toJson() => { + "SetupID": setupId, + "ProjectID": projectId, + "PatientID": patientId, + "InvoiceNo": invoiceNo, + "ProcedureID": procedureId, + "VaccineName": vaccineName, + "VaccineNameN": vaccineNameN, + "InvoiceDate": invoiceDate, + "DoctorID": doctorId, + "ClinicID": clinicId, + "FirstName": firstName, + "MiddleName": middleName, + "LastName": lastName, + "FirstNameN": firstNameN, + "MiddleNameN": middleNameN, + "LastNameN": lastNameN, + "DateofBirth": dateofBirth, + "ActualDoctorRate": actualDoctorRate, + "Age": age, + "ClinicName": clinicName, + "DecimalDoctorRate": decimalDoctorRate, + "DoctorImageURL": doctorImageUrl, + "DoctorName": doctorName, + "DoctorRate": doctorRate, + "DoctorStarsRate": doctorStarsRate, + "DoctorTitle": doctorTitle, + "Gender": gender, + "GenderDescription": genderDescription, + "InvoiceNo_VP": invoiceNoVp, + "IsActiveDoctorProfile": isActiveDoctorProfile, + "IsDoctorAllowVedioCall": isDoctorAllowVedioCall, + "IsExecludeDoctor": isExecludeDoctor, + "NoOfPatientsRate": noOfPatientsRate, + "PatientName": patientName, + "ProjectName": projectName, + "QR": qr, + "Speciality": speciality == null ? [] : List.from(speciality!.map((x) => x)), + "VaccinationDate": vaccinationDate, + }; } diff --git a/lib/presentation/medical_file/vaccine_list_page.dart b/lib/presentation/medical_file/vaccine_list_page.dart index bf02cb74..9f5f7d6c 100644 --- a/lib/presentation/medical_file/vaccine_list_page.dart +++ b/lib/presentation/medical_file/vaccine_list_page.dart @@ -29,11 +29,19 @@ class _VaccineListPageState extends State { @override void initState() { + super.initState(); scheduleMicrotask(() { + medicalFileViewModel = Provider.of(context, listen: false); medicalFileViewModel.setIsPatientVaccineListLoading(true); - medicalFileViewModel.getPatientVaccinesList(); + medicalFileViewModel.getPatientVaccinesList( + onSuccess: (data) { + print("✅ Vaccine data received: ${medicalFileViewModel.patientVaccineList.length} items"); + }, + onError: (error) { + print("❌ Vaccine error: $error"); + }, + ); }); - super.initState(); } @override