From 889828d4d493b4a9a42fa5ef68da25f2a7002e24 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 5 Mar 2025 11:31:54 +0300 Subject: [PATCH] Lab report download VIDA Plus implementation --- lib/core/service/medical/labs_service.dart | 2 +- .../components/DocAvailableAppointments.dart | 141 ++++++++++-------- 2 files changed, 77 insertions(+), 66 deletions(-) diff --git a/lib/core/service/medical/labs_service.dart b/lib/core/service/medical/labs_service.dart index 28e922f2..3f83a493 100644 --- a/lib/core/service/medical/labs_service.dart +++ b/lib/core/service/medical/labs_service.dart @@ -233,7 +233,7 @@ class LabsService extends BaseService { // await baseAppClient.post(SEND_LAB_RESULT_EMAIL, onSuccess: (dynamic response, int statusCode) { await baseAppClient.post(isVidaPlus ? SEND_LAB_RESULT_EMAIL : SEND_LAB_RESULT_EMAIL_NEW, onSuccess: (dynamic response, int statusCode) { if (isDownload) { - labReportPDF = response['PdfContent']; + labReportPDF = isVidaPlus ? response['LabReportsPDFContent'] : response['PdfContent']; } }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart index e08d9397..67a795da 100644 --- a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart +++ b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart @@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/custom_text_button.dart'; import 'package:flutter/cupertino.dart'; @@ -55,6 +56,7 @@ class _DocAvailableAppointmentsState extends State wit int selectedButtonIndex = 0; int selectedNextDayButtonIndex = -1; dynamic freeSlotsResponse; + // String nextDayAppointmentDate =""; late ScrollController _scrollController; @@ -120,7 +122,7 @@ class _DocAvailableAppointmentsState extends State wit _calendarController.selectedDate = day; openTimeSlotsPickerForDate(day, docFreeSlots); DocAvailableAppointments.selectedDate = formatter.format(day); - selectedNextDayButtonIndex =-1; + selectedNextDayButtonIndex = -1; print(_calendarController.selectedDate); }); } @@ -143,45 +145,51 @@ class _DocAvailableAppointmentsState extends State wit ), DocAvailableAppointments.areSlotsAvailable ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ Container( - height: 40, - child: - ListView.builder( - controller: _scrollController, - scrollDirection: Axis.horizontal, - itemCount: dayEvents.length, - itemBuilder: (context, index) { - return Container( - margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5), - child: index == selectedButtonIndex ? getSelectedButton(index) : getNormalButton(index), - ); - }, - ), - ), - SizedBox(height: 20,), - nextDayEvents.isNotEmpty ? Container( - padding: EdgeInsets.only(left: 20, right: 20, bottom:20), - child: Text(selectedNextDate, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.black))) :SizedBox(), - Container( - height: 40, - padding: EdgeInsets.only(left: 0, right: 0), - child: - ListView.builder( - controller: _scrollController, - scrollDirection: Axis.horizontal, - itemCount: nextDayEvents.length, - itemBuilder: (context, index) { - return Container( - margin: EdgeInsets.only(right: (index == nextDayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5), - child: index == selectedNextDayButtonIndex ? getSelectedNextDayButton(index) : getNormalNextDayButton(index), - ); - }, - ), - ) - ],) - - + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 40, + child: ListView.builder( + controller: _scrollController, + scrollDirection: Axis.horizontal, + itemCount: dayEvents.length, + itemBuilder: (context, index) { + return Container( + margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5), + child: index == selectedButtonIndex ? getSelectedButton(index) : getNormalButton(index), + ); + }, + ), + ), + SizedBox( + height: 20, + ), + nextDayEvents.isNotEmpty && projectViewModel.havePrivilege(110) + ? Container( + padding: EdgeInsets.only(left: 20, right: 20, bottom: 20), + child: Text( + selectedNextDate, + style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.black), + ), + ) + : SizedBox(), + Container( + height: 40, + padding: EdgeInsets.only(left: 0, right: 0), + child: ListView.builder( + controller: _scrollController, + scrollDirection: Axis.horizontal, + itemCount: nextDayEvents.length, + itemBuilder: (context, index) { + return Container( + margin: EdgeInsets.only(right: (index == nextDayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5), + child: index == selectedNextDayButtonIndex ? getSelectedNextDayButton(index) : getNormalNextDayButton(index), + ); + }, + ), + ) + ], + ) : Center( child: Padding( padding: const EdgeInsets.only(left: 12.0, right: 12.0), @@ -261,20 +269,24 @@ class _DocAvailableAppointmentsState extends State wit } else DocAvailableAppointments.areSlotsAvailable = false; }); - } - filterNextDayAppo(List freeSlots, Map listList){ - DateTime dateStart = DateTime.parse(listList['end']).add(Duration(days: 1)); + + filterNextDayAppo(List freeSlots, Map listList) { + DateTime dateStart = DateTime.parse(listList['end']).add(Duration(days: 1)); DateTime dateStartObj = new DateTime(dateStart.year, dateStart.month, dateStart.day, 0, 0, 0, 0, 0); - nextDayEvents = []; - DateTime beforeHour = new DateTime(dateStart.year, dateStart.month, dateStart.day, 6, 0, 0, 0, 0); + nextDayEvents = []; + DateTime beforeHour = new DateTime(dateStart.year, dateStart.month, dateStart.day, 6, 0, 0, 0, 0); + if (projectViewModel.havePrivilege(110)) { freeSlots.forEach((v) { - if (v.start == dateStartObj && v.end!.isBefore(beforeHour) ) nextDayEvents.add(v); + if (v.start == dateStartObj && v.end!.isBefore(beforeHour)) nextDayEvents.add(v); }); - // print(nextDayEvents); - + } else { + nextDayEvents = []; + } + // print(nextDayEvents); } + Future> _getJSONSlots() async { Map _eventsParsed; List slotsList = []; @@ -299,7 +311,7 @@ class _DocAvailableAppointmentsState extends State wit ), ), ); - + DocAvailableAppointments.selectedAppoDateTime = (isLiveCareSchedule != null && isLiveCareSchedule) ? DateUtil.convertStringToDate(freeSlotsResponse[0]) : DateUtil.convertStringToDateSaudiTimezone( @@ -318,15 +330,15 @@ class _DocAvailableAppointmentsState extends State wit ), ), language); - selectedNextDate = DateUtil.getWeekDayMonthDayYearDateFormatted( + selectedNextDate = DateUtil.getWeekDayMonthDayYearDateFormatted( (isLiveCareSchedule != null && isLiveCareSchedule) - ? DateUtil.convertStringToDate(freeSlotsResponse[0]).add(Duration(days:1)) + ? DateUtil.convertStringToDate(freeSlotsResponse[0]).add(Duration(days: 1)) : DateUtil.convertStringToDateSaudiTimezone( - freeSlotsResponse[0], - int.parse( - widget.doctor.projectID.toString(), - ), - ).add(Duration(days:1)), + freeSlotsResponse[0], + int.parse( + widget.doctor.projectID.toString(), + ), + ).add(Duration(days: 1)), language); selectedDateJSON = freeSlotsResponse[0]; }); @@ -370,13 +382,11 @@ class _DocAvailableAppointmentsState extends State wit DocAvailableAppointments.selectedAppoDateTime = timeslot.end; setState(() { - selectedButtonIndex = index; - selectedNextDayButtonIndex =-1; + selectedNextDayButtonIndex = -1; DocAvailableAppointments.selectedTime = dayEvents[index].isoTime; print(DocAvailableAppointments.selectedTime); DocAvailableAppointments.selectedDate = dateFormatter.format(_calendarController.selectedDate!); - }); projectViewModel.analytics.appointment.book_appointment_time_selection(appointment_type: 'regular', dateTime: timeslot.end, doctor: widget.doctor); }, @@ -404,6 +414,7 @@ class _DocAvailableAppointmentsState extends State wit child: Text(dayEvents[index].isoTime!, style: TextStyle(fontSize: 12.0, color: Colors.white)), ); } + Widget getNormalNextDayButton(int index) { return CustomTextButton( backgroundColor: Colors.white, @@ -412,16 +423,16 @@ class _DocAvailableAppointmentsState extends State wit color: Colors.black, //Color of the border style: BorderStyle.solid, //Style of the border width: 1.5 //width of the border - ), + ), onPressed: () { final timeslot = nextDayEvents[index]; DocAvailableAppointments.selectedAppoDateTime = timeslot.end; setState(() { selectedButtonIndex = -1; - selectedNextDayButtonIndex =index; + selectedNextDayButtonIndex = index; DocAvailableAppointments.selectedTime = nextDayEvents[index].isoTime; - DocAvailableAppointments.selectedDate = dateFormatter.format(_calendarController.selectedDate!.add(Duration(days:1))); + DocAvailableAppointments.selectedDate = dateFormatter.format(_calendarController.selectedDate!.add(Duration(days: 1))); print(DocAvailableAppointments.selectedTime); }); projectViewModel.analytics.appointment.book_appointment_time_selection(appointment_type: 'regular', dateTime: timeslot.end, doctor: widget.doctor); @@ -438,13 +449,13 @@ class _DocAvailableAppointmentsState extends State wit color: nextDayEvents[index].isoTime == TranslationBase.of(context).waitingAppointment ? CustomColors.darkOrange : CustomColors.green, //Color of the border style: BorderStyle.solid, //Style of the border width: 1.5 //width of the border - ), + ), onPressed: () { setState(() { - selectedButtonIndex =-1; + selectedButtonIndex = -1; selectedNextDayButtonIndex = index; DocAvailableAppointments.selectedTime = nextDayEvents[index].isoTime; - DocAvailableAppointments.selectedDate =dateFormatter.format(_calendarController.selectedDate!.add(Duration(days:1))); + DocAvailableAppointments.selectedDate = dateFormatter.format(_calendarController.selectedDate!.add(Duration(days: 1))); print(DocAvailableAppointments.selectedTime); }); },