@ -1,7 +1,9 @@
import ' dart:developer ' ;
import ' dart:io ' ;
import ' package:diplomaticquarterapp/analytics/google-analytics.dart ' ;
import ' package:diplomaticquarterapp/config/shared_pref_kay.dart ' ;
import ' package:diplomaticquarterapp/core/enum/PayfortEnums.dart ' ;
import ' package:diplomaticquarterapp/core/model/ImagesInfo.dart ' ;
import ' package:diplomaticquarterapp/core/viewModels/project_view_model.dart ' ;
import ' package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart ' ;
@ -10,6 +12,7 @@ import 'package:diplomaticquarterapp/models/Appointments/OBGyneProcedureListResp
import ' package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart ' ;
import ' package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart ' ;
import ' package:diplomaticquarterapp/models/Authentication/authenticated_user.dart ' ;
import ' package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart ' ;
import ' package:diplomaticquarterapp/models/anicllary-orders/ancillary_order_list_model.dart ' ;
import ' package:diplomaticquarterapp/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart ' ;
import ' package:diplomaticquarterapp/pages/BookAppointment/QRCode.dart ' ;
@ -20,6 +23,10 @@ import 'package:diplomaticquarterapp/pages/ToDoList/widgets/paymentDialog.dart';
import ' package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart ' ;
import ' package:diplomaticquarterapp/pages/landing/landing_page.dart ' ;
import ' package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart ' ;
import ' package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart ' ;
import ' package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart ' ;
import ' package:diplomaticquarterapp/services/payfort_services/payfort_project_details_resp_model.dart ' ;
import ' package:diplomaticquarterapp/services/payfort_services/payfort_view_model.dart ' ;
import ' package:diplomaticquarterapp/theme/colors.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_shared_preferences.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.dart ' ;
@ -47,11 +54,7 @@ import 'package:rating_bar/rating_bar.dart';
class ToDo extends StatefulWidget {
PatientShareResponse patientShareResponse ;
List < AppoitmentAllHistoryResultList > appoList = [ ] ;
List < AncillaryOrdersListModel > ancillaryLists = [ ] ;
List < OBGyneProcedureListResponse > obGyneAppoList = [ ] ;
var languageID ;
MyInAppBrowser browser ;
bool isShowAppBar = true ;
Function onBackClick ;
@ -84,6 +87,12 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
bool isInsured = false ;
bool isEligible = false ;
bool isCash = false ;
MyInAppBrowser browser ;
List < AppoitmentAllHistoryResultList > appoList = [ ] ;
List < AncillaryOrdersListModel > ancillaryLists = [ ] ;
List < OBGyneProcedureListResponse > obGyneAppoList = [ ] ;
String transID ;
@ override
void initState ( ) {
@ -102,6 +111,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
@ override
void dispose ( ) {
super . dispose ( ) ;
/ / getToDoCount ( ) ;
_tabController . dispose ( ) ;
}
@ -161,15 +171,15 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
child: AppExpandableNotifier (
isExpand: true ,
hasCounter: true ,
counter: widget. appoList. length . toString ( ) ,
counter: appoList. length . toString ( ) ,
title: TranslationBase . of ( context ) . appointments ,
bodyWidget: widget. appoList. length ! = 0
bodyWidget: appoList. length ! = 0
? ListView . builder (
scrollDirection: Axis . vertical ,
shrinkWrap: true ,
physics: ScrollPhysics ( ) ,
padding: EdgeInsets . all ( 0.0 ) ,
itemCount: widget. appoList. length ,
itemCount: appoList. length ,
itemBuilder: ( context , index ) {
return Container (
width: double . infinity ,
@ -189,12 +199,12 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
children: [
Padding (
padding: const EdgeInsets . only ( top: 4.0 ) ,
child: widget. appoList[ index ] . clinicID = = 265
child: appoList[ index ] . clinicID = = 265
? Container (
margin: EdgeInsets . only ( left: 5.0 , right: 5.0 ) ,
child: SvgPicture . asset ( " assets/images/new/CoronaIcon.svg " , width: 35.0 , height: 35.0 ) ,
)
: widget. appoList[ index ] . isLiveCareAppointment
: appoList[ index ] . isLiveCareAppointment
? SvgPicture . asset ( " assets/images/new/virtual.svg " )
: SvgPicture . asset ( " assets/images/new/hospital-visit.svg " ) ,
) ,
@ -204,9 +214,9 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
Padding (
padding: const EdgeInsets . only ( left: 8.0 , right: 8.0 ) ,
child: Text (
widget. appoList[ index ] . clinicID = = 265
appoList[ index ] . clinicID = = 265
? TranslationBase . of ( context ) . covidTestTodo
: widget. appoList[ index ] . isLiveCareAppointment
: appoList[ index ] . isLiveCareAppointment
? TranslationBase . of ( context ) . liveCareAppo
: TranslationBase . of ( context ) . walkinAppo ,
style: TextStyle ( fontSize: 12 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.48 ) ) ,
@ -214,8 +224,8 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
Padding (
padding: const EdgeInsets . only ( left: 8.0 , right: 8.0 ) ,
child: CountdownTimer (
controller: new CountdownTimerController (
endTime: DateTime . now ( ) . millisecondsSinceEpoch + ( widget . appoList [ index ] . remaniningHoursTocanPay * 1000 ) * 60 ) ,
controller:
new CountdownTimerController ( endTime: DateTime . now ( ) . millisecondsSinceEpoch + ( appoList [ index ] . remaniningHoursTocanPay * 1000 ) * 60 ) ,
widgetBuilder: ( _ , CurrentRemainingTime time ) {
return time ! = null
? Text (
@ -235,17 +245,17 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
child: Container (
child: InkWell (
onTap: ( ) {
performNextAction ( widget. appoList[ index ] ) ;
performNextAction ( appoList[ index ] ) ;
} ,
child: Container (
padding: EdgeInsets . symmetric ( vertical: 8 , horizontal: 14 ) ,
decoration: BoxDecoration (
color: getNextActionButtonColor ( widget. appoList[ index ] . nextAction ) ,
color: getNextActionButtonColor ( appoList[ index ] . nextAction ) ,
border: Border . all ( color: Colors . white , width: 1 ) ,
borderRadius: BorderRadius . circular ( 6 ) ,
) ,
child: Text (
getNextActionText ( widget. appoList[ index ] . nextAction ) ,
getNextActionText ( appoList[ index ] . nextAction ) ,
textAlign: TextAlign . center ,
style: TextStyle ( fontSize: 12 , fontWeight: FontWeight . w600 , color: Colors . white , letterSpacing: - 0.4 ) ,
) ,
@ -258,7 +268,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
Padding (
padding: const EdgeInsets . only ( top: 8.0 ) ,
child: Text (
widget. appoList[ index ] . doctorTitle + " " + widget . appoList [ index ] . doctorNameObj ,
appoList[ index ] . doctorTitle + " " + appoList [ index ] . doctorNameObj ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: Color ( 0xff2E303A ) , letterSpacing: - 0.64 , height: 25 / 16 ) ,
) ,
) ,
@ -266,8 +276,8 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
mainAxisSize: MainAxisSize . min ,
children: < Widget > [
LargeAvatar (
name: widget. appoList[ index ] . doctorTitle + " " + widget . appoList [ index ] . doctorNameObj ,
url: widget. appoList[ index ] . doctorImageURL ,
name: appoList[ index ] . doctorTitle + " " + appoList [ index ] . doctorNameObj ,
url: appoList[ index ] . doctorImageURL ,
width: 52 ,
height: 52 ,
) ,
@ -277,32 +287,32 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . min ,
children: < Widget > [
MyRichText ( TranslationBase . of ( context ) . clinic + " : " , widget. appoList[ index ] . clinicName , projectViewModel . isArabic ) ,
MyRichText ( TranslationBase . of ( context ) . clinic + " : " , appoList[ index ] . clinicName , projectViewModel . isArabic ) ,
/ / MyRichText ( TranslationBase . of ( context ) . appointmentDate + " : " ,
/ / DateUtil . getDayMonthYearDateFormatted ( DateUtil . convertStringToDate ( widget. appoList[ index ] . appointmentDate ) ) + " " + widget . appoList [ index ] . startTime . substring ( 0 , 5 ) , projectViewModel . isArabic ) ,
/ / DateUtil . getDayMonthYearDateFormatted ( DateUtil . convertStringToDate ( appoList[ index ] . appointmentDate ) ) + " " + appoList [ index ] . startTime . substring ( 0 , 5 ) , projectViewModel . isArabic ) ,
/ / Timezone changes
widget. appoList[ index ] . isLiveCareAppointment
appoList[ index ] . isLiveCareAppointment
? MyRichText (
TranslationBase . of ( context ) . appointmentDate + " : " ,
DateUtil . getDayMonthYearDateFormatted ( DateUtil . convertStringToDate ( widget. appoList[ index ] . appointmentDate ) ) +
DateUtil . getDayMonthYearDateFormatted ( DateUtil . convertStringToDate ( appoList[ index ] . appointmentDate ) ) +
" " +
DateUtil . convertStringToDate ( widget. appoList[ index ] . appointmentDate ) . toString ( ) . split ( " " ) [ 1 ] . substring ( 0 , 5 ) ,
DateUtil . convertStringToDate ( appoList[ index ] . appointmentDate ) . toString ( ) . split ( " " ) [ 1 ] . substring ( 0 , 5 ) ,
projectViewModel . isArabic )
: MyRichText (
TranslationBase . of ( context ) . appointmentDate + " : " ,
DateUtil . getDayMonthYearDateFormatted ( DateUtil . convertStringToDate ( widget. appoList[ index ] . appointmentDate ) ) +
DateUtil . getDayMonthYearDateFormatted ( DateUtil . convertStringToDate ( appoList[ index ] . appointmentDate ) ) +
" " +
widget. appoList[ index ] . startTime . substring ( 0 , 5 ) ,
appoList[ index ] . startTime . substring ( 0 , 5 ) ,
projectViewModel . isArabic ) ,
MyRichText ( TranslationBase . of ( context ) . branch , widget. appoList[ index ] . projectName , projectViewModel . isArabic ) ,
MyRichText ( TranslationBase . of ( context ) . branch , appoList[ index ] . projectName , projectViewModel . isArabic ) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
mainAxisSize: MainAxisSize . max ,
children: < Widget > [
RatingBar . readOnly (
initialRating: widget. appoList[ index ] . actualDoctorRate . toDouble ( ) ,
initialRating: appoList[ index ] . actualDoctorRate . toDouble ( ) ,
size: 16.0 ,
filledColor: Color ( 0XFFD02127 ) ,
emptyColor: Color ( 0XFFD02127 ) ,
@ -321,13 +331,13 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
Padding (
padding: const EdgeInsets . only ( top: 12.0 ) ,
child: Text (
getNextActionDescription ( widget. appoList[ index ] . nextAction ) ,
getNextActionDescription ( appoList[ index ] . nextAction ) ,
style: TextStyle ( fontSize: 10 , fontWeight: FontWeight . w600 , color: Color ( 0xff2E303A ) , letterSpacing: - 0.48 , height: 25 / 16 ) ,
) ,
) ,
InkWell (
onTap: ( ) {
navigateToAppointmentDetails ( context , widget. appoList[ index ] ) ;
navigateToAppointmentDetails ( context , appoList[ index ] ) ;
} ,
child: Padding (
padding: const EdgeInsets . only ( top: 0.0 ) ,
@ -356,9 +366,9 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
child: AppExpandableNotifier (
isExpand: true ,
hasCounter: true ,
counter: ( widget. ancillaryLists. isNotEmpty ) ? widget . ancillaryLists [ 0 ] . ancillaryOrderList . length . toString ( ) : " 0 " ,
counter: ( ancillaryLists. isNotEmpty ) ? ancillaryLists [ 0 ] . ancillaryOrderList . length . toString ( ) : " 0 " ,
title: TranslationBase . of ( context ) . anicllaryOrders ,
bodyWidget: widget. ancillaryLists. length ! = 0
bodyWidget: ancillaryLists. length ! = 0
? Container (
padding: EdgeInsets . all ( 12 ) ,
child: ListView . separated (
@ -367,18 +377,18 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
reverse: true ,
itemBuilder: ( context , index ) {
return DoctorCard (
onTap: ( ) = > ancillaryOrdersDetails ( widget. ancillaryLists[ 0 ] . ancillaryOrderList [ index ] , widget . ancillaryLists [ 0 ] . projectID ) ,
onTap: ( ) = > ancillaryOrdersDetails ( ancillaryLists[ 0 ] . ancillaryOrderList [ index ] , ancillaryLists [ 0 ] . projectID ) ,
isInOutPatient: true ,
name: TranslationBase . of ( context ) . dr . toString ( ) + " " + ( widget. ancillaryLists[ 0 ] . ancillaryOrderList [ index ] . doctorName ? ? " " ) ,
billNo: widget. ancillaryLists[ 0 ] . ancillaryOrderList [ index ] . orderNo . toString ( ) ,
name: TranslationBase . of ( context ) . dr . toString ( ) + " " + ( ancillaryLists[ 0 ] . ancillaryOrderList [ index ] . doctorName ? ? " " ) ,
billNo: ancillaryLists[ 0 ] . ancillaryOrderList [ index ] . orderNo . toString ( ) ,
profileUrl: " https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png " ,
subName: widget. ancillaryLists[ 0 ] . projectName ,
subName: ancillaryLists[ 0 ] . projectName ,
isLiveCareAppointment: false ,
date: DateUtil . convertStringToDate ( widget. ancillaryLists[ 0 ] . ancillaryOrderList [ index ] . orderDate ) ,
date: DateUtil . convertStringToDate ( ancillaryLists[ 0 ] . ancillaryOrderList [ index ] . orderDate ) ,
isSortByClinic: true ,
) ;
} ,
itemCount: widget. ancillaryLists[ 0 ] . ancillaryOrderList . length ,
itemCount: ancillaryLists[ 0 ] . ancillaryOrderList . length ,
separatorBuilder: ( context , index ) = > SizedBox ( height: 14 ) ,
) ,
)
@ -388,13 +398,13 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
) ,
) ,
Container (
child: widget. obGyneAppoList. length ! = 0
child: obGyneAppoList. length ! = 0
? ListView . builder (
scrollDirection: Axis . vertical ,
shrinkWrap: true ,
physics: ScrollPhysics ( ) ,
padding: EdgeInsets . all ( 0.0 ) ,
itemCount: widget. obGyneAppoList. length ,
itemCount: obGyneAppoList. length ,
itemBuilder: ( context , index ) {
return Container (
width: double . infinity ,
@ -432,7 +442,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
Container (
child: InkWell (
onTap: ( ) {
getOBGyneDoctorsList ( widget. obGyneAppoList[ index ] . projectID , widget. obGyneAppoList[ index ] . setupID , widget . obGyneAppoList [ index ] ) ;
getOBGyneDoctorsList ( obGyneAppoList[ index ] . projectID , obGyneAppoList[ index ] . setupID , obGyneAppoList [ index ] ) ;
} ,
child: Container (
padding: EdgeInsets . symmetric ( vertical: 8 , horizontal: 14 ) ,
@ -453,7 +463,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
Padding (
padding: const EdgeInsets . only ( top: 8.0 ) ,
child: Text (
TranslationBase . of ( context ) . dr + " " + widget. obGyneAppoList[ index ] . doctorName ,
TranslationBase . of ( context ) . dr + " " + obGyneAppoList[ index ] . doctorName ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: Color ( 0xff2E303A ) , letterSpacing: - 0.64 , height: 25 / 16 ) ,
) ,
) ,
@ -461,7 +471,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
mainAxisSize: MainAxisSize . min ,
children: < Widget > [
LargeAvatar (
name: TranslationBase . of ( context ) . dr + " " + widget. obGyneAppoList[ index ] . doctorName ,
name: TranslationBase . of ( context ) . dr + " " + obGyneAppoList[ index ] . doctorName ,
url: " https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png " ,
width: 52 ,
height: 52 ,
@ -472,12 +482,12 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . min ,
children: < Widget > [
MyRichText ( TranslationBase . of ( context ) . clinic + " : " , widget. obGyneAppoList[ index ] . clinicDescription , projectViewModel . isArabic ) ,
MyRichText ( TranslationBase . of ( context ) . clinic + " : " , obGyneAppoList[ index ] . clinicDescription , projectViewModel . isArabic ) ,
MyRichText (
TranslationBase . of ( context ) . orderDate + " : " ,
DateUtil . getDayMonthYearHourMinuteDateFormatted ( DateUtil . convertStringToDate ( widget. obGyneAppoList[ index ] . orderDate ) ) . split ( " " ) [ 0 ] ,
DateUtil . getDayMonthYearHourMinuteDateFormatted ( DateUtil . convertStringToDate ( obGyneAppoList[ index ] . orderDate ) ) . split ( " " ) [ 0 ] ,
projectViewModel . isArabic ) ,
MyRichText ( TranslationBase . of ( context ) . branch , widget. obGyneAppoList[ index ] . projectDescription , projectViewModel . isArabic ) ,
MyRichText ( TranslationBase . of ( context ) . branch , obGyneAppoList[ index ] . projectDescription , projectViewModel . isArabic ) ,
] ,
) ,
) ,
@ -545,9 +555,15 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
performNextAction ( AppoitmentAllHistoryResultList appo ) {
switch ( appo . nextAction ) {
case 0 :
/ / getAppoQR ( context , appo ) ;
break ;
case 10 :
confirmAppointment ( appo ) ;
break ;
case 15 :
AppToast . showErrorToast ( message: TranslationBase . of ( context ) . upcomingPaymentPending ) ;
break ;
case 20 :
getPatientShare ( context , appo ) ;
/ / checkPatientNphiesEligibility ( context , appo ) ;
@ -742,14 +758,14 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
service . getOBGyneOrdersList ( context ) . then ( ( res ) {
widget. obGyneAppoList. clear ( ) ;
obGyneAppoList. clear ( ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
if ( res [ ' HIS_OBGYNEProcedureGet_List ' ] . length ! = 0 ) {
widget. obGyneAppoList. clear ( ) ;
obGyneAppoList. clear ( ) ;
res [ ' HIS_OBGYNEProcedureGet_List ' ] . forEach ( ( v ) {
widget. obGyneAppoList. add ( new OBGyneProcedureListResponse . fromJson ( v ) ) ;
obGyneAppoList. add ( new OBGyneProcedureListResponse . fromJson ( v ) ) ;
} ) ;
} else {
/ / Navigator . of ( context ) . popAndPushNamed ( HOME ) ;
@ -769,7 +785,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
DoctorsListService service = new DoctorsListService ( ) ;
List < DoctorList > doctorsList = [ ] ;
List < PatientDoctorAppointmentList > _patientDoctorAppointmentListHospital = [ ] ;
service . getOBGyneDoctorsList ( projectID , setupID , context) . then ( ( res ) {
service . getOBGyneDoctorsList ( projectID , setupID , projectViewModel. isArabic ? 1 : 2 , context) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( res [ ' HIS_ObgyneUltrasoundDoctorsList ' ] [ 0 ] ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {
@ -815,30 +831,31 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
obGyneProcedureListResponse: obGyneProcedureListResponse ) ) ) ;
}
getPatientAppointmentHistory ( ) {
getPatientAppointmentHistory ( ) async {
int languageID = projectViewModel . isArabic ? 1 : 2 ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
service . getPatientAppointmentHistory ( true , context) . then ( ( res ) {
widget. appoList. clear ( ) ;
service . getPatientAppointmentHistory ( true , languageID, context) . then ( ( res ) {
appoList. clear ( ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
if ( res [ ' AppoimentAllHistoryResultList ' ] . length ! = 0 ) {
widget . appoList . clear ( ) ;
res[ ' AppoimentAllHistoryResultList ' ] . forEach ( ( v ) {
widget . appoList . add ( new AppoitmentAllHistoryResultList . fromJson ( v ) ) ;
} ) ;
}
if ( res [ ' AncillaryOrderList ' ] . length ! = 0 ) {
res[ ' AncillaryOrderList ' ] . forEach ( ( item ) {
widget . ancillaryLists . add ( AncillaryOrdersListModel . fromJson ( item ) ) ;
} ) ;
}
dataLoaded = true ;
if ( widget . isFromMyAppointments ) {
getPatientShare ( context , widget . appointment ) ;
}
} ) ;
if ( res [ ' AppoimentAllHistoryResultList ' ] . length ! = 0 ) {
appoList . clear ( ) ;
res [ ' AppoimentAllHistoryResultList ' ] . forEach ( ( v ) {
appoList. add ( new AppoitmentAllHistoryResultList . fromJson ( v ) ) ;
} ) ;
}
if ( res [ ' AncillaryOrderList ' ] . length ! = 0 ) {
res [ ' AncillaryOrderList ' ] . forEach( ( item ) {
ancillaryLists. add ( AncillaryOrdersListModel . fromJson ( item ) ) ;
} ) ;
}
dataLoaded = true ;
if ( widget . isFromMyAppointments ) {
performNextAction ( widget . appointment ) ;
widget . isFromMyAppointments = false ;
}
setState ( ( ) { } ) ;
} else {
AppToast . showErrorToast ( message: res [ ' ErrorEndUserMessage ' ] ) ;
}
@ -847,7 +864,19 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
GifLoaderDialogUtils . hideDialog ( context ) ;
err ! = null ? ? AppToast . showErrorToast ( message: err ) ;
} ) ;
/ / getAncillaryOrders ( ) ;
getToDoCount ( ) ;
}
getToDoCount ( ) {
toDoProvider . setState ( 0 , 0 , true , " 0 " ) ;
ClinicListService service = new ClinicListService ( ) ;
service . getActiveAppointmentNo ( context ) . then ( ( res ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
toDoProvider . setState ( res [ ' AppointmentActiveNumber ' ] , res [ ' AncillaryOrderListCount ' ] , true , " 0 " ) ;
} else { }
} ) . catchError ( ( err ) {
print ( err ) ;
} ) ;
}
checkPatientNphiesEligibility ( context , AppoitmentAllHistoryResultList appo ) {
@ -898,13 +927,14 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
}
getPatientShare ( context , AppoitmentAllHistoryResultList appo ) {
int languageID = projectViewModel . isArabic ? 1 : 2 ;
String errorMsg = " " ;
DoctorsListService service = new DoctorsListService ( ) ;
if ( appo . isLiveCareAppointment ) {
getLiveCareAppointmentPatientShare ( context , service , appo ) ;
} else {
GifLoaderDialogUtils . showMyDialog ( context ) ;
service . getPatientShare ( appo . appointmentNo . toString ( ) , appo . clinicID , appo . projectID , context) . then ( ( res ) {
service . getPatientShare ( appo . appointmentNo . toString ( ) , appo . clinicID , appo . projectID , languageID, context) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( res [ ' OnlineCheckInAppointments ' ] . length ! = 0 ) {
widget . patientShareResponse = new PatientShareResponse . fromJson ( res [ ' OnlineCheckInAppointments ' ] [ 0 ] ) ;
@ -945,7 +975,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
getLiveCareAppointmentPatientShare ( context , DoctorsListService service , AppoitmentAllHistoryResultList appo ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
service . getLiveCareAppointmentPatientShare ( appo . appointmentNo . toString ( ) , appo . clinicID , appo . projectID , context) . then ( ( res ) {
service . getLiveCareAppointmentPatientShare ( appo . appointmentNo . toString ( ) , appo . clinicID , appo . projectID , projectViewModel. isArabic ? 1 : 2 , context) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
widget . patientShareResponse = new PatientShareResponse . fromJson ( res ) ;
openPaymentDialog ( appo , widget . patientShareResponse ) ;
@ -969,23 +999,23 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
patientShareResponse . projectID = appo . projectID ;
patientShareResponse . isFollowup = appo . isFollowup ;
FlutterNfcKit . nfcAvailability . then ( ( value ) {
if ( value = = NFCAvailability . available ) {
PatientShareResponse patientShareResponse = new PatientShareResponse ( ) ;
patientShareResponse . doctorNameObj = appo . doctorNameObj ;
patientShareResponse . doctorSpeciality = appo . doctorSpeciality ;
patientShareResponse . projectName = appo . projectName ;
patientShareResponse . appointmentDate = appo . appointmentDate ;
patientShareResponse . appointmentNo = appo . appointmentNo ;
patientShareResponse . clinicID = appo . clinicID ;
patientShareResponse . projectID = appo . projectID ;
patientShareResponse . isFollowup = appo . isFollowup ;
navigateToQR ( context , " " , patientShareResponse , appo ) ;
projectViewModel . analytics . todoList . to_do_list_check_in ( appo ) ;
} else {
Utils . showErrorToast ( TranslationBase . of ( context ) . NFCNotSupported ) ;
}
} ) ;
/ / FlutterNfcKit . nfcAvailability . then ( ( value ) {
/ / if ( value = = NFCAvailability . available ) {
/ / PatientShareResponse patientShareResponse = new PatientShareResponse ( ) ;
patientShareResponse . doctorNameObj = appo . doctorNameObj ;
patientShareResponse . doctorSpeciality = appo . doctorSpeciality ;
patientShareResponse . projectName = appo . projectName ;
patientShareResponse . appointmentDate = appo . appointmentDate ;
patientShareResponse . appointmentNo = appo . appointmentNo ;
patientShareResponse . clinicID = appo . clinicID ;
patientShareResponse . projectID = appo . projectID ;
patientShareResponse . isFollowup = appo . isFollowup ;
navigateToQR ( context , " " , patientShareResponse , appo ) ;
projectViewModel . analytics . todoList . to_do_list_check_in ( appo ) ;
/ / } else {
/ / Utils . showErrorToast ( TranslationBase . of ( context ) . NFCNotSupported ) ;
/ / }
/ / } ) ;
projectViewModel . analytics . todoList . to_do_list_check_in ( appo ) ;
DoctorsListService service = new DoctorsListService ( ) ;
@ -1031,12 +1061,12 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
}
openPayment ( List < String > paymentMethod , AuthenticatedUser authenticatedUser , num amount , PatientShareResponse patientShareResponse , AppoitmentAllHistoryResultList appo ) {
widget. browser = new MyInAppBrowser ( onExitCallback: onBrowserExit , appo: appo , onLoadStartCallback: onBrowserLoadStart , context: context ) ;
widget. browser. openPaymentBrowser (
browser = new MyInAppBrowser ( onExitCallback: onBrowserExit , appo: appo , onLoadStartCallback: onBrowserLoadStart , context: context ) ;
transID = Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) ;
browser. openPaymentBrowser (
amount ,
" Appointment check in " ,
U tils. getAppointmentT ransID( appo . projectID , appo . clinicID , appo . appointmentNo ) ,
transID,
appo . projectID . toString ( ) ,
authenticatedUser . emailAddress ,
paymentMethod [ 0 ] ,
@ -1044,7 +1074,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
authenticatedUser . firstName ,
authenticatedUser . patientID ,
authenticatedUser ,
widget. browser,
browser,
appo . isLiveCareAppointment ,
" 2 " ,
appo . isLiveCareAppointment ? widget . patientShareResponse . clinicID . toString ( ) : " " ,
@ -1075,7 +1105,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
/ / if ( selectedPaymentMethod ! = " TAMARA " ) {
MyInAppBrowser . successURLS . forEach ( ( element ) {
if ( url . contains ( element ) ) {
if ( widget . browser . isOpened ( ) ) widget . browser . close ( ) ;
browser . close ( ) ;
MyInAppBrowser . isPaymentDone = true ;
return ;
}
@ -1085,7 +1115,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
/ / if ( selectedPaymentMethod ! = " TAMARA " ) {
MyInAppBrowser . errorURLS . forEach ( ( element ) {
if ( url . contains ( element ) ) {
if ( widget . browser . isOpened ( ) ) widget . browser . close ( ) ;
browser . close ( ) ;
MyInAppBrowser . isPaymentDone = false ;
return ;
}
@ -1096,7 +1126,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
onBrowserExit ( AppoitmentAllHistoryResultList appo , bool isPaymentMade ) {
print ( " onBrowserExit Called!!!! " ) ;
if ( selectedPaymentMethod = = " TAMARA " ) {
checkTamaraPaymentStatus ( U tils. getAppointmentT ransID( appo . projectID , appo . clinicID , appo . appointmentNo ) , appo ) ;
checkTamaraPaymentStatus ( transID, appo ) ;
/ / if ( tamaraPaymentStatus ! = null & & tamaraPaymentStatus . toLowerCase ( ) = = " approved " ) {
/ / updateTamaraRequestStatus ( " success " , " 14 " , Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) , tamaraOrderID , num . parse ( selectedInstallments ) , appo ) ;
/ / } else {
@ -1115,8 +1145,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
if ( res [ " status " ] . toString ( ) . toLowerCase ( ) = = " success " ) {
updateTamaraRequestStatus ( " success " , " 14 " , orderID , res [ " tamara_order_id " ] , num . parse ( selectedInstallments ) , appo ) ;
} else {
updateTamaraRequestStatus (
" Failed " , " 00 " , Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) , tamaraOrderID ! = null ? tamaraOrderID : " " , num . parse ( selectedInstallments ) , appo ) ;
updateTamaraRequestStatus ( " Failed " , " 00 " , transID , tamaraOrderID ! = null ? tamaraOrderID : " " , num . parse ( selectedInstallments ) , appo ) ;
}
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
@ -1185,7 +1214,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
final currency = projectViewModel . user . outSA = = 0 ? " sar " : ' aed ' ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
service . checkPaymentStatus ( U tils. getAppointmentT ransID( appo . projectID , appo . clinicID , appo . appointmentNo ) , false , context ) . then ( ( res ) {
service . checkPaymentStatus ( transID, false , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
String paymentInfo = res [ ' Response_Message ' ] ;
if ( paymentInfo = = ' Success ' ) {
@ -1250,10 +1279,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
addVIDARequestInsert ( String advanceNumber , String paymentReference , AppoitmentAllHistoryResultList appo ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
service
. insertVIDARequest ( appo . appointmentNo , appo . clinicID , appo . projectID , appo . serviceID , appo . doctorID , appo . appointmentDate ,
Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) , context )
. then ( ( res ) {
service . insertVIDARequest ( appo . appointmentNo , appo . clinicID , appo . projectID , appo . serviceID , appo . doctorID , appo . appointmentDate , transID , projectViewModel . isArabic ? 1 : 2 , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
getPatientAppointmentHistory ( ) ;
} ) . catchError ( ( err ) {
@ -1279,12 +1305,103 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
if ( value ! = null ) {
final appType = appo . isLiveCareAppointment ? ' livecare ' : ' regular ' ;
openPayment ( value , projectViewModel . user , double . parse ( patientShareResponse . patientShareWithTax . toString ( ) ) , patientShareResponse , appo ) ;
if ( selectedPaymentMethod = = " ApplePay " ) {
if ( projectViewModel . havePrivilege ( 103 ) ) {
startApplePay ( appo , patientShareResponse ) ;
} else {
openPayment ( value , projectViewModel . user , double . parse ( patientShareResponse . patientShareWithTax . toString ( ) ) , patientShareResponse , appo ) ;
}
} else {
openPayment ( value , projectViewModel . user , double . parse ( patientShareResponse . patientShareWithTax . toString ( ) ) , patientShareResponse , appo ) ;
}
projectViewModel . analytics . appointment . payment_method ( appointment_type: appType , clinic: appo . clinicName , payment_method: value [ 0 ] , payment_type: ' appointment ' ) ;
}
} ) ;
}
void startApplePay ( AppoitmentAllHistoryResultList appo , PatientShareResponse patientShareResponse ) async {
transID = Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) ;
print ( " TransactionID: $ transID " ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
LiveCareService service = new LiveCareService ( ) ;
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest ( ) ;
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel ;
await context . read < PayfortViewModel > ( ) . getProjectDetailsForPayfort ( projectId: appo . projectID , serviceId: ServiceTypeEnum . appointmentPayment . getIdFromServiceEnum ( ) ) . then ( ( value ) {
payfortProjectDetailsRespModel = value ;
} ) ;
applePayInsertRequest . clientRequestID = transID ;
applePayInsertRequest . clinicID = appo . clinicID ;
applePayInsertRequest . currency = projectViewModel . user . outSA = = 1 ? " AED " : " SAR " ;
/ / applePayInsertRequest . customerEmail = projectViewModel . authenticatedUserObject . user . emailAddress ;
applePayInsertRequest . customerEmail = " CustID_ ${ projectViewModel . user . patientID } @HMG.com " ;
applePayInsertRequest . customerID = projectViewModel . user . patientID ;
applePayInsertRequest . customerName = projectViewModel . user . firstName + " " + projectViewModel . user . lastName ;
applePayInsertRequest . deviceToken = await AppSharedPreferences ( ) . getString ( PUSH_TOKEN ) ;
applePayInsertRequest . voipToken = await AppSharedPreferences ( ) . getString ( ONESIGNAL_APNS_TOKEN ) ;
applePayInsertRequest . doctorID = appo . doctorID ;
applePayInsertRequest . projectID = appo . projectID . toString ( ) ;
applePayInsertRequest . serviceID = ServiceTypeEnum . appointmentPayment . getIdFromServiceEnum ( ) . toString ( ) ;
applePayInsertRequest . channelID = 3 ;
applePayInsertRequest . patientID = projectViewModel . user . patientID ;
applePayInsertRequest . patientTypeID = projectViewModel . user . patientType ;
applePayInsertRequest . patientOutSA = projectViewModel . user . outSA ;
applePayInsertRequest . appointmentDate = appo . appointmentDate ;
applePayInsertRequest . appointmentNo = appo . appointmentNo ;
applePayInsertRequest . orderDescription = " Appointment Payment " ;
applePayInsertRequest . liveServiceID = " 0 " ;
applePayInsertRequest . latitude = " 0.0 " ;
applePayInsertRequest . longitude = " 0.0 " ;
applePayInsertRequest . amount = patientShareResponse . patientShareWithTax . toString ( ) ;
applePayInsertRequest . isSchedule = appo . isLiveCareAppointment ? " 1 " : " 0 " ;
applePayInsertRequest . language = projectViewModel . isArabic ? ' ar ' : ' en ' ;
applePayInsertRequest . languageID = projectViewModel . isArabic ? 1 : 2 ;
applePayInsertRequest . userName = projectViewModel . user . patientID ;
applePayInsertRequest . responseContinueURL = " http://hmg.com/Documents/success.html " ;
applePayInsertRequest . backClickUrl = " http://hmg.com/Documents/success.html " ;
applePayInsertRequest . paymentOption = " ApplePay " ;
applePayInsertRequest . isMobSDK = true ;
applePayInsertRequest . merchantReference = transID ;
applePayInsertRequest . merchantIdentifier = payfortProjectDetailsRespModel . merchantIdentifier ;
applePayInsertRequest . commandType = " PURCHASE " ;
applePayInsertRequest . signature = payfortProjectDetailsRespModel . signature ;
applePayInsertRequest . accessCode = payfortProjectDetailsRespModel . accessCode ;
applePayInsertRequest . shaRequestPhrase = payfortProjectDetailsRespModel . shaRequest ;
applePayInsertRequest . shaResponsePhrase = payfortProjectDetailsRespModel . shaResponse ;
applePayInsertRequest . returnURL = " " ;
service . applePayInsertRequest ( applePayInsertRequest , context ) . then ( ( res ) async {
await context . read < PayfortViewModel > ( ) . initiateApplePayWithPayfort (
customerName: projectViewModel . user . firstName + " " + projectViewModel . user . lastName ,
/ / customerEmail: projectViewModel . authenticatedUserObject . user . emailAddress ,
customerEmail: " CustID_ ${ projectViewModel . user . patientID } @HMG.com " ,
orderDescription: " Appointment Payment " ,
orderAmount: double . parse ( patientShareResponse . patientShareWithTax . toString ( ) ) ,
merchantReference: transID ,
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel ,
currency: projectViewModel . user . outSA = = 1 ? " AED " : " SAR " ,
onFailed: ( failureResult ) async {
log ( " failureResult: ${ failureResult . toString ( ) } " ) ;
AppToast . showErrorToast ( message: failureResult . toString ( ) ) ;
} ,
onSuccess: ( successResult ) async {
log ( " Payfort: ${ successResult . responseMessage } " ) ;
await context . read < PayfortViewModel > ( ) . addPayfortApplePayResponse ( projectViewModel . user . patientID , result: successResult ) ;
checkPaymentStatus ( appo ) ;
} ,
projectId: appo . projectID ,
serviceTypeEnum: ServiceTypeEnum . appointmentPayment ,
) ;
} ) . catchError ( ( err ) {
print ( err ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
AppToast . showErrorToast ( message: err ) ;
} ) ;
}
confirmAppointment ( AppoitmentAllHistoryResultList appo ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
@ -1312,7 +1429,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
DoctorsListService service = new DoctorsListService ( ) ;
service
. insertVIDARequest ( appo . appointmentNo , appo . clinicID , appo . projectID , appo . serviceID , appo . doctorID , appo . appointmentDate ,
Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) , context)
Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) , projectViewModel. isArabic ? 1 : 2 , context)
. then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {