From 9b065036aedfd4e87e000638d7af6359236f0db5 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Thu, 11 Jun 2020 09:24:10 +0300 Subject: [PATCH] fix issues in get patients service --- lib/client/base_app_client.dart | 9 +++- lib/config/config.dart | 6 +-- lib/providers/patients_provider.dart | 22 +++++----- lib/screens/QR_reader_screen.dart | 14 ++++-- lib/screens/doctor/my_schedule_screen.dart | 3 +- .../patients/patients_list_screen.dart | 4 ++ lib/screens/patients/patients_screen.dart | 3 +- .../profile/radiology/radiology_screen.dart | 4 -- .../doctor/my_referral_patient_widget.dart | 44 +++++++++++-------- .../patients/profile/large_avatar.dart | 12 ++--- 10 files changed, 74 insertions(+), 47 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 031c70ac..93ca0690 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -9,6 +9,8 @@ import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; +import 'package:http_interceptor/http_methods.dart'; +import 'package:http_interceptor/models/request_data.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = new Helpers(); @@ -36,6 +38,9 @@ class BaseAppClient { Function(String error, int statusCode) onFailure, }) async { String url = BASE_URL + endPoint; + RequestData data = RequestData(body: body,baseUrl: url,method: Method.POST); + + try { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); @@ -44,7 +49,7 @@ class BaseAppClient { body['DoctorID'] = doctorProfile?.doctorID; body['EditedBy'] = doctorProfile?.doctorID; body['ProjectID'] = doctorProfile?.projectID; - if (!body.containsKey('ClinicID')) + // if (!body.containsKey('ClinicID')) body['ClinicID'] = doctorProfile?.clinicID; } body['TokenID'] = token ?? ''; @@ -56,6 +61,8 @@ class BaseAppClient { body['SessionID'] = SESSION_ID; body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['PatientOutSA'] = PATIENT_OUT_SA; + print("URL : $url"); + print("Body : ${json.encode(body)}"); if (await Helpers.checkConnection()) { final response = await http.post(url, diff --git a/lib/config/config.dart b/lib/config/config.dart index f6849172..5f902f2f 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_DATE = "[0-9/]"; - // const BASE_URL = 'https://hmgwebservices.com/Services/'; -const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; +const BASE_URL = 'https://hmgwebservices.com/Services/'; +//const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; @@ -23,7 +23,7 @@ const GET_RADIOLOGY = 'DoctorApplication.svc/REST/GetPatientRadResult'; var selectedPatientType = 0; -//*********change value to decode json from Dropdown ************ +//*********change value to decode json from Dropdown ************1 var SERVICES_PATIANT = [ "GetMyOutPatient", "GetMyInPatient", diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 2984398e..3aebd306 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -62,17 +62,16 @@ class PatientsProvider with ChangeNotifier { PatiantInformtion _selectedPatient; - getPatientList(PatientModel patient, patientType) async { + Future getPatientList(PatientModel patient, patientType) async { int val = int.parse(patientType); try { - var localResponse; - await BaseAppClient.post( - 'DoctorApplication.svc/REST/' + SERVICES_PATIANT[val], - onSuccess: (dynamic response, int statusCode) async { - localResponse = response; - }, onFailure: (String error, int statusCode) async { - throw error; + dynamic localRes; + await BaseAppClient.post('DoctorApplication.svc/REST/' + SERVICES_PATIANT[val], + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; }, body: { "ProjectID": patient.ProjectID, "ClinicID": patient.ClinicID, @@ -96,9 +95,10 @@ class PatientsProvider with ChangeNotifier { "PatientOutSA": patient.PatientOutSA }); - return localResponse; - } catch (err) { - handelCatchErrorCase(error); + return Future.value(localRes); + } catch (error) { + print(error); + throw error; } } diff --git a/lib/screens/QR_reader_screen.dart b/lib/screens/QR_reader_screen.dart index bbbe327a..80d9332d 100644 --- a/lib/screens/QR_reader_screen.dart +++ b/lib/screens/QR_reader_screen.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart'; import 'package:doctor_app_flutter/providers/patients_provider.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -159,9 +160,9 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); } else { setState(() { isError = true; - error = 'No patient'; isLoading = false; }); + DrAppToastMsg.showErrorToast('No patient'); } break; case "1": @@ -176,20 +177,27 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); }); } else { setState(() { - error = 'No patient'; isError = true; isLoading = false; }); + DrAppToastMsg.showErrorToast('No patient'); break; } } } else { setState(() { - error = response['ErrorEndUserMessage'] ?? response['ErrorMessage'] ; isLoading = false; isError = true; }); + DrAppToastMsg.showErrorToast(response['ErrorEndUserMessage'] ?? response['ErrorMessage']); + } + }).catchError((error){ + setState(() { + isLoading = false; + }); + helpers.showErrorToast(error); + //DrAppToastMsg.showErrorToast(error); }); } // } diff --git a/lib/screens/doctor/my_schedule_screen.dart b/lib/screens/doctor/my_schedule_screen.dart index f7b9d444..cd0f94a3 100644 --- a/lib/screens/doctor/my_schedule_screen.dart +++ b/lib/screens/doctor/my_schedule_screen.dart @@ -15,7 +15,8 @@ class MyScheduleScreen extends StatelessWidget { @override Widget build(BuildContext context) { scheduleProvider = Provider.of(context); - return Scaffold( + return AppScaffold( + appBarTitle: TranslationBase.of(context).mySchedule, body: scheduleProvider.isLoading ? DrAppCircularProgressIndeicator() : scheduleProvider.isError diff --git a/lib/screens/patients/patients_list_screen.dart b/lib/screens/patients/patients_list_screen.dart index 6d0b97a8..150de5df 100644 --- a/lib/screens/patients/patients_list_screen.dart +++ b/lib/screens/patients/patients_list_screen.dart @@ -33,6 +33,10 @@ class _PatientsListScreenState extends State { print(res); }).catchError((error) { print(error); + setState(() { + _isLoading = false; + _hasError = error; + }); }); } _isInit = false; diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 1128832f..a5142dce 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -104,7 +104,8 @@ class _PatientsScreenState extends State { }).catchError((error) { setState(() { _isError = true; - this.error = helpers.generateContactAdminMsg(error); + _isLoading = false; + this.error = error; }); }); } diff --git a/lib/screens/patients/profile/radiology/radiology_screen.dart b/lib/screens/patients/profile/radiology/radiology_screen.dart index 1ddf944e..5d232d3a 100644 --- a/lib/screens/patients/profile/radiology/radiology_screen.dart +++ b/lib/screens/patients/profile/radiology/radiology_screen.dart @@ -132,10 +132,6 @@ class _RadiologyScreenState extends State { url: patientsProv .patientRadiologyList[index] .doctorImageURL, - name: patientsProv - .patientLabResultOrdersList[ - index] - .doctorName, ), Expanded( child: Padding( diff --git a/lib/widgets/doctor/my_referral_patient_widget.dart b/lib/widgets/doctor/my_referral_patient_widget.dart index 02d3f10a..67db51fa 100644 --- a/lib/widgets/doctor/my_referral_patient_widget.dart +++ b/lib/widgets/doctor/my_referral_patient_widget.dart @@ -42,24 +42,26 @@ class _MyReferralPatientWidgetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText( - '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.lastName}', - fontSize: 2.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - InkWell( - onTap: () { - setState(() { - _showDetails = !_showDetails; - }); - }, - child: Icon(_showDetails - ? Icons.keyboard_arrow_up - : Icons.keyboard_arrow_down)), - ], + InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText( + '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.lastName}', + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down), + + ], + ), ), !_showDetails ? Container() @@ -87,6 +89,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.referringDoctor}', fontSize: @@ -108,6 +111,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( widget.myReferralPatientModel .referringClinicDescription, @@ -135,6 +139,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.referringClinicDescription}', fontSize: @@ -157,6 +162,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( widget.myReferralPatientModel .frequencyDescription, @@ -184,6 +190,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.priorityDescription}', fontSize: @@ -206,6 +213,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( Helpers.getDateFormatted(widget .myReferralPatientModel diff --git a/lib/widgets/patients/profile/large_avatar.dart b/lib/widgets/patients/profile/large_avatar.dart index 54cbcb30..3b70f393 100644 --- a/lib/widgets/patients/profile/large_avatar.dart +++ b/lib/widgets/patients/profile/large_avatar.dart @@ -35,25 +35,27 @@ class LargeAvatar extends StatelessWidget { ), ), ); - } else if (name == null || name.isEmpty) { + } else if (name != null || name.isNotEmpty) { return Center( child: AppText( - 'DR', + name[0].toUpperCase(), color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold, )); } else { return Center( child: AppText( - name[0].toUpperCase(), + 'DR', color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.bold, )); } } @override Widget build(BuildContext context) { + var vlr = name; + var asd; return InkWell( onTap: disableProfileView ? null