get clinic list

merge-requests/146/head
hussam al-habibeh 6 years ago
parent 4fe69599fb
commit d866d8b9de

@ -35,23 +35,31 @@ const START_LIVECARE_CALL = 'LiveCareApi/DoctorApp/CallPatient';
const LIVE_CARE_STATISTICS_FOR_CERTAIN_DOCTOR_URL = const LIVE_CARE_STATISTICS_FOR_CERTAIN_DOCTOR_URL =
"Lists.svc/REST/DashBoard_GetLiveCareDoctorsStatsticsForCertainDoctor"; "Lists.svc/REST/DashBoard_GetLiveCareDoctorsStatsticsForCertainDoctor";
const GET_PRESCRIPTION_REPORT = 'Services/Patients.svc/REST/GetPrescriptionReport'; const GET_PRESCRIPTION_REPORT =
'Services/Patients.svc/REST/GetPrescriptionReport';
const GT_MY_PATIENT_QUESTION = 'Services/DoctorApplication.svc/REST/GtMyPatientsQuestions'; const GT_MY_PATIENT_QUESTION =
'Services/DoctorApplication.svc/REST/GtMyPatientsQuestions';
const GET_PATIENT = 'Services/DoctorApplication.svc/REST/'; const GET_PATIENT = 'Services/DoctorApplication.svc/REST/';
const GET_PRESCRIPTION_REPORT_FOR_IN_PATIENT= 'Services/DoctorApplication.svc/REST/GetPrescriptionReportForInPatient'; const GET_PRESCRIPTION_REPORT_FOR_IN_PATIENT =
'Services/DoctorApplication.svc/REST/GetPrescriptionReportForInPatient';
const GET_MY_REFERRAL_PATIENT = 'Services/DoctorApplication.svc/REST/GtMyReferralPatient'; const GET_MY_REFERRAL_PATIENT =
'Services/DoctorApplication.svc/REST/GtMyReferralPatient';
const ADD_REFERRED_DOCTOR_REMARKS= 'Services/DoctorApplication.svc/REST/AddReferredDoctorRemarks'; const ADD_REFERRED_DOCTOR_REMARKS =
'Services/DoctorApplication.svc/REST/AddReferredDoctorRemarks';
const GET_MY_REFERRED_PATIENT = 'Services/DoctorApplication.svc/REST/GtMyReferredPatient'; const GET_MY_REFERRED_PATIENT =
'Services/DoctorApplication.svc/REST/GtMyReferredPatient';
const GET_DOCTOR_WORKING_HOURS_TABLE = 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; const GET_DOCTOR_WORKING_HOURS_TABLE =
'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable';
const GET_PATIENT_LAB_RESULTS= 'Services/DoctorApplication.svc/REST/GetPatientLabResults'; const GET_PATIENT_LAB_RESULTS =
'Services/DoctorApplication.svc/REST/GetPatientLabResults';
var selectedPatientType = 1; var selectedPatientType = 1;

@ -18,6 +18,10 @@ const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE =
const MEMBER_CHECK_ACTIVATION_CODE_NEW = const MEMBER_CHECK_ACTIVATION_CODE_NEW =
'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; 'Services/Sentry.svc/REST/MemberCheckActivationCode_New';
const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles';
const GET_CLINICS_FOR_DOCTOR =
'Services/DoctorApplication.svc/REST/GetClinicsForDoctor';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
@ -166,11 +170,12 @@ class AuthProvider with ChangeNotifier {
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
//ClinicDescription //ClinicDescription
selectedClinicName = response['DoctorProfileList'][0]['ClinicDescription']; selectedClinicName =
response['DoctorProfileList'][0]['ClinicDescription'];
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: docInfo); }, body: docInfo);
notifyListeners(); notifyListeners();
return Future.value(localRes); return Future.value(localRes);
} catch (error) { } catch (error) {
print(error); print(error);

@ -1,8 +1,10 @@
import 'dart:async'; import 'dart:async';
import 'package:connectivity/connectivity.dart'; import 'package:connectivity/connectivity.dart';
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:doctor_app_flutter/providers/auth_provider.dart'; import 'package:doctor_app_flutter/providers/auth_provider.dart';
@ -10,6 +12,7 @@ import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
Helpers helpers = Helpers(); Helpers helpers = Helpers();
class ProjectProvider with ChangeNotifier { class ProjectProvider with ChangeNotifier {
@ -18,12 +21,15 @@ class ProjectProvider with ChangeNotifier {
String currentLanguage = 'ar'; String currentLanguage = 'ar';
bool _isArabic = false; bool _isArabic = false;
bool isInternetConnection = true; bool isInternetConnection = true;
List<ClinicModel> clinicList = [];
bool isLoading = false;
bool isError = false;
String error = '';
Locale get appLocal => _appLocale; Locale get appLocal => _appLocale;
bool get isArabic => _isArabic; bool get isArabic => _isArabic;
StreamSubscription subscription; StreamSubscription subscription;
// AuthProvider authProvider = AuthProvider();
ProjectProvider() { ProjectProvider() {
loadSharedPrefLanguage(); loadSharedPrefLanguage();
@ -66,7 +72,7 @@ class ProjectProvider with ChangeNotifier {
currentLanguage = 'en'; currentLanguage = 'en';
sharedPref.setString(APP_Language, 'en'); sharedPref.setString(APP_Language, 'en');
} }
getProfile(); getProfile();
notifyListeners(); notifyListeners();
} }
@ -76,7 +82,29 @@ class ProjectProvider with ChangeNotifier {
super.dispose(); super.dispose();
} }
void getProfile()async{ Future<dynamic> getClinicNames() async {
try {
dynamic localRes;
await BaseAppClient.post(GET_CLINICS_FOR_DOCTOR,
onSuccess: (dynamic response, int statusCode) {
clinicList = [];
response['List_DoctorsClinic'].forEach((v) {
clinicList.add(new ClinicModel.fromJson(v));
});
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: {});
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
void getProfile() async {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE); Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile);
ProfileReqModel docInfo = new ProfileReqModel( ProfileReqModel docInfo = new ProfileReqModel(
@ -87,13 +115,12 @@ class ProjectProvider with ChangeNotifier {
tokenID: '', tokenID: '',
languageID: 2); languageID: 2);
Provider.of<AuthProvider>(AppGlobal.CONTEX,listen: false) Provider.of<AuthProvider>(AppGlobal.CONTEX, listen: false)
.getDocProfiles(docInfo.toJson()).then((res) async { .getDocProfiles(docInfo.toJson())
.then((res) async {
sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]); sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]);
}).catchError((err) { }).catchError((err) {
print(err); print(err);
}); });
} }
} }

@ -49,13 +49,22 @@ class _DashboardScreenState extends State<DashboardScreen> {
AuthProvider authProvider; AuthProvider authProvider;
bool isLoading = false; bool isLoading = false;
ProjectProvider projectsProvider; ProjectProvider projectsProvider;
var _isInit = true;
void didChangeDependencies() {
super.didChangeDependencies();
if (_isInit) {
projectsProvider = Provider.of<ProjectProvider>(context);
projectsProvider.getClinicNames();
}
_isInit = false;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
hospitalProvider = Provider.of(context); hospitalProvider = Provider.of(context);
authProvider = Provider.of(context); authProvider = Provider.of(context);
projectsProvider = Provider.of(context); projectsProvider = Provider.of(context);
print(authProvider.doctorsClinicList);
FocusScopeNode currentFocus = FocusScope.of(context); FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) { if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus(); currentFocus.unfocus();
@ -90,7 +99,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
onTap: () { onTap: () {
showCupertinoPicker( showCupertinoPicker(
context: context, context: context,
actionList: authProvider.doctorsClinicList); actionList: projectsProvider.clinicList);
}, },
child: Container( child: Container(
margin: margin:
@ -542,6 +551,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
changeIsLoading(true); changeIsLoading(true);
Map profile = await sharedPref.getObj(DOCTOR_PROFILE); Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile);
ProfileReqModel docInfo = new ProfileReqModel( ProfileReqModel docInfo = new ProfileReqModel(
doctorID: doctorProfile.doctorID, doctorID: doctorProfile.doctorID,
clinicID: clinicId, clinicID: clinicId,
@ -549,7 +559,6 @@ class _DashboardScreenState extends State<DashboardScreen> {
projectID: doctorProfile.projectID, projectID: doctorProfile.projectID,
tokenID: '', tokenID: '',
languageID: 2); languageID: 2);
// authProvider.getDocProfiles(docInfo) // authProvider.getDocProfiles(docInfo)
authProvider.getDocProfiles(docInfo.toJson()).then((res) async { authProvider.getDocProfiles(docInfo.toJson()).then((res) async {
changeIsLoading(false); changeIsLoading(false);

@ -301,7 +301,7 @@ class _LoginFormState extends State<LoginForm> {
platformImei = platformImei =
await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: false); await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: false);
idunique = await ImeiPlugin.getImei(); idunique = await ImeiPlugin.getImei();
} catch(e) { } catch (e) {
platformImei = 'Failed to get platform version.'; platformImei = 'Failed to get platform version.';
} }

Loading…
Cancel
Save