@ -1,7 +1,10 @@
import " dart:collection " ;
import ' package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart ' ;
import ' package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart ' ;
import ' package:diplomaticquarterapp/models/Appointments/SearchInfoModel.dart ' ;
import ' package:diplomaticquarterapp/models/Clinics/ClinicListResponse.dart ' ;
import ' package:diplomaticquarterapp/pages/BookAppointment/DentalComplaints.dart ' ;
import ' package:diplomaticquarterapp/pages/BookAppointment/widgets/BranchView.dart ' ;
import ' package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart ' ;
import ' package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart ' ;
@ -19,8 +22,11 @@ class SearchByClinic extends StatefulWidget {
class _SearchByClinicState extends State < SearchByClinic > {
bool nearestAppo = false ;
String dropdownValue ;
String projectDropdownValue ;
var event = RobotProvider ( ) ;
List < ListClinicCentralized > clinicsList = [ ] ;
List < HospitalsModel > projectsList = [ ] ;
bool isMobileAppDentalAllow = false ;
@ override
void initState ( ) {
@ -76,25 +82,91 @@ class _SearchByClinicState extends State<SearchByClinic> {
onChanged: ( newValue ) {
setState ( ( ) {
dropdownValue = newValue ;
getDoctorsList ( context ) ;
if ( ! isDentalSelectedAndSupported ( ) ) {
projectDropdownValue = " " ;
getDoctorsList ( context ) ;
}
} ) ;
} ,
) ,
) ) ,
isDentalSelectedAndSupported ( ) = = true | | nearestAppo
? Container (
height: 60.0 ,
decoration: BoxDecoration (
color: Colors . white ,
border: Border . all (
color: Colors . grey [ 400 ] ,
width: 1.0 ,
) ,
borderRadius: BorderRadius . circular ( 10 ) ,
) ,
padding: EdgeInsets . all ( 8.0 ) ,
width: MediaQuery . of ( context ) . size . width ,
margin: EdgeInsets . only ( top: 15.0 ) ,
child: DropdownButtonHideUnderline (
child: DropdownButton < String > (
hint: new Text ( " Select Project " ) ,
value: projectDropdownValue ,
items: projectsList . map ( ( item ) {
return new DropdownMenuItem < String > (
value: item . mainProjectID . toString ( ) ,
child: new Text ( item . name ) ,
) ;
} ) . toList ( ) ,
onChanged: ( newValue ) {
setState ( ( ) {
projectDropdownValue = newValue ;
getDoctorsList ( context ) ;
} ) ;
} ,
) ,
) )
: Container ( ) ,
] ,
) ,
) ;
}
bool isDentalSelectedAndSupported ( ) {
return dropdownValue ! = " " & &
( dropdownValue = = " 17 " ) & &
isMobileAppDentalAllow ;
}
getClinicsList ( ) {
ClinicListService service = new ClinicListService ( ) ;
service . getClinicsList ( context ) . then ( ( res ) {
service
. getClinicsList ( context )
. then ( ( res ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
isMobileAppDentalAllow = res [ ' ISMobileAppDentalAllow ' ] ;
res [ ' ListClinicCentralized ' ] . forEach ( ( v ) {
clinicsList . add ( new ListClinicCentralized . fromJson ( v ) ) ;
} ) ;
} ) ;
} else { }
} )
. catchError ( ( err ) {
print ( err ) ;
} )
. showProgressBar (
text: " Loading " , backgroundColor: Colors . blue . withOpacity ( 0.6 ) )
. then ( ( value ) {
getProjectsList ( ) ;
} ) ;
}
getProjectsList ( ) {
ClinicListService service = new ClinicListService ( ) ;
service . getProjectsList ( context ) . then ( ( res ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
res [ ' ListClinicCentralized ' ] . forEach ( ( v ) {
clinicsList . add ( new ListClinicCentralized . fromJson ( v ) ) ;
res [ ' List Project ' ] . forEach ( ( v ) {
projectsList. add ( new HospitalsModel . fromJson ( v ) ) ;
} ) ;
print ( projectsList . length ) ;
} ) ;
} else { }
} ) . catchError ( ( err ) {
@ -104,51 +176,65 @@ class _SearchByClinicState extends State<SearchByClinic> {
}
getDoctorsList ( BuildContext context ) {
List < DoctorList > doctorsList = [ ] ;
SearchInfo searchInfo = new SearchInfo ( ) ;
if ( dropdownValue = = " 17 " ) {
searchInfo . ProjectID = int . parse ( projectDropdownValue ) ;
searchInfo . ClinicID = int . parse ( dropdownValue ) ;
searchInfo . date = DateTime . now ( ) ;
List < String > arr = [ ] ;
List < String > arrDistance = [ ] ;
var distinctIds ;
List < String > result ;
int numAll ;
DoctorsListService service = new DoctorsListService ( ) ;
service . getDoctorsList ( int . parse ( dropdownValue ) , 0 , context ) . then ( ( res ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
if ( res [ ' DoctorList ' ] . length ! = 0 ) {
print ( res [ ' DoctorList ' ] ) ;
doctorsList . clear ( ) ;
res [ ' DoctorList ' ] . forEach ( ( v ) {
doctorsList . add ( new DoctorList . fromJson ( v ) ) ;
navigateToDentalComplaints ( context , searchInfo ) ;
} else {
List < DoctorList > doctorsList = [ ] ;
List < String > arr = [ ] ;
List < String > arrDistance = [ ] ;
List < String > result ;
int numAll ;
DoctorsListService service = new DoctorsListService ( ) ;
service
. getDoctorsList (
int . parse ( dropdownValue ) ,
projectDropdownValue ! = " " ? int . parse ( projectDropdownValue ) : 0 ,
context )
. then ( ( res ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
if ( res [ ' DoctorList ' ] . length ! = 0 ) {
print ( res [ ' DoctorList ' ] ) ;
doctorsList . clear ( ) ;
res [ ' DoctorList ' ] . forEach ( ( v ) {
doctorsList . add ( new DoctorList . fromJson ( v ) ) ;
arr . add ( new DoctorList . fromJson ( v ) . projectName ) ;
arrDistance . add ( new DoctorList . fromJson ( v )
. projectDistanceInKiloMeters
. toString ( ) ) ;
arr . add ( new DoctorList . fromJson ( v ) . projectName ) ;
arrDistance . add ( new DoctorList . fromJson ( v )
. projectDistanceInKiloMeters
. toString ( ) ) ;
} ) ;
} else { }
} ) ;
/ / print ( DoctorList
/ / . fromJson ( v )
/ / . projectName ) ;
/ / print ( DoctorList
/ / . fromJson ( v )
/ / . projectDistanceInKiloMeters ) ;
/ / distinctIds = result . toSet ( ) . toList ( ) ;
} ) ;
} else { }
} ) ;
result = LinkedHashSet < String > . from ( arr ) . toList ( ) ;
numAll = result . length ;
result = LinkedHashSet < String > . from ( arr ) . toList ( ) ;
numAll = result . length ;
navigateToSearchResults (
context , doctorsList , result , numAll , arrDistance ) ;
} else {
AppToast . showErrorToast ( message: res [ ' ErrorEndUserMessage ' ] ) ;
}
} ) . catchError ( ( err ) {
print ( err ) ;
} ) . showProgressBar (
text: " Loading " , backgroundColor: Colors . blue . withOpacity ( 0.6 ) ) ;
}
}
navigateToSearchResults (
context , doctorsList , result , numAll , arrDistance ) ;
} else {
AppToast . showErrorToast ( message: res [ ' ErrorEndUserMessage ' ] ) ;
}
} ) . catchError ( ( err ) {
print ( err ) ;
} ) . showProgressBar (
text: " Loading " , backgroundColor: Colors . blue . withOpacity ( 0.6 ) ) ;
Future navigateToDentalComplaints (
BuildContext context , SearchInfo searchInfo ) async {
Navigator . push (
context ,
MaterialPageRoute (
builder: ( context ) = > DentalComplaints ( searchInfo: searchInfo ) ,
) ,
) ;
}
Future navigateToSearchResults (
@ -156,7 +242,6 @@ class _SearchByClinicState extends State<SearchByClinic> {
Navigator . push (
context ,
MaterialPageRoute (
/ / builder: ( context ) = > SearchResults ( doctorsList: docList )
builder: ( context ) = > BranchView (
doctorsList: docList ,
result: result ,
@ -164,6 +249,5 @@ class _SearchByClinicState extends State<SearchByClinic> {
resultDistance: resultDistance ) ,
) ,
) ;
/ / builder: ( context ) = > SearchResults ( doctorsList: docList ) ) ) ;
}
}