diff --git a/fonts/DoctorApp.ttf b/fonts/DoctorApp.ttf index 5992d28b..b7fa0f30 100644 Binary files a/fonts/DoctorApp.ttf and b/fonts/DoctorApp.ttf differ diff --git a/icons_app/config.json b/icons_app/config.json index 6893355b..d863816c 100644 --- a/icons_app/config.json +++ b/icons_app/config.json @@ -34,20 +34,6 @@ "male" ] }, - { - "uid": "0bbb324cc39e62b3a4e05639a4f4008f", - "css": "home_icon", - "code": 59394, - "src": "custom_icons", - "selected": true, - "svg": { - "path": "M973.1 435L973.1 435 565 27A92 92 0 0 0 434.9 27L27.2 434.7 26.8 435.1A92 92 0 0 0 88 591.9C88.9 591.9 89.9 591.9 90.8 591.9H107.1V892.1A107.9 107.9 0 0 0 214.8 999.9H374.4A29.3 29.3 0 0 0 403.7 970.6V735.3A49.2 49.2 0 0 1 452.9 686.2H547A49.2 49.2 0 0 1 596.2 735.3V970.7A29.3 29.3 0 0 0 625.5 1000H785.1A107.9 107.9 0 0 0 892.8 892.3V592H907.8A92.1 92.1 0 0 0 973 434.9ZM931.6 523.7A33.4 33.4 0 0 1 907.9 533.5H863.5A29.3 29.3 0 0 0 834.2 562.8V892.3A49.2 49.2 0 0 1 785.1 941.4H654.9V735.3A107.9 107.9 0 0 0 547 627.5H452.9A107.9 107.9 0 0 0 345.1 735.2V941.3H215A49.2 49.2 0 0 1 165.8 892.1V562.8A29.3 29.3 0 0 0 136.5 533.5H92.8L91.4 533.5A33.4 33.4 0 0 1 68.4 476.4H68.4L476.3 68.4A33.4 33.4 0 0 1 523.6 68.4L931.4 476.2 931.6 476.4A33.4 33.4 0 0 1 931.6 523.7ZM931.6 523.7", - "width": 1000 - }, - "search": [ - "home_icon" - ] - }, { "uid": "06d6838cdcf6af812f2eb51e0269afc0", "css": "home_icon_active", @@ -145,6 +131,62 @@ "search": [ "schedule_icon" ] + }, + { + "uid": "5a324eddf382f5a1167d7d40325f82c8", + "css": "reject_icon", + "code": 59402, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M681 626.7L554.3 500 681 373.3A38.5 38.5 0 0 0 626.7 318.9L500 445.7 373.3 319A38.5 38.5 0 1 0 318.9 373.3L445.7 500 318.9 626.8A37.2 37.2 0 0 0 318.9 681.1 38.2 38.2 0 0 0 373.3 681.1L500 554.4 626.7 681.1A38.5 38.5 0 0 0 681.1 681.1 38.2 38.2 0 0 0 681 626.7ZM500 67.3A432.5 432.5 0 1 1 194 194 429.8 429.8 0 0 1 500 67.3M500 0A500 500 0 1 0 1000 500 500 500 0 0 0 500 0Z", + "width": 1000 + }, + "search": [ + "reject_icon" + ] + }, + { + "uid": "2742f64b5e69cc4f39a2dcc5a081ad03", + "css": "approved_icon", + "code": 59403, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M756.3 348.3L714 304.8A9.1 9.1 0 0 0 707.2 302H707.2A8.7 8.7 0 0 0 700.5 304.8L407.2 600.3 300.5 493.5A9.3 9.3 0 0 0 287.1 493.5L244.2 536.3A9.6 9.6 0 0 0 244.2 550L378.8 684.5A42.6 42.6 0 0 0 406.9 698.2 44.6 44.6 0 0 0 434.8 685H435L756.5 362A10.3 10.3 0 0 0 756.3 348.3ZM500 67.3A432.5 432.5 0 1 1 194 194 429.8 429.8 0 0 1 500 67.3M500 0A499.9 499.9 0 1 0 999.9 500 499.9 499.9 0 0 0 500 0Z", + "width": 1000 + }, + "search": [ + "approved_icon" + ] + }, + { + "uid": "148de09f7fd22c378cdfdbaacaa8e205", + "css": "pending_icon", + "code": 59404, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M809.8 932H797.3C781.5 932 768.2 929.8 766.5 914V913.7C731 583.9 523.3 577.6 523.3 499.9S731.1 415.9 766.5 86V85.9C768.2 70.1 781.5 68 797.3 68H809.8A34.8 34.8 0 0 0 844.7 35.7 34 34 0 0 0 810.7 0H35A34.8 34.8 0 0 0 0 32.3 34 34 0 0 0 34 68H47.2C63 68 76.3 70.2 78.1 85.9V86.2C113.7 416 321.5 422.3 321.5 500S113.7 584 78.3 913.8V914C76.6 929.8 63.3 932 47.5 932H35A34.8 34.8 0 0 0 0.1 964.3 34 34 0 0 0 34.1 1000H810.7A33.9 33.9 0 0 0 844.7 964.3 34.8 34.8 0 0 0 809.8 932ZM197.4 848.9C267 655.2 390.6 678.7 390.6 602.3V467.5C390.6 420.4 301.2 387.6 245.4 311.1A19 19 0 0 1 261.2 281H583.8A18.9 18.9 0 0 1 600 310.6C545.2 387.3 454.2 420.4 454.2 467.4V602.4C454.2 678.1 572.9 657.5 647.8 849 654.7 866.3 649.5 887.8 631.2 887.8H214.1C195.4 887.8 191.1 866.5 197.4 849Z", + "width": 845 + }, + "search": [ + "pending_icon" + ] + }, + { + "uid": "0bbb324cc39e62b3a4e05639a4f4008f", + "css": "home_icon", + "code": 59394, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M973.1 435L973.1 435 565 27A92 92 0 0 0 434.9 27L27.2 434.7 26.8 435.1A92 92 0 0 0 88 591.9C88.9 591.9 89.9 591.9 90.8 591.9H107.1V892.1A107.9 107.9 0 0 0 214.8 999.9H374.4A29.3 29.3 0 0 0 403.7 970.6V735.3A49.2 49.2 0 0 1 452.9 686.2H547A49.2 49.2 0 0 1 596.2 735.3V970.7A29.3 29.3 0 0 0 625.5 1000H785.1A107.9 107.9 0 0 0 892.8 892.3V592H907.8A92.1 92.1 0 0 0 973 434.9ZM931.6 523.7A33.4 33.4 0 0 1 907.9 533.5H863.5A29.3 29.3 0 0 0 834.2 562.8V892.3A49.2 49.2 0 0 1 785.1 941.4H654.9V735.3A107.9 107.9 0 0 0 547 627.5H452.9A107.9 107.9 0 0 0 345.1 735.2V941.3H215A49.2 49.2 0 0 1 165.8 892.1V562.8A29.3 29.3 0 0 0 136.5 533.5H92.8L91.4 533.5A33.4 33.4 0 0 1 68.4 476.4H68.4L476.3 68.4A33.4 33.4 0 0 1 523.6 68.4L931.4 476.2 931.6 476.4A33.4 33.4 0 0 1 931.6 523.7ZM931.6 523.7", + "width": 1000 + }, + "search": [ + "home_icon" + ] } ] } \ No newline at end of file diff --git a/lib/client/app_client.dart b/lib/client/app_client.dart new file mode 100644 index 00000000..68c4fb8b --- /dev/null +++ b/lib/client/app_client.dart @@ -0,0 +1,18 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/interceptor/http_interceptor.dart'; +import 'package:http/http.dart'; + +// OWNER : Ibrahim albitar +// DATE : 22-04-2020 +// DESCRIPTION : Custom App client to pin base url for all srvices + +class AppClient { + + static Client client = HttpInterceptor().getClient(); + + static Future post(dynamic path, {dynamic body}) async { + String _fullUrl = BASE_URL + path; + final response = await client.post(_fullUrl, body: body); + return response; + } +} \ No newline at end of file diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index d04cfa78..63ae8fca 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -37,9 +37,6 @@ 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); @@ -76,8 +73,7 @@ class BaseAppClient { } else { var parsed = json.decode(response.body.toString()); if (!parsed['IsAuthenticated']) { - await helpers.logout(); - + Navigator.of(AppGlobal.CONTEX).pushNamed(LOGIN); helpers.showErrorToast('Your session expired Please login agian'); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); diff --git a/lib/config/config.dart b/lib/config/config.dart index bc655778..d199986c 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -1,8 +1,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; -const ONLY_LETTERS = "[a-zA-Z]"; +const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; -const BASE_URL = 'https://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"; @@ -68,7 +68,3 @@ const PATIENT_OUT_SA = false; /// Timer Info const TIMER_MIN =10; -class AppGlobal{ -static var CONTEX; -} - diff --git a/lib/interceptor/http_interceptor.dart b/lib/interceptor/http_interceptor.dart new file mode 100644 index 00000000..4d0f9c33 --- /dev/null +++ b/lib/interceptor/http_interceptor.dart @@ -0,0 +1,65 @@ +import 'dart:convert'; + +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/providers/auth_provider.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:http/http.dart'; +import 'package:http_interceptor/http_interceptor.dart'; + +import '../providers/auth_provider.dart'; +import '../util/dr_app_shared_pref.dart'; + +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +List publicUrls = [ + LOGIN_URL, + SELECT_DEVICE_IMEI, + MEMBER_CHECK_ACTIVATION_CODE_NEW, + SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE +]; + +class HttpInterceptor extends InterceptorContract { + + Client getClient(){ + return HttpClientWithInterceptor.build(interceptors: [this]); +} + + Future interceptRequest({RequestData data}) async { + print('RequestData ${data.body}'); + print('RequestData ${data.url}'); + try { + data.headers["Content-Type"] = "application/json"; + data.headers["Accept"] = "application/json"; + // if (publicUrls.contains(data.url)) { + // var loggedUserInfo = await sharedPref.getObj('loggedUser'); + // var token = await sharedPref.getString(TOKEN); + // // print("token"+token); + // // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}'); + // // // the sevices handel the token in differat name so I ask to be change + // // // we must change the imple + // var body = json.decode(data.body); + // body['LogInTokenID']=token; + // data.body = json.encode(body); + + // // data.body['LogInTokenID'] = ''; + // } else { + // if (data.body['LogInTokenID']) { + // data.body['LogInTokenID'] = ''; + // } + // if (data.body['TokenID']) { + // data.body['TokenID'] = ''; + // } + // } + } catch (e) { + print(e); + } + + // print('data.body${data.body}'); + return data; + } + + @override + Future interceptResponse({ResponseData data}) async { + // print('ResponseData ${data.body}'); + return data; + } +} diff --git a/lib/models/patient/refer_to_doctor_request.dart b/lib/models/patient/refer_to_doctor_request.dart index 11229596..28eb488b 100644 --- a/lib/models/patient/refer_to_doctor_request.dart +++ b/lib/models/patient/refer_to_doctor_request.dart @@ -1,3 +1,5 @@ +import 'package:flutter/cupertino.dart'; + class ReferToDoctorRequest { /* @@ -64,27 +66,27 @@ class ReferToDoctorRequest { */ ReferToDoctorRequest( - {this.projectID, - this.admissionNo, - this.roomID = "ISO-6", - this.referralClinic, - this.referralDoctor , - this.createdBy, - this.editedBy , - this.patientID, - this.patientTypeID = 1, - this.referringClinic, - this.referringDoctor, - this.referringDoctorRemarks, - this.priority , - this.frequency, - this.extension, + {@required this.projectID, + @required this.admissionNo, + @required this.roomID , + @required this.referralClinic, + @required this.referralDoctor , + @required this.createdBy, + @required this.editedBy , + @required this.patientID, + @required this.patientTypeID, + @required this.referringClinic, + @required this.referringDoctor, + @required this.referringDoctorRemarks, + @required this.priority , + @required this.frequency, + @required this.extension, this.languageID = 2, this.stamp = "2020-06-03T11:26:42.358Z", this.iPAdress = "11.11.11.11", this.versionID = 1.2, this.channel = 9, - this.tokenID, + @required this.tokenID, this.sessionID = "JBXRsDl37L", this.isLoginForDoctorApp = true, this.patientOutSA = false}); diff --git a/lib/presentation/doctor_app_icons.dart b/lib/presentation/doctor_app_icons.dart index c4430db3..76aefa45 100644 --- a/lib/presentation/doctor_app_icons.dart +++ b/lib/presentation/doctor_app_icons.dart @@ -31,4 +31,7 @@ class DoctorApp { static const IconData message_icon_active = IconData(0xe807, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData scdedule_icon_active = IconData(0xe808, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData schedule_icon = IconData(0xe809, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData reject_icon = IconData(0xe80a, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData approved_icon = IconData(0xe80b, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData pending_icon = IconData(0xe80c, fontFamily: _kFontFam, fontPackage: _kFontPkg); } diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index f362442d..af93c837 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -1,108 +1,86 @@ -import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'dart:convert'; +import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:flutter/cupertino.dart'; - import '../models/user_model.dart'; -const LOGIN_URL = 'Sentry.svc/REST/MemberLogIN_New'; -const INSERT_DEVICE_IMEI = 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; +const LOGIN_URL = + 'Sentry.svc/REST/MemberLogIN_New'; +const INSERT_DEVICE_IMEI = + 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; const SELECT_DEVICE_IMEI = 'Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = 'Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; -const MEMBER_CHECK_ACTIVATION_CODE_NEW = - 'Sentry.svc/REST/MemberCheckActivationCode_New'; +const MEMBER_CHECK_ACTIVATION_CODE_NEW ='Sentry.svc/REST/MemberCheckActivationCode_New'; const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles'; - class AuthProvider with ChangeNotifier { - Future login(UserModel userInfo) async { - try { - dynamic localRes; + Future login(UserModel userInfo) async { + const url = LOGIN_URL; - await BaseAppClient.post(LOGIN_URL, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: { - "UserID": userInfo.UserID, - "Password": userInfo.Password, - "ProjectID": userInfo.ProjectID, - "LanguageID": userInfo.LanguageID, - "IPAdress": userInfo.IPAdress, - "VersionID": userInfo.VersionID, - "Channel": userInfo.Channel, - "SessionID": userInfo.SessionID - }); - - return Future.value(localRes); + try { + final response = await AppClient.post(url, + body: json.encode({ + "UserID": userInfo.UserID, + "Password": userInfo.Password, + "ProjectID": userInfo.ProjectID, + "LanguageID": userInfo.LanguageID, + "IPAdress": userInfo.IPAdress, + "VersionID": userInfo.VersionID, + "Channel": userInfo.Channel, + "SessionID": userInfo.SessionID + })); + return Future.value(json.decode(response.body)); } catch (error) { print(error); throw error; } } - Future insertDeviceImei(imei) async { - try { - dynamic localRes; + Future insertDeviceImei(imei) async { + const url = INSERT_DEVICE_IMEI; - await BaseAppClient.post(INSERT_DEVICE_IMEI, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: imei); - return Future.value(localRes); + try { + final response = await AppClient.post(url, body: json.encode(imei)); + return Future.value(json.decode(response.body)); } catch (error) { print(error); throw error; } } - Future selectDeviceImei(imei) async { + Future selectDeviceImei(imei) async { + const url = SELECT_DEVICE_IMEI; + try { - dynamic localRes; - await BaseAppClient.post(SELECT_DEVICE_IMEI, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: imei); - return Future.value(localRes); + final response = await AppClient.post(url, body: json.encode(imei)); + return Future.value(json.decode(response.body)); } catch (error) { print(error); throw error; } } - Future sendActivationCodeByOtpNotificationType( + Future sendActivationCodeByOtpNotificationType( activationCodeModel) async { + const url = SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE; + try { - var localRes; - await BaseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: activationCodeModel); - return Future.value(localRes); + final response = await AppClient.post(url, body: json.encode(activationCodeModel)); + return Future.value(json.decode(response.body)); } catch (error) { print(error); throw error; } } - Future memberCheckActivationCodeNew(activationCodeModel) async { + Future memberCheckActivationCodeNew(activationCodeModel) async { + const url = MEMBER_CHECK_ACTIVATION_CODE_NEW; + try { - dynamic localRes; - await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: activationCodeModel); - return Future.value(localRes); + final response = await AppClient.post(url, body: json.encode(activationCodeModel)); + return Future.value(json.decode(response.body)); } catch (error) { print(error); throw error; @@ -116,16 +94,12 @@ class AuthProvider with ChangeNotifier { *@return:Future *@desc: getDocProfiles */ - Future getDocProfiles(docInfo) async { + Future getDocProfiles(docInfo) async { + const url = GET_DOC_PROFILES; + try { - dynamic localRes; - await BaseAppClient.post(GET_DOC_PROFILES, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: docInfo); - return Future.value(localRes); + final response = await AppClient.post(url, body: json.encode(docInfo)); + return Future.value(json.decode(response.body)); } catch (error) { print(error); throw error; diff --git a/lib/providers/hospital_provider.dart b/lib/providers/hospital_provider.dart index e2561632..abf758a2 100644 --- a/lib/providers/hospital_provider.dart +++ b/lib/providers/hospital_provider.dart @@ -1,8 +1,11 @@ -import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'dart:convert'; + +import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:flutter/cupertino.dart'; class HospitalProvider with ChangeNotifier { + Future getProjectsList() async { const url = GET_PROJECTS; var info = { @@ -15,17 +18,12 @@ class HospitalProvider with ChangeNotifier { "SessionID": "i1UJwCTSqt", "IsLoginForDoctorApp": true }; - dynamic localRes ; - - await BaseAppClient.post(url, - onSuccess: ( response, statusCode) async { - localRes= response; - }, - onFailure: (String error, int statusCode) { - throw error; - }, - body: info); - return Future.value(localRes); - + try { + final response = await AppClient.post(url, body: json.encode(info)); + return Future.value(json.decode(response.body)); + } catch (error) { + throw error; + // print('error'); + } } } diff --git a/lib/providers/medicine_provider.dart b/lib/providers/medicine_provider.dart index 1f432531..a0d8f4ed 100644 --- a/lib/providers/medicine_provider.dart +++ b/lib/providers/medicine_provider.dart @@ -1,39 +1,57 @@ -import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'dart:convert'; + +import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/pharmacies_List_request_model.dart'; import 'package:doctor_app_flutter/models/pharmacies_items_request_model.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; -import '.../../../util/dr_app_shared_pref.dart'; - class MedicineProvider with ChangeNotifier { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - + var pharmacyItemsList = []; var pharmaciesList = []; bool isFinished = true; bool hasError = false; String errorMsg = ''; - PharmaciesItemsRequestModel _itemsRequestModel = - PharmaciesItemsRequestModel(); + PharmaciesItemsRequestModel _itemsRequestModel =PharmaciesItemsRequestModel(); PharmaciesListRequestModel _listRequestModel = PharmaciesListRequestModel(); Future getMedicineItem(String itemName) async { resetDefaultValues(); try { - _itemsRequestModel.pHRItemName = itemName; - await BaseAppClient.post(PHARMACY_ITEMS_URL, - onSuccess: (dynamic response, int statusCode) { - pharmacyItemsList = response['ListPharmcy_Region']; - hasError = false; + if (await Helpers.checkConnection()) { + _itemsRequestModel.pHRItemName = itemName; + + final response = await AppClient.post(PHARMACY_ITEMS_URL, + body: json.encode(_itemsRequestModel.toJson())); + final int statusCode = response.statusCode; isFinished = true; - errorMsg = "Done"; - }, onFailure: (String error, int statusCode) { + if (statusCode < 200 || statusCode >= 400 || json == null) { + isFinished = true; + hasError = true; + errorMsg = 'Error While Fetching data'; + } else { + var parsed = json.decode(response.body.toString()); + if (parsed['MessageStatus'] == 1) { + pharmacyItemsList = parsed['ListPharmcy_Region']; + hasError = false; + isFinished = true; + errorMsg = "Done"; + } else { + hasError = true; + errorMsg = parsed['ErrorMessage'] ?? parsed['ErrorEndUserMessage']; + } + } + } else { isFinished = true; hasError = true; - errorMsg = error; - }, body: _itemsRequestModel.toJson()); + errorMsg = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (error) { throw error; @@ -43,20 +61,37 @@ class MedicineProvider with ChangeNotifier { } Future getPharmaciesList(int itemId) async { + String token = await sharedPref.getString(TOKEN); resetDefaultValues(); try { - _listRequestModel.itemID = itemId; - await BaseAppClient.post(PHARMACY_LIST_URL, - onSuccess: (dynamic response, int statusCode) { - pharmaciesList = response['PharmList']; - hasError = false; + if (await Helpers.checkConnection()) { + _listRequestModel.itemID = itemId; + _listRequestModel.tokenID = token; + final response = await AppClient.post(PHARMACY_LIST_URL, + body: json.encode(_listRequestModel.toJson())); + final int statusCode = response.statusCode; isFinished = true; - errorMsg = "Done"; - }, onFailure: (String error, int statusCode) { + if (statusCode < 200 || statusCode >= 400 || json == null) { + isFinished = true; + hasError = true; + errorMsg = 'Error While Fetching data'; + } else { + var parsed = json.decode(response.body.toString()); + if (parsed['MessageStatus'] == 1) { + pharmaciesList = parsed['PharmList']; + hasError = false; + isFinished = true; + errorMsg = "Done"; + } else { + hasError = true; + errorMsg = parsed['ErrorMessage'] ?? parsed['ErrorEndUserMessage']; + } + } + } else { isFinished = true; hasError = true; - errorMsg = error; - }, body: _listRequestModel.toJson()); + errorMsg = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (error) { throw error; diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 2a626c28..91b5c09f 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -1,3 +1,6 @@ +import 'dart:convert'; + +import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; @@ -15,8 +18,12 @@ import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; import 'package:doctor_app_flutter/models/prescription_report.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; +import 'package:http/http.dart'; +import 'package:http_interceptor/http_client_with_interceptor.dart'; +import '../client/app_client.dart'; import '../config/config.dart'; +import '../interceptor/http_interceptor.dart'; import '../models/patient/lab_orders_res_model.dart'; import '../models/patient/patiant_info_model.dart'; import '../models/patient/patient_model.dart'; @@ -60,47 +67,53 @@ class PatientsProvider with ChangeNotifier { STPReferralFrequencyRequest(); ClinicByProjectIdRequest _clinicByProjectIdRequest = ClinicByProjectIdRequest(); - ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); + ReferToDoctorRequest _referToDoctorRequest ; + Client client = + HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); PatiantInformtion _selectedPatient; - Future getPatientList(PatientModel patient, patientType) async { + Future getPatientList(PatientModel patient, patientType) async { + /* const url = + BASE_URL+'DoctorApplication.svc/REST/GetMyInPatient';*/ + int val = int.parse(patientType); + //**********Modify url by amjad amireh for patiant type********* - try { - 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, - "DoctorID": patient.DoctorID, - "FirstName": patient.FirstName, - "MiddleName": patient.MiddleName, - "LastName": patient.LastName, - "PatientMobileNumber": patient.PatientMobileNumber, - "PatientIdentificationID": patient.PatientIdentificationID, - "PatientID": patient.PatientID, - "From": patient.From, - "To": patient.To, - "LanguageID": patient.LanguageID, - "stamp": patient.stamp, - "IPAdress": patient.IPAdress, - "VersionID": patient.VersionID, - "Channel": patient.Channel, - "TokenID": patient.TokenID, - "SessionID": patient.SessionID, - "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, - "PatientOutSA": patient.PatientOutSA - }); + final url = + BASE_URL + "DoctorApplication.svc/REST/" + SERVICES_PATIANT[val]; + // print("a===========$url=======a"); - return Future.value(localRes); - } catch (error) { - print(error); - throw error; + try { + final response = await client.post(url, + body: json.encode({ + "ProjectID": patient.ProjectID, + "ClinicID": patient.ClinicID, + "DoctorID": patient.DoctorID, + "FirstName": patient.FirstName, + "MiddleName": patient.MiddleName, + "LastName": patient.LastName, + "PatientMobileNumber": patient.PatientMobileNumber, + "PatientIdentificationID": patient.PatientIdentificationID, + "PatientID": patient.PatientID, + "From": patient.From, + "To": patient.To, + "LanguageID": patient.LanguageID, + "stamp": patient.stamp, + "IPAdress": patient.IPAdress, + "VersionID": patient.VersionID, + "Channel": patient.Channel, + "TokenID": patient.TokenID, + "SessionID": patient.SessionID, + "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, + "PatientOutSA": patient.PatientOutSA + })); +//********************** +//*********************** + + return Future.value(json.decode(response.body)); + } catch (err) { + throw err; } } @@ -122,38 +135,48 @@ class PatientsProvider with ChangeNotifier { setBasicData(); try { - await BaseAppClient.post(GET_PATIENT_VITAL_SIGN, - onSuccess: (dynamic response, int statusCode) { - patientVitalSignList = []; - response['List_DoctorPatientVitalSign'].forEach((v) { - patientVitalSignList.add(new VitalSignResModel.fromJson(v)); - }); + if (await Helpers.checkConnection()) { + final response = await AppClient.post(GET_PATIENT_VITAL_SIGN, + body: json.encode(patient)); + final int statusCode = response.statusCode; + isLoading = false; - if (patientVitalSignList.length > 0) { - List patientVitalSignOrderdSubListTemp = []; - patientVitalSignOrderdSubListTemp = patientVitalSignList; - patientVitalSignOrderdSubListTemp - .sort((VitalSignResModel a, VitalSignResModel b) { - return b.vitalSignDate.microsecondsSinceEpoch - - a.vitalSignDate.microsecondsSinceEpoch; - }); - patientVitalSignOrderdSubList.clear(); - int length = patientVitalSignOrderdSubListTemp.length >= 20 - ? 20 - : patientVitalSignOrderdSubListTemp.length; - for (int x = 0; x < length; x++) { - patientVitalSignOrderdSubList - .add(patientVitalSignOrderdSubListTemp[x]); + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientVitalSignList = []; + res['List_DoctorPatientVitalSign'].forEach((v) { + patientVitalSignList.add(new VitalSignResModel.fromJson(v)); + }); + + if (patientVitalSignList.length > 0) { + List patientVitalSignOrderdSubListTemp = []; + patientVitalSignOrderdSubListTemp = patientVitalSignList; + patientVitalSignOrderdSubListTemp + .sort((VitalSignResModel a, VitalSignResModel b) { + return b.vitalSignDate.microsecondsSinceEpoch - + a.vitalSignDate.microsecondsSinceEpoch; + }); + patientVitalSignOrderdSubList.clear(); + for (int x = 0; x < 20; x++) { + patientVitalSignOrderdSubList + .add(patientVitalSignOrderdSubListTemp[x]); + } + } + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; } } - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + } else { isLoading = false; isError = true; - this.error = error; - }, body: patient); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -172,20 +195,33 @@ class PatientsProvider with ChangeNotifier { setBasicData(); try { - await BaseAppClient.post(GET_PATIENT_LAB_OREDERS, - onSuccess: (dynamic response, int statusCode) { - patientLabResultOrdersList = []; - response['List_GetLabOreders'].forEach((v) { - patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); - }); + if (await Helpers.checkConnection()) { + final response = await AppClient.post(GET_PATIENT_LAB_OREDERS, + body: json.encode(patient)); + final int statusCode = response.statusCode; isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientLabResultOrdersList = []; + res['List_GetLabOreders'].forEach((v) { + patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); + }); + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: patient); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -200,21 +236,36 @@ class PatientsProvider with ChangeNotifier { */ getOutPatientPrescriptions(patient) async { setBasicData(); + try { - await BaseAppClient.post(GET_PRESCRIPTION, - onSuccess: (dynamic response, int statusCode) { - patientPrescriptionsList = []; - response['PatientPrescriptionList'].forEach((v) { - patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v)); - }); + if (await Helpers.checkConnection()) { + final response = + await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); + final int statusCode = response.statusCode; isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientPrescriptionsList = []; + res['PatientPrescriptionList'].forEach((v) { + patientPrescriptionsList + .add(new PrescriptionResModel.fromJson(v)); + }); + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: patient); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -298,20 +349,33 @@ class PatientsProvider with ChangeNotifier { // notifyListeners(); setBasicData(); try { - await BaseAppClient.post(GET_RADIOLOGY, - onSuccess: (dynamic response, int statusCode) { - patientRadiologyList = []; - response['List_GetRadOreders'].forEach((v) { - patientRadiologyList.add(new RadiologyResModel.fromJson(v)); - }); + if (await Helpers.checkConnection()) { + final response = + await AppClient.post(GET_RADIOLOGY, body: json.encode(patient)); + final int statusCode = response.statusCode; isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientRadiologyList = []; + res['List_GetRadOreders'].forEach((v) { + patientRadiologyList.add(new RadiologyResModel.fromJson(v)); + }); + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: patient); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -345,17 +409,31 @@ class PatientsProvider with ChangeNotifier { getPatientInsuranceApprovals(patient) async { setBasicData(); try { - await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL, - onSuccess: (dynamic response, int statusCode) { - insuranceApporvalsList = response['List_ApprovalMain_InPatient']; + if (await Helpers.checkConnection()) { + final response = await AppClient.post(PATIENT_INSURANCE_APPROVALS_URL, + body: json.encode(patient)); + final int statusCode = response.statusCode; isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + //patientRadiologyList = []; + insuranceApporvalsList = res['List_ApprovalMain_InPatient']; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: patient); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -369,17 +447,30 @@ class PatientsProvider with ChangeNotifier { getPatientProgressNote(patient) async { setBasicData(); try { - await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL, - onSuccess: (dynamic response, int statusCode) { - patientProgressNoteList = response['List_GetPregressNoteForInPatient']; + if (await Helpers.checkConnection()) { + final response = await AppClient.post(PATIENT_PROGRESS_NOTE_URL, + body: json.encode(patient)); + final int statusCode = response.statusCode; isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientProgressNoteList = res['List_GetPregressNoteForInPatient']; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: patient); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -391,23 +482,45 @@ class PatientsProvider with ChangeNotifier { *@desc: getDoctorsList */ getDoctorsList(String clinicId) async { + String token = await sharedPref.getString(TOKEN); + int projectID = await sharedPref.getInt(PROJECT_ID); setBasicData(); try { - _doctorsByClinicIdRequest.clinicID = clinicId; - await BaseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, - onSuccess: (dynamic response, int statusCode) { - doctorsList = response['List_Doctors_All']; - isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + if (await Helpers.checkConnection()) { + _doctorsByClinicIdRequest.projectID = projectID; + _doctorsByClinicIdRequest.clinicID = clinicId; + _doctorsByClinicIdRequest.tokenID = token; + + final response = await AppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, + body: json.encode(_doctorsByClinicIdRequest)); + final int statusCode = response.statusCode; + + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + isLoading = false; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + doctorsList = res['List_Doctors_All']; + isLoading = false; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + isLoading = false; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: _doctorsByClinicIdRequest.toJson()); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); + isLoading = false; } } @@ -422,19 +535,37 @@ class PatientsProvider with ChangeNotifier { *@desc: getClinicsList */ getClinicsList() async { + String token = await sharedPref.getString(TOKEN); setBasicData(); try { - await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, - onSuccess: (dynamic response, int statusCode) { - clinicsList = response['List_Clinic_All']; + if (await Helpers.checkConnection()) { + int projectID = await sharedPref.getInt(PROJECT_ID); + _clinicByProjectIdRequest.projectID = projectID; + _clinicByProjectIdRequest.tokenID = token; + + final response = await AppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, + body: json.encode(_clinicByProjectIdRequest)); + final int statusCode = response.statusCode; isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + clinicsList = res['List_Clinic_All']; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: _clinicByProjectIdRequest.toJson()); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -453,19 +584,33 @@ class PatientsProvider with ChangeNotifier { *@desc: getReferralFrequancyList */ getReferralFrequancyList() async { + String token = await sharedPref.getString(TOKEN); setBasicData(); try { - await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL, - onSuccess: (dynamic response, int statusCode) { - referalFrequancyList = response['list_STPReferralFrequency']; + if (await Helpers.checkConnection()) { + _referralFrequencyRequest.tokenID = token; + final response = await AppClient.post(PATIENT_GET_LIST_REFERAL_URL, + body: json.encode(_referralFrequencyRequest)); + final int statusCode = response.statusCode; isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + referalFrequancyList = res['list_STPReferralFrequency']; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: _referralFrequencyRequest.toJson()); + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -483,48 +628,69 @@ class PatientsProvider with ChangeNotifier { *@Date:3/6/2020 *@desc: referToDoctor */ - referToDoctor( - int selectedDoctorID, - int selectedClinicID, - String selectedReferralFrequancyID, + referToDoctor(context, + {String selectedDoctorID, + String selectedClinicID, int admissionNo, String extension, - String doctorRemark) async { - String token = await sharedPref.getString(TOKEN); - int projectID = await sharedPref.getInt(PROJECT_ID); - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); - int doctorID = doctorProfile.doctorID; - int clinicId = doctorProfile.clinicID; + String priority, + String frequency, + String referringDoctorRemarks, + int patientID, + int patientTypeID, + String roomID, + int projectID}) async { setBasicData(); try { - // _referToDoctorRequest.tokenID = token; - // _referToDoctorRequest.admissionNo = admissionNo; - // _referToDoctorRequest.projectID = projectID; - // _referToDoctorRequest.tokenID = token; - // _referToDoctorRequest.extension = extension; - // _referToDoctorRequest.frequency = selectedReferralFrequancyID; - // _referToDoctorRequest.patientID = - // _referToDoctorRequest.priority = - // _referToDoctorRequest.referralClinic = - // _referToDoctorRequest.referralDoctor = - // _referToDoctorRequest.referringDoctorRemarks = - // _referToDoctorRequest.roomID = - // _referToDoctorRequest.referringClinic = - // _referToDoctorRequest.referringDoctor = - - await BaseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL, - onSuccess: (dynamic response, int statusCode) { - patientProgressNoteList = response['List_GetPregressNoteForInPatient']; + if (await Helpers.checkConnection()) { + String token = await sharedPref.getString(TOKEN); + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + DoctorProfileModel doctorProfile = + new DoctorProfileModel.fromJson(profile); + int doctorID = doctorProfile.doctorID; + int clinicId = doctorProfile.clinicID; + _referToDoctorRequest = ReferToDoctorRequest( + projectID: projectID, + admissionNo: admissionNo, + roomID: roomID, + referralClinic: selectedClinicID.toString(), + referralDoctor: selectedDoctorID.toString(), + createdBy: doctorID, + editedBy: doctorID, + patientID: patientID, + patientTypeID: patientTypeID, + referringClinic: clinicId, + referringDoctor: doctorID, + referringDoctorRemarks: referringDoctorRemarks, + priority: priority, + frequency: frequency, + extension: extension, + tokenID: token); + + final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL, + body: json.encode(_referToDoctorRequest)); + final int statusCode = response.statusCode; isLoading = false; - isError = false; - this.error = ''; - }, onFailure: (String error, int statusCode) { + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + print('Done : \n $res'); + Navigator.pop(context); + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { isLoading = false; isError = true; - this.error = error; - }, body: _referralFrequencyRequest.toJson()); - + error = 'Please Check The Internet Connection'; + } notifyListeners(); } catch (err) { handelCatchErrorCase(err); diff --git a/lib/screens/QR_reader_screen.dart b/lib/screens/QR_reader_screen.dart index 80d9332d..bbbe327a 100644 --- a/lib/screens/QR_reader_screen.dart +++ b/lib/screens/QR_reader_screen.dart @@ -7,7 +7,6 @@ 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'; @@ -160,9 +159,9 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); } else { setState(() { isError = true; + error = 'No patient'; isLoading = false; }); - DrAppToastMsg.showErrorToast('No patient'); } break; case "1": @@ -177,27 +176,20 @@ 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/medicine/medicine_search_screen.dart b/lib/screens/medicine/medicine_search_screen.dart index 1add0181..2b14edeb 100644 --- a/lib/screens/medicine/medicine_search_screen.dart +++ b/lib/screens/medicine/medicine_search_screen.dart @@ -11,7 +11,6 @@ import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../util/extenstions.dart'; @@ -61,9 +60,6 @@ class _MedicineSearchState extends State { hintText: 'Search Medicine Name Here..', controller: myController, onSaved: (value) {}, - // validator: (value) { - // return TextValidator().validateName(value); - // }, inputFormatter: ONLY_LETTERS), ), @@ -99,7 +95,7 @@ class _MedicineSearchState extends State { ), Expanded( child: Container( - width: SizeConfig.screenWidth * 0.80, + width: SizeConfig.screenWidth * 0.97, child: !_medicineProvider.isFinished ? DrAppCircularProgressIndeicator() : _medicineProvider.hasError @@ -127,7 +123,7 @@ class _MedicineSearchState extends State { builder: (context) => ChangeNotifierProvider( create: (_) => MedicineProvider(), child: PharmaciesListScreen( - itemID: data[index]["ItemID"]), + itemID: data[index]["ItemID"], url: data[index]["ProductImageBase64"]), ), ), ); diff --git a/lib/screens/medicine/pharmacies_list_screen.dart b/lib/screens/medicine/pharmacies_list_screen.dart index 4c682cea..60f24862 100644 --- a/lib/screens/medicine/pharmacies_list_screen.dart +++ b/lib/screens/medicine/pharmacies_list_screen.dart @@ -1,11 +1,10 @@ -import 'package:doctor_app_flutter/config/config.dart'; +import 'dart:convert'; +import 'dart:typed_data'; + import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/models/pharmacies_List_request_model.dart'; import 'package:doctor_app_flutter/providers/medicine_provider.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; -import 'package:doctor_app_flutter/widgets/medicine/medicine_item_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; @@ -20,8 +19,11 @@ DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); class PharmaciesListScreen extends StatefulWidget { final int itemID; + final String url; + // In the constructor, require a item id. - PharmaciesListScreen({Key key, @required this.itemID}) : super(key: key); + PharmaciesListScreen({Key key, @required this.itemID, this.url}) + : super(key: key); @override _PharmaciesListState createState() => _PharmaciesListState(); @@ -61,44 +63,77 @@ class _PharmaciesListState extends State { TextStyle(color: Theme.of(context).errorColor), ), ) - : Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - AppText( - "Description", - margin: 10, - fontWeight: FontWeight.bold, - ), - AppText( - _data[0]["ItemDescription"], - marginLeft: 10, - marginTop: 0, - marginRight: 10, - marginBottom: 10, - ), - AppText( - "Price", - margin: 10, - fontWeight: FontWeight.bold, - ), - AppText( - _data[0]["SellingPrice"].toString(), - marginLeft: 10, - marginTop: 0, - marginRight: 10, - marginBottom: 10, - ), - ], - )), + : StreamBuilder( + stream: null, + builder: (context, snapshot) { + return Row( + children: [ + Expanded( + flex: 1, + child: ClipRRect( + borderRadius: + BorderRadius.all(Radius.circular(7)), + child: Image.memory( + dataFromBase64String(widget.url), + height: SizeConfig.imageSizeMultiplier * 21, + width: SizeConfig.imageSizeMultiplier * 20, + fit: BoxFit.cover, + ), + ), + ), + Expanded( + flex: 3, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.stretch, + children: [ + AppText( + "Description", + marginLeft: 10, + marginTop: 0, + marginRight: 10, + marginBottom: 2, + fontWeight: FontWeight.bold, + ), + AppText( + _data[0]["ItemDescription"], + marginLeft: 10, + marginTop: 0, + marginRight: 10, + marginBottom: 10, + ), + AppText( + "Price", + marginLeft: 10, + marginTop: 0, + marginRight: 10, + marginBottom: 2, + fontWeight: FontWeight.bold, + ), + AppText( + _data[0]["SellingPrice"].toString(), + marginLeft: 10, + marginTop: 0, + marginRight: 10, + marginBottom: 10, + ), + ], + ), + ) + ], + ); + })), Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + margin: EdgeInsets.only(top:SizeConfig.widthMultiplier * 2, + bottom: SizeConfig.widthMultiplier * 2, + right: SizeConfig.widthMultiplier * 4, + left: SizeConfig.widthMultiplier * 4,), child: Align( alignment: Alignment.centerLeft, child: AppText( "You can Find it in", fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 3, ))), Expanded( child: Container( @@ -114,7 +149,8 @@ class _PharmaciesListState extends State { Expanded( flex: 1, child: ClipRRect( - borderRadius:BorderRadius.all(Radius.circular(7)), + borderRadius: + BorderRadius.all(Radius.circular(7)), child: Image.network( _data[index]["ProjectImageURL"], height: SizeConfig.imageSizeMultiplier * 15, @@ -138,25 +174,36 @@ class _PharmaciesListState extends State { crossAxisAlignment: WrapCrossAlignment.end, children: [ Padding( - padding: EdgeInsets.all(5), - child: InkWell(child: Icon(Icons.call, color: Colors.red,),onTap: ()=>launch( - "tel://" + _data[index]["PhoneNumber"]),), - ), -Padding( - padding: EdgeInsets.all(5), - child: InkWell(child: Icon(Icons.pin_drop, color: Colors.red,),onTap: () { - MapsLauncher.launchCoordinates( - double.parse(_data[index]["Latitude"]), - double.parse(_data[index]["Longitude"]), - _data[index]["LocationDescription"]); - },), - ), + padding: EdgeInsets.all(5), + child: InkWell( + child: Icon( + Icons.call, + color: Colors.red, + ), + onTap: () => launch( + "tel://" + _data[index]["PhoneNumber"]), + ), + ), + Padding( + padding: EdgeInsets.all(5), + child: InkWell( + child: Icon( + Icons.pin_drop, + color: Colors.red, + ), + onTap: () { + MapsLauncher.launchCoordinates( + double.parse( + _data[index]["Latitude"]), + double.parse( + _data[index]["Longitude"]), + _data[index]["LocationDescription"]); + }, + ), + ), ], - ), ), - - ], ), ); @@ -170,9 +217,20 @@ Padding( _medicineProvider.getPharmaciesList(widget.itemID).then((result) { this.setState(() { _data = _medicineProvider.pharmaciesList; - //if(_data == null || _data.length == 0) }); }); return true; } + + Image imageFromBase64String(String base64String) { + return Image.memory(base64Decode(base64String)); + } + + Uint8List dataFromBase64String(String base64String) { + return base64Decode(base64String); + } + + String base64String(Uint8List data) { + return base64Encode(data); + } } diff --git a/lib/screens/patients/patients_list_screen.dart b/lib/screens/patients/patients_list_screen.dart index 150de5df..6d0b97a8 100644 --- a/lib/screens/patients/patients_list_screen.dart +++ b/lib/screens/patients/patients_list_screen.dart @@ -33,10 +33,6 @@ 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 7076cc09..a5d8d96e 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -104,8 +104,7 @@ class _PatientsScreenState extends State { }).catchError((error) { setState(() { _isError = true; - _isLoading = false; - this.error = error; + this.error = helpers.generateContactAdminMsg(error); }); }); } diff --git a/lib/screens/patients/profile/insurance_approvals_screen.dart b/lib/screens/patients/profile/insurance_approvals_screen.dart index bb88321d..2bb59318 100644 --- a/lib/screens/patients/profile/insurance_approvals_screen.dart +++ b/lib/screens/patients/profile/insurance_approvals_screen.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/models/patient/insurance_aprovals_request.dart'; +import 'package:doctor_app_flutter/presentation/doctor_app_icons.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; @@ -116,29 +117,46 @@ class _InsuranceApprovalsState extends State { ExpansionTile( title: Row( children: [ - Icon( - approvalsList[index][ - "ApprovalStatusDescption"] - .toString() - .contains("Approved") - ? Icons.check_circle_outline - : approvalsList[index][ + Column( + children: [ + Icon( + approvalsList[index][ "ApprovalStatusDescption"] .toString() - .contains("Cancelled") - ? Icons.highlight_off - : Icons.history, - color: approvalsList[index][ - "ApprovalStatusDescption"] - .toString() - .contains("Approved") - ? Colors.green - : approvalsList[index][ + .contains("Approved") + ? DoctorApp.approved_icon + : approvalsList[index][ + "ApprovalStatusDescption"] + .toString() + .contains("Cancelled") + ? DoctorApp.reject_icon + : DoctorApp.pending_icon, + color: approvalsList[index][ "ApprovalStatusDescption"] .toString() - .contains("Cancelled") - ? Colors.red - : Colors.yellow, + .contains("Approved") + ? Colors.green + : approvalsList[index][ + "ApprovalStatusDescption"] + .toString() + .contains("Cancelled") + ? Colors.red + : Colors.yellow, + ), + AppText(approvalsList[index]["ApprovalStatusDescption"], + fontSize: SizeConfig.textMultiplier * 1.5, + color: approvalsList[index][ + "ApprovalStatusDescption"] + .toString() + .contains("Approved") + ? Colors.green + : approvalsList[index][ + "ApprovalStatusDescption"] + .toString() + .contains("Cancelled") + ? Colors.red + : Colors.yellow,) + ], ), Expanded( child: Column( @@ -186,15 +204,8 @@ class _InsuranceApprovalsState extends State { backgroundColor: Color(PRIMARY_COLOR), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - AppText( - "Approval No:", - color: Colors.white, - fontSize: 16, - margin: 10, - ), AppText( approvalsList[index] ["ApprovalNo"] @@ -203,10 +214,21 @@ class _InsuranceApprovalsState extends State { fontSize: 19, fontWeight: FontWeight.bold, - margin: 5, + marginTop: 10, + marginLeft: 10, + marginRight: 10, + marginBottom: 2, + ), + + AppText( + "Approval No:", + color: Colors.white, + fontSize: 16, + marginTop: 2, + marginLeft: 10, + marginBottom: 15, + marginRight: 10, ), - ], - ), Row( children: [ Expanded( diff --git a/lib/screens/patients/profile/radiology/radiology_screen.dart b/lib/screens/patients/profile/radiology/radiology_screen.dart index 5d232d3a..1ddf944e 100644 --- a/lib/screens/patients/profile/radiology/radiology_screen.dart +++ b/lib/screens/patients/profile/radiology/radiology_screen.dart @@ -132,6 +132,10 @@ class _RadiologyScreenState extends State { url: patientsProv .patientRadiologyList[index] .doctorImageURL, + name: patientsProv + .patientLabResultOrdersList[ + index] + .doctorName, ), Expanded( child: Padding( diff --git a/lib/screens/patients/profile/refer_patient_screen.dart b/lib/screens/patients/profile/refer_patient_screen.dart index 1781867c..24146ca5 100644 --- a/lib/screens/patients/profile/refer_patient_screen.dart +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -1,6 +1,13 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import '../../../config/size_config.dart'; import '../../../providers/patients_provider.dart'; @@ -27,26 +34,29 @@ class ReferPatientScreen extends StatefulWidget { class _ReferPatientState extends State { PatientsProvider patientsProv; var doctorsList; - var clinicsList; - var referralFrequancyList; - final _controller = TextEditingController(); + final _remarksController = TextEditingController(); + final _extController = TextEditingController(); var _isInit = true; + var clinicId; + var doctorId; + var freqId; + String _selectedClinic; String _selectedDoctor; String _selectedReferralFrequancy; + List _priorities = ['Very Urgent', 'Urgent', 'Routine']; + int _activePriority = 2; + @override void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { + doctorsList = null; patientsProv = Provider.of(context); patientsProv.getClinicsList(); - patientsProv.getReferralFrequancyList(); - setState(() { - clinicsList = patientsProv.clinicsList; - referralFrequancyList = patientsProv.referalFrequancyList; - }); + patientsProv.getReferralFrequancyList(); } _isInit = false; } @@ -54,214 +64,413 @@ class _ReferPatientState extends State { @override Widget build(BuildContext context) { return AppScaffold( - appBarTitle: "Progress Note", + appBarTitle: "Refer Patient", body: patientsProv.isLoading ? DrAppCircularProgressIndeicator() : patientsProv.isError ? DrAppEmbeddedError(error: patientsProv.error) - : clinicsList == null + : patientsProv.clinicsList == null ? DrAppEmbeddedError( - error: 'You don\'t have any Progress Note') - : Column( - children: [ - RoundedContainer( - margin: 0, - showBorder: true, - raduis: 30, - borderColor: Color(0xff707070), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButton( - isExpanded: true, - value: _selectedClinic, - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return patientsProv + error: 'Something Wrong!') + : SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "Clinic", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + RoundedContainer( + margin: 10, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedClinic, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getClinicNameList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedDoctor = null; + _selectedClinic = newValue; + var clinicInfo = patientsProv.clinicsList.where((i) => + i['ClinicDescription'] + .toString() + .contains(_selectedClinic)).toList(); + + clinicId = + clinicInfo[0]['ClinicID'].toString(); + + patientsProv.getDoctorsList(clinicId); + }) + }, + items: patientsProv .getClinicNameList() .map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item, - fontSize: - SizeConfig.textMultiplier * - 2.1, - ), - ], + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), ); - }).toList(); - }, - onChanged: (newValue) => { - setState(() { - _selectedDoctor = null; - _selectedClinic = newValue; - var clinicInfo = - clinicsList.singleWhere((i) => - i['ClinicDescription'] - .toString() - .contains(_selectedClinic)); - var clinicId = - clinicInfo['ClinicID'].toString(); - patientsProv.getDoctorsList(clinicId); - }) - }, - items: patientsProv - .getClinicNameList() - .map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: TextAlign.end, - ), - ); - }).toList(), + }).toList(), + ), ), - ), - ], + ], + ), ), ), - ), - //--------------------------------------------------------------------// - RoundedContainer( - margin: 0, - showBorder: true, - raduis: 30, - borderColor: Color(0xff707070), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButton( - isExpanded: true, - value: _selectedDoctor, - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return patientsProv + //--------------------------------------------------------------------// + AppText( + "Doctor", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + + RoundedContainer( + margin: 10, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedDoctor, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getDoctorNameList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedDoctor = newValue; + doctorsList = patientsProv.doctorsList; + + var doctorInfo = + doctorsList.where((i) => + i['DoctorName'] + .toString() + .contains(_selectedDoctor)).toList(); + doctorId = doctorInfo[0]['DoctorID'].toString(); + + }) + }, + items: patientsProv .getDoctorNameList() .map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item, - fontSize: - SizeConfig.textMultiplier * - 2.1, - ), - ], + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), ); - }).toList(); - }, - onChanged: (newValue) => { - setState(() { - _selectedDoctor = newValue; - }) - }, - items: patientsProv - .getDoctorNameList() - .map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: TextAlign.end, - ), - ); - }).toList(), + }).toList(), + ), ), - ), - ], + ], + ), ), + ), //-----------------------------/// + AppText( + "Ext#", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: AppTextFormField( + hintText: "Ext#", + controller: _extController, + inputFormatter: ONLY_NUMBERS, + textInputType: TextInputType.number, + onChanged: (value) => {}, + ), + ), + AppText( + "Priority", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + + priorityBar(context), + + AppText( + "Replay Before: " + getPriority(), + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + + AppText( + "Referral Frequency", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, ), - ), //-----------------------------/// - RoundedContainer( - margin: 0, - showBorder: true, - raduis: 30, - borderColor: Color(0xff707070), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButton( - isExpanded: true, - value: _selectedReferralFrequancy, - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return patientsProv + RoundedContainer( + margin: 10, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedReferralFrequancy, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getReferralNamesList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedReferralFrequancy = newValue; + var freqInfo = + patientsProv.referalFrequancyList.singleWhere((i) => + i['Description'] + .toString() + .contains(_selectedReferralFrequancy)); + freqId = + freqInfo['ParameterCode'].toString(); + }) + }, + items: patientsProv .getReferralNamesList() .map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item, - fontSize: - SizeConfig.textMultiplier * - 2.1, - ), - ], + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), ); - }).toList(); - }, - onChanged: (newValue) => { - setState(() { - _selectedReferralFrequancy = newValue; - }) - }, - items: patientsProv - .getReferralNamesList() - .map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: TextAlign.end, - ), - ); - }).toList(), + }).toList(), + ), ), - ), - ], + ], + ), + ), + ), + AppText( + "Clinical Details and Remarks", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: AppTextFormField( + hintText: "Remarks", + controller: _remarksController, + inputFormatter: ONLY_LETTERS, + textInputType: TextInputType.text, + onChanged: (value) => {}, ), ), + Padding( + padding: const EdgeInsets.all(20.0), + child: AppButton(title: "Send", color: Color(PRIMARY_COLOR),onPressed: ()=>{ + referToDoctor(context) + },), + ) + ], + ), + ), + ); + } + + Widget priorityBar(BuildContext _context) { + return Container( + height: MediaQuery.of(context).size.height * 0.065, + width: SizeConfig.screenWidth * 0.9, + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + color: Color(0Xffffffff), borderRadius: BorderRadius.circular(20)), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: _priorities.map((item) { + bool _isActive = _priorities[_activePriority] == item ? true : false; + return Column(mainAxisSize: MainAxisSize.min, children: [ + InkWell( + child: Center( + child: Container( + height: 40, + width: 90, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + color: _isActive ? Hexcolor("#B8382B") : Colors.white, + ), + child: Center( + child: Text( + item, + style: TextStyle( + fontSize: 12, + color: _isActive + ? Colors.white + : Colors.black, //Colors.black, + // backgroundColor:_isActive + // ? Hexcolor("#B8382B") + // : Colors.white,//sideColor, + + fontWeight: FontWeight.bold, + ), ), - ], - ), + )), + ), + onTap: () { + print(_priorities.indexOf(item)); + setState(() { + _activePriority = _priorities.indexOf(item); + }); + }), + _isActive + ? Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white), + alignment: Alignment.center, + height: 3, + width: 90, + ) + : Container() + ]); + }).toList(), + ), ); } + + String getPriority() { + DateTime date = DateTime.now(); + switch (_activePriority) { + case 0: + date = date.add(new Duration(hours: 3)); + break; + case 1: + date = date.add(new Duration(hours: 6)); + break; + case 2: + date = date.add(new Duration(days: 1)); + break; + } + var format = DateFormat('yyyy/mm/dd HH:mm a'); + var time = format.format(date); + print(time); + return time; + } + + void referToDoctor(context){ + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatiantInformtion patient = routeArgs['patient']; + patientsProv.referToDoctor(context, + extension: _extController.value.text, + admissionNo:int.parse( patient.admissionNo), + referringDoctorRemarks: _remarksController.value.text, + frequency: freqId, + patientID: patient.patientId, + patientTypeID: patient.patientType, + priority: (_activePriority + 1).toString(), + roomID: patient.roomId, + selectedClinicID: clinicId.toString(), + selectedDoctorID: doctorId.toString(), + projectID: patient.projectId + ); + } } diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 2b620e10..c4da1707 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -256,7 +256,7 @@ class _VerificationMethodsState extends State { if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); - Map model = { + Map model = { "LogInTokenID": _loggedUser['LogInTokenID'], "Channel": 9, "MobileNumber": _loggedUser['MobileNumber'], diff --git a/lib/widgets/doctor/my_referral_patient_widget.dart b/lib/widgets/doctor/my_referral_patient_widget.dart index 67db51fa..02d3f10a 100644 --- a/lib/widgets/doctor/my_referral_patient_widget.dart +++ b/lib/widgets/doctor/my_referral_patient_widget.dart @@ -42,26 +42,24 @@ class _MyReferralPatientWidgetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - 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), - - ], - ), + 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)), + ], ), !_showDetails ? Container() @@ -89,7 +87,6 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), - SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.referringDoctor}', fontSize: @@ -111,7 +108,6 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), - SizedBox(height: 5,), AppText( widget.myReferralPatientModel .referringClinicDescription, @@ -139,7 +135,6 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), - SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.referringClinicDescription}', fontSize: @@ -162,7 +157,6 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), - SizedBox(height: 5,), AppText( widget.myReferralPatientModel .frequencyDescription, @@ -190,7 +184,6 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), - SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.priorityDescription}', fontSize: @@ -213,7 +206,6 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), - SizedBox(height: 5,), AppText( Helpers.getDateFormatted(widget .myReferralPatientModel diff --git a/lib/widgets/medicine/medicine_item_widget.dart b/lib/widgets/medicine/medicine_item_widget.dart index 1d606793..3998adc6 100644 --- a/lib/widgets/medicine/medicine_item_widget.dart +++ b/lib/widgets/medicine/medicine_item_widget.dart @@ -1,10 +1,6 @@ import 'dart:convert'; import 'dart:typed_data'; - -import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart'; - import '../shared/rounded_container_widget.dart'; import '../shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; diff --git a/lib/widgets/patients/profile/large_avatar.dart b/lib/widgets/patients/profile/large_avatar.dart index 845f1ee3..54cbcb30 100644 --- a/lib/widgets/patients/profile/large_avatar.dart +++ b/lib/widgets/patients/profile/large_avatar.dart @@ -35,19 +35,19 @@ class LargeAvatar extends StatelessWidget { ), ), ); - } else if (name != null || name.isNotEmpty) { + } else if (name == null || name.isEmpty) { return Center( child: AppText( - name[0].toUpperCase(), + 'DR', color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.bold, )); } else { return Center( child: AppText( - 'DR', + name[0].toUpperCase(), color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold, )); } } diff --git a/lib/widgets/shared/errors/dr_app_embedded_error.dart b/lib/widgets/shared/errors/dr_app_embedded_error.dart index 6bac4a2c..de9fd698 100644 --- a/lib/widgets/shared/errors/dr_app_embedded_error.dart +++ b/lib/widgets/shared/errors/dr_app_embedded_error.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import '../app_texts_widget.dart'; + /* *@author: Elham Rababah *@Date:12/5/2020 @@ -18,10 +20,11 @@ class DrAppEmbeddedError extends StatelessWidget { @override Widget build(BuildContext context) { return Center( - child: Text( + child: AppText( error, - style: TextStyle(color: Theme.of(context).errorColor), + color: Theme.of(context).errorColor, textAlign: TextAlign.center, + margin: 10, ), ); }