diff --git a/lib/config/config.dart b/lib/config/config.dart index 25508b33..9824883e 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -12,6 +12,9 @@ const BASE_URL = 'https://hmgwebservices.com/'; // Production Environment //URL to get clinic list const GET_CLINICS_LIST_URL = "Services/lists.svc/REST/GetClinicCentralized"; +//URL to get doctors list +const GET_DOCTORS_LIST_URL = "Services/Doctors.svc/REST/SearchDoctorsByTime"; + class AppGlobal { static var context; diff --git a/lib/models/FreeSlot.dart b/lib/models/FreeSlot.dart deleted file mode 100644 index 46692982..00000000 --- a/lib/models/FreeSlot.dart +++ /dev/null @@ -1,12 +0,0 @@ -class FreeSlot { - List event; - DateTime slot; - - - FreeSlot(this.slot, this.event); - - @override - String toString() { - return '{ ${this.slot}, ${this.event} }'; - } -} \ No newline at end of file diff --git a/lib/pages/BookAppointment/Search.dart b/lib/pages/BookAppointment/Search.dart index a5f840e1..a83dee33 100644 --- a/lib/pages/BookAppointment/Search.dart +++ b/lib/pages/BookAppointment/Search.dart @@ -32,9 +32,9 @@ class _SearchState extends State with SingleTickerProviderStateMixin { ), title: Text(TranslationBase.of(context).bookAppo), ), - body: TabBarView(children: [ - SearchByClinic(), - SearchByDoctor() - ], controller: _tabController)); + body: TabBarView( + physics: NeverScrollableScrollPhysics(), + children: [SearchByClinic(), SearchByDoctor()], + controller: _tabController)); } } diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index 366f45bf..d09fde11 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -1,5 +1,5 @@ import 'package:diplomaticquarterapp/models/Clinics/ClinicListResponse.dart'; -import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; @@ -11,7 +11,7 @@ class SearchByClinic extends StatefulWidget { class _SearchByClinicState extends State { bool nearestAppo = false; - String dropdownValue = null; + String dropdownValue; List clinicsList = []; @override @@ -60,17 +60,17 @@ class _SearchByClinicState extends State { child: DropdownButton( hint: new Text("Select Clinic"), value: dropdownValue, - items: clinicsList - .map((ListClinicCentralized clinicSelected) { + items: clinicsList.map((item) { return new DropdownMenuItem( -// value: dropdownValue, - child: new Text(clinicSelected.clinicDescription), + value: item.clinicID.toString(), + child: new Text(item.clinicDescription), ); }).toList(), onChanged: (newValue) { setState(() { - print(newValue); dropdownValue = newValue; + print(dropdownValue); + getDoctorsList(); }); }, ), @@ -88,22 +88,26 @@ class _SearchByClinicState extends State { res['ListClinicCentralized'].forEach((v) { clinicsList.add(new ListClinicCentralized.fromJson(v)); }); - clinicsList.forEach((v) { - print(v.clinicID); - }); - }); - } else { - // handel error - setState(() { -// projectsList = ListProject; }); - } + } else {} }).catchError((err) { - setState(() { -// projectsList = ListProject; - }); print(err); }); } + getDoctorsList() { + DoctorsListService service = new DoctorsListService(); + service.getDoctorsList(int.parse(dropdownValue), 0).then((res) { + print(res['DoctorList']); +// if (res['MessageStatus'] == 1) { +// setState(() { +// res['ListClinicCentralized'].forEach((v) { +// clinicsList.add(new ListClinicCentralized.fromJson(v)); +// }); +// }); +// } else {} + }).catchError((err) { + print(err); + }); + } } diff --git a/lib/pages/BookAppointment/components/SearchByDoctor.dart b/lib/pages/BookAppointment/components/SearchByDoctor.dart index a0a0540c..95ef0100 100644 --- a/lib/pages/BookAppointment/components/SearchByDoctor.dart +++ b/lib/pages/BookAppointment/components/SearchByDoctor.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; @@ -73,6 +74,23 @@ class _SearchByDoctorState extends State { ); } + getDoctorsList() { + DoctorsListService service = new DoctorsListService(); + service.getDoctorsListByName(doctorNameController.text).then((res) { + print(res['DoctorList']); + if (res['MessageStatus'] == 1) { +// setState(() { +// res['ListClinicCentralized'].forEach((v) { +// clinicsList.add(new ListClinicCentralized.fromJson(v)); +// }); +// }); + navigateToSearchResults(context); + } else {} + }).catchError((err) { + print(err); + }); + } + _onDocTextChanged(content) { print(content); if (content.length >= 4) { @@ -88,7 +106,7 @@ class _SearchByDoctorState extends State { } void _searchDoctor() { - navigateToSearchResults(context); + getDoctorsList(); } Future navigateToSearchResults(context) async { diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart new file mode 100644 index 00000000..5743a577 --- /dev/null +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -0,0 +1,88 @@ +import 'package:diplomaticquarterapp/client/base_app_client.dart'; +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/models/Request.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; + +class DoctorsListService { + AppSharedPreferences sharedPref = AppSharedPreferences(); + AppGlobal appGlobal = new AppGlobal(); + + Future getDoctorsList(int clinicID, int projectID) async { + Map request; + var languageID = await sharedPref.getString(APP_LANGUAGE); + Request req = appGlobal.getPublicRequest(); + request = { + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": "10.20.10.20", + "VersionID": req.VersionID, + "Channel": req.Channel, + "generalid": 'Cs2020@2016\$2958', + "PatientOutSA": 0, + "TokenID": "", + "DeviceTypeID": req.DeviceTypeID, + "SessionID": null, + "ClinicID": 21, + "ProjectID": 0, + "ContinueDentalPlan": false, + "IsSearchAppointmnetByClinicID": true, + "PatientID": 0, + "gender": 0, + "age": 0, + "IsGetNearAppointment": false, + "Latitude": 0, + "Longitude": 0, + "License": true + }; + + dynamic localRes; + + await BaseAppClient.post(GET_DOCTORS_LIST_URL, + onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + + Future getDoctorsListByName(String docName) async { + Map request; + var languageID = await sharedPref.getString(APP_LANGUAGE); + Request req = appGlobal.getPublicRequest(); + request = { + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": "10.20.10.20", + "VersionID": req.VersionID, + "Channel": req.Channel, + "generalid": 'Cs2020@2016\$2958', + "PatientOutSA": 0, + "TokenID": "", + "DeviceTypeID": req.DeviceTypeID, + "SessionID": null, + "ClinicID": 0, + "ProjectID": 0, + "ContinueDentalPlan": false, + "IsSearchAppointmnetByClinicID": false, + "DoctorName": docName, + "PatientID": 0, + "gender": 0, + "age": 0, + "IsGetNearAppointment": false, + "Latitude": 0, + "Longitude": 0, + "License": true + }; + + dynamic localRes; + + await BaseAppClient.post(GET_DOCTORS_LIST_URL, + onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + +}