@ -39,6 +39,9 @@ class _clinic_listState extends State<ClinicList> {
int currentSelectedIndex = 0 ;
LiveCareClinicsListResponse liveCareClinicsListResponse ;
List < PatientERGetClinicsList > liveCareOnlineClinicsListResponse ;
List < PatientERGetClinicsList > liveCareOfflineClinicsListResponse ;
LiveCareScheduleClinicsListResponse liveCareScheduleClinicsListResponse ;
bool isDataLoaded = false ;
@ -62,8 +65,11 @@ class _clinic_listState extends State<ClinicList> {
@ override
void initState ( ) {
liveCareClinicsListResponse = new LiveCareClinicsListResponse ( ) ;
liveCareScheduleClinicsListResponse =
new LiveCareScheduleClinicsListResponse ( ) ;
liveCareOnlineClinicsListResponse = new List ( ) ;
liveCareOfflineClinicsListResponse = new List ( ) ;
liveCareScheduleClinicsListResponse = new LiveCareScheduleClinicsListResponse ( ) ;
WidgetsBinding . instance . addPostFrameCallback ( ( _ ) {
if ( ! isLiveCareTypeSelected ) {
@ -77,18 +83,14 @@ class _clinic_listState extends State<ClinicList> {
@ override
Widget build ( BuildContext context ) {
return SingleChildScrollView (
child: currentSelectedLiveCareType = = " immediate "
? getLiveCareImmediateClinicList ( )
: getLiveCareScheduleClinicList ( ) ) ;
return SingleChildScrollView ( child: currentSelectedLiveCareType = = " immediate " ? getLiveCareImmediateClinicList ( ) : getLiveCareScheduleClinicList ( ) ) ;
}
void startLiveCare ( ) {
bool isError = false ;
LiveCareService service = new LiveCareService ( ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
ERAppointmentFeesResponse erAppointmentFeesResponse =
new ERAppointmentFeesResponse ( ) ;
ERAppointmentFeesResponse erAppointmentFeesResponse = new ERAppointmentFeesResponse ( ) ;
service . getERAppointmentFees ( selectedClinicID , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( res [ ' HasAppointment ' ] = = true ) {
@ -98,9 +100,7 @@ class _clinic_listState extends State<ClinicList> {
erAppointmentFeesResponse = ERAppointmentFeesResponse . fromJson ( res ) ;
isError = false ;
}
if ( ! isError )
getERAppointmentTime (
erAppointmentFeesResponse . getERAppointmentFeesList ) ;
if ( ! isError ) getERAppointmentTime ( erAppointmentFeesResponse . getERAppointmentFeesList ) ;
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( err ) ;
@ -158,8 +158,7 @@ class _clinic_listState extends State<ClinicList> {
service . getERAppointmentTime ( selectedClinicID , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( res ) ;
showLiveCarePaymentDialog (
getERAppointmentFeesList , res [ ' WatingtimeInteger ' ] ) ;
showLiveCarePaymentDialog ( getERAppointmentFeesList , res [ ' WatingtimeInteger ' ] ) ;
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( err ) ;
@ -167,22 +166,16 @@ class _clinic_listState extends State<ClinicList> {
} ) ;
}
showLiveCarePaymentDialog (
GetERAppointmentFeesList getERAppointmentFeesList , int waitingTime ) {
showLiveCarePaymentDialog ( GetERAppointmentFeesList getERAppointmentFeesList , int waitingTime ) {
showGeneralDialog (
barrierColor: Colors . black . withOpacity ( 0.5 ) ,
transitionBuilder: ( context , a1 , a2 , widget ) {
final curvedValue =
Curves . easeInOutBack . transform ( a1 . value ) - 1.0 ;
final curvedValue = Curves . easeInOutBack . transform ( a1 . value ) - 1.0 ;
return Transform (
transform:
Matrix4 . translationValues ( 0.0 , curvedValue * 200 , 0.0 ) ,
transform: Matrix4 . translationValues ( 0.0 , curvedValue * 200 , 0.0 ) ,
child: Opacity (
opacity: a1 . value ,
child: LiveCarePaymentDialog (
getERAppointmentFeesList: getERAppointmentFeesList ,
waitingTime: waitingTime ,
clinicName: selectedClinicName ) ,
child: LiveCarePaymentDialog ( getERAppointmentFeesList: getERAppointmentFeesList , waitingTime: waitingTime , clinicName: selectedClinicName ) ,
) ,
) ;
} ,
@ -193,8 +186,7 @@ class _clinic_listState extends State<ClinicList> {
pageBuilder: ( context , animation1 , animation2 ) { } )
. then ( ( value ) {
if ( value ) {
if ( getERAppointmentFeesList . total = = " 0 " | |
getERAppointmentFeesList . total = = " 0.0 " ) {
if ( getERAppointmentFeesList . total = = " 0 " | | getERAppointmentFeesList . total = = " 0.0 " ) {
showLiveCareInfoDialog ( getERAppointmentFeesList ) ;
} else {
navigateToPaymentMethod ( getERAppointmentFeesList , context ) ;
@ -203,11 +195,9 @@ class _clinic_listState extends State<ClinicList> {
} ) ;
}
showLiveCareInfoDialog (
GetERAppointmentFeesList getERAppointmentFeesList ) async {
showLiveCareInfoDialog ( GetERAppointmentFeesList getERAppointmentFeesList ) async {
if ( await this . sharedPref . getObject ( USER_PROFILE ) ! = null ) {
var data = AuthenticatedUser . fromJson (
await this . sharedPref . getObject ( USER_PROFILE ) ) ;
var data = AuthenticatedUser . fromJson ( await this . sharedPref . getObject ( USER_PROFILE ) ) ;
setState ( ( ) {
authUser = data ;
} ) ;
@ -216,11 +206,9 @@ class _clinic_listState extends State<ClinicList> {
showGeneralDialog (
barrierColor: Colors . black . withOpacity ( 0.5 ) ,
transitionBuilder: ( context , a1 , a2 , widget ) {
final curvedValue =
Curves . easeInOutBack . transform ( a1 . value ) - 1.0 ;
final curvedValue = Curves . easeInOutBack . transform ( a1 . value ) - 1.0 ;
return Transform (
transform:
Matrix4 . translationValues ( 0.0 , curvedValue * 200 , 0.0 ) ,
transform: Matrix4 . translationValues ( 0.0 , curvedValue * 200 , 0.0 ) ,
child: Opacity (
opacity: a1 . value ,
child: LiveCareInfoDialog ( ) ,
@ -234,11 +222,8 @@ class _clinic_listState extends State<ClinicList> {
pageBuilder: ( context , animation1 , animation2 ) { } )
. then ( ( value ) {
if ( value ) {
if ( getERAppointmentFeesList . total = = " 0 " | |
getERAppointmentFeesList . total = = " 0.0 " ) {
addNewCallForPatientER ( authUser . patientID . toString ( ) +
" " +
DateTime . now ( ) . millisecondsSinceEpoch . toString ( ) ) ;
if ( getERAppointmentFeesList . total = = " 0 " | | getERAppointmentFeesList . total = = " 0.0 " ) {
addNewCallForPatientER ( authUser . patientID . toString ( ) + " " + DateTime . now ( ) . millisecondsSinceEpoch . toString ( ) ) ;
} else {
navigateToPaymentMethod ( getERAppointmentFeesList , context ) ;
}
@ -246,16 +231,14 @@ class _clinic_listState extends State<ClinicList> {
} ) ;
}
Future navigateToPaymentMethod (
GetERAppointmentFeesList getERAppointmentFeesList , context ) async {
Future navigateToPaymentMethod ( GetERAppointmentFeesList getERAppointmentFeesList , context ) async {
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList ( ) ;
appo . clinicID = selectedClinicID ;
appo . appointmentNo = DateTime . now ( ) . millisecondsSinceEpoch ;
if ( await this . sharedPref . getObject ( USER_PROFILE ) ! = null ) {
var data = AuthenticatedUser . fromJson (
await this . sharedPref . getObject ( USER_PROFILE ) ) ;
var data = AuthenticatedUser . fromJson ( await this . sharedPref . getObject ( USER_PROFILE ) ) ;
setState ( ( ) {
authUser = data ;
} ) ;
@ -264,32 +247,16 @@ class _clinic_listState extends State<ClinicList> {
Navigator . push ( context , FadePage ( page: PaymentMethod ( ) ) ) . then ( ( value ) {
print ( value ) ;
if ( value ! = null ) {
openPayment ( value , authUser ,
double . parse ( getERAppointmentFeesList . total ) , appo ) ;
openPayment ( value , authUser , double . parse ( getERAppointmentFeesList . total ) , appo ) ;
}
} ) ;
}
openPayment ( String paymentMethod , AuthenticatedUser authenticatedUser ,
double amount , AppoitmentAllHistoryResultList appo ) {
browser = new MyInAppBrowser (
onExitCallback: onBrowserExit ,
appo: appo ,
onLoadStartCallback: onBrowserLoadStart ) ;
browser . openPaymentBrowser (
amount ,
" LiveCare Payment " ,
Utils . getAppointmentTransID ( 12 , appo . clinicID , appo . appointmentNo ) ,
" 12 " ,
authenticatedUser . emailAddress ,
paymentMethod ,
authenticatedUser . patientType ,
authenticatedUser . firstName ,
authenticatedUser . patientID ,
authenticatedUser ,
browser ,
false ) ;
openPayment ( String paymentMethod , AuthenticatedUser authenticatedUser , double amount , AppoitmentAllHistoryResultList appo ) {
browser = new MyInAppBrowser ( onExitCallback: onBrowserExit , appo: appo , onLoadStartCallback: onBrowserLoadStart ) ;
browser . openPaymentBrowser ( amount , " LiveCare Payment " , Utils . getAppointmentTransID ( 12 , appo . clinicID , appo . appointmentNo ) , " 12 " , authenticatedUser . emailAddress , paymentMethod ,
authenticatedUser . patientType , authenticatedUser . firstName , authenticatedUser . patientID , authenticatedUser , browser , false , " 4 " , selectedClinicID . toString ( ) ) ;
}
onBrowserLoadStart ( String url ) {
@ -321,19 +288,13 @@ class _clinic_listState extends State<ClinicList> {
checkPaymentStatus ( AppoitmentAllHistoryResultList appo ) {
DoctorsListService service = new DoctorsListService ( ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
service
. checkPaymentStatus (
Utils . getAppointmentTransID (
appo . projectID , appo . clinicID , appo . appointmentNo ) ,
context )
. then ( ( res ) {
service . checkPaymentStatus ( Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( " Printing Payment Status Reponse!!!! " ) ;
print ( res ) ;
String paymentInfo = res [ ' Response_Message ' ] ;
if ( paymentInfo = = ' Success ' ) {
addNewCallForPatientER ( Utils . getAppointmentTransID (
appo . projectID , appo . clinicID , appo . appointmentNo ) ) ;
addNewCallForPatientER ( Utils . getAppointmentTransID ( appo . projectID , appo . clinicID , appo . appointmentNo ) ) ;
} else {
AppToast . showErrorToast ( message: res [ ' Response_Message ' ] ) ;
}
@ -347,12 +308,9 @@ class _clinic_listState extends State<ClinicList> {
addNewCallForPatientER ( String clientRequestID ) {
LiveCareService service = new LiveCareService ( ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
service
. addNewCallForPatientER ( selectedClinicID , clientRequestID , context )
. then ( ( res ) {
service . addNewCallForPatientER ( selectedClinicID , clientRequestID , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
AppToast . showSuccessToast (
message: " New Call has been added successfully " ) ;
AppToast . showSuccessToast ( message: " New Call has been added successfully " ) ;
widget . getLiveCareHistory ( ) ;
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
@ -374,13 +332,19 @@ class _clinic_listState extends State<ClinicList> {
print ( res [ ' PatientER_GetClinicsList ' ] . length ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
liveCareClinicsListResponse =
LiveCareClinicsListResponse . fromJson ( res ) ;
print ( liveCareClinicsListResponse . patientERGetClinicsList . length ) ;
selectedClinicID =
liveCareClinicsListResponse . patientERGetClinicsList [ 0 ] . serviceID ;
selectedClinicName = liveCareClinicsListResponse
. patientERGetClinicsList [ 0 ] . serviceName ;
liveCareOnlineClinicsListResponse . clear ( ) ;
liveCareClinicsListResponse = LiveCareClinicsListResponse . fromJson ( res ) ;
liveCareClinicsListResponse . patientERGetClinicsList . forEach ( ( clinic ) {
if ( clinic . isOnline = = 1 ) {
liveCareOnlineClinicsListResponse . add ( clinic ) ;
} else {
liveCareOfflineClinicsListResponse . add ( clinic ) ;
}
} ) ;
selectedClinicID = liveCareClinicsListResponse . patientERGetClinicsList [ 0 ] . serviceID ;
selectedClinicName = liveCareClinicsListResponse . patientERGetClinicsList [ 0 ] . serviceName ;
isDataLoaded = true ;
} ) ;
} else {
@ -403,14 +367,10 @@ class _clinic_listState extends State<ClinicList> {
print ( res [ ' ClinicsHaveScheduleList ' ] . length ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
liveCareScheduleClinicsListResponse =
LiveCareScheduleClinicsListResponse . fromJson ( res ) ;
print ( liveCareScheduleClinicsListResponse
. clinicsHaveScheduleList . length ) ;
selectedClinicID = liveCareScheduleClinicsListResponse
. clinicsHaveScheduleList [ 0 ] . serviceID ;
selectedClinicName = liveCareScheduleClinicsListResponse
. clinicsHaveScheduleList [ 0 ] . clinicDesc ;
liveCareScheduleClinicsListResponse = LiveCareScheduleClinicsListResponse . fromJson ( res ) ;
print ( liveCareScheduleClinicsListResponse . clinicsHaveScheduleList . length ) ;
selectedClinicID = liveCareScheduleClinicsListResponse . clinicsHaveScheduleList [ 0 ] . serviceID ;
selectedClinicName = liveCareScheduleClinicsListResponse . clinicsHaveScheduleList [ 0 ] . clinicDesc ;
isDataLoaded = true ;
} ) ;
} else {
@ -483,25 +443,15 @@ class _clinic_listState extends State<ClinicList> {
shrinkWrap: true ,
physics: ScrollPhysics ( ) ,
padding: EdgeInsets . all ( 0.0 ) ,
itemCount: liveCareScheduleClinicsListResponse
. clinicsHaveScheduleList . length ,
itemCount: liveCareScheduleClinicsListResponse . clinicsHaveScheduleList . length ,
itemBuilder: ( context , index ) {
return InkWell (
onTap: ( ) {
updateSelectedScheduleIndex (
liveCareScheduleClinicsListResponse
. clinicsHaveScheduleList [ index ] ) ;
updateSelectedScheduleIndex ( liveCareScheduleClinicsListResponse . clinicsHaveScheduleList [ index ] ) ;
} ,
child: ScheduleClinicCard (
isSelected: selectedClinicID = =
liveCareScheduleClinicsListResponse
. clinicsHaveScheduleList [ index ]
. serviceID
? true
: false ,
clinicsHaveScheduleList:
liveCareScheduleClinicsListResponse
. clinicsHaveScheduleList [ index ] ,
isSelected: selectedClinicID = = liveCareScheduleClinicsListResponse . clinicsHaveScheduleList [ index ] . serviceID ? true : false ,
clinicsHaveScheduleList: liveCareScheduleClinicsListResponse . clinicsHaveScheduleList [ index ] ,
languageID: languageID ,
) ,
) ;
@ -555,39 +505,51 @@ class _clinic_listState extends State<ClinicList> {
children: < Widget > [
Container (
margin: EdgeInsets . all ( 15.0 ) ,
child: Text ( " Online Clinics: " ,
style: TextStyle (
fontSize: 20.0 , fontWeight: FontWeight . bold ) ) ,
child: Text ( " Online Clinics: " , style: TextStyle ( fontSize: 20.0 , fontWeight: FontWeight . bold ) ) ,
) ,
ListView . builder (
scrollDirection: Axis . vertical ,
shrinkWrap: true ,
physics: ScrollPhysics ( ) ,
padding: EdgeInsets . all ( 0.0 ) ,
/ / itemCount: liveCareClinicsListResponse . patientERGetClinicsList . length ,
itemCount: liveCareOnlineClinicsListResponse . length ,
itemBuilder: ( context , index ) {
return InkWell (
onTap: ( ) {
updateSelectedIndex ( liveCareOnlineClinicsListResponse [ index ] ) ;
} ,
child: ClinicCard (
isSelected: selectedClinicID = = liveCareOnlineClinicsListResponse [ index ] . serviceID ? true : false ,
patientERGetClinicsList: liveCareOnlineClinicsListResponse [ index ] ,
languageID: languageID ,
) ,
) ;
} ,
) ,
Container (
margin: EdgeInsets . all ( 15.0 ) ,
child: Text ( " Offline Clinics: " , style: TextStyle ( fontSize: 20.0 , fontWeight: FontWeight . bold ) ) ,
) ,
ListView . builder (
scrollDirection: Axis . vertical ,
shrinkWrap: true ,
physics: ScrollPhysics ( ) ,
padding: EdgeInsets . all ( 0.0 ) ,
itemCount: liveCareClinicsListResponse
. patientERGetClinicsList . length ,
/ / itemCount: liveCareClinicsListResponse . patientERGetClinicsList . length ,
itemCount: liveCareOfflineClinicsListResponse . length ,
itemBuilder: ( context , index ) {
return InkWell (
onTap: ( ) {
if ( liveCareClinicsListResponse
. patientERGetClinicsList [ index ] . isOnline = =
1 ) {
updateSelectedIndex ( liveCareClinicsListResponse
. patientERGetClinicsList [ index ] ) ;
} else {
AppToast . showErrorToast (
message: " Clinic is offline " ) ;
}
/ / if ( liveCareClinicsListResponse . patientERGetClinicsList [ index ] . isOnline = = 1 ) {
/ / updateSelectedIndex ( liveCareOnlineClinicsListResponse [ index ] ) ;
/ / } else {
/ / AppToast . showErrorToast ( message: " Clinic is offline " ) ;
/ / }
} ,
child: ClinicCard (
isSelected: selectedClinicID = =
liveCareClinicsListResponse
. patientERGetClinicsList [ index ]
. serviceID
? true
: false ,
patientERGetClinicsList: liveCareClinicsListResponse
. patientERGetClinicsList [ index ] ,
isSelected: selectedClinicID = = liveCareOfflineClinicsListResponse [ index ] . serviceID ? true : false ,
patientERGetClinicsList: liveCareOfflineClinicsListResponse [ index ] ,
languageID: languageID ,
) ,
) ;
@ -633,11 +595,8 @@ class _clinic_listState extends State<ClinicList> {
List < DoctorList > doctorsList = [ ] ;
LiveCareService service = new LiveCareService ( ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
List < PatientDoctorAppointmentList > _patientDoctorAppointmentListHospital =
List ( ) ;
service
. getLiveCareScheduledDoctorList ( context , selectedClinicID )
. then ( ( res ) {
List < PatientDoctorAppointmentList > _patientDoctorAppointmentListHospital = List ( ) ;
service . getLiveCareScheduledDoctorList ( context , selectedClinicID ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
@ -647,34 +606,23 @@ class _clinic_listState extends State<ClinicList> {
} ) ;
doctorsList . forEach ( ( element ) {
List < PatientDoctorAppointmentList > doctorByHospital =
_patientDoctorAppointmentListHospital
. where (
( elementClinic ) = >
elementClinic . filterName = = element . projectName ,
)
. toList ( ) ;
List < PatientDoctorAppointmentList > doctorByHospital = _patientDoctorAppointmentListHospital
. where (
( elementClinic ) = > elementClinic . filterName = = element . projectName ,
)
. toList ( ) ;
if ( doctorByHospital . length ! = 0 ) {
_patientDoctorAppointmentListHospital [
_patientDoctorAppointmentListHospital
. indexOf ( doctorByHospital [ 0 ] ) ]
. patientDoctorAppointmentList
. add ( element ) ;
_patientDoctorAppointmentListHospital [ _patientDoctorAppointmentListHospital . indexOf ( doctorByHospital [ 0 ] ) ] . patientDoctorAppointmentList . add ( element ) ;
} else {
_patientDoctorAppointmentListHospital . add (
PatientDoctorAppointmentList (
filterName: element . projectName ,
distanceInKMs:
element . projectDistanceInKiloMeters . toString ( ) ,
patientDoctorAppointment: element ) ) ;
_patientDoctorAppointmentListHospital
. add ( PatientDoctorAppointmentList ( filterName: element . projectName , distanceInKMs: element . projectDistanceInKiloMeters . toString ( ) , patientDoctorAppointment: element ) ) ;
}
} ) ;
} else { }
} ) ;
this . sharedPref . setBool ( IS_LIVECARE_APPOINTMENT , true ) ;
navigateToSearchResults (
context , doctorsList , _patientDoctorAppointmentListHospital ) ;
navigateToSearchResults ( context , doctorsList , _patientDoctorAppointmentListHospital ) ;
} else { }
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
@ -683,19 +631,8 @@ class _clinic_listState extends State<ClinicList> {
} ) ;
}
Future navigateToSearchResults (
context ,
List < DoctorList > docList ,
List < PatientDoctorAppointmentList >
patientDoctorAppointmentListHospital ) async {
Navigator . push (
context ,
FadePage (
page: SearchResults (
doctorsList: docList ,
isLiveCareAppointment: true ,
patientDoctorAppointmentListHospital:
patientDoctorAppointmentListHospital ) ) ) ;
Future navigateToSearchResults ( context , List < DoctorList > docList , List < PatientDoctorAppointmentList > patientDoctorAppointmentListHospital ) async {
Navigator . push ( context , FadePage ( page: SearchResults ( doctorsList: docList , isLiveCareAppointment: true , patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital ) ) ) ;
}
updateSelectedIndex ( PatientERGetClinicsList patientERGetClinicsList ) {