diff --git a/lib/features/book_appointments/book_appointments_repo.dart b/lib/features/book_appointments/book_appointments_repo.dart index 0db37274..9afa113e 100644 --- a/lib/features/book_appointments/book_appointments_repo.dart +++ b/lib/features/book_appointments/book_appointments_repo.dart @@ -1003,6 +1003,8 @@ class BookAppointmentsRepoImp implements BookAppointmentsRepo { Future>> getPatientShareWalkInAppointment({required int projectID, required int clinicID, required int doctorID}) async { Map mapRequest = {"ProjectID": projectID, "ClinicID": clinicID, "DoctorID": doctorID}; + late PatientAppointmentShareResponseModel patientShareObj; + try { GenericApiModel? apiResponse; Failure? failure; @@ -1015,14 +1017,18 @@ class BookAppointmentsRepoImp implements BookAppointmentsRepo { onSuccess: (response, statusCode, {messageStatus, errorMessage}) { try { final list = response['OnlineCheckInAppointmentsWalkInModel']; - if (list == null || list.isEmpty) { - throw Exception("patient share list is empty"); - } - - final patientShareObj = PatientAppointmentShareResponseModel.fromJson(list); + patientShareObj = (list == null || list.isEmpty) ? PatientAppointmentShareResponseModel() : PatientAppointmentShareResponseModel.fromJson(list); patientShareObj.isCash = response["IsCash"]; patientShareObj.isEligible = response["IsEligible"]; patientShareObj.isInsured = response["IsInsured"]; + // if (list == null || list.isEmpty) { + // throw Exception("patient share list is empty"); + // } + + // final patientShareObj = PatientAppointmentShareResponseModel.fromJson(list); + // patientShareObj.isCash = response["IsCash"]; + // patientShareObj.isEligible = response["IsEligible"]; + // patientShareObj.isInsured = response["IsInsured"]; apiResponse = GenericApiModel( messageStatus: messageStatus, diff --git a/lib/features/my_appointments/my_appointments_repo.dart b/lib/features/my_appointments/my_appointments_repo.dart index 541e8878..eeef41e4 100644 --- a/lib/features/my_appointments/my_appointments_repo.dart +++ b/lib/features/my_appointments/my_appointments_repo.dart @@ -151,6 +151,8 @@ class MyAppointmentsRepoImp implements MyAppointmentsRepo { {required int projectID, required int clinicID, required String appointmentNo, required bool isLiveCareAppointment}) async { Map mapRequest = {"ProjectID": projectID, "ClinicID": clinicID, "AppointmentNo": appointmentNo, "IsActiveAppointment": true, "IsForLiveCare": isLiveCareAppointment}; + late PatientAppointmentShareResponseModel patientShareObj; + try { GenericApiModel? apiResponse; Failure? failure; @@ -163,15 +165,20 @@ class MyAppointmentsRepoImp implements MyAppointmentsRepo { onSuccess: (response, statusCode, {messageStatus, errorMessage}) { try { final list = response['OnlineCheckInAppointments']; - if (list == null || list.isEmpty) { - throw Exception("patient share list is empty"); - } - - final patientShareObj = PatientAppointmentShareResponseModel.fromJson(list[0]); + patientShareObj = (list == null || list.isEmpty) ? PatientAppointmentShareResponseModel() : PatientAppointmentShareResponseModel.fromJson(list[0]); patientShareObj.isCash = response["IsCash"]; patientShareObj.isEligible = response["IsEligible"]; patientShareObj.isInsured = response["IsInsured"]; + // if (list == null || list.isEmpty) { + // throw Exception("patient share list is empty"); + // } + + // final patientShareObj = PatientAppointmentShareResponseModel.fromJson(list[0]); + // patientShareObj.isCash = response["IsCash"]; + // patientShareObj.isEligible = response["IsEligible"]; + // patientShareObj.isInsured = response["IsInsured"]; + apiResponse = GenericApiModel( messageStatus: messageStatus, statusCode: statusCode, diff --git a/lib/presentation/appointments/appointment_payment_page.dart b/lib/presentation/appointments/appointment_payment_page.dart index 54d7991a..340501c0 100644 --- a/lib/presentation/appointments/appointment_payment_page.dart +++ b/lib/presentation/appointments/appointment_payment_page.dart @@ -281,9 +281,7 @@ class _AppointmentPaymentPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ LocaleKeys.amountBeforeTax.tr(context: context).toText14(isBold: true), - Utils.getPaymentAmountWithSymbol( - myAppointmentsVM.patientAppointmentShareResponseModel!.patientShare!.toString().toText16(isBold: true), - AppColors.blackColor, + Utils.getPaymentAmountWithSymbol((myAppointmentsVM.patientAppointmentShareResponseModel!.patientShare ?? 0).toString().toText16(isBold: true), AppColors.blackColor, 13, isSaudiCurrency: true), ], @@ -293,8 +291,7 @@ class _AppointmentPaymentPageState extends State { children: [ "VAT 15%".toText14(isBold: true, color: AppColors.greyTextColor), Utils.getPaymentAmountWithSymbol( - myAppointmentsVM.patientAppointmentShareResponseModel!.patientTaxAmount! - .toString() + (myAppointmentsVM.patientAppointmentShareResponseModel!.patientTaxAmount ?? 0).toString() .toText14(isBold: true, color: AppColors.greyTextColor), AppColors.greyTextColor, 13, @@ -307,8 +304,7 @@ class _AppointmentPaymentPageState extends State { children: [ "".toText14(isBold: true), Utils.getPaymentAmountWithSymbol( - myAppointmentsVM.patientAppointmentShareResponseModel!.patientShareWithTax!.toString().toText24(isBold: true), - AppColors.blackColor, + (myAppointmentsVM.patientAppointmentShareResponseModel!.patientShareWithTax ?? 0).toString().toText24(isBold: true), AppColors.blackColor, 17, isSaudiCurrency: true), ],