From 7cefbb4dbd249ff4d039f77e39d7ccfe12f1cfdd Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 23 Dec 2020 18:36:29 +0200 Subject: [PATCH 1/3] add referral pages --- lib/client/base_app_client.dart | 11 +- lib/config/config.dart | 6 + lib/config/localized_values.dart | 16 + lib/core/service/base/base_service.dart | 55 ++- .../patient-doctor-referral-service.dart | 145 ++++++ lib/core/service/patient_service.dart | 3 +- .../service/referral_patient_service.dart | 1 + .../service/referred_patient_service.dart | 3 +- lib/core/viewModel/base_view_model.dart | 22 + .../patient-doctor-referral-viewModel.dart | 117 +++++ lib/core/viewModel/patient_view_model.dart | 18 +- lib/locator.dart | 4 + lib/main.dart | 2 +- lib/models/patient/PatientArrivalEntity.dart | 84 ++++ .../patient/my_referral/PendingReferral.dart | 119 +++++ .../my_referred_patient_model.dart | 2 + lib/routes.dart | 6 + lib/screens/dashboard_screen.dart | 399 ++++++---------- lib/screens/patients/patients_screen.dart | 1 + .../referral/my-referral-detail-screen.dart | 147 ++++++ .../referral/my-referral-patient-screen.dart | 98 ++++ .../referral/refer-patient-screen.dart | 445 ++++++++++++++++++ .../referral/referred-patient-screen.dart | 74 +++ lib/util/dr_app_toast_msg.dart | 2 +- lib/util/translations_delegate_base.dart | 16 + .../patient-referral-item-widget.dart | 143 ++++++ .../profile/PatientProfileButton.dart | 86 ++++ .../profile/profile-welcome-widget.dart | 86 ++++ .../profile/profile_medical_info_widget.dart | 91 +--- lib/widgets/shared/borderedButton.dart | 83 ++++ 30 files changed, 1914 insertions(+), 371 deletions(-) create mode 100644 lib/core/service/patient-doctor-referral-service.dart create mode 100644 lib/core/viewModel/patient-doctor-referral-viewModel.dart create mode 100644 lib/models/patient/PatientArrivalEntity.dart create mode 100644 lib/models/patient/my_referral/PendingReferral.dart create mode 100644 lib/screens/patients/profile/referral/my-referral-detail-screen.dart create mode 100644 lib/screens/patients/profile/referral/my-referral-patient-screen.dart create mode 100644 lib/screens/patients/profile/referral/refer-patient-screen.dart create mode 100644 lib/screens/patients/profile/referral/referred-patient-screen.dart create mode 100644 lib/widgets/patients/patient-referral-item-widget.dart create mode 100644 lib/widgets/patients/profile/PatientProfileButton.dart create mode 100644 lib/widgets/patients/profile/profile-welcome-widget.dart create mode 100644 lib/widgets/shared/borderedButton.dart diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 454f4d04..ca1b196a 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -45,7 +45,9 @@ class BaseAppClient { body['DoctorID'] = doctorProfile?.doctorID; body['EditedBy'] = doctorProfile?.doctorID; - body['ProjectID'] = doctorProfile?.projectID; + if(body['ProjectID'] == null){ + body['ProjectID'] = doctorProfile?.projectID; + } if (body['ClinicID'] == null) body['ClinicID'] = doctorProfile?.clinicID; } @@ -80,9 +82,10 @@ class BaseAppClient { } else { var parsed = json.decode(response.body.toString()); if (!parsed['IsAuthenticated']) { - await helpers.logout(); - - helpers.showErrorToast('Your session expired Please login agian'); + // TODO commented this and make si success just for test + // await helpers.logout(); + // helpers.showErrorToast('Your session expired Please login again'); + onSuccess(parsed, statusCode); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); } else { diff --git a/lib/config/config.dart b/lib/config/config.dart index 8af0a4a5..7e7e279e 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -57,6 +57,9 @@ const ADD_REFERRED_DOCTOR_REMARKS = const GET_MY_REFERRED_PATIENT = 'Services/DoctorApplication.svc/REST/GtMyReferredPatient'; +const GET_PENDING_REFERRAL_PATIENT = + 'Services/DoctorApplication.svc/REST/PendingReferrals'; + const GET_DOCTOR_WORKING_HOURS_TABLE = 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; @@ -78,6 +81,9 @@ const TRANSFERT_TO_ADMIN = 'LiveCareApi/DoctorApp/TransferToAdmin'; const END_CALL = 'LiveCareApi/DoctorApp/EndCall'; const END_CALL_WITH_CHARGE = 'LiveCareApi/DoctorApp/CompleteCallWithCharge'; +const GET_PATIENT_ARRIVAL_LIST = + 'Services/DoctorApplication.svc/REST/PatientArrivalList'; + var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 2b84f389..e29c3b79 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -49,6 +49,7 @@ const Map> localizedValues = { 'patientServices': {'en': 'Patient Services', 'ar': 'خدمات المرضى'}, 'searchMedicine': {'en': 'Search Medicine', 'ar': 'بحث عن الدواء'}, 'myReferralPatient': {'en': 'My Referral Patient', 'ar': 'مرضى الاحالة'}, + 'referPatient': {'en': 'Refer Patient', 'ar': 'إحالة مريض'}, 'myReferral': {'en': 'My Referral', 'ar': 'إحالة'}, 'myReferredPatient': {'en': 'My Referred Patient', 'ar': 'مرضاي المحالين'}, 'firstName': {'en': 'First Name', 'ar': 'الاسم الاول'}, @@ -277,4 +278,19 @@ const Map> localizedValues = { 'bed': {'en': 'BED:', 'ar': 'السرير'}, 'clinicSelect': {'en': "Select Clinic", 'ar': 'اختار عيادة'}, 'doctorSelect': {'en': "Select Doctor", 'ar': 'اختار طبيب'}, + 'referTo': {'en': "Refer To", 'ar': 'محال إلى'}, + 'referredFrom': {'en': "Referred From", 'ar': 'محال من'}, + 'branch': {'en': "Branch", 'ar': 'الفرع'}, + 'chooseAppointment': {'en': "Choose Appointment", 'ar': 'اختر موعد'}, + 'appointmentNo': {'en': "Appointment #:", 'ar': '# الموعد:'}, + 'refer': {'en': "REFER", 'ar': 'إحالة'}, + 'approved': {'en': "Approved", 'ar': 'موافق عليه'}, + 'rejected': {'en': "Rejected", 'ar': 'مرفوض'}, + 'sameBranch': {'en': "Same Branch", 'ar': 'نفس الفرع'}, + 'otherBranch': {'en': "Other Branch", 'ar': 'فرع آخر'}, + 'dr': {'en': "DR.", 'ar': 'د.'}, + 'previewHealth': {'en': "Preview Health", 'ar': 'معاينة الصحة'}, + 'summaryReport': {'en': "Summary Report", 'ar': 'تقرير موجز'}, + 'accept': {'en': "ACCEPT", 'ar': 'قبول'}, + 'reject': {'en': "REJECT", 'ar': 'رفض'}, }; diff --git a/lib/core/service/base/base_service.dart b/lib/core/service/base/base_service.dart index c4cb240d..1867cf99 100644 --- a/lib/core/service/base/base_service.dart +++ b/lib/core/service/base/base_service.dart @@ -1,8 +1,61 @@ import 'package:doctor_app_flutter/client/base_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/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/models/patient/PatientArrivalEntity.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; class BaseService { String error; bool hasError = false; BaseAppClient baseAppClient = BaseAppClient(); - //TODO add the user login model when we need it + DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); + DoctorProfileModel doctorProfile; + + List patientArrivalList = []; + +//TODO add the user login model when we need it + Future getDoctorProfile() async { + if (doctorProfile == null) { + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + if (profile != null) { + doctorProfile = DoctorProfileModel.fromJson(profile); + if (doctorProfile != null) { + return doctorProfile; + } + } + return null; + } else { + return doctorProfile; + } + } + + Future getPatientArrivalList(String date) async{ + hasError = false; + Map body = Map(); + body['VidaAuthTokenID'] = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiYjVjZTZkZGEtNDA0OC00N2U4LWFhMmMtYmY5NDJiNjg0MGI0IiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODU1MDQiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODU1MDE2OSwiZXhwIjoxNjA5NDE0MTY5LCJpYXQiOjE2MDg1NTAxNjl9.mBoylGXXcfoeZcf61R2m7OfjRHnt8MmzLMG74VcotQ8"; + body['From'] = date; + body['To'] = date; + body['PageIndex'] = 0; + body['PageSize'] = 0; + + await baseAppClient.post( + GET_PATIENT_ARRIVAL_LIST, + onSuccess: (dynamic response, int statusCode) { + patientArrivalList.clear(); + + response['patientArrivalList']['entityList'].forEach((v) { + PatientArrivalEntity item = PatientArrivalEntity.fromJson(v); + patientArrivalList.add(item); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + this.error = error; + }, + body: body, + ); + } + } diff --git a/lib/core/service/patient-doctor-referral-service.dart b/lib/core/service/patient-doctor-referral-service.dart new file mode 100644 index 00000000..66db83c6 --- /dev/null +++ b/lib/core/service/patient-doctor-referral-service.dart @@ -0,0 +1,145 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/lookups/hospital_lookup.dart'; +import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/models/patient/get_clinic_by_project_id_request.dart'; +import 'package:doctor_app_flutter/models/patient/get_doctor_by_clinic_id_request.dart'; +import 'package:doctor_app_flutter/models/patient/my_referral/PendingReferral.dart'; +import 'package:doctor_app_flutter/models/patient/my_referral/my_referred_patient_model.dart'; +import 'package:doctor_app_flutter/models/patient/request_my_referral_patient_model.dart'; + +class PatientReferralService extends BaseService { + List projectsList = []; + List clinicsList = []; + List doctorsList = []; + List listMyReferredPatientModel = []; + List pendingReferralList = []; + + Future getProjectsList() async { + hasError = false; + const url = GET_PROJECTS; + var info = { + "LanguageID": 1, + "stamp": "2020-02-26T13:51:44.111Z", + "IPAdress": "11.11.11.11", + "VersionID": 1.2, + "Channel": 9, + "TokenID": "", + "SessionID": "i1UJwCTSqt", + "IsLoginForDoctorApp": true + }; + dynamic localRes; + + await baseAppClient.post(url, onSuccess: (response, statusCode) async { + if (response['MessageStatus'] == 1) { + projectsList = response['ListProject']; + } else { + // handel error + projectsList = ListProject; + } + }, onFailure: (String error, int statusCode) { + projectsList = ListProject; + }, body: info); + } + + Future getClinicsList(int projectId) async { + hasError = false; + ClinicByProjectIdRequest _clinicByProjectIdRequest = + ClinicByProjectIdRequest(); + _clinicByProjectIdRequest.projectID = projectId; + + await baseAppClient.post( + PATIENT_GET_CLINIC_BY_PROJECT_URL, + onSuccess: (dynamic response, int statusCode) { + clinicsList = []; + clinicsList = response['List_Clinic_All']; + print(response['List_Clinic_All']); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _clinicByProjectIdRequest.toJson(), + ); + } + + Future getDoctorsList(String clinicId) async { + hasError = false; + DoctorsByClinicIdRequest _doctorsByClinicIdRequest = + DoctorsByClinicIdRequest(); + + _doctorsByClinicIdRequest.clinicID = clinicId; + await baseAppClient.post( + PATIENT_GET_DOCTOR_BY_CLINIC_URL, + onSuccess: (dynamic response, int statusCode) { + doctorsList = []; + doctorsList = response['List_Doctors_All']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _doctorsByClinicIdRequest.toJson(), + ); + } + + Future getMyReferredPatient() async { + hasError = false; + RequestMyReferralPatientModel _requestMyReferralPatient = + RequestMyReferralPatientModel(); + DoctorProfileModel doctorProfile = await getDoctorProfile(); + + await baseAppClient.post( + GET_MY_REFERRED_PATIENT, + onSuccess: (dynamic response, int statusCode) { + listMyReferredPatientModel.clear(); + + response['List_MyReferredPatient'].forEach((v) { + MyReferredPatientModel item = MyReferredPatientModel.fromJson(v); + if (doctorProfile != null) { + item.isReferralDoctorSameBranch = + doctorProfile.projectID == item.projectId; + } else { + item.isReferralDoctorSameBranch = false; + } + listMyReferredPatientModel.add(item); + }); + // print(response['List_MyReferredPatient']); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _requestMyReferralPatient.toJson(), + ); + } + + Future getPendingReferralList() async { + hasError = false; + DoctorProfileModel doctorProfile = await getDoctorProfile(); + Map body = Map(); + body['ClinicID'] = 0; + body['DoctorID'] = doctorProfile.doctorID; + body['VidaAuthTokenID'] = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiYjVjZTZkZGEtNDA0OC00N2U4LWFhMmMtYmY5NDJiNjg0MGI0IiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODU1MDQiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODU1MDE2OSwiZXhwIjoxNjA5NDE0MTY5LCJpYXQiOjE2MDg1NTAxNjl9.mBoylGXXcfoeZcf61R2m7OfjRHnt8MmzLMG74VcotQ8"; + + await baseAppClient.post( + GET_PENDING_REFERRAL_PATIENT, + onSuccess: (dynamic response, int statusCode) { + pendingReferralList.clear(); + + response['PendingReferralList'].forEach((v) { + PendingReferral item = PendingReferral.fromJson(v); + item.isReferralDoctorSameBranch = + item.targetProjectId == item.sourceProjectId; + pendingReferralList.add(item); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: body, + ); + } +} diff --git a/lib/core/service/patient_service.dart b/lib/core/service/patient_service.dart index b16753f5..9aa52923 100644 --- a/lib/core/service/patient_service.dart +++ b/lib/core/service/patient_service.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/doctor/request_schedule.dart'; +import 'package:doctor_app_flutter/models/patient/PatientArrivalEntity.dart'; import 'package:doctor_app_flutter/models/patient/get_clinic_by_project_id_request.dart'; import 'package:doctor_app_flutter/models/patient/get_doctor_by_clinic_id_request.dart'; import 'package:doctor_app_flutter/models/patient/get_list_stp_referral_frequency_request.dart'; @@ -82,8 +83,6 @@ class PatientService extends BaseService { ClinicByProjectIdRequest(); ReferToDoctorRequest _referToDoctorRequest; - RequestSchedule _requestSchedule = RequestSchedule(); - Future getPatientList(PatientModel patient, patientType) async { hasError = false; int val = int.parse(patientType); diff --git a/lib/core/service/referral_patient_service.dart b/lib/core/service/referral_patient_service.dart index 088e40ca..e3ca6fae 100644 --- a/lib/core/service/referral_patient_service.dart +++ b/lib/core/service/referral_patient_service.dart @@ -24,6 +24,7 @@ class ReferralPatientService extends BaseService { response['List_MyReferralPatient'].forEach((v) { listMyReferralPatientModel.add(MyReferralPatientModel.fromJson(v)); }); + print(response['List_MyReferralPatient']); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/core/service/referred_patient_service.dart b/lib/core/service/referred_patient_service.dart index 0fb3de64..7285d904 100644 --- a/lib/core/service/referred_patient_service.dart +++ b/lib/core/service/referred_patient_service.dart @@ -11,8 +11,6 @@ class ReferredPatientService extends BaseService { List get listMyReferredPatientModel => _listMyReferredPatientModel; - Helpers helpers = Helpers(); - RequestMyReferralPatientModel _requestMyReferralPatient = RequestMyReferralPatientModel(); VerifyReferralDoctorRemarks _verifyreferraldoctorremarks = @@ -26,6 +24,7 @@ class ReferredPatientService extends BaseService { response['List_MyReferredPatient'].forEach((v) { listMyReferredPatientModel.add(MyReferredPatientModel.fromJson(v)); }); + // print(response['List_MyReferredPatient']); }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/viewModel/base_view_model.dart b/lib/core/viewModel/base_view_model.dart index 29acdd42..d8591660 100644 --- a/lib/core/viewModel/base_view_model.dart +++ b/lib/core/viewModel/base_view_model.dart @@ -1,17 +1,39 @@ +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/material.dart'; class BaseViewModel extends ChangeNotifier { + DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); + DoctorProfileModel doctorProfile; + ViewState _state = ViewState.Idle; bool isInternetConnection = true; ViewState get state => _state; String error = ""; + //TODO add the user login model when we need it void setState(ViewState viewState) { _state = viewState; notifyListeners(); } + + Future getDoctorProfile() async { + if (doctorProfile == null) { + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + if (profile != null) { + doctorProfile = DoctorProfileModel.fromJson(profile); + if (doctorProfile != null) { + return doctorProfile; + } + } + return null; + } else { + return doctorProfile; + } + } } diff --git a/lib/core/viewModel/patient-doctor-referral-viewModel.dart b/lib/core/viewModel/patient-doctor-referral-viewModel.dart new file mode 100644 index 00000000..bd7bc549 --- /dev/null +++ b/lib/core/viewModel/patient-doctor-referral-viewModel.dart @@ -0,0 +1,117 @@ +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/service/patient-doctor-referral-service.dart'; +import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; +import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/models/patient/PatientArrivalEntity.dart'; +import 'package:doctor_app_flutter/models/patient/my_referral/PendingReferral.dart'; +import 'package:doctor_app_flutter/models/patient/my_referral/my_referred_patient_model.dart'; + +import '../../locator.dart'; + +class PatientReferralViewModel extends BaseViewModel { + PatientReferralService _referralPatientService = + locator(); + + List get branchesList => _referralPatientService.projectsList; + + List get clinicsList => _referralPatientService.clinicsList; + + List get doctorsList => _referralPatientService.doctorsList; + + List get listMyReferredPatientModel => + _referralPatientService.listMyReferredPatientModel; + + List get pendingReferral => + _referralPatientService.pendingReferralList; + + List get patientArrivalList => _referralPatientService.patientArrivalList; + + Future getBranches() async { + setState(ViewState.Busy); + await _referralPatientService.getProjectsList(); + if (_referralPatientService.hasError) { + error = _referralPatientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getClinics(int projectId) async { + setState(ViewState.Busy); + await _referralPatientService.getClinicsList(projectId); + if (_referralPatientService.hasError) { + error = _referralPatientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getClinicDoctors(String clinicId) async { + setState(ViewState.Busy); + await _referralPatientService.getDoctorsList(clinicId); + if (_referralPatientService.hasError) { + error = _referralPatientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getDoctorBranch() async { + DoctorProfileModel doctorProfile = await getDoctorProfile(); + if (doctorProfile != null) { + dynamic _selectedBranch = { + "ID": doctorProfile.projectID, + "Desciption": doctorProfile.projectName + }; + return _selectedBranch; + } + return null; + } + + Future getMyReferredPatient() async { + setState(ViewState.Busy); + await _referralPatientService.getMyReferredPatient(); + if (_referralPatientService.hasError) { + error = _referralPatientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + MyReferredPatientModel getReferredPatientItem(int index){ + return listMyReferredPatientModel[index]; + } + + Future getPendingReferralPatients() async { + setState(ViewState.Busy); + await _referralPatientService.getPendingReferralList(); + if (_referralPatientService.hasError) { + error = _referralPatientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getPatientArrivalList(String date) async { + setState(ViewState.Busy); + await _referralPatientService.getPatientArrivalList(date); + if (_referralPatientService.hasError) { + error = _referralPatientService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + + List getAppointmentsByPatientName(String patientName){ + List appointments = []; + patientArrivalList.forEach((element) { + if(element.patientName == patientName){ + appointments.add(element.toJson()); + } + }); + return appointments; + } + +} diff --git a/lib/core/viewModel/patient_view_model.dart b/lib/core/viewModel/patient_view_model.dart index 6fdbde32..e03e0853 100644 --- a/lib/core/viewModel/patient_view_model.dart +++ b/lib/core/viewModel/patient_view_model.dart @@ -43,12 +43,15 @@ class PatientViewModel extends BaseViewModel { get patientProgressNoteList => _patientService.patientProgressNoteList; List get clinicsList => _patientService.clinicsList; + List get doctorsList => _patientService.doctorsList; - List get referralFrequencyList => _patientService.referalFrequancyList; + + List get referralFrequencyList => + _patientService.referalFrequancyList; Future getPatientList(PatientModel patient, patientType, {bool isBusyLocal = false}) async { - if(isBusyLocal) { + if (isBusyLocal) { setState(ViewState.BusyLocal); } else { setState(ViewState.Busy); @@ -56,11 +59,12 @@ class PatientViewModel extends BaseViewModel { return _patientService.getPatientList(patient, patientType); if (_patientService.hasError) { error = _patientService.error; - if(isBusyLocal) { + if (isBusyLocal) { setState(ViewState.ErrorLocal); } else { setState(ViewState.Error); - } } else + } + } else setState(ViewState.Idle); } @@ -183,8 +187,9 @@ class PatientViewModel extends BaseViewModel { } List getDoctorNameList() { - var doctorNamelist = - _patientService.doctorsList.map((value) => value['DoctorName'].toString()).toList(); + var doctorNamelist = _patientService.doctorsList + .map((value) => value['DoctorName'].toString()) + .toList(); return doctorNamelist; } @@ -194,6 +199,7 @@ class PatientViewModel extends BaseViewModel { .toList(); return clinicsNameslist; } + Future getReferralFrequancyList() async { setState(ViewState.Busy); await _patientService.getReferralFrequancyList(); diff --git a/lib/locator.dart b/lib/locator.dart index 550b4666..90a06bc9 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -4,11 +4,13 @@ import 'package:get_it/get_it.dart'; import 'core/service/doctor_reply_service.dart'; import 'core/service/medicine_service.dart'; +import 'core/service/patient-doctor-referral-service.dart'; import 'core/service/referral_patient_service.dart'; import 'core/service/referred_patient_service.dart'; import 'core/service/schedule_service.dart'; import 'core/viewModel/doctor_replay_view_model.dart'; import 'core/viewModel/medicine_view_model.dart'; +import 'core/viewModel/patient-doctor-referral-viewModel.dart'; import 'core/viewModel/referral_view_model.dart'; import 'core/viewModel/referred_view_model.dart'; import 'core/viewModel/schedule_view_model.dart'; @@ -24,6 +26,7 @@ void setupLocator() { locator.registerLazySingleton(() => ReferredPatientService()); locator.registerLazySingleton(() => MedicineService()); locator.registerLazySingleton(() => PatientService()); + locator.registerLazySingleton(() => PatientReferralService()); /// View Model locator.registerFactory(() => DoctorReplayViewModel()); @@ -32,4 +35,5 @@ void setupLocator() { locator.registerFactory(() => ReferredPatientViewModel()); locator.registerFactory(() => MedicineViewModel()); locator.registerFactory(() => PatientViewModel()); + locator.registerFactory(() => PatientReferralViewModel()); } diff --git a/lib/main.dart b/lib/main.dart index 06d0ecfa..87de7057 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -60,7 +60,7 @@ class MyApp extends StatelessWidget { buttonColor: HexColor('#B8382C'), fontFamily: 'WorkSans', dividerColor: Colors.grey[350], - backgroundColor: Color.fromRGBO(255,255,255, 1) + backgroundColor: Color.fromRGBO(255,255,255, 1), ), initialRoute: INIT_ROUTE, routes: routes, diff --git a/lib/models/patient/PatientArrivalEntity.dart b/lib/models/patient/PatientArrivalEntity.dart new file mode 100644 index 00000000..54622cd7 --- /dev/null +++ b/lib/models/patient/PatientArrivalEntity.dart @@ -0,0 +1,84 @@ +class PatientArrivalEntity { + String age; + String appointmentDate; + int appointmentNo; + String appointmentType; + String arrivedOn; + String companyName; + String endTime; + int episodeNo; + int fallRiskScore; + String gender; + int medicationOrders; + String mobileNumber; + String nationality; + int patientMRN; + String patientName; + int rowCount; + String startTime; + String visitType; + + PatientArrivalEntity( + {this.age, + this.appointmentDate, + this.appointmentNo, + this.appointmentType, + this.arrivedOn, + this.companyName, + this.endTime, + this.episodeNo, + this.fallRiskScore, + this.gender, + this.medicationOrders, + this.mobileNumber, + this.nationality, + this.patientMRN, + this.patientName, + this.rowCount, + this.startTime, + this.visitType}); + + PatientArrivalEntity.fromJson(Map json) { + age = json['age']; + appointmentDate = json['appointmentDate']; + appointmentNo = json['appointmentNo']; + appointmentType = json['appointmentType']; + arrivedOn = json['arrivedOn']; + companyName = json['companyName']; + endTime = json['endTime']; + episodeNo = json['episodeNo']; + fallRiskScore = json['fallRiskScore']; + gender = json['gender']; + medicationOrders = json['medicationOrders']; + mobileNumber = json['mobileNumber']; + nationality = json['nationality']; + patientMRN = json['patientMRN']; + patientName = json['patientName']; + rowCount = json['rowCount']; + startTime = json['startTime']; + visitType = json['visitType']; + } + + Map toJson() { + final Map data = new Map(); + data['age'] = this.age; + data['appointmentDate'] = this.appointmentDate; + data['appointmentNo'] = this.appointmentNo; + data['appointmentType'] = this.appointmentType; + data['arrivedOn'] = this.arrivedOn; + data['companyName'] = this.companyName; + data['endTime'] = this.endTime; + data['episodeNo'] = this.episodeNo; + data['fallRiskScore'] = this.fallRiskScore; + data['gender'] = this.gender; + data['medicationOrders'] = this.medicationOrders; + data['mobileNumber'] = this.mobileNumber; + data['nationality'] = this.nationality; + data['patientMRN'] = this.patientMRN; + data['patientName'] = this.patientName; + data['rowCount'] = this.rowCount; + data['startTime'] = this.startTime; + data['visitType'] = this.visitType; + return data; + } +} \ No newline at end of file diff --git a/lib/models/patient/my_referral/PendingReferral.dart b/lib/models/patient/my_referral/PendingReferral.dart new file mode 100644 index 00000000..9da17985 --- /dev/null +++ b/lib/models/patient/my_referral/PendingReferral.dart @@ -0,0 +1,119 @@ +class PendingReferral { + String responded; + String answerFromTarget; + String createdOn; + int data; + String editedOn; + int interBranchReferral; + int patientID; + String patientName; + int patientType; + int referralNo; + String referralStatus; + String referredByDoctorInfo; + String referredFromBranchName; + String referredOn; + String referredType; + String remarksFromSource; + String respondedOn; + int sourceAppointmentNo; + int sourceProjectId; + String sourceSetupID; + String startDate; + int targetAppointmentNo; + String targetClinicID; + String targetDoctorID; + int targetProjectId; + String targetSetupID; + bool isReferralDoctorSameBranch; + + PendingReferral( + {this.responded, + this.answerFromTarget, + this.createdOn, + this.data, + this.editedOn, + this.interBranchReferral, + this.patientID, + this.patientName, + this.patientType, + this.referralNo, + this.referralStatus, + this.referredByDoctorInfo, + this.referredFromBranchName, + this.referredOn, + this.referredType, + this.remarksFromSource, + this.respondedOn, + this.sourceAppointmentNo, + this.sourceProjectId, + this.sourceSetupID, + this.startDate, + this.targetAppointmentNo, + this.targetClinicID, + this.targetDoctorID, + this.targetProjectId, + this.targetSetupID, + this.isReferralDoctorSameBranch, + }); + + PendingReferral.fromJson(Map json) { + responded = json['Responded']; + answerFromTarget = json['answerFromTarget']; + createdOn = json['createdOn']; + data = json['data']; + editedOn = json['editedOn']; + interBranchReferral = json['interBranchReferral']; + patientID = json['patientID']; + patientName = json['patientName']; + patientType = json['patientType']; + referralNo = json['referralNo']; + referralStatus = json['referralStatus']; + referredByDoctorInfo = json['referredByDoctorInfo']; + referredFromBranchName = json['referredFromBranchName']; + referredOn = json['referredOn']; + referredType = json['referredType']; + remarksFromSource = json['remarksFromSource']; + respondedOn = json['respondedOn']; + sourceAppointmentNo = json['sourceAppointmentNo']; + sourceProjectId = json['sourceProjectId']; + sourceSetupID = json['sourceSetupID']; + startDate = json['startDate']; + targetAppointmentNo = json['targetAppointmentNo']; + targetClinicID = json['targetClinicID']; + targetDoctorID = json['targetDoctorID']; + targetProjectId = json['targetProjectId']; + targetSetupID = json['targetSetupID']; + } + + Map toJson() { + final Map data = new Map(); + data['Responded'] = this.responded; + data['answerFromTarget'] = this.answerFromTarget; + data['createdOn'] = this.createdOn; + data['data'] = this.data; + data['editedOn'] = this.editedOn; + data['interBranchReferral'] = this.interBranchReferral; + data['patientID'] = this.patientID; + data['patientName'] = this.patientName; + data['patientType'] = this.patientType; + data['referralNo'] = this.referralNo; + data['referralStatus'] = this.referralStatus; + data['referredByDoctorInfo'] = this.referredByDoctorInfo; + data['referredFromBranchName'] = this.referredFromBranchName; + data['referredOn'] = this.referredOn; + data['referredType'] = this.referredType; + data['remarksFromSource'] = this.remarksFromSource; + data['respondedOn'] = this.respondedOn; + data['sourceAppointmentNo'] = this.sourceAppointmentNo; + data['sourceProjectId'] = this.sourceProjectId; + data['sourceSetupID'] = this.sourceSetupID; + data['startDate'] = this.startDate; + data['targetAppointmentNo'] = this.targetAppointmentNo; + data['targetClinicID'] = this.targetClinicID; + data['targetDoctorID'] = this.targetDoctorID; + data['targetProjectId'] = this.targetProjectId; + data['targetSetupID'] = this.targetSetupID; + return data; + } +} \ No newline at end of file diff --git a/lib/models/patient/my_referral/my_referred_patient_model.dart b/lib/models/patient/my_referral/my_referred_patient_model.dart index 9ecfdb2f..850c29cb 100644 --- a/lib/models/patient/my_referral/my_referred_patient_model.dart +++ b/lib/models/patient/my_referral/my_referred_patient_model.dart @@ -59,6 +59,7 @@ class MyReferredPatientModel { this.priorityDescription, this.referralClinicDescription, this.referralDoctorName, + this.isReferralDoctorSameBranch, }); int projectId; @@ -111,6 +112,7 @@ class MyReferredPatientModel { String priorityDescription; String referralClinicDescription; String referralDoctorName; + bool isReferralDoctorSameBranch; factory MyReferredPatientModel.fromJson(Map json) => MyReferredPatientModel( projectId: json["ProjectID"], diff --git a/lib/routes.dart b/lib/routes.dart index dff02129..4c9e53a3 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -37,6 +37,8 @@ import './screens/settings/settings_screen.dart'; import 'landing_page.dart'; import 'screens/doctor/doctor_reply_screen.dart'; import 'screens/live_care/panding_list.dart'; +import 'screens/patients/profile/referral/my-referral-detail-screen.dart'; +import 'screens/patients/profile/referral/refer-patient-screen.dart'; const String INIT_ROUTE = ROOT; const String ROOT = 'root'; @@ -65,6 +67,8 @@ const String PRESCRIPTIONS = 'patients/prescription'; const String RADIOLOGY = 'patients/radiology'; const String PROGRESS_NOTE = 'patients/progress-note'; const String REFER_PATIENT = 'patients/refer-patient'; +const String MY_REFERRAL_DETAIL = 'my_referral_detail'; +const String REFER_PATIENT_TO_DOCTOR = 'patients/refer-to-doctor'; const String PATIENT_ORDERS = 'patients/patient_orders'; const String PATIENT_INSURANCE_APPROVALS = 'patients/patient_insurance_approvals'; @@ -102,6 +106,7 @@ var routes = { RADIOLOGY: (_) => RadiologyScreen(), PROGRESS_NOTE: (_) => ProgressNoteScreen(), REFER_PATIENT: (_) => ReferPatientScreen(), + REFER_PATIENT_TO_DOCTOR: (_) => PatientMakeReferralScreen(), PATIENT_ORDERS: (_) => PatientsOrdersScreen(), PATIENT_INSURANCE_APPROVALS: (_) => InsuranceApprovalsScreen(), VITAL_SIGN_DETAILS: (_) => VitalSignDetailsScreen(), @@ -110,4 +115,5 @@ var routes = { // VIDEO_CALL: (_) => VideoCallPage(patientData: null), LIVECARE_PENDING_LIST: (_) => LiveCarePandingListScreen(), // LIVECARE_END_DIALOG: (_) => EndCallDialogBox() + MY_REFERRAL_DETAIL: (_) => MyReferralDetailScreen(), }; diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 80697352..0c1c4812 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -7,9 +7,11 @@ import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/hospital_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/referral/my-referral-patient-screen.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/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -23,6 +25,7 @@ import 'doctor/doctor_reply_screen.dart'; import 'doctor/my_referral_patient_screen.dart'; import 'doctor/my_referred_patient_screen.dart'; import 'medicine/medicine_search_screen.dart'; +import 'patients/profile/referral/referred-patient-screen.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = Helpers(); @@ -80,133 +83,56 @@ class _DashboardScreenState extends State { Stack(children: [ Column( children: [ - Container( - height: 140, - color: HexColor('#515B5D'), - width: double.infinity, - child: FractionallySizedBox( - widthFactor: 0.9, + ProfileWelcomeWidget( + InkWell( + onTap: () async { + showCupertinoPicker( + decKey: '', + context: context, + actionList: projectsProvider.doctorClinicsList); + }, child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( - children: [ - AppText( - TranslationBase - .of(context) - .welcome, - fontSize: SizeConfig.textMultiplier * 1.7, - color: Colors.white, - ) - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - AppText( - 'Dr. ${authProvider.doctorProfile.doctorName}', - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 2.5, - color: Colors.white, - ) - ], - ), - SizedBox( - height: 4, - ), - InkWell( - onTap: () async { - showCupertinoPicker( - decKey: '', - context: context, - actionList: projectsProvider - .doctorClinicsList); - }, - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Container( - child: AppText( - authProvider.selectedClinicName != - null - ? authProvider.selectedClinicName - : authProvider.doctorProfile - .clinicDescription, - fontSize: - SizeConfig.textMultiplier * 1.7, - color: Colors.white, - textAlign: TextAlign.center, - ), - alignment: projectsProvider.isArabic - ? Alignment.topRight - : Alignment.topLeft, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - InkWell( - - child: Container( - margin: EdgeInsets.only( - left: 5, - top: projectsProvider - .isArabic ? 0 : 5, - right: 10, - bottom: projectsProvider - .isArabic ? 15 : 7), - child: Icon( - DoctorApp.sync_icon, - - color: Colors.white, - size: SizeConfig - .textMultiplier * - 1.8, - )), - ), - ], - ), - ]), + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: AppText( + authProvider.selectedClinicName != null + ? authProvider.selectedClinicName + : authProvider + .doctorProfile.clinicDescription, + fontSize: SizeConfig.textMultiplier * 1.7, + color: Colors.white, + textAlign: TextAlign.center, ), - - ], - ), - Expanded( - child: Column( + alignment: projectsProvider.isArabic + ? Alignment.topRight + : Alignment.topLeft, + ), + Row( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.end, - + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - decoration: BoxDecoration( - color: Theme - .of(context) - .backgroundColor, - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - ), - height: 50, - width: 60, - child: Image.network( - authProvider.doctorProfile - .doctorImageURL, -// fit: BoxFit.fill, - ), + InkWell( + child: Container( + margin: EdgeInsets.only( + left: 5, + top: projectsProvider.isArabic + ? 0 + : 5, + right: 10, + bottom: projectsProvider.isArabic + ? 15 + : 7), + child: Icon( + DoctorApp.sync_icon, + color: Colors.white, + size: SizeConfig.textMultiplier * 1.8, + )), ), ], ), - ), - ], - ), + ]), ), ), Container( @@ -246,18 +172,18 @@ class _DashboardScreenState extends State { center: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - AppText("38", - fontSize: - SizeConfig.textMultiplier * 3.7, + AppText( + "38", + fontSize: SizeConfig.textMultiplier * 3.7, color: HexColor('#5D4C35'), - fontWeight: FontWeight.bold,), - AppText(TranslationBase - .of(context) - .outPatients, - fontWeight: FontWeight.normal, - fontSize: SizeConfig.textMultiplier * 1.4, - color: HexColor('#5D4C35'), - ), + fontWeight: FontWeight.bold, + ), + AppText( + TranslationBase.of(context).outPatients, + fontWeight: FontWeight.normal, + fontSize: SizeConfig.textMultiplier * 1.4, + color: HexColor('#5D4C35'), + ), ], ), circularStrokeCap: CircularStrokeCap.butt, @@ -418,15 +344,12 @@ class _DashboardScreenState extends State { color: Colors.white, ), AppText( - TranslationBase - .of(context) - .labResult, + TranslationBase.of(context).labResult, color: Colors.white, ) ], ), ), - ], ), imageName: '1.png', @@ -446,7 +369,6 @@ class _DashboardScreenState extends State { ), Container( margin: EdgeInsets.only(bottom: 10), - child: Column( children: [ AppText( @@ -455,15 +377,12 @@ class _DashboardScreenState extends State { color: Colors.white, ), AppText( - TranslationBase - .of(context) - .radiology, + TranslationBase.of(context).radiology, color: Colors.white, ) ], ), ), - ], ), imageName: '2.png', @@ -481,10 +400,8 @@ class _DashboardScreenState extends State { color: Colors.white, ), ), - Container( margin: EdgeInsets.only(bottom: 10), - child: Column( children: [ AppText( @@ -493,20 +410,16 @@ class _DashboardScreenState extends State { color: Colors.white, ), AppText( - TranslationBase - .of(context) - .referral, + TranslationBase.of(context).referral, color: Colors.white, ) ], ), ), - ], ), imageName: '3.png', opacity: 0.9, - ), ], ), @@ -522,7 +435,7 @@ class _DashboardScreenState extends State { padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.spaceBetween, children: [ Column( children: [ @@ -542,9 +455,7 @@ class _DashboardScreenState extends State { color: Colors.white, ), AppText( - TranslationBase - .of(context) - .inPatient, + TranslationBase.of(context).inPatient, color: Colors.white, ) ], @@ -555,28 +466,18 @@ class _DashboardScreenState extends State { imageName: '4.png', color: HexColor('#B8382C'), hasBorder: false, - width: MediaQuery - .of(context) - .size - .width * 0.44, - height: MediaQuery - .of(context) - .orientation == Orientation.portrait - ? MediaQuery - .of(context) - .size - .height * 0.13: - MediaQuery - .of(context) - .size - .height * 0.25, + width: MediaQuery.of(context).size.width * 0.44, + height: MediaQuery.of(context).orientation == + Orientation.portrait + ? MediaQuery.of(context).size.height * 0.13 + : MediaQuery.of(context).size.height * 0.25, ), DashboardItem( child: Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.spaceBetween, children: [ Column( children: [ @@ -596,9 +497,7 @@ class _DashboardScreenState extends State { color: Colors.white, ), AppText( - TranslationBase - .of(context) - .operations, + TranslationBase.of(context).operations, color: Colors.white, ) ], @@ -609,21 +508,11 @@ class _DashboardScreenState extends State { imageName: '5.png', color: HexColor('#B8382C'), hasBorder: false, - width: MediaQuery - .of(context) - .size - .width * 0.44, - height: MediaQuery - .of(context) - .orientation == Orientation.portrait - ? MediaQuery - .of(context) - .size - .height * 0.13: - MediaQuery - .of(context) - .size - .height * 0.25, + width: MediaQuery.of(context).size.width * 0.44, + height: MediaQuery.of(context).orientation == + Orientation.portrait + ? MediaQuery.of(context).size.height * 0.13 + : MediaQuery.of(context).size.height * 0.25, ), ], ), @@ -633,9 +522,7 @@ class _DashboardScreenState extends State { Row( children: [ AppText( - TranslationBase - .of(context) - .patientServices, + TranslationBase.of(context).patientServices, fontSize: SizeConfig.textMultiplier * 3, ), ], @@ -691,16 +578,12 @@ class _DashboardScreenState extends State { Column( children: [ AppText( - TranslationBase - .of(context) - .theDoctor, + TranslationBase.of(context).theDoctor, textAlign: TextAlign.center, color: Colors.black, ), AppText( - TranslationBase - .of(context) - .reply, + TranslationBase.of(context).reply, textAlign: TextAlign.center, color: Colors.black, ), @@ -713,8 +596,7 @@ class _DashboardScreenState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => - DoctorReplyScreen(), + builder: (context) => DoctorReplyScreen(), ), ); }, @@ -729,9 +611,7 @@ class _DashboardScreenState extends State { color: Colors.black, ), AppText( - TranslationBase - .of(context) - .searchMedicine, + TranslationBase.of(context).searchMedicine, color: Colors.black, textAlign: TextAlign.center, ) @@ -742,8 +622,7 @@ class _DashboardScreenState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => - MedicineSearchScreen(), + builder: (context) => MedicineSearchScreen(), ), ); }, @@ -777,12 +656,8 @@ class _DashboardScreenState extends State { ), AppText( projectsProvider.isArabic - ? TranslationBase - .of(context) - .qr - : TranslationBase - .of(context) - .reader, + ? TranslationBase.of(context).qr + : TranslationBase.of(context).reader, color: Colors.black, textAlign: TextAlign.center, ), @@ -806,9 +681,7 @@ class _DashboardScreenState extends State { color: Colors.black, ), AppText( - TranslationBase - .of(context) - .myReferralPatient, + TranslationBase.of(context).myReferralPatient, textAlign: TextAlign.center, color: Colors.black, ) @@ -820,7 +693,7 @@ class _DashboardScreenState extends State { context, MaterialPageRoute( builder: (context) => - MyReferralPatient(), + MyReferralPatientScreen(), ), ); }, @@ -835,9 +708,7 @@ class _DashboardScreenState extends State { color: Colors.black, ), AppText( - TranslationBase - .of(context) - .myReferredPatient, + TranslationBase.of(context).myReferredPatient, color: Colors.black, textAlign: TextAlign.center, ) @@ -848,8 +719,8 @@ class _DashboardScreenState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => - MyReferredPatient(), + builder: (context) => ReferredPatientScreen(), + // MyReferredPatient(), ), ); }, @@ -890,21 +761,17 @@ class _DashboardScreenState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ CupertinoButton( - child: AppText(TranslationBase - .of(context) - .cancel - // style: TextStyle(context) - ), + child: AppText(TranslationBase.of(context).cancel + // style: TextStyle(context) + ), onPressed: () { Navigator.pop(context); }, ), CupertinoButton( - child: AppText(TranslationBase - .of(context) - .done - // style: textStyle(context), - ), + child: AppText(TranslationBase.of(context).done + // style: textStyle(context), + ), onPressed: () { Navigator.pop(context); // onSelectFun(cupertinoPickerIndex); @@ -927,8 +794,7 @@ class _DashboardScreenState extends State { child: AppText( e.clinicName, fontSize: - SizeConfig.textMultiplier * - 1.9, + SizeConfig.textMultiplier * 1.9, )), ), )) @@ -969,19 +835,20 @@ class _DashboardScreenState extends State { }); } } + // TODO Move to it file class DashboardItem extends StatelessWidget { - const DashboardItem({ - this.hasBorder = false, - this.imageName, - @required this.child, - this.onTap, - Key key, - this.width, - this.height, - this.color, - this.opacity = 0.4 - }) : super(key: key); + const DashboardItem( + {this.hasBorder = false, + this.imageName, + @required this.child, + this.onTap, + Key key, + this.width, + this.height, + this.color, + this.opacity = 0.4}) + : super(key: key); final bool hasBorder; final String imageName; final Widget child; @@ -996,38 +863,34 @@ class DashboardItem extends StatelessWidget { return InkWell( onTap: onTap, child: Container( - width: width != null ? width : MediaQuery - .of(context) - .size - .width * 0.29, - height: height != null ? height : MediaQuery - .of(context) - .orientation == Orientation.portrait ? MediaQuery - .of(context) - .size - .height * 0.19 : MediaQuery - .of(context) - .size - .height * 0.35, - + width: width != null ? width : MediaQuery.of(context).size.width * 0.29, + height: height != null + ? height + : MediaQuery.of(context).orientation == Orientation.portrait + ? MediaQuery.of(context).size.height * 0.19 + : MediaQuery.of(context).size.height * 0.35, decoration: BoxDecoration( - color: !hasBorder ? color != null ? color : HexColor('#050705') - .withOpacity(opacity) : Colors - .white, + color: !hasBorder + ? color != null + ? color + : HexColor('#050705').withOpacity(opacity) + : Colors.white, borderRadius: BorderRadius.circular(6.0), - border: hasBorder ? Border.all( - width: 1.0, color: const Color(0xffcccccc)) : Border.all( - width: 0.0, color: Colors.transparent), - image: imageName != null ? DecorationImage( - image: AssetImage('assets/images/dashboard/${imageName}'), - fit: BoxFit.cover, - colorFilter: new ColorFilter.mode( - Colors.black.withOpacity(0.2), BlendMode.dstIn), - - ) : null, - + border: hasBorder + ? Border.all(width: 1.0, color: const Color(0xffcccccc)) + : Border.all(width: 0.0, color: Colors.transparent), + image: imageName != null + ? DecorationImage( + image: AssetImage('assets/images/dashboard/${imageName}'), + fit: BoxFit.cover, + colorFilter: new ColorFilter.mode( + Colors.black.withOpacity(0.2), BlendMode.dstIn), + ) + : null, + ), + child: Center( + child: child, ), - child: Center(child: child,), ), ); } diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 4ca3e587..6ec180e9 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -293,6 +293,7 @@ class _PatientsScreenState extends State { } }); }).catchError((error) { + setState(() { _isError = true; _isLoading = false; diff --git a/lib/screens/patients/profile/referral/my-referral-detail-screen.dart b/lib/screens/patients/profile/referral/my-referral-detail-screen.dart new file mode 100644 index 00000000..3d2b5202 --- /dev/null +++ b/lib/screens/patients/profile/referral/my-referral-detail-screen.dart @@ -0,0 +1,147 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient-doctor-referral-viewModel.dart'; +import 'package:doctor_app_flutter/models/patient/my_referral/PendingReferral.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/PatientProfileButton.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-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/borderedButton.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyReferralDetailScreen extends StatelessWidget { + PendingReferral pendingReferral; + + @override + Widget build(BuildContext context) { + final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8; + + AuthViewModel authProvider = Provider.of(context); + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + pendingReferral = routeArgs['referral']; + + return BaseView( + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).referPatient, + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ProfileWelcomeWidget( + AppText( + authProvider.selectedClinicName != null + ? authProvider.selectedClinicName + : authProvider.doctorProfile.clinicDescription, + fontSize: SizeConfig.textMultiplier * 1.7, + color: Colors.white, + textAlign: TextAlign.center, + ), + height: 100, + ), + SizedBox( + height: 16, + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: AppText( + TranslationBase.of(context).myReferralPatient, + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + PatientReferralItemWidget( + patientName: pendingReferral.patientName, + referralStatus: null, + isReferredTo: false, + isSameBranch: pendingReferral.isReferralDoctorSameBranch, + referralDoctorName: pendingReferral.referredByDoctorInfo, + clinicDescription: null, + remark: pendingReferral.remarksFromSource, + ), + SizedBox( + child: GridView.count( + childAspectRatio: 1.8, + crossAxisSpacing: 8, + mainAxisSpacing: 10, + controller: new ScrollController(keepScrollOffset: false), + shrinkWrap: true, + padding: const EdgeInsets.all(4.0), + crossAxisCount: 2, + children: [ + PatientProfileButton( + key: key, + // patient: patient, + // route: RADIOLOGY, + nameLine1: TranslationBase.of(context).previewHealth, + nameLine2: TranslationBase.of(context).summaryReport, + icon: 'radiology-1.png'), + PatientProfileButton( + key: key, + // patient: patient, + // route: LAB_ORDERS, + nameLine1: TranslationBase.of(context).lab, + nameLine2: TranslationBase.of(context).result, + icon: 'lab.png'), + PatientProfileButton( + key: key, + // patient: patient, + // route: VITAL_SIGN_DETAILS, + nameLine1: TranslationBase.of(context).vital, + nameLine2: TranslationBase.of(context).signs, + icon: 'heartbeat.png'), + ], + ), + ), + ], + ), + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + child: Row( + children: [ + Expanded( + child: BorderedButton( + TranslationBase.of(context).accept, + backgroundColor: Color(0xFF4BA821), + textColor: Colors.white, + fontSize: 16, + hPadding: 8, + vPadding: 12, + handler: null, + ), + ), + SizedBox( + height: 8, + ), + Expanded( + child: BorderedButton( + TranslationBase.of(context).reject, + backgroundColor: Color(0xFFB9382C), + textColor: Colors.white, + fontSize: 16, + hPadding: 8, + vPadding: 12, + handler: null, + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/patients/profile/referral/my-referral-patient-screen.dart b/lib/screens/patients/profile/referral/my-referral-patient-screen.dart new file mode 100644 index 00000000..5a91ac51 --- /dev/null +++ b/lib/screens/patients/profile/referral/my-referral-patient-screen.dart @@ -0,0 +1,98 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient-doctor-referral-viewModel.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-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:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../../routes.dart'; + +class MyReferralPatientScreen extends StatelessWidget { + // previous design page is: MyReferralPatient + @override + Widget build(BuildContext context) { + AuthViewModel authProvider = Provider.of(context); + + return BaseView( + onModelReady: (model) => model.getPendingReferralPatients(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).referPatient, + body: model.pendingReferral == null || + model.pendingReferral.length == 0 + ? Center( + child: AppText( + TranslationBase.of(context).errorNoSchedule, + color: Theme.of(context).errorColor, + ), + ) + : SingleChildScrollView( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ProfileWelcomeWidget( + AppText( + authProvider.selectedClinicName != null + ? authProvider.selectedClinicName + : authProvider.doctorProfile.clinicDescription, + fontSize: SizeConfig.textMultiplier * 1.7, + color: Colors.white, + textAlign: TextAlign.center, + ), + height: 100, + ), + SizedBox( + height: 16, + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: AppText( + TranslationBase.of(context).myReferralPatient, + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + ...List.generate( + model.pendingReferral.length, + (index) => PatientReferralItemWidget( + patientName: model.pendingReferral[index].patientName, + referralStatus: null, + isReferredTo: false, + isSameBranch: model.pendingReferral[index] + .isReferralDoctorSameBranch, + referralDoctorName: + model.pendingReferral[index].referredByDoctorInfo, + clinicDescription: null, + remark: + model.pendingReferral[index].remarksFromSource, + infoIcon: InkWell( + onTap: () { + Navigator.of(context).pushNamed( + MY_REFERRAL_DETAIL, + arguments: { + 'referral': model.pendingReferral[index] + }); + }, + child: Icon( + Icons.info_outline, + color: Colors.black, + size: 30, + ), + ), + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/screens/patients/profile/referral/refer-patient-screen.dart b/lib/screens/patients/profile/referral/refer-patient-screen.dart new file mode 100644 index 00000000..ec8aaf93 --- /dev/null +++ b/lib/screens/patients/profile/referral/refer-patient-screen.dart @@ -0,0 +1,445 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient-doctor-referral-viewModel.dart'; +import 'package:doctor_app_flutter/models/patient/PatientArrivalEntity.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.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/dialogs/dailog-list-select.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:hexcolor/hexcolor.dart'; + +import '../../../QR_reader_screen.dart'; + +class PatientMakeReferralScreen extends StatefulWidget { + // previous design page is: ReferPatientScreen + @override + _PatientMakeReferralScreenState createState() => + _PatientMakeReferralScreenState(); +} + +class _PatientMakeReferralScreenState extends State { + PatiantInformtion patient; + List referToList; + dynamic _referTo; + dynamic _selectedBranch; + dynamic _selectedClinic; + dynamic _selectedDoctor; + DateTime appointmentDate; + final _remarksController = TextEditingController(); + PatientArrivalEntity _selectedPatientArrivalEntity; + + @override + void initState() { + super.initState(); + referToList = List(); + dynamic sameBranch = {"id": 1, "name": "Same Branch"}; + dynamic otherBranch = {"id": 2, "name": "Other Branch"}; + referToList.add(sameBranch); + referToList.add(otherBranch); + appointmentDate = DateTime.now(); + } + + @override + Widget build(BuildContext context) { + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + patient = routeArgs['patient']; + + final screenSize = MediaQuery.of(context).size; + + return BaseView( + onModelReady: (model) => model.getBranches(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).referPatient, + body: SingleChildScrollView( + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + Container( + height: 75, + child: AppText( + "This is where upper view for avatar.. etc placed", + fontWeight: FontWeight.normal, + fontSize: 16, + ), + ), + const Divider( + color: Color(0xffCCCCCC), + height: 1, + thickness: 2, + indent: 0, + endIndent: 0, + ), + Container( + margin: + EdgeInsets.symmetric(vertical: 16, horizontal: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 16, + ), + AppText( + TranslationBase.of(context).referPatient, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + SizedBox( + height: 16, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: referToList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: referToList, + attributeName: 'name', + attributeValueId: 'id', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _referTo = selectedValue; + _selectedBranch = null; + _selectedClinic = null; + _selectedDoctor = null; + model + .getDoctorBranch() + .then((value) { + _selectedBranch = value; + if (_referTo['id'] == 1) { + model.getClinics( + _selectedBranch['ID']); + } + }); + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).referTo, + _referTo != null ? _referTo['name'] : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.branchesList != null && + model.branchesList.length > 0 && + _referTo != null && + _referTo['id'] == 2 + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: model.branchesList, + attributeName: 'Desciption', + attributeValueId: 'ID', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedBranch = selectedValue; + _selectedClinic = null; + _selectedDoctor = null; + model.getClinics( + _selectedBranch['ID']); + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).branch, + _selectedBranch != null + ? _selectedBranch['Desciption'] + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: _selectedBranch != null && + model.clinicsList != null && + model.clinicsList.length > 0 + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: model.clinicsList, + attributeName: 'ClinicDescription', + attributeValueId: 'ClinicID', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedDoctor = null; + _selectedClinic = selectedValue; + model.getClinicDoctors( + _selectedClinic['ClinicID'] + .toString()); + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).clinic, + _selectedClinic != null + ? _selectedClinic['ClinicDescription'] + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: _selectedClinic != null && + model.doctorsList != null && + model.doctorsList.length > 0 + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: model.doctorsList, + attributeName: 'DoctorName', + attributeValueId: 'DoctorID', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedDoctor = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).doctor, + _selectedDoctor != null + ? _selectedDoctor['DoctorName'] + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: () => _selectDate(context, model), + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context) + .chooseAppointment, + _selectedPatientArrivalEntity != null + ? "${TranslationBase.of(context).appointmentNo} ${_selectedPatientArrivalEntity.appointmentNo}" + : null, + true, + suffixIcon: Icon( + Icons.calendar_today, + color: Colors.black, + )), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).remarks, + null, + false), + enabled: true, + controller: _remarksController, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_LETTERS)) + ], + keyboardType: TextInputType.text, + minLines: 4, + maxLines: 6, + )), + ], + ), + ), + ], + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: AppButton( + title: TranslationBase.of(context).refer, + color: HexColor("#B8382B"), + onPressed: () => { + /*referToDoctor(context, model)*/ + }, + ), + ) + ], + ), + ), + ), + ), + ); + } + + _selectDate(BuildContext context, PatientReferralViewModel model) async { + // https://medium.com/flutter-community/a-deep-dive-into-datepicker-in-flutter-37e84f7d8d6c good reference + // https://stackoverflow.com/a/63147062/6246772 to customize a date picker + final DateTime picked = await showDatePicker( + context: context, + initialDate: appointmentDate, + firstDate: DateTime(2000), + lastDate: DateTime(2040), + initialEntryMode: DatePickerEntryMode.calendar, + ); + if (picked != null && picked != appointmentDate) { + appointmentDate = picked; + model + .getPatientArrivalList(DateUtils.convertStringToDateFormat( + appointmentDate.toString(), "yyyy-MM-dd")) + .then((_) { + if (model.patientArrivalList != null && + model.patientArrivalList.length > 0) { + List appointments = model.getAppointmentsByPatientName("${patient.firstName} ${patient.middleName} ${patient.lastName}"); + if(appointments.length > 0){ + ListSelectDialog dialog = + ListSelectDialog( + list: appointments, + attributeName: 'appointmentNo', + attributeValueId: 'appointmentNo', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedPatientArrivalEntity = PatientArrivalEntity.fromJson(selectedValue); + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + }else { + setState(() { + _selectedPatientArrivalEntity = null; + }); + DrAppToastMsg.showErrorToast("There is no appointments for ${patient.firstName} ${patient.middleName} ${patient.lastName}"); + } + }else { + setState(() { + _selectedPatientArrivalEntity = null; + }); + DrAppToastMsg.showErrorToast("There is no appointments for ${patient.firstName} ${patient.middleName} ${patient.lastName}"); + } + }); + } + } + + InputDecoration textFieldSelectorDecoration( + String hintText, String selectedText, bool isDropDown, + {Icon suffixIcon}) { + return InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown + ? suffixIcon != null + ? suffixIcon + : Icon( + Icons.arrow_drop_down, + color: Colors.black, + ) + : null, + hintStyle: TextStyle( + fontSize: 14, + color: Colors.grey.shade600, + ), + ); + } + + BoxDecoration containerBorderDecoration( + Color containerColor, Color borderColor) { + return BoxDecoration( + color: containerColor, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all(Radius.circular(6)), + border: Border.fromBorderSide(BorderSide( + color: borderColor, + width: 2.0, + )), + ); + } +} diff --git a/lib/screens/patients/profile/referral/referred-patient-screen.dart b/lib/screens/patients/profile/referral/referred-patient-screen.dart new file mode 100644 index 00000000..9fc5b4f8 --- /dev/null +++ b/lib/screens/patients/profile/referral/referred-patient-screen.dart @@ -0,0 +1,74 @@ +import 'package:doctor_app_flutter/core/viewModel/patient-doctor-referral-viewModel.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-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:flutter/material.dart'; + +class ReferredPatientScreen extends StatelessWidget { + // previous design page is: MyReferredPatient + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getMyReferredPatient(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).referPatient, + body: model.listMyReferredPatientModel == null || + model.listMyReferredPatientModel.length == 0 + ? Center( + child: AppText( + TranslationBase.of(context).errorNoSchedule, + color: Theme.of(context).errorColor, + ), + ) + : SingleChildScrollView( + child: Container( + child: Column( + children: [ + Container( + height: 75, + child: AppText( + "This is where upper view for avatar.. etc placed", + fontWeight: FontWeight.normal, + fontSize: 16, + ), + ), + const Divider( + color: Color(0xffCCCCCC), + height: 1, + thickness: 2, + indent: 0, + endIndent: 0, + ), + ...List.generate( + model.listMyReferredPatientModel.length, + (index) => PatientReferralItemWidget( + patientName: + "${model.getReferredPatientItem(index).firstName} ${model.getReferredPatientItem(index).middleName} ${model.getReferredPatientItem(index).lastName}", + referralStatus: + "${model.getReferredPatientItem(index).referralStatus}", + isReferredTo: true, + isSameBranch: model + .getReferredPatientItem(index) + .isReferralDoctorSameBranch, + referralDoctorName: model + .getReferredPatientItem(index) + .referralDoctorName, + clinicDescription: model + .getReferredPatientItem(index) + .referralClinicDescription, + remark: model + .getReferredPatientItem(index) + .referringDoctorRemarks, + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/util/dr_app_toast_msg.dart b/lib/util/dr_app_toast_msg.dart index fd1baa01..09259b45 100644 --- a/lib/util/dr_app_toast_msg.dart +++ b/lib/util/dr_app_toast_msg.dart @@ -41,7 +41,7 @@ import 'package:flutter_flexible_toast/flutter_flexible_toast.dart'; timeInSeconds: 1); } - void showTopShortToast(msg) { + static void showTopShortToast(msg) { FlutterFlexibleToast.showToast( message: msg, toastLength: Toast.LENGTH_SHORT, diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index b520fd6f..940e0617 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -80,6 +80,7 @@ class TranslationBase { String get searchMedicine => localizedValues['searchMedicine'][locale.languageCode]; String get myReferralPatient => localizedValues['myReferralPatient'][locale.languageCode]; + String get referPatient => localizedValues['referPatient'][locale.languageCode]; String get myReferral => localizedValues['myReferral'][locale.languageCode]; String get myReferredPatient => localizedValues['myReferredPatient'][locale.languageCode]; @@ -297,6 +298,21 @@ class TranslationBase { String get area => localizedValues['area'][locale.languageCode]; String get room => localizedValues['room'][locale.languageCode]; String get bed => localizedValues['bed'][locale.languageCode]; + String get referTo => localizedValues['referTo'][locale.languageCode]; + String get referredFrom => localizedValues['referredFrom'][locale.languageCode]; + String get branch => localizedValues['branch'][locale.languageCode]; + String get chooseAppointment => localizedValues['chooseAppointment'][locale.languageCode]; + String get appointmentNo => localizedValues['appointmentNo'][locale.languageCode]; + String get refer => localizedValues['refer'][locale.languageCode]; + String get approved => localizedValues['approved'][locale.languageCode]; + String get rejected => localizedValues['rejected'][locale.languageCode]; + String get sameBranch => localizedValues['sameBranch'][locale.languageCode]; + String get otherBranch => localizedValues['otherBranch'][locale.languageCode]; + String get dr => localizedValues['dr'][locale.languageCode]; + String get previewHealth => localizedValues['previewHealth'][locale.languageCode]; + String get summaryReport => localizedValues['summaryReport'][locale.languageCode]; + String get accept => localizedValues['accept'][locale.languageCode]; + String get reject => localizedValues['reject'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/patients/patient-referral-item-widget.dart b/lib/widgets/patients/patient-referral-item-widget.dart new file mode 100644 index 00000000..662e7fee --- /dev/null +++ b/lib/widgets/patients/patient-referral-item-widget.dart @@ -0,0 +1,143 @@ +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; + +class PatientReferralItemWidget extends StatelessWidget { + final String patientName; + final String referralStatus; + final isReferredTo; + final isSameBranch; + final String referralDoctorName; + final String clinicDescription; + final String remark; + final Widget infoIcon; + + PatientReferralItemWidget({ + this.patientName, + this.referralStatus, + this.isReferredTo = false, + this.isSameBranch, + this.referralDoctorName, + this.clinicDescription, + this.remark, + this.infoIcon, + }); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.all(16.0), + child: Column( + children: [ + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: AppText( + patientName, + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + if (referralStatus != null) + Container( + color: Color(0xFF4BA821), + padding: EdgeInsets.all(4), + child: AppText( + referralStatus == "46" + ? TranslationBase.of(context).approved + : TranslationBase.of(context).rejected, + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12, + ), + ), + SizedBox( + height: 8, + ), + Row( + children: [ + AppText( + isReferredTo + ? "${TranslationBase.of(context).referTo}: " + : "${TranslationBase.of(context).referredFrom}: ", + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 12, + ), + AppText( + isSameBranch + ? TranslationBase.of(context).sameBranch + : TranslationBase.of(context).otherBranch, + color: Colors.grey, + fontWeight: FontWeight.normal, + fontSize: 12, + ), + ], + ), + SizedBox( + height: 8, + ), + AppText( + "${TranslationBase.of(context).dr} $referralDoctorName", + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 12, + ), + SizedBox( + height: 8, + ), + if (clinicDescription != null) + Row( + children: [ + AppText( + "${TranslationBase.of(context).clinic}: ", + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 12, + ), + AppText( + clinicDescription, + color: Colors.grey, + fontWeight: FontWeight.normal, + fontSize: 12, + ), + ], + ), + SizedBox( + height: 8, + ), + AppText( + remark, + color: Colors.grey, + fontWeight: FontWeight.normal, + fontSize: 12, + ), + SizedBox( + height: 16, + ), + ], + ), + ), + if (infoIcon != null) infoIcon, + ], + ), + const Divider( + color: Color(0xffCCCCCC), + height: 1, + thickness: 1, + indent: 0, + endIndent: 0, + ), + SizedBox( + height: 8, + ), + ], + ), + ); + } +} diff --git a/lib/widgets/patients/profile/PatientProfileButton.dart b/lib/widgets/patients/profile/PatientProfileButton.dart new file mode 100644 index 00000000..dab1f9de --- /dev/null +++ b/lib/widgets/patients/profile/PatientProfileButton.dart @@ -0,0 +1,86 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; + +class PatientProfileButton extends StatelessWidget { + final String nameLine1; + final String nameLine2; + final String icon; + final dynamic route; + final PatiantInformtion patient; + final String url = "assets/images/"; + PatientProfileButton( + {Key key, this.patient, this.nameLine1, this.nameLine2, this.icon, this.route}) + : super(key: key); + @override + Widget build(BuildContext context) { + return new Container( + margin: new EdgeInsets.symmetric(horizontal: 4.0), + child: InkWell( + onTap: () { + navigator(context, this.route); + }, + child: Column(children: [ + Container( + alignment: Alignment.topLeft, + padding: EdgeInsets.all(5), + child: + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + this.nameLine1, + color: Color(0xFFB9382C), + fontWeight: FontWeight.w600, + textAlign: TextAlign.left, + fontSize: SizeConfig.textMultiplier * 2, + ), + AppText( + this.nameLine2, + color: Colors.black, + fontWeight: FontWeight.w600, + textAlign: TextAlign.left, + fontSize: SizeConfig.textMultiplier * 2, + ), + ], + ), + ), + Expanded( + child: Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Container( + padding: EdgeInsets.all(10), + child: new Image.asset(url + icon)) + ], + )), + ) + ]), + ), + decoration: BoxDecoration( + // border: Border.all(), + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(10)), + border: Border.fromBorderSide(BorderSide( + color: Color(0xffBBBBBB), + width: 1, + )), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.2), + spreadRadius: 5, + blurRadius: 7, + offset: Offset(0, 3), // changes position of shadow + ), + ], + ), + padding: EdgeInsets.fromLTRB(5, 10, 5, 5), + ); + } + + void navigator(BuildContext context, route) { + Navigator.of(context).pushNamed(route, arguments: {'patient': patient}); + } +} \ No newline at end of file diff --git a/lib/widgets/patients/profile/profile-welcome-widget.dart b/lib/widgets/patients/profile/profile-welcome-widget.dart new file mode 100644 index 00000000..fae705f4 --- /dev/null +++ b/lib/widgets/patients/profile/profile-welcome-widget.dart @@ -0,0 +1,86 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:provider/provider.dart'; + +class ProfileWelcomeWidget extends StatelessWidget { + + final Widget clinicWidget; +final double height; + + ProfileWelcomeWidget(this.clinicWidget, {this.height = 140}); + + @override + Widget build(BuildContext context) { + AuthViewModel authProvider = Provider.of(context); + + return Container( + height: height, + color: HexColor('#515B5D'), + width: double.infinity, + child: FractionallySizedBox( + widthFactor: 0.9, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + children: [ + AppText( + TranslationBase.of(context).welcome, + fontSize: SizeConfig.textMultiplier * 1.7, + color: Colors.white, + ) + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + AppText( + 'Dr. ${authProvider.doctorProfile.doctorName}', + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 2.5, + color: Colors.white, + ) + ], + ), + SizedBox( + height: 4, + ), + clinicWidget, + ], + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + decoration: BoxDecoration( + color: Theme.of(context).backgroundColor, + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + ), + height: 50, + width: 60, + child: Image.network( + authProvider.doctorProfile.doctorImageURL, +// fit: BoxFit.fill, + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index b8136026..76a26fac 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -6,9 +6,10 @@ import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import '../../../config/size_config.dart'; import '../../shared/app_texts_widget.dart'; -import '../../shared/rounded_container_widget.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'PatientProfileButton.dart'; + /* *@author: Elham Rababah *@Date:22/4/2020 @@ -52,8 +53,8 @@ class ProfileMedicalInfoWidget extends StatelessWidget { key: key, patient: patient, route: RADIOLOGY, - nameLine1: TranslationBase.of(context).radiology, - nameLine2: TranslationBase.of(context).service, + nameLine1: TranslationBase.of(context).previewHealth, + nameLine2: TranslationBase.of(context).summaryReport, icon: 'radiology-1.png'), Visibility( visible: selectedPatientType != 0 && selectedPatientType != 5, @@ -78,7 +79,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { child: PatientProfileButton( key: key, patient: patient, - route: REFER_PATIENT, + route: REFER_PATIENT_TO_DOCTOR, nameLine1: TranslationBase.of(context).myReferral, nameLine2: TranslationBase.of(context).patient, icon: 'note.png')), @@ -143,85 +144,3 @@ class CircleAvatarWidget extends StatelessWidget { ); } } - -class PatientProfileButton extends StatelessWidget { - final String nameLine1; - final String nameLine2; - final String icon; - final dynamic route; - final PatiantInformtion patient; - final String url = "assets/images/"; - PatientProfileButton( - {Key key, this.patient, this.nameLine1, this.nameLine2, this.icon, this.route}) - : super(key: key); - @override - Widget build(BuildContext context) { - return new Container( - margin: new EdgeInsets.symmetric(horizontal: 4.0), - child: InkWell( - onTap: () { - navigator(context, this.route); - }, - child: Column(children: [ - Container( - alignment: Alignment.topLeft, - padding: EdgeInsets.all(5), - child: - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - this.nameLine1, - color: Color(0xFFB9382C), - fontWeight: FontWeight.w600, - textAlign: TextAlign.left, - fontSize: SizeConfig.textMultiplier * 2, - ), - AppText( - this.nameLine2, - color: Colors.black, - fontWeight: FontWeight.w600, - textAlign: TextAlign.left, - fontSize: SizeConfig.textMultiplier * 2, - ), - ], - ), - ), - Expanded( - child: Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( - padding: EdgeInsets.all(10), - child: new Image.asset(url + icon)) - ], - )), - ) - ]), - ), - decoration: BoxDecoration( - // border: Border.all(), - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(10)), - border: Border.fromBorderSide(BorderSide( - color: Color(0xffBBBBBB), - width: 1, - )), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.2), - spreadRadius: 5, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - ), - padding: EdgeInsets.fromLTRB(5, 10, 5, 5), - ); - } - - void navigator(BuildContext context, route) { - Navigator.of(context).pushNamed(route, arguments: {'patient': patient}); - } -} diff --git a/lib/widgets/shared/borderedButton.dart b/lib/widgets/shared/borderedButton.dart new file mode 100644 index 00000000..5ccf4544 --- /dev/null +++ b/lib/widgets/shared/borderedButton.dart @@ -0,0 +1,83 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:flutter/material.dart'; + +class BorderedButton extends StatelessWidget { + final String text; + final Function handler; + final Color textColor; + final bool hasBorder; + final Color borderColor; + final Color backgroundColor; + final double vPadding; + final double hPadding; + final double radius; + final double lPadding; + final double tPadding; + final double rPadding; + final double bPadding; + final double fontSize; + final Widget icon; + final FontWeight fontWeight; + + BorderedButton( + this.text, { + this.handler, + this.textColor, + this.hasBorder = false, + this.borderColor, + this.backgroundColor, + this.vPadding = 0, + this.hPadding = 0, + this.radius = 4.0, + this.lPadding = 4.0, + this.tPadding = 0.0, + this.rPadding = 4.0, + this.bPadding = 0.0, + this.fontSize = 0, + this.icon, + this.fontWeight, + }); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + handler(); + }, + child: Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: backgroundColor ?? Colors.white, + borderRadius: BorderRadius.circular(radius), + border: Border.fromBorderSide(BorderSide( + color: hasBorder ? borderColor : Colors.white, + width: 0.8, + )), + ), + child: Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + icon != null ? icon : Container(), + Container( + padding: (hPadding > 0 || vPadding > 0) + ? EdgeInsets.symmetric( + vertical: vPadding, horizontal: hPadding) + : EdgeInsets.fromLTRB( + lPadding, tPadding, rPadding, bPadding), + child: Text( + text, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: fontSize == 0 ? SizeConfig.textMultiplier * 1.6 : fontSize, + fontWeight: fontWeight != null ? fontWeight : FontWeight.normal, + color: textColor ?? Color(0xffc4aa54)), + ), + ), + ], + ), + ), + ), + ); + } +} From cb80ce778523c8ec8fa5588a568a3ab4c2d00b93 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 23 Dec 2020 18:38:41 +0200 Subject: [PATCH 2/3] isAuthunticated behaviour --- lib/client/base_app_client.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index ca1b196a..f7498cc8 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -82,10 +82,8 @@ class BaseAppClient { } else { var parsed = json.decode(response.body.toString()); if (!parsed['IsAuthenticated']) { - // TODO commented this and make si success just for test - // await helpers.logout(); - // helpers.showErrorToast('Your session expired Please login again'); - onSuccess(parsed, statusCode); + await helpers.logout(); + helpers.showErrorToast('Your session expired Please login again'); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); } else { From f6ddf7a9eb44e574e8a53c5f07df540e7589e560 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Sun, 27 Dec 2020 13:58:21 +0200 Subject: [PATCH 3/3] make logout button close all screen stack and push to login --- lib/util/helpers.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 41c0b4f7..0c3f1b5f 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -348,6 +348,7 @@ class Helpers { String lang = await sharedPref.getString(APP_Language); await clearSharedPref(); sharedPref.setString(APP_Language, lang); - Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); + // Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); + Navigator.of(AppGlobal.CONTEX).popUntil((ModalRoute.withName(LOGIN))); } }