import ' dart:async ' ;
import ' package:easy_localization/easy_localization.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:hmg_patient_app_new/core/api_consts.dart ' ;
import ' package:hmg_patient_app_new/core/app_assets.dart ' ;
import ' package:hmg_patient_app_new/core/app_state.dart ' ;
import ' package:hmg_patient_app_new/core/dependencies.dart ' ;
import ' package:hmg_patient_app_new/core/utils/calender_utils_new.dart ' ;
import ' package:hmg_patient_app_new/core/utils/date_util.dart ' ;
import ' package:hmg_patient_app_new/core/utils/size_utils.dart ' ;
import ' package:hmg_patient_app_new/core/utils/utils.dart ' ;
import ' package:hmg_patient_app_new/extensions/string_extensions.dart ' ;
import ' package:hmg_patient_app_new/extensions/widget_extensions.dart ' ;
import ' package:hmg_patient_app_new/features/book_appointments/book_appointments_view_model.dart ' ;
import ' package:hmg_patient_app_new/features/book_appointments/models/resp_models/doctors_list_response_model.dart ' ;
import ' package:hmg_patient_app_new/features/contact_us/contact_us_view_model.dart ' ;
import ' package:hmg_patient_app_new/features/lab/lab_view_model.dart ' ;
import ' package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart ' ;
import ' package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart ' ;
import ' package:hmg_patient_app_new/features/my_appointments/utils/appointment_type.dart ' ;
import ' package:hmg_patient_app_new/features/prescriptions/models/resp_models/patient_prescriptions_response_model.dart ' ;
import ' package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart ' ;
import ' package:hmg_patient_app_new/features/radiology/radiology_view_model.dart ' ;
import ' package:hmg_patient_app_new/generated/locale_keys.g.dart ' ;
import ' package:hmg_patient_app_new/presentation/appointments/appointment_payment_page.dart ' ;
import ' package:hmg_patient_app_new/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart ' ;
import ' package:hmg_patient_app_new/presentation/appointments/widgets/appointment_doctor_card.dart ' ;
import ' package:hmg_patient_app_new/presentation/appointments/widgets/ask_doctor_request_type_select.dart ' ;
import ' package:hmg_patient_app_new/presentation/book_appointment/widgets/appointment_calendar.dart ' ;
import ' package:hmg_patient_app_new/presentation/contact_us/feedback_page.dart ' ;
import ' package:hmg_patient_app_new/presentation/prescriptions/prescription_detail_page.dart ' ;
import ' package:hmg_patient_app_new/theme/colors.dart ' ;
import ' package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart ' ;
import ' package:hmg_patient_app_new/widgets/buttons/custom_button.dart ' ;
import ' package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart ' ;
import ' package:hmg_patient_app_new/widgets/common_bottom_sheet.dart ' ;
import ' package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart ' ;
import ' package:hmg_patient_app_new/widgets/routes/custom_page_route.dart ' ;
import ' package:maps_launcher/maps_launcher.dart ' ;
import ' package:provider/provider.dart ' ;
import ' ../medical_file/widgets/medical_file_card.dart ' ;
class AppointmentDetailsPage extends StatefulWidget {
const AppointmentDetailsPage ( { super . key , required this . patientAppointmentHistoryResponseModel } ) ;
final PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel ;
@ override
State < AppointmentDetailsPage > createState ( ) = > _AppointmentDetailsPageState ( ) ;
}
class _AppointmentDetailsPageState extends State < AppointmentDetailsPage > {
late MyAppointmentsViewModel myAppointmentsViewModel ;
late PrescriptionsViewModel prescriptionsViewModel ;
late BookAppointmentsViewModel bookAppointmentsViewModel ;
late ContactUsViewModel contactUsViewModel ;
late LabViewModel labViewModel ;
late RadiologyViewModel radiologyViewModel ;
@ override
void initState ( ) {
scheduleMicrotask ( ( ) async {
CalenderUtilsNew calendarUtils = await CalenderUtilsNew . instance ;
var doesExist = await calendarUtils . checkIfEventExist ( " ${ widget . patientAppointmentHistoryResponseModel . appointmentNo } " ) ;
myAppointmentsViewModel . setAppointmentReminder ( doesExist , widget . patientAppointmentHistoryResponseModel ) ;
setState ( ( ) {
} ) ;
} ) ;
super . initState ( ) ;
}
@ override
Widget build ( BuildContext context ) {
myAppointmentsViewModel = Provider . of < MyAppointmentsViewModel > ( context , listen: false ) ;
prescriptionsViewModel = Provider . of < PrescriptionsViewModel > ( context , listen: false ) ;
bookAppointmentsViewModel = Provider . of < BookAppointmentsViewModel > ( context , listen: false ) ;
contactUsViewModel = Provider . of < ContactUsViewModel > ( context , listen: false ) ;
labViewModel = Provider . of < LabViewModel > ( context , listen: false ) ;
radiologyViewModel = Provider . of < RadiologyViewModel > ( context , listen: false ) ;
return Scaffold (
backgroundColor: AppColors . bgScaffoldColor ,
body: Column (
children: [
Expanded (
child: CollapsingListView (
title: LocaleKeys . appointmentDetails . tr ( ) ,
report: AppointmentType . isArrived ( widget . patientAppointmentHistoryResponseModel )
? ( ) {
contactUsViewModel . setPatientFeedbackSelectedAppointment ( widget . patientAppointmentHistoryResponseModel ) ;
Navigator . of ( context ) . push (
CustomPageRoute (
page: FeedbackPage ( ) ,
) ,
) ;
}
: null ,
child: SingleChildScrollView (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
AppointmentDoctorCard (
patientAppointmentHistoryResponseModel: widget . patientAppointmentHistoryResponseModel ,
onAskDoctorTap: ( ) async {
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . checkingDoctorAvailability . tr ( ) ) ;
await myAppointmentsViewModel . isDoctorAvailable (
projectID: widget . patientAppointmentHistoryResponseModel . projectID ,
doctorId: widget . patientAppointmentHistoryResponseModel . doctorID ,
clinicId: widget . patientAppointmentHistoryResponseModel . clinicID ,
onSuccess: ( value ) async {
if ( value ) {
await myAppointmentsViewModel . getAskDoctorRequestTypes ( onSuccess: ( val ) {
LoaderBottomSheet . hideLoader ( ) ;
showCommonBottomSheetWithoutHeight (
context ,
title: LocaleKeys . askDoctor . tr ( context: context ) ,
child: AskDoctorRequestTypeSelect (
askDoctorRequestTypeList: myAppointmentsViewModel . askDoctorRequestTypeList ,
myAppointmentsViewModel: myAppointmentsViewModel ,
patientAppointmentHistoryResponseModel: widget . patientAppointmentHistoryResponseModel ,
) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ) ;
} else {
debugPrint ( " Doctor is not available " ) ;
}
} ) ;
} ,
onCancelTap: ( ) async {
myAppointmentsViewModel . setIsAppointmentDataToBeLoaded ( true ) ;
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . cancellingAppointmentPleaseWait . tr ( ) ) ;
await myAppointmentsViewModel . cancelAppointment (
patientAppointmentHistoryResponseModel: widget . patientAppointmentHistoryResponseModel ,
onSuccess: ( apiResponse ) {
LoaderBottomSheet . hideLoader ( ) ;
myAppointmentsViewModel . setIsAppointmentDataToBeLoaded ( true ) ;
myAppointmentsViewModel . getPatientAppointments ( true , false ) ;
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getSuccessWidget ( loadingText: LocaleKeys . appointmentCancelledSuccessfully . tr ( ) ) ,
callBackFunc: ( ) {
Navigator . of ( context ) . pop ( ) ;
} ,
title: " " ,
isCloseButtonVisible: true ,
isDismissible: false ,
isFullScreen: false ,
) ;
} ) ;
var isEventAddedOrRemoved = await CalenderUtilsNew . instance . checkAndRemove ( id: " ${ widget . patientAppointmentHistoryResponseModel . appointmentNo } " , ) ;
setState ( ( ) {
myAppointmentsViewModel . setAppointmentReminder ( isEventAddedOrRemoved , widget . patientAppointmentHistoryResponseModel ) ;
} ) ;
} ,
onRescheduleTap: ( ) async {
openDoctorScheduleCalendar ( ) ;
} ,
) ,
SizedBox ( height: 16. h ) ,
! AppointmentType . isArrived ( widget . patientAppointmentHistoryResponseModel )
? Column (
children: [
Consumer < BookAppointmentsViewModel > ( builder: ( context , bookAppointmentsVM , child ) {
return Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 20. r ,
hasShadow: false ,
) ,
child: Padding (
padding: EdgeInsets . all ( 16. h ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Row (
children: [
LocaleKeys . appointmentStatus . tr ( ) . toText16 ( isBold: true ) ,
] ,
) ,
SizedBox ( height: 4. h ) ,
( ! AppointmentType . isConfirmed ( widget . patientAppointmentHistoryResponseModel )
? LocaleKeys . notConfirmed . tr ( ) . toText12 ( color: AppColors . primaryRedColor , fontWeight: FontWeight . w500 )
: LocaleKeys . confirmed . tr ( ) . toText12 ( color: AppColors . successColor , fontWeight: FontWeight . w500 ) ) ,
SizedBox ( height: 16. h ) ,
//TODO Add countdown timer in case of LiveCare Appointment
widget . patientAppointmentHistoryResponseModel . isLiveCareAppointment ? ? false
? Row (
children: [
Utils . buildSvgWithAssets ( icon: AppAssets . livecare_clinic_icon , width: 40. h , height: 40. h ) ,
SizedBox ( width: 12. w ) ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
LocaleKeys . doctorWillCallYou . tr ( ) . toText14 ( color: AppColors . greyTextColor , weight: FontWeight . w500 ) ,
] ,
) ,
) ,
] ,
)
: Stack (
children: [
ClipRRect (
clipBehavior: Clip . hardEdge ,
borderRadius: BorderRadius . circular ( 24. r ) ,
// Todo: what is this???? Api Key??? 😲
child: Image . network (
" https://maps.googleapis.com/maps/api/staticmap?center= ${ widget . patientAppointmentHistoryResponseModel . latitude } , ${ widget . patientAppointmentHistoryResponseModel . longitude } &zoom=14&size=350x165&maptype=roadmap&markers=color:red%7C ${ widget . patientAppointmentHistoryResponseModel . latitude } , ${ widget . patientAppointmentHistoryResponseModel . longitude } &key= ${ ApiKeyConstants . googleMapsApiKey } " ,
fit: BoxFit . contain ,
) ,
) ,
Positioned (
bottom: 0 ,
child: SizedBox (
width: MediaQuery . of ( context ) . size . width * 0.785 ,
child: CustomButton (
onPressed: ( ) {
MapsLauncher . launchCoordinates ( double . parse ( widget . patientAppointmentHistoryResponseModel . latitude ! ) ,
double . parse ( widget . patientAppointmentHistoryResponseModel . longitude ! ) , widget . patientAppointmentHistoryResponseModel . projectName ) ;
} ,
text: LocaleKeys . getDirections . tr ( ) ,
backgroundColor: AppColors . textColor . withValues ( alpha: 0.8 ) ,
borderColor: AppointmentType . getNextActionButtonColor ( widget . patientAppointmentHistoryResponseModel . nextAction ) . withValues ( alpha: 0.01 ) ,
textColor: AppColors . whiteColor ,
fontSize: 14. f ,
fontWeight: FontWeight . w500 ,
borderRadius: 12. r ,
padding: EdgeInsets . symmetric ( horizontal: 10. w ) ,
height: 40. h ,
icon: AppAssets . directions_icon ,
iconColor: AppColors . whiteColor ,
iconSize: 14. h ,
) . paddingAll ( 12. h ) ,
) ,
) ,
] ,
) ,
SizedBox ( height: 8. h ) ,
bookAppointmentsViewModel . appointmentNearestGateResponseModel ! = null ? Wrap (
direction: Axis . horizontal ,
spacing: 8. w ,
runSpacing: 8. h ,
children: [
AppCustomChipWidget (
labelText: bookAppointmentsVM . isAppointmentNearestGateLoading
? " Floor: Ground Floor "
: " Floor: ${ getIt . get < AppState > ( ) . isArabic ( ) ? bookAppointmentsViewModel . appointmentNearestGateResponseModel ! . clinicLocationN : bookAppointmentsViewModel . appointmentNearestGateResponseModel ! . clinicLocation } " ,
) . toShimmer2 ( isShow: bookAppointmentsVM . isAppointmentNearestGateLoading ) ,
AppCustomChipWidget (
labelText:
" Nearest Gate: ${ getIt . get < AppState > ( ) . isArabic ( ) ? bookAppointmentsVM . appointmentNearestGateResponseModel ! . nearestGateNumberN : bookAppointmentsVM . appointmentNearestGateResponseModel ! . nearestGateNumber } " )
. toShimmer2 ( isShow: bookAppointmentsVM . isAppointmentNearestGateLoading ) ,
] ,
) : SizedBox . shrink ( ) ,
] ,
) ,
) ,
) ;
} ) ,
SizedBox ( height: 16. h ) ,
Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 20. r ,
hasShadow: false ,
) ,
child: Row (
mainAxisSize: MainAxisSize . max ,
children: [
Utils . buildSvgWithAssets ( icon: AppAssets . prescription_reminder_icon , width: 35. h , height: 35. h ) ,
SizedBox ( width: 8. h ) ,
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
LocaleKeys . setReminder . tr ( context: context ) . toText13 ( isBold: true ) ,
LocaleKeys . notifyMeBeforeAppointment . tr ( ) . toText11 ( color: AppColors . textColorLight , weight: FontWeight . w500 ) ,
] ,
) ,
const Spacer ( ) ,
Switch (
// activeThumbColor: AppColors.successColor,
activeTrackColor: AppColors . successColor . withValues ( alpha: . 15 ) ,
value: widget . patientAppointmentHistoryResponseModel . hasReminder ! ,
onChanged: ( newValue ) async {
CalenderUtilsNew calender = CalenderUtilsNew . instance ;
bool isEventAddedOrRemoved = false ;
if ( newValue = = true ) {
DateTime startDate = DateTime . now ( ) ;
DateTime endDate = DateUtil . convertStringToDate ( widget
. patientAppointmentHistoryResponseModel . appointmentDate ) ;
BottomSheetUtils ( ) . showReminderBottomSheet (
context ,
endDate ,
widget . patientAppointmentHistoryResponseModel . doctorNameObj ? ? " " ,
" ${ widget . patientAppointmentHistoryResponseModel . appointmentNo } " ? ? " " ,
" " ,
" " ,
title: " Appointment with ${ widget . patientAppointmentHistoryResponseModel . doctorNameObj } " ,
description:
" ${ widget . patientAppointmentHistoryResponseModel . doctorNameObj } will be having an appointment on ${ widget . patientAppointmentHistoryResponseModel . appointmentDate } " ,
onSuccess: ( ) {
setState ( ( ) {
myAppointmentsViewModel . setAppointmentReminder ( newValue , widget . patientAppointmentHistoryResponseModel ) ;
} ) ;
} ,
isMultiAllowed: true ,
onMultiDateSuccess: ( int selectedIndex ) async {
isEventAddedOrRemoved = await calender . createOrUpdateEvent (
title:
" Appointment Reminder with ${ widget . patientAppointmentHistoryResponseModel . doctorNameObj } on ${ DateUtil . convertStringToDate ( widget . patientAppointmentHistoryResponseModel . appointmentDate ) } , Appointment # ${ widget . patientAppointmentHistoryResponseModel . appointmentNo } " ,
description:
" Appointment Reminder with ${ widget . patientAppointmentHistoryResponseModel . doctorNameObj } in ${ widget . patientAppointmentHistoryResponseModel . projectName } " ,
scheduleDateTime: DateUtil . convertStringToDate ( widget
. patientAppointmentHistoryResponseModel . appointmentDate ) ,
eventId: " ${ widget . patientAppointmentHistoryResponseModel . appointmentNo } " ,
location: ' ' ,
reminderMinutes: selectedIndex
) ;
setState ( ( ) {
myAppointmentsViewModel . setAppointmentReminder ( isEventAddedOrRemoved , widget . patientAppointmentHistoryResponseModel ) ;
} ) ;
} ,
) ;
} else {
isEventAddedOrRemoved = await calender . checkAndRemove ( id: " ${ widget . patientAppointmentHistoryResponseModel . appointmentNo } " , ) ;
setState ( ( ) {
myAppointmentsViewModel . setAppointmentReminder ( ! isEventAddedOrRemoved , widget . patientAppointmentHistoryResponseModel ) ;
} ) ;
}
} ,
) ,
] ,
) . paddingSymmetrical ( 16. h , 16. h ) ,
) ,
SizedBox ( height: 16. h ) ,
] ,
)
// : SizedBox.shrink()
: GridView (
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount (
crossAxisCount: 3 ,
crossAxisSpacing: 16. h ,
mainAxisSpacing: 16. w ,
mainAxisExtent: 115. h ,
) ,
physics: NeverScrollableScrollPhysics ( ) ,
padding: EdgeInsets . zero ,
shrinkWrap: true ,
children: [
MedicalFileCard (
label: LocaleKeys . labResults . tr ( context: context ) ,
textColor: AppColors . blackColor ,
backgroundColor: AppColors . whiteColor ,
svgIcon: AppAssets . lab_result_icon ,
isLargeText: true ,
iconSize: 36. w ,
) . onPress ( ( ) async {
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . fetchingLabResults . tr ( ) ) ;
await labViewModel . getLabResultsByAppointmentNo (
appointmentNo: widget . patientAppointmentHistoryResponseModel . appointmentNo ,
projectID: widget . patientAppointmentHistoryResponseModel . projectID ,
clinicID: widget . patientAppointmentHistoryResponseModel . clinicID ,
doctorID: widget . patientAppointmentHistoryResponseModel . doctorID ,
doctorName: widget . patientAppointmentHistoryResponseModel . doctorNameObj ! ,
clinicName: widget . patientAppointmentHistoryResponseModel . clinicName ! ,
projectName: widget . patientAppointmentHistoryResponseModel . projectName ! ,
appointmentDate: widget . patientAppointmentHistoryResponseModel . appointmentDate ! ,
onSuccess: ( val ) {
LoaderBottomSheet . hideLoader ( ) ;
} ,
onError: ( err ) {
LoaderBottomSheet . hideLoader ( ) ;
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: err ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ,
) ;
} ) ,
MedicalFileCard (
label: " ${ LocaleKeys . radiology . tr ( context: context ) } ${ LocaleKeys . radiologySubtitle . tr ( context: context ) } " ,
textColor: AppColors . blackColor ,
backgroundColor: AppColors . whiteColor ,
svgIcon: AppAssets . radiology_icon ,
isLargeText: true ,
iconSize: 36. w ,
) . onPress ( ( ) async {
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . fetchingRadiologyResults . tr ( ) ) ;
await radiologyViewModel . getPatientRadiologyOrdersByAppointment (
appointmentNo: widget . patientAppointmentHistoryResponseModel . appointmentNo ,
projectID: widget . patientAppointmentHistoryResponseModel . projectID ,
onSuccess: ( val ) {
LoaderBottomSheet . hideLoader ( ) ;
} ,
onError: ( err ) {
LoaderBottomSheet . hideLoader ( ) ;
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: err ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ,
) ;
} ) ,
MedicalFileCard (
label: LocaleKeys . prescriptions . tr ( context: context ) ,
textColor: AppColors . blackColor ,
backgroundColor: AppColors . whiteColor ,
svgIcon: AppAssets . prescription_item_icon ,
isLargeText: true ,
iconSize: 36. w ,
) . onPress ( ( ) async {
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . fetchingAppointmentPrescriptions . tr ( ) ) ;
await prescriptionsViewModel . getPrescriptionDetails (
getPrescriptionRequestModel ( ) ,
onSuccess: ( val ) {
LoaderBottomSheet . hideLoader ( ) ;
if ( val . data . isNotEmpty ) {
PatientPrescriptionsResponseModel patientPrescriptionsResponseModel = PatientPrescriptionsResponseModel (
doctorImageURL: widget . patientAppointmentHistoryResponseModel . doctorImageURL ,
doctorName: widget . patientAppointmentHistoryResponseModel . doctorNameObj ,
appointmentDate: widget . patientAppointmentHistoryResponseModel . appointmentDate ,
clinicDescription: widget . patientAppointmentHistoryResponseModel . clinicName ,
decimalDoctorRate: widget . patientAppointmentHistoryResponseModel . decimalDoctorRate ,
name: widget . patientAppointmentHistoryResponseModel . projectName ,
isHomeMedicineDeliverySupported: false ,
projectID: widget . patientAppointmentHistoryResponseModel . projectID ,
clinicID: widget . patientAppointmentHistoryResponseModel . clinicID ,
doctorID: widget . patientAppointmentHistoryResponseModel . doctorID ,
setupID: widget . patientAppointmentHistoryResponseModel . setupID ,
) ;
Navigator . of ( context ) . push (
CustomPageRoute (
page: PrescriptionDetailPage (
isFromAppointments: true , prescriptionsResponseModel: patientPrescriptionsResponseModel ) ,
) ,
) ;
} else {
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: LocaleKeys . noPrescriptionsForAppointment . tr ( ) ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
}
} ,
onError: ( err ) {
LoaderBottomSheet . hideLoader ( ) ;
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: err ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ,
) ;
// Navigator.of(context).push(
// CustomPageRoute(
// page: VaccineListPage(),
// ),
// );
} ) ,
] ,
) ,
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// "Lab & Radiology".needTranslation.toText18(isBold: true),
// SizedBox(height: 16.h),
// Row(
// children: [
// Expanded(
// child: LabRadCard(
// icon: AppAssets.lab_result_icon,
// labelText: LocaleKeys.labResults.tr(context: context),
// // labOrderTests: ["Complete blood count", "Creatinine", "Blood Sugar"],
// // labOrderTests: labViewModel.isLabOrdersLoading ? [] : labViewModel.labOrderTests,
// labOrderTests: [],
// // isLoading: labViewModel.isLabOrdersLoading,
// isLoading: false,
// ).onPress(() {
// Navigator.of(context).push(
// CustomPageRoute(
// page: LabOrdersPage(),
// ),
// );
// }),
// ),
// SizedBox(width: 16.h),
// Expanded(
// child: LabRadCard(
// icon: AppAssets.radiology_icon,
// labelText: LocaleKeys.radiology.tr(context: context),
// // labOrderTests: ["Chest X-ray", "Abdominal Ultrasound", "Dental X-ray"],
// labOrderTests: [],
// isLoading: false,
// ).onPress(() {
// Navigator.of(context).push(
// CustomPageRoute(
// page: RadiologyOrdersPage(),
// ),
// );
// }),
// ),
// ],
// ),
// SizedBox(height: 16.h),
// LocaleKeys.prescriptions.tr().toText18(isBold: true),
// SizedBox(height: 16.h),
// Consumer<PrescriptionsViewModel>(builder: (context, prescriptionVM, child) {
// return prescriptionVM.isPrescriptionsDetailsLoading
// ? const MoviesShimmerWidget()
// : Container(
// decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
// color: Colors.white,
// borderRadius: 20.r,
// ),
// padding: EdgeInsets.all(16.w),
// child: Column(
// children: [
// // ListView.separated(
// // itemCount: prescriptionVM.prescriptionDetailsList.length,
// // shrinkWrap: true,
// // padding: EdgeInsets.only(right: 8.w),
// // physics: NeverScrollableScrollPhysics(),
// // itemBuilder: (context, index) {
// // return AnimationConfiguration.staggeredList(
// // position: index,
// // duration: const Duration(milliseconds: 500),
// // child: SlideAnimation(
// // verticalOffset: 100.0,
// // child: FadeInAnimation(
// // child: Row(
// // children: [
// // Utils.buildSvgWithAssets(
// // icon: AppAssets.prescription_item_icon,
// // width: 40.h,
// // height: 40.h,
// // ),
// // SizedBox(width: 8.h),
// // Row(
// // mainAxisSize: MainAxisSize.max,
// // children: [
// // Column(
// // children: [
// // prescriptionVM.prescriptionDetailsList[index].itemDescription!
// // .toText12(isBold: true, maxLine: 1),
// // "Prescribed By: ${widget.patientAppointmentHistoryResponseModel.doctorTitle} ${widget.patientAppointmentHistoryResponseModel.doctorNameObj}"
// // .needTranslation
// // .toText10(
// // weight: FontWeight.w500,
// // color: AppColors.greyTextColor,
// // letterSpacing: -0.4),
// // ],
// // ),
// // SizedBox(width: 68.w),
// // Transform.flip(
// // flipX: appState.isArabic(),
// // child: Utils.buildSvgWithAssets(
// // icon: AppAssets.forward_arrow_icon,
// // iconColor: AppColors.blackColor,
// // width: 18.w,
// // height: 13.h,
// // fit: BoxFit.contain,
// // ),
// // ),
// // ],
// // ),
// // ],
// // ),
// // ),
// // ),
// // );
// // },
// // separatorBuilder: (BuildContext cxt, int index) => SizedBox(height: 16.h),
// // ).onPress(() {
// // prescriptionVM.setPrescriptionsDetailsLoading();
// // Navigator.of(context).push(
// // CustomPageRoute(
// // page: PrescriptionDetailPage(prescriptionsResponseModel: getPrescriptionRequestModel()),
// // ),
// // );
// // }),
// SizedBox(height: 16.h),
// const Divider(color: AppColors.dividerColor),
// SizedBox(height: 16.h),
// // Wrap(
// // runSpacing: 6.w,
// // children: [
// // // Expanded(
// // // child: CustomButton(
// // // text: widget.prescriptionsResponseModel.isHomeMedicineDeliverySupported! ? LocaleKeys.resendOrder.tr(context: context) : LocaleKeys.prescriptionDeliveryError.tr(context: context),
// // // onPressed: () {},
// // // backgroundColor: AppColors.secondaryLightRedColor,
// // // borderColor: AppColors.secondaryLightRedColor,
// // // textColor: AppColors.primaryRedColor,
// // // fontSize: 14,
// // // fontWeight: FontWeight.w500,
// // // borderRadius: 12.h,
// // // height: 40.h,
// // // icon: AppAssets.appointment_calendar_icon,
// // // iconColor: AppColors.primaryRedColor,
// // // iconSize: 16.h,
// // // ),
// // // ),
// // // SizedBox(width: 16.h),
// // Expanded(
// // child: CustomButton(
// // text: "Refill & Delivery".needTranslation,
// // onPressed: () {
// // Navigator.of(context)
// // .push(
// // CustomPageRoute(
// // page: PrescriptionsListPage(),
// // ),
// // )
// // .then((val) {
// // prescriptionsViewModel.setPrescriptionsDetailsLoading();
// // prescriptionsViewModel.getPrescriptionDetails(getPrescriptionRequestModel());
// // });
// // },
// // backgroundColor: AppColors.secondaryLightRedColor,
// // borderColor: AppColors.secondaryLightRedColor,
// // textColor: AppColors.primaryRedColor,
// // fontSize: 14.f,
// // fontWeight: FontWeight.w500,
// // borderRadius: 12.r,
// // height: 40.h,
// // icon: AppAssets.requests,
// // iconColor: AppColors.primaryRedColor,
// // iconSize: 16.h,
// // ),
// // ),
// //
// // SizedBox(width: 16.w),
// // Expanded(
// // child: CustomButton(
// // text: "All Prescriptions".needTranslation,
// // onPressed: () {
// // Navigator.of(context)
// // .push(
// // CustomPageRoute(
// // page: PrescriptionsListPage(),
// // ),
// // )
// // .then((val) {
// // prescriptionsViewModel.setPrescriptionsDetailsLoading();
// // prescriptionsViewModel.getPrescriptionDetails(getPrescriptionRequestModel());
// // });
// // },
// // backgroundColor: AppColors.secondaryLightRedColor,
// // borderColor: AppColors.secondaryLightRedColor,
// // textColor: AppColors.primaryRedColor,
// // fontSize: 14.f,
// // fontWeight: FontWeight.w500,
// // borderRadius: 12.r,
// // height: 40.h,
// // icon: AppAssets.requests,
// // iconColor: AppColors.primaryRedColor,
// // iconSize: 16.h,
// // ),
// // ),
// // ],
// // ),
// ],
// ),
// );
// }),
// ],
// ),
] ,
) . paddingAll ( 24. w ) ,
) ,
) ,
) ,
Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 24. r ,
hasShadow: true ,
) ,
child: SizedBox (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
if ( widget . patientAppointmentHistoryResponseModel . nextAction = = 15 | |
widget . patientAppointmentHistoryResponseModel . nextAction = = 20 )
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
LocaleKeys . amountBeforeTax . tr ( ) . toText18 ( isBold: true ) ,
Utils . getPaymentAmountWithSymbol (
widget . patientAppointmentHistoryResponseModel . patientShare ! . toString ( ) . toText16 ( isBold: true ) ,
AppColors . blackColor ,
13 ,
isSaudiCurrency: true ) ,
] ,
) ,
SizedBox ( height: 4. h ) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Expanded (
child: LocaleKeys . upcomingPaymentNow
. tr ( context: context )
. toText12 ( fontWeight: FontWeight . w500 , color: AppColors . greyTextColor ) ) ,
" VAT 15%( ${ widget . patientAppointmentHistoryResponseModel . patientTaxAmount } ) "
. toText14 ( isBold: true , color: AppColors . greyTextColor , letterSpacing: - 2 ) ,
] ,
) ,
SizedBox ( height: 18. h ) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
SizedBox (
width: 150. h ,
child: Utils . getPaymentMethods ( ) ,
) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Utils . getPaymentAmountWithSymbol (
widget . patientAppointmentHistoryResponseModel . patientShareWithTax ! . toString ( ) . toText24 ( isBold: true ) ,
AppColors . blackColor ,
17 ,
isSaudiCurrency: true ) ,
] ,
) ,
] ,
)
] ,
) . paddingOnly ( left: 16. h , top: 24. h , right: 16. h , bottom: 0. h ) ,
AppointmentType . isArrived ( widget . patientAppointmentHistoryResponseModel )
? CustomButton (
text: LocaleKeys . rebookAppointment . tr ( ) ,
onPressed: ( ) {
openDoctorScheduleCalendar ( ) ;
} ,
backgroundColor: AppColors . successColor ,
borderColor: AppColors . successColor ,
textColor: AppColors . whiteColor ,
fontSize: 16. f ,
fontWeight: FontWeight . w500 ,
borderRadius: 12. r ,
padding: EdgeInsets . symmetric ( horizontal: 10. w ) ,
height: 50. h ,
icon: AppAssets . add_icon ,
iconColor: AppColors . whiteColor ,
iconSize: 18. h ,
) . paddingSymmetrical ( 16. h , 24. h )
: CustomButton (
text: AppointmentType . getNextActionText ( widget . patientAppointmentHistoryResponseModel . nextAction ) ,
onPressed: ( ) {
myAppointmentsViewModel . setIsAppointmentDataToBeLoaded ( true ) ;
handleAppointmentNextAction ( widget . patientAppointmentHistoryResponseModel . nextAction ) ;
} ,
backgroundColor: AppointmentType . getNextActionButtonColor ( widget . patientAppointmentHistoryResponseModel . nextAction ) ,
borderColor:
AppointmentType . getNextActionButtonColor ( widget . patientAppointmentHistoryResponseModel . nextAction ) . withOpacity ( 0.01 ) ,
textColor: widget . patientAppointmentHistoryResponseModel . nextAction = = 15 ? AppColors . textColor : AppColors . whiteColor ,
fontSize: 16. f ,
fontWeight: FontWeight . w500 ,
borderRadius: 12. r ,
padding: EdgeInsets . symmetric ( horizontal: 10. w ) ,
height: 56. h ,
icon: AppointmentType . getNextActionIcon ( widget . patientAppointmentHistoryResponseModel . nextAction ) ,
iconColor: AppColors . whiteColor ,
iconSize: 18. h ,
) . paddingSymmetrical ( 16. h , 24. h ) ,
] ,
) ,
) ,
) ,
] ,
) ,
) ;
}
openDoctorScheduleCalendar ( ) async {
DoctorsListResponseModel doctor = DoctorsListResponseModel (
clinicID: widget . patientAppointmentHistoryResponseModel . clinicID ,
projectID: widget . patientAppointmentHistoryResponseModel . projectID ,
doctorID: widget . patientAppointmentHistoryResponseModel . doctorID ,
doctorImageURL: widget . patientAppointmentHistoryResponseModel . doctorImageURL ,
doctorTitle: widget . patientAppointmentHistoryResponseModel . doctorTitle ,
name: widget . patientAppointmentHistoryResponseModel . doctorNameObj ,
nationalityFlagURL: " https://hmgwebservices.com/Images/flag/SYR.png " ,
speciality: [ ] ,
clinicName: widget . patientAppointmentHistoryResponseModel . clinicName ,
projectName: widget . patientAppointmentHistoryResponseModel . projectName ,
) ;
bookAppointmentsViewModel . setSelectedDoctor ( doctor ) ;
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . fetchingDoctorSchedulePleaseWait . tr ( ) ) ;
await bookAppointmentsViewModel . getDoctorFreeSlots (
isBookingForLiveCare: false ,
onSuccess: ( dynamic respData ) async {
LoaderBottomSheet . hideLoader ( ) ;
showCommonBottomSheetWithoutHeight (
title: LocaleKeys . pickADate . tr ( ) ,
context ,
child: AppointmentCalendar ( ) ,
isFullScreen: false ,
isCloseButtonVisible: true ,
callBackFunc: ( ) { } ,
) ;
} ,
onError: ( err ) {
LoaderBottomSheet . hideLoader ( ) ;
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: err ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ) ;
}
Future < void > handleAppointmentNextAction ( nextAction ) async {
switch ( nextAction ) {
case 0 :
break ;
case 10 :
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . confirmingAppointmentPleaseWait . tr ( ) ) ;
await myAppointmentsViewModel . confirmAppointment (
patientAppointmentHistoryResponseModel: widget . patientAppointmentHistoryResponseModel ,
onSuccess: ( apiResponse ) {
LoaderBottomSheet . hideLoader ( ) ;
myAppointmentsViewModel . setIsAppointmentDataToBeLoaded ( true ) ;
myAppointmentsViewModel . getPatientAppointments ( true , false ) ;
showCommonBottomSheet ( context , child: Utils . getSuccessWidget ( loadingText: LocaleKeys . appointmentConfirmedSuccessfully . tr ( ) ) , callBackFunc: ( str ) {
Navigator . of ( context ) . pop ( ) ;
} ,
title: " " ,
height: ResponsiveExtension . screenHeight * 0.3 ,
isCloseButtonVisible: true ,
isDismissible: false ,
isFullScreen: false ,
isSuccessDialog: true ) ;
} ) ;
// LoaderBottomSheet.hideLoader();
case 15 :
break ;
case 20 :
myAppointmentsViewModel . setIsPatientAppointmentShareLoading ( true ) ;
Navigator . of ( context ) . push (
CustomPageRoute (
page: AppointmentPaymentPage ( patientAppointmentHistoryResponseModel: widget . patientAppointmentHistoryResponseModel ) ,
) ,
) ;
case 50 :
// return LocaleKeys.confirmLiveCare.tr();
case 90 :
showCommonBottomSheetWithoutHeight ( context ,
title: LocaleKeys . onlineCheckIn . tr ( ) ,
child: AppointmentCheckinBottomSheet (
patientAppointmentHistoryResponseModel: widget . patientAppointmentHistoryResponseModel ,
myAppointmentsViewModel: myAppointmentsViewModel ,
) ,
callBackFunc: ( ) { } ,
isFullScreen: false ) ;
default :
// return "No Action".needTranslation;
}
}
PatientPrescriptionsResponseModel getPrescriptionRequestModel ( ) {
return PatientPrescriptionsResponseModel (
appointmentNo: widget . patientAppointmentHistoryResponseModel . appointmentNo ,
setupID: widget . patientAppointmentHistoryResponseModel . setupID ,
episodeID: widget . patientAppointmentHistoryResponseModel . episodeID ,
clinicID: widget . patientAppointmentHistoryResponseModel . clinicID ,
projectID: widget . patientAppointmentHistoryResponseModel . projectID ,
dischargeNo: 0 ,
isInOutPatient: widget . patientAppointmentHistoryResponseModel . isInOutPatient ,
isHomeMedicineDeliverySupported: false ,
doctorImageURL: widget . patientAppointmentHistoryResponseModel . doctorImageURL ,
doctorName: " ${ widget . patientAppointmentHistoryResponseModel . doctorTitle } ${ widget . patientAppointmentHistoryResponseModel . doctorNameObj } " ,
appointmentDate: widget . patientAppointmentHistoryResponseModel . appointmentDate ,
clinicDescription: widget . patientAppointmentHistoryResponseModel . clinicName ,
decimalDoctorRate: widget . patientAppointmentHistoryResponseModel . decimalDoctorRate ,
name: widget . patientAppointmentHistoryResponseModel . projectName ,
) ;
}
}