From c800219428d8e813026edd7041048b34bba01f45 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 6 Jun 2021 16:58:42 +0300 Subject: [PATCH] Live Care Is Login Service --- .../patient/LiveCarePatientServices.dart | 8 +- .../viewModel/LiveCarePatientViewModel.dart | 46 +++--- .../live_care/live_care_patient_screen.dart | 132 +++++++++--------- pubspec.lock | 8 +- 4 files changed, 99 insertions(+), 95 deletions(-) diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index cf44cd68..d05f6dd9 100644 --- a/lib/core/service/patient/LiveCarePatientServices.dart +++ b/lib/core/service/patient/LiveCarePatientServices.dart @@ -55,7 +55,7 @@ class LiveCarePatientServices extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: endCallReq.toJson(), isLiveCare:_isLive); + }, body: endCallReq.toJson(), isLiveCare: _isLive); } Future startCall(StartCallReq startCallReq) async { @@ -65,7 +65,7 @@ class LiveCarePatientServices extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: startCallReq.toJson(), isLiveCare:_isLive); + }, body: startCallReq.toJson(), isLiveCare: _isLive); } Future endCallWithCharge(int vcID) async { @@ -95,13 +95,13 @@ class LiveCarePatientServices extends BaseService { }, isLiveCare: _isLive); } - Future isLogin(LiveCareUserLoginRequestModel isLoginRequestModel) async { + Future isLogin({LiveCareUserLoginRequestModel isLoginRequestModel, int loginStatus}) async { hasError = false; await baseAppClient.post(LIVE_CARE_IS_LOGIN, onSuccess: (response, statusCode) async { isLoginResponse = response; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: isLoginRequestModel.toJson(), isLiveCare: true); + }, body: isLoginRequestModel.toJson(), isLiveCare: _isLive); } } diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index 844ebf55..b1b18672 100644 --- a/lib/core/viewModel/LiveCarePatientViewModel.dart +++ b/lib/core/viewModel/LiveCarePatientViewModel.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/live_care/PendingPatientERForDoctorAppRequestModel.dart'; +import 'package:doctor_app_flutter/core/model/live_care/live_care_login_reguest_model.dart'; import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart'; import 'package:doctor_app_flutter/core/service/patient/LiveCarePatientServices.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; @@ -14,8 +15,7 @@ import '../../locator.dart'; class LiveCarePatientViewModel extends BaseViewModel { List filterData = []; - LiveCarePatientServices _liveCarePatientServices = - locator(); + LiveCarePatientServices _liveCarePatientServices = locator(); StartCallRes get startCallRes => _liveCarePatientServices.startCallRes; @@ -28,12 +28,9 @@ class LiveCarePatientViewModel extends BaseViewModel { setState(ViewState.BusyLocal); } - PendingPatientERForDoctorAppRequestModel - pendingPatientERForDoctorAppRequestModel = - PendingPatientERForDoctorAppRequestModel( - sErServiceID: _dashboardService.sServiceID, outSA: false); - await _liveCarePatientServices.getPendingPatientERForDoctorApp( - pendingPatientERForDoctorAppRequestModel); + PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel = + PendingPatientERForDoctorAppRequestModel(sErServiceID: _dashboardService.sServiceID, outSA: false); + await _liveCarePatientServices.getPendingPatientERForDoctorApp(pendingPatientERForDoctorAppRequestModel); if (_liveCarePatientServices.hasError) { error = _liveCarePatientServices.error; @@ -120,16 +117,11 @@ class LiveCarePatientViewModel extends BaseViewModel { if (strExist) { filterData = []; for (var i = 0; i < _liveCarePatientServices.patientList.length; i++) { - String fullName = - _liveCarePatientServices.patientList[i].fullName.toUpperCase(); - String patientID = - _liveCarePatientServices.patientList[i].patientId.toString(); - String mobile = - _liveCarePatientServices.patientList[i].mobileNumber.toUpperCase(); - - if (fullName.contains(str.toUpperCase()) || - patientID.contains(str) || - mobile.contains(str)) { + String fullName = _liveCarePatientServices.patientList[i].fullName.toUpperCase(); + String patientID = _liveCarePatientServices.patientList[i].patientId.toString(); + String mobile = _liveCarePatientServices.patientList[i].mobileNumber.toUpperCase(); + + if (fullName.contains(str.toUpperCase()) || patientID.contains(str) || mobile.contains(str)) { filterData.add(_liveCarePatientServices.patientList[i]); } } @@ -139,4 +131,22 @@ class LiveCarePatientViewModel extends BaseViewModel { notifyListeners(); } } + + Future isLogin(int loginStatus) async { + await getDoctorProfile(isGetProfile: true); + + LiveCareUserLoginRequestModel userLoginRequestModel = new LiveCareUserLoginRequestModel(); + userLoginRequestModel.isOutKsa = (doctorProfile.projectID == 2 || doctorProfile.projectID == 3) ? 1 : 0; + userLoginRequestModel.isLogin = loginStatus; + userLoginRequestModel.generalid = "Cs2020@2016\$2958"; + + setState(ViewState.BusyLocal); + await _liveCarePatientServices.isLogin(loginStatus: loginStatus, isLoginRequestModel: userLoginRequestModel); + if (_liveCarePatientServices.hasError) { + error = _liveCarePatientServices.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } } diff --git a/lib/screens/live_care/live_care_patient_screen.dart b/lib/screens/live_care/live_care_patient_screen.dart index 43afd4c1..51757bf0 100644 --- a/lib/screens/live_care/live_care_patient_screen.dart +++ b/lib/screens/live_care/live_care_patient_screen.dart @@ -30,7 +30,7 @@ class _LiveCarePatientScreenState extends State { void initState() { super.initState(); timer = Timer.periodic(Duration(seconds: 10), (Timer t) { - if(_liveCareViewModel != null){ + if (_liveCareViewModel != null) { _liveCareViewModel.getPendingPatientERForDoctorApp(isFromTimer: true); } }); @@ -38,6 +38,7 @@ class _LiveCarePatientScreenState extends State { @override void dispose() { + _liveCareViewModel.isLogin(0); _liveCareViewModel = null; timer?.cancel(); super.dispose(); @@ -49,7 +50,7 @@ class _LiveCarePatientScreenState extends State { onModelReady: (model) async { _liveCareViewModel = model; await model.getPendingPatientERForDoctorApp(); - + await model.isLogin(1); }, builder: (_, model, w) => AppScaffold( baseViewModel: model, @@ -82,7 +83,9 @@ class _LiveCarePatientScreenState extends State { ]), ), ), - SizedBox(height: 20,), + SizedBox( + height: 20, + ), Center( child: FractionallySizedBox( widthFactor: .9, @@ -90,44 +93,35 @@ class _LiveCarePatientScreenState extends State { width: double.maxFinite, height: 75, decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), + borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: Color(0xffCCCCCC), ), color: Colors.white), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - left: 10, top: 10), - child: AppText( - TranslationBase.of( - context) - .searchPatientName, - fontSize: 13, - )), - AppTextFormField( - // focusNode: focusProject, - controller: _controller, - borderColor: Colors.white, - prefix: IconButton( - icon: Icon( - DoctorApp.filter_1, - color: Colors.black, - ), - iconSize: 20, - padding: - EdgeInsets.only( - bottom: 30), - ), - onChanged: (String str) { - model.searchData(str); - }), - ])), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Padding( + padding: EdgeInsets.only(left: 10, top: 10), + child: AppText( + TranslationBase.of(context).searchPatientName, + fontSize: 13, + )), + AppTextFormField( + // focusNode: focusProject, + controller: _controller, + borderColor: Colors.white, + prefix: IconButton( + icon: Icon( + DoctorApp.filter_1, + color: Colors.black, + ), + iconSize: 20, + padding: EdgeInsets.only(bottom: 30), + ), + onChanged: (String str) { + model.searchData(str); + }), + ])), ), ), model.state == ViewState.Idle @@ -136,44 +130,44 @@ class _LiveCarePatientScreenState extends State { child: model.filterData.isEmpty ? Center( child: ErrorMessage( - error: TranslationBase.of(context) - .youDontHaveAnyPatient, + error: TranslationBase.of(context).youDontHaveAnyPatient, ), ) : ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: model.filterData.length, - itemBuilder: (BuildContext ctxt, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: PatientCard( - patientInfo: model.filterData[index], - patientType: "0", - arrivalType: "0", - isFromSearch: false, - isInpatient: false, - isFromLiveCare:true, - onTap: () { - // TODO change the parameter to daynamic - Navigator.of(context).pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": model.filterData[index], - "patientType": "0", - "isSearch": false, - "isInpatient": false, - "arrivalType": "0", - "isSearchAndOut": false, - "isFromLiveCare":true, - }); - }, - // isFromSearch: widget.isSearch, - ), - ); - })), - ) : Expanded( - child: AppLoaderWidget(containerColor: Colors.transparent,)), + itemCount: model.filterData.length, + itemBuilder: (BuildContext ctxt, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: PatientCard( + patientInfo: model.filterData[index], + patientType: "0", + arrivalType: "0", + isFromSearch: false, + isInpatient: false, + isFromLiveCare: true, + onTap: () { + // TODO change the parameter to daynamic + Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { + "patient": model.filterData[index], + "patientType": "0", + "isSearch": false, + "isInpatient": false, + "arrivalType": "0", + "isSearchAndOut": false, + "isFromLiveCare": true, + }); + }, + // isFromSearch: widget.isSearch, + ), + ); + })), + ) + : Expanded( + child: AppLoaderWidget( + containerColor: Colors.transparent, + )), ], ), ), diff --git a/pubspec.lock b/pubspec.lock index 49ff6372..25596d43 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -587,7 +587,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.2" + version: "0.6.3-nullsafety.1" json_annotation: dependency: transitive description: @@ -629,7 +629,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.4" mime: dependency: transitive description: @@ -921,7 +921,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.2" sticky_headers: dependency: "direct main" description: @@ -1119,5 +1119,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <2.11.0" + dart: ">=2.10.0 <=2.11.0-213.1.beta" flutter: ">=1.22.0 <2.0.0"