import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/material.dart'; class ClinicListService extends BaseService { AppSharedPreferences sharedPref = AppSharedPreferences(); AppGlobal appGlobal = new AppGlobal(); AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); double lat; double long; Future getClinicsList(context) 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 }; dynamic localRes; await baseAppClient.post(GET_CLINICS_LIST_URL, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: request); return Future.value(localRes); } Future getActiveAppointmentNo(context) 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": "", "IsActiveAppointment": true, "DeviceTypeID": req.DeviceTypeID, "PatientType": user.patientType, "PatientTypeID": user.patientType, "SessionID": null }; dynamic localRes; await baseAppClient.post(GET_ACTIVE_APPOINTMENTS_LIST_URL, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: request); return Future.value(localRes); } Future getProjectsList(context) 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 }; dynamic localRes; await baseAppClient.post(GET_PROJECTS_LIST, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: request); return Future.value(localRes); } Future getChiefComplaintsList( int clinicID, int projectID, BuildContext context, {doctorId}) async { //Utils.showProgressDialog(context); Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { var data = AuthenticatedUser.fromJson( await this.sharedPref.getObject(USER_PROFILE)); authUser = data; } var languageID = await sharedPref.getString(APP_LANGUAGE); Request req = appGlobal.getPublicRequest(); request = { "ClinicID": clinicID, "ProjectID": projectID, "SelectedDate": "", "SelectedTime": "", "License": true, "VersionID": 5.6, "Channel": 3, "LanguageID": languageID == 'ar' ? 1 : 2, "IPAdress": "10.20.10.20", "generalid": "Cs2020@2016\$2958", "PatientOutSA": 0, "SessionID": null, "isDentalAllowedBackend": true, "DeviceTypeID": 1, "PatientID": 1, "ContinueDentalPlan": true, "IsSearchAppointmnetByClinicID": false }; 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 getChiefComplaintDoctorList( int chiefComplaintID, int projectID, BuildContext context, {doctorId}) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { var data = AuthenticatedUser.fromJson( await this.sharedPref.getObject(USER_PROFILE)); authUser = data; } if (await this.sharedPref.getDouble(USER_LAT) != null && await this.sharedPref.getDouble(USER_LONG) != null) { lat = await this.sharedPref.getDouble(USER_LAT); long = await this.sharedPref.getDouble(USER_LONG); } var languageID = await sharedPref.getString(APP_LANGUAGE); Request req = appGlobal.getPublicRequest(); request = { "ChiefComplaintID": chiefComplaintID, "ProjectID": projectID, "VersionID": 5.6, "Channel": 3, "LanguageID": languageID == 'ar' ? 1 : 2, "IPAdress": req.IPAdress, "generalid": req.generalid, "PatientOutSA": 0, "SessionID": null, "isDentalAllowedBackend": true, "Latitude": lat.toString(), "Longitude": long.toString(), "DeviceTypeID": req.DeviceTypeID, "IsPublicRequest" : true }; dynamic localRes; await baseAppClient.post(GET_DENTAL_DOCTORS_LIST_URL, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: request); return Future.value(localRes); } }