From 7559ab31c0e3182ccd0d802a25f981ddc98fe96a Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 3 May 2021 12:45:15 +0300 Subject: [PATCH 1/2] fix out patient + fix steper in arabic --- .../viewModel/PatientSearchViewModel.dart | 8 +-- .../out_patient/out_patient_screen.dart | 2 +- .../shared_soap_widgets/SOAP_step_header.dart | 1 - .../shared_soap_widgets/steps_widget.dart | 52 ++++++++++++------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 36d51248..5b5a99a3 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/core/enum/filter_type.dart'; import 'package:doctor_app_flutter/core/enum/patient_type.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; @@ -83,11 +84,10 @@ class PatientSearchViewModel extends BaseViewModel{ getPatientBasedOnDate ( {item, PatientSearchRequestModel patientSearchRequestModel, PatientType selectedPatientType, - bool isSearchWithKeyInfo })async { + bool isSearchWithKeyInfo,OutPatientFilterType outPatientFilterType })async { String dateTo; String dateFrom; - // TODO Fix this in Arabic - if (item == 'Previous') { + if (OutPatientFilterType.Previous == outPatientFilterType) { selectedFromDate = DateTime(DateTime.now().year, DateTime.now().month-1, DateTime.now().day); @@ -101,7 +101,7 @@ class PatientSearchViewModel extends BaseViewModel{ 'yyyy-MM-dd'); - } else if (item == 'Next Week') { + } else if (OutPatientFilterType.NextWeek == outPatientFilterType) { dateTo = DateUtils.convertDateToFormat( diff --git a/lib/screens/patients/out_patient/out_patient_screen.dart b/lib/screens/patients/out_patient/out_patient_screen.dart index f9e4bfd7..3052c77d 100644 --- a/lib/screens/patients/out_patient/out_patient_screen.dart +++ b/lib/screens/patients/out_patient/out_patient_screen.dart @@ -142,7 +142,7 @@ class _OutPatientsScreenState extends State { selectedPatientType: widget.selectedPatientType, patientSearchRequestModel: widget .patientSearchRequestModel, - isSearchWithKeyInfo: widget.isSearchWithKeyInfo); + isSearchWithKeyInfo: widget.isSearchWithKeyInfo, outPatientFilterType: outPatientFilterType); GifLoaderDialogUtils.hideDialog(context); }, child: Center( diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_step_header.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_step_header.dart index da1abd28..85614b6d 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_step_header.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_step_header.dart @@ -33,7 +33,6 @@ class SOAPStepHeader extends StatelessWidget { child: StepsWidget( index: currentIndex, changeCurrentTab: changePageViewIndex, - height: 100, ), ), SizedBox( diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/steps_widget.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/steps_widget.dart index 059674a8..c5c2e8ca 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/steps_widget.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/steps_widget.dart @@ -20,23 +20,26 @@ class StepsWidget extends StatelessWidget { ? Stack( children: [ Container( - height: height == 0 ? 150 : height, + height: height == 0 ? 100 : height, width: MediaQuery.of(context).size.width * 0.9, color: Colors.transparent, ), Positioned( top: 30 - , - child: Center( - child: Container( - width: MediaQuery.of(context).size.width * 0.9, - child: Divider( - color: Colors.grey, - height: 0.75, - thickness: 0.75, - ), + , + child: Center( + child: Container( + width: MediaQuery + .of(context) + .size + .width * 0.9, + child: Divider( + color: Colors.grey, + height: 0.75, + thickness: 0.75, ), - )), + ), + ),), Positioned( top: 10, left: 0, @@ -260,17 +263,26 @@ class StepsWidget extends StatelessWidget { : Stack( children: [ Container( - height: height == 0 ? 150 : height, - width: MediaQuery.of(context).size.width, + height: height == 0 ? 100 : height, + width: MediaQuery.of(context).size.width * 0.9, color: Colors.transparent, + ), + Positioned( + top: 30 + , child: Center( - child: Divider( - color: Colors.grey, - height: 0.75, - thickness: 0.75, + child: Container( + width: MediaQuery + .of(context) + .size + .width * 0.9, + child: Divider( + color: Colors.grey, + height: 0.75, + thickness: 0.75, + ), ), - ), - ), + ),), Positioned( top: 10, right: 0, @@ -303,7 +315,7 @@ class StepsWidget extends StatelessWidget { color: Colors.white, )), ), - SizedBox(height: 5), + SizedBox(height: 3), Column( children: [ AppText( From c3c4b662711df3c8660b460c7ba8b75e431798a6 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 3 May 2021 13:18:55 +0300 Subject: [PATCH 2/2] refactor search file name --- lib/routes.dart | 2 - lib/screens/home/home_screen.dart | 7 +- .../search_medicine_patient_screen.dart | 112 -- .../out_patient/out_patient_screen.dart | 4 +- ...header.dart => patient_search_header.dart} | 4 +- ...dart => patient_search_result_screen.dart} | 105 +- ...en_new.dart => patient_search_screen.dart} | 123 +- .../patients/patient_search_screen.dart | 641 ----------- lib/screens/patients/patients_screen.dart | 1005 ----------------- 9 files changed, 26 insertions(+), 1977 deletions(-) delete mode 100644 lib/screens/medicine/search_medicine_patient_screen.dart rename lib/screens/patients/patient_search/{header.dart => patient_search_header.dart} (88%) rename lib/screens/patients/patient_search/{patients_screen_new.dart => patient_search_result_screen.dart} (64%) rename lib/screens/patients/patient_search/{patient_search_screen_new.dart => patient_search_screen.dart} (56%) delete mode 100644 lib/screens/patients/patient_search_screen.dart delete mode 100644 lib/screens/patients/patients_screen.dart diff --git a/lib/routes.dart b/lib/routes.dart index 44613100..2684cd82 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -17,7 +17,6 @@ import 'package:doctor_app_flutter/screens/sick-leave/show-sickleave.dart'; import './screens/auth/login_screen.dart'; import './screens/auth/verification_methods_screen.dart'; -import './screens/patients/patients_screen.dart'; import 'screens/patients/profile/profile_screen/patient_profile_screen.dart'; import './screens/patients/profile/vital_sign/vital_sign_details_screen.dart'; import 'landing_page.dart'; @@ -66,7 +65,6 @@ var routes = { ROOT: (_) => RootPage(), HOME: (_) => LandingPage(), LOGIN: (_) => Loginsreen(), - PATIENTS: (_) => PatientsScreen(), VERIFICATION_METHODS: (_) => VerificationMethodsScreen(), PATIENTS_PROFILE: (_) => PatientProfileScreen(), LAB_RESULT: (_) => LabsHomePage(), diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 36f86c85..f6f1d85b 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -19,9 +19,8 @@ import 'package:doctor_app_flutter/screens/patients/DischargedPatientPage.dart'; import 'package:doctor_app_flutter/screens/patients/PatientsInPatientScreen.dart'; import 'package:doctor_app_flutter/screens/patients/ReferralDischargedPatientPage.dart'; import 'package:doctor_app_flutter/screens/patients/out_patient/out_patient_screen.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_screen_new.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search/patients_screen_new.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search_screen.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_screen.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_result_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/referral/patient_referral_screen.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; @@ -782,7 +781,7 @@ class _HomeScreenState extends State { context, MaterialPageRoute( builder: (context) => - PatientSearchScreenNew(), + PatientSearchScreen(), )); }, ), diff --git a/lib/screens/medicine/search_medicine_patient_screen.dart b/lib/screens/medicine/search_medicine_patient_screen.dart deleted file mode 100644 index d80c065b..00000000 --- a/lib/screens/medicine/search_medicine_patient_screen.dart +++ /dev/null @@ -1,112 +0,0 @@ -import 'dart:ui'; - -import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search_screen.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.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/cupertino.dart'; -import 'package:flutter/material.dart'; - -class SearchMedicinePatientScreen extends StatefulWidget { - @override - _SearchMedicinePatientScreen createState() => _SearchMedicinePatientScreen(); -} - -class _SearchMedicinePatientScreen extends State - with SingleTickerProviderStateMixin { - TabController _tabController; - var activeIndex = 0; - @override - void initState() { - super.initState(); - _tabController = TabController(length: 2, vsync: this); - } - - @override - void dispose() { - super.dispose(); - _tabController.dispose(); - } - - @override - @override - Widget build(BuildContext context) { - return AppScaffold( - isShowAppBar: true, - appBarTitle: TranslationBase.of(context).searchmedicinepatient, - body: Scaffold( - extendBodyBehindAppBar: true, - appBar: PreferredSize( - preferredSize: Size.fromHeight(65.0), - child: Center( - child: Container( - height: 60.0, - margin: EdgeInsets.only(top: 10.0), - width: MediaQuery.of(context).size.width * 0.92, // 0.9, - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Theme.of(context).dividerColor, - width: 0.9), //width: 0.7 - ), - color: Colors.white), - child: TabBar( - isScrollable: true, - onTap: (index) { - setState(() { - activeIndex = index; - }); - }, - controller: _tabController, - indicatorWeight: 5.0, - indicatorSize: TabBarIndicatorSize.tab, - indicatorColor: Colors.red[800], - labelColor: Theme.of(context).primaryColor, - labelPadding: - EdgeInsets.only(top: 4.0, left: 30.0, right: 30.0), - unselectedLabelColor: Colors.grey[800], - tabs: [ - Container( - width: MediaQuery.of(context).size.width * 0.35, - child: Center( - child: AppText( - TranslationBase.of(context).searchPatient, - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 14, - ), - ), - ), - Container( - width: MediaQuery.of(context).size.width * 0.35, - child: Center( - child: AppText( - TranslationBase.of(context).searchMedicine, - fontWeight: FontWeight.bold, - fontSize: 14, - color: Colors.black), - ), - ), - ], - ), - ), - ), - ), - body: Column( - children: [ - Expanded( - child: TabBarView( - physics: BouncingScrollPhysics(), - controller: _tabController, - children: [ - PatientSearchScreen(), - MedicineSearchScreen() - ], - ), - ) - ], - ), - )); - } -} diff --git a/lib/screens/patients/out_patient/out_patient_screen.dart b/lib/screens/patients/out_patient/out_patient_screen.dart index 3052c77d..8d1d2eb8 100644 --- a/lib/screens/patients/out_patient/out_patient_screen.dart +++ b/lib/screens/patients/out_patient/out_patient_screen.dart @@ -10,7 +10,7 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search/header.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -103,7 +103,7 @@ class _OutPatientsScreenState extends State { builder: (_, model, w) => AppScaffold( appBarTitle: "Search Patient", isShowAppBar: true, - appBar: HeaderInSearch( + appBar: PatientSearchHeader( title: "My Out patient", ), diff --git a/lib/screens/patients/patient_search/header.dart b/lib/screens/patients/patient_search/patient_search_header.dart similarity index 88% rename from lib/screens/patients/patient_search/header.dart rename to lib/screens/patients/patient_search/patient_search_header.dart index 0fbcdf1a..b9afab7d 100644 --- a/lib/screens/patients/patient_search/header.dart +++ b/lib/screens/patients/patient_search/patient_search_header.dart @@ -2,10 +2,10 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; -class HeaderInSearch extends StatelessWidget with PreferredSizeWidget { +class PatientSearchHeader extends StatelessWidget with PreferredSizeWidget { final String title; - const HeaderInSearch({Key key, this.title}) : super(key: key); + const PatientSearchHeader({Key key, this.title}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/screens/patients/patient_search/patients_screen_new.dart b/lib/screens/patients/patient_search/patient_search_result_screen.dart similarity index 64% rename from lib/screens/patients/patient_search/patients_screen_new.dart rename to lib/screens/patients/patient_search/patient_search_result_screen.dart index 7074bda9..0f536fcd 100644 --- a/lib/screens/patients/patient_search/patients_screen_new.dart +++ b/lib/screens/patients/patient_search/patient_search_result_screen.dart @@ -8,26 +8,19 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search/header.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/PatientCard.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/errors/error_message.dart'; -import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; // ignore: must_be_immutable -class PatientsScreenNew extends StatefulWidget { - final patientSearchForm; - final selectedType; - final isAppbar; - final arrivalType; - final isView; +class PatientsSearchResultScreen extends StatefulWidget { final PatientType selectedPatientType; final PatientSearchRequestModel patientSearchRequestModel; final bool isSearchWithKeyInfo; @@ -37,29 +30,27 @@ class PatientsScreenNew extends StatefulWidget { final String searchKey; - PatientsScreenNew( - {this.patientSearchForm, - this.selectedType, - this.isAppbar = true, - this.arrivalType, - this.isView, + PatientsSearchResultScreen( + { this.selectedPatientType, this.patientSearchRequestModel, this.isSearchWithKeyInfo = true, this.isSearch = false, - this.isInpatient = false, this.searchKey, this.isSearchAndOut=false}); + this.isInpatient = false, + this.searchKey, + this.isSearchAndOut = false}); @override - _PatientsScreenNewState createState() => _PatientsScreenNewState(); + _PatientsSearchResultScreenState createState() => + _PatientsSearchResultScreenState(); } -class _PatientsScreenNewState extends State { +class _PatientsSearchResultScreenState + extends State { int clinicId; AuthViewModel authProvider; - List _locations = []; //['All', 'Today', 'Tomorrow', 'Next Week']; - int _activeLocation = 0; String patientType; String patientTypeTitle; var selectedFilter = 1; @@ -74,14 +65,6 @@ class _PatientsScreenNewState extends State { @override Widget build(BuildContext context) { authProvider = Provider.of(context); - _locations = [ - TranslationBase.of(context).today, - TranslationBase.of(context).tomorrow, - TranslationBase.of(context).nextWeek, - ]; - final screenSize = MediaQuery.of(context).size; - - return BaseView( onModelReady: (model) async { if(!widget.isSearchWithKeyInfo && widget.selectedPatientType == PatientType.OutPatient) { @@ -95,72 +78,12 @@ class _PatientsScreenNewState extends State { builder: (_, model, w) => AppScaffold( appBarTitle: "Search Patient", isShowAppBar: true, - appBar: !widget.isSearch && !widget.isInpatient?HeaderInSearch( - title: "My Out patient", - ):HeaderInSearch( - title: "Search for ${widget.searchKey}", - ), + appBar: PatientSearchHeader( + title: "Search for ${widget.searchKey}", + ), baseViewModel: model, body: Column( children: [ - if(!widget.isInpatient && !widget.isSearch) - Container( - // color: Colors.red, - height: screenSize.height * 0.070, - decoration: TextFieldsUtils - .containerBorderDecoration( - Color(0Xffffffff), - Color(0xFFCCCCCC), - borderRadius: 4, - borderWidth: 0), - child: Row( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: _locations.map((item) { - bool _isActive = _locations[_activeLocation] == item - ? true - : false; - - return Expanded( - child: InkWell( - onTap: () async { - setState(() { - _activeLocation = _locations.indexOf(item); - }); - GifLoaderDialogUtils.showMyDialog(context); - await model.getPatientBasedOnDate(item: item, - selectedPatientType: widget.selectedPatientType, - patientSearchRequestModel: widget - .patientSearchRequestModel, - isSearchWithKeyInfo: widget.isSearchWithKeyInfo); - GifLoaderDialogUtils.hideDialog(context); - }, - child: Center( - child: Container( - height: screenSize.height * 0.070, - decoration: TextFieldsUtils.containerBorderDecoration( - _isActive - ? Color(0xFFD02127 /*B8382B*/) - : Color(0xFFEAEAEA), - _isActive ? Color(0xFFD02127) : Color(0xFFEAEAEA), - borderRadius: 4, - borderWidth: 0), - child: Center( - child: AppText( - item, - fontSize: SizeConfig.textMultiplier * 1.8, - color: _isActive ? Colors.white : Color(0xFF2B353E), - fontWeight: FontWeight.w700, - ), - ), - ), - ), - ), - ); - }).toList(), - ), - ), - SizedBox(height: 18.5), Container( width: SizeConfig.screenWidth * 0.9, diff --git a/lib/screens/patients/patient_search/patient_search_screen_new.dart b/lib/screens/patients/patient_search/patient_search_screen.dart similarity index 56% rename from lib/screens/patients/patient_search/patient_search_screen_new.dart rename to lib/screens/patients/patient_search/patient_search_screen.dart index 5270511d..dc6d3587 100644 --- a/lib/screens/patients/patient_search/patient_search_screen_new.dart +++ b/lib/screens/patients/patient_search/patient_search_screen.dart @@ -4,11 +4,10 @@ import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search/patients_screen_new.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_result_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.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/buttons/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; @@ -17,12 +16,12 @@ import 'package:flutter/services.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; -class PatientSearchScreenNew extends StatefulWidget { +class PatientSearchScreen extends StatefulWidget { @override - _PatientSearchScreenNewState createState() => _PatientSearchScreenNewState(); + _PatientSearchScreenState createState() => _PatientSearchScreenState(); } -class _PatientSearchScreenNewState extends State { +class _PatientSearchScreenState extends State { bool showOther = false; bool isFormSubmitted = false; TextEditingController patientFileInfoController = TextEditingController(); @@ -57,46 +56,6 @@ class _PatientSearchScreenNewState extends State { SizedBox( height: 16, ), - // AppText( - // 'Patient Type', - // fontWeight: FontWeight.w600, - // ), - // Row( - // children: [ - // Row( - // children: [ - // Radio( - // activeColor: Color(0xFFB9382C), - // value: PatientType.inPatient, - // groupValue: selectedPatientType, - // onChanged: (value) { - // setState(() { - // selectedPatientType = - // PatientType.inPatient; - // }); - // }, - // ), - // Text('InPatient'), - // ], - // ), - // Row( - // children: [ - // Radio( - // activeColor: Color(0xFFB9382C), - // value: PatientType.OutPatient, - // groupValue: selectedPatientType, - // onChanged: (value) { - // setState(() { - // selectedPatientType = - // PatientType.OutPatient; - // }); - // }, - // ), - // Text('OutPatient'), - // ], - // ), - // ], - // ), SizedBox( height: 10, ), @@ -133,78 +92,6 @@ class _PatientSearchScreenNewState extends State { SizedBox( height: 5, ), - // Row( - // mainAxisAlignment: MainAxisAlignment.end, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // InkWell( - // child: this.showOther == false - // ? AppText( - // TranslationBase.of(context) - // .searchWithOther, - // color: Colors.red, - // fontWeight: FontWeight.bold, - // ) - // : AppText( - // TranslationBase.of(context) - // .hideOtherCriteria, - // color: Colors.red, - // fontWeight: FontWeight.bold), - // onTap: () { - // setState(() { - // this.showOther = !this.showOther; - // }); - // }, - // ) - // ], - // ), - // SizedBox( - // height: 30, - // ), - // if (showOther) - // Column( - // children: [ - // AppTextFieldCustom( - // hintText: - // TranslationBase.of(context).firstName, - // controller: firstNameInfoController, - // maxLines: 1, - // minLines: 1, - // hasBorder: true, - // onChanged: (_) {}, - // // validationError:illnessController.text.isEmpty && illnessControllerError !=''?illnessControllerError:null , - // ), - // SizedBox( - // height: 10, - // ), - // AppTextFieldCustom( - // hintText: - // TranslationBase.of(context).middleName, - // controller: middleNameInfoController, - // maxLines: 1, - // minLines: 1, - // onChanged: (_) {}, - // hasBorder: true, - // // validationError:illnessController.text.isEmpty && illnessControllerError !=''?illnessControllerError:null , - // ), - // SizedBox( - // height: 10, - // ), - // AppTextFieldCustom( - // hintText: - // TranslationBase.of(context).lastName, - // controller: lastNameFileInfoController, - // maxLines: 1, - // minLines: 1, - // onChanged: (_) {}, - // hasBorder: true, - // // validationError:illnessController.text.isEmpty && illnessControllerError !=''?illnessControllerError:null , - // ), - // SizedBox( - // height: 10, - // ), - // ], - // ), SizedBox( height: MediaQuery.of(context).size.height * 0.12, ), @@ -301,7 +188,7 @@ class _PatientSearchScreenNewState extends State { Navigator.push( context, MaterialPageRoute( - builder: (BuildContext context) => PatientsScreenNew( + builder: (BuildContext context) => PatientsSearchResultScreen( selectedPatientType: selectedPatientType, patientSearchRequestModel: patientSearchRequestModel, isSearchWithKeyInfo: diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart deleted file mode 100644 index 88b8547b..00000000 --- a/lib/screens/patients/patient_search_screen.dart +++ /dev/null @@ -1,641 +0,0 @@ -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; -import 'package:doctor_app_flutter/models/patient/patient_model.dart'; -import 'package:doctor_app_flutter/routes.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:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/services.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; - -import '../../config/config.dart'; -import '../../config/size_config.dart'; -import '../../lookups/patient_lookup.dart'; -import '../../widgets/patients/dynamic_elements.dart'; -import '../../widgets/shared/app_scaffold_widget.dart'; -import '../../widgets/shared/app_texts_widget.dart'; -import '../../widgets/shared/buttons/app_buttons_widget.dart'; -import '../../widgets/shared/rounded_container_widget.dart'; -import '../../widgets/shared/text_fields/app_text_form_field.dart'; - -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); -Helpers helpers = Helpers(); - -// OWNER : Ibrahim albitar -// DATE : 19-04-2020 -// DESCRIPTION : Patient Search Screen. - -class PatientSearchScreen extends StatefulWidget { - @override - _PatientSearchScreenState createState() => _PatientSearchScreenState(); -} - -class _PatientSearchScreenState extends State { - String _selectedType = '1'; - String _selectedLocation = '1'; - String error = ''; - ProjectViewModel projectsProvider; - String itemText = ''; - String itemText2 = ''; - final GlobalKey _formKey = GlobalKey(); - bool _autoValidate = false; - bool onlyArrived = true; - bool isView = false; - bool isFormSubmitted = false; - - FocusNode _nodeText1 = FocusNode(); - FocusNode _nodeText2 = FocusNode(); - FocusNode _nodeText3 = FocusNode(); - - var _patientSearchFormValues = PatientModel( - FirstName: "0", - MiddleName: "0", - LastName: "0", - PatientMobileNumber: "0", - PatientIdentificationID: "0", - MobileNo: '0', - PatientID: 0, - From: "0", - To: "0", - LanguageID: 2, - stamp: "2020-03-02T13:56:39.170Z", - IPAdress: "11.11.11.11", - VersionID: 5.8, - Channel: 9, - TokenID: "2Fi7HoIHB0eDyekVa6tCJg==", - SessionID: "5G0yXn0Jnq", - IsLoginForDoctorApp: true, - IdentificationNo: '0', - PatientOutSA: false); - - void _validateInputs() async { - setState(() { - isFormSubmitted = true; - }); - - try { - if (_formKey.currentState.validate()) { - _formKey.currentState.save(); - - if ((_patientSearchFormValues.From == "0" || - _patientSearchFormValues.To == "0") && - _selectedType == "7" || - ((_patientSearchFormValues.From == "0" || - _patientSearchFormValues.To == "0") && - _selectedType == "6")) { - // Helpers.showErrorToast("Please Choose The Dates"); - } else { - setState(() { - isFormSubmitted = false; - }); - Navigator.of(context).pushNamed(PATIENTS, arguments: { - "patientSearchForm": _patientSearchFormValues, - "selectedType": _selectedType, - "isSearch": true, - "isView": isView - }); - } - } else { - setState(() { - _autoValidate = true; - }); - } - } catch (err) { - error = err.toString(); - } - } - - handelCatchErrorCase(err) { - //isLoading = false; - //isError = true; - error = Helpers.generateContactAdminMsg(err); - //notifyListeners(); - throw err; - } - - @override - Widget build(BuildContext context) { - projectsProvider = Provider.of(context); - return GestureDetector( - onTap: () { - FocusScope.of(context).requestFocus(new FocusNode()); - }, - child: AppScaffold( - appBarTitle: TranslationBase.of(context).searchPatient, - isShowAppBar: true, - body: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - RoundedContainer( - showBorder: false, - child: Column( - children: [ - Column( - children: [ - // Container( - // child: Icon( - // DoctorApp.search_patient_1, - // size: 100, - // color: Colors.black, - // ), - // margin: EdgeInsets.only(top: 10), - // ), - // Padding( - // padding: const EdgeInsets.only(top: 12.0), - // child: AppText( - // TranslationBase.of(context) - // .searchPatientImageCaptionTitle - // .toUpperCase(), - // fontWeight: FontWeight.bold, - // fontSize: SizeConfig.heightMultiplier * 2.5, - // ), - // ), - // Padding( - // padding: const EdgeInsets.only(top: 5.0), - // child: AppText( - // TranslationBase.of(context) - // .searchPatientImageCaptionBody, - // fontSize: SizeConfig.heightMultiplier * 2, - // ), - // ) - ], - ), - Container( - padding: EdgeInsets.all(15), - width: SizeConfig.screenWidth * 1, - child: Form( - key: _formKey, - autovalidate: _autoValidate, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 15, - ), - if (_selectedType != '7') - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - labelText: TranslationBase.of(context) - .patpatientIDMobilenationalientID, - borderColor: Colors.white, - textInputType: TextInputType.number, - textInputAction: TextInputAction.done, - inputFormatter: ONLY_NUMBERS, - focusNode: _nodeText1, - onSaved: (value) { - if (value != null && value != '') { - if (value.length == 10 && - (value[0] == '2' || - value[0] == '1')) { - _patientSearchFormValues - .IdentificationNo = value; - _patientSearchFormValues.Searchtype = 2; - _patientSearchFormValues.setPatientID = - 0; - } else if ((value.length == 10 || - value.length == 9) && - ((value[0] == '0' && - value[1] == '5') || - value[0] == '5')) { - _patientSearchFormValues.MobileNo = - value; - _patientSearchFormValues.Searchtype = 0; - } else { - _patientSearchFormValues.setPatientID = - int.parse(value); - _patientSearchFormValues.Searchtype = 1; - } - } - - // else{ - - // } - - // value == null || value == '' - // ? _patientSearchFormValues.setPatientID = - // 0 - // : _patientSearchFormValues.setPatientID = - // int.parse(value); - - // if (value != null && - // value.toString().trim().isEmpty) { - // _patientSearchFormValues.setPatientID = 0; - // } - }, - ), - ), - SizedBox( - height: 10, - ), - // Row( - // mainAxisAlignment: MainAxisAlignment.end, - // children: [ - // InkWell( - // child: this.isView == false - // ? AppText( - // TranslationBase.of(context) - // .searchWithOther, - // color: Colors.red, - // fontWeight: FontWeight.bold, - // ) - // : AppText( - // TranslationBase.of(context) - // .hideOtherCriteria, - // color: Colors.red, - // fontWeight: FontWeight.bold), - // onTap: () { - // setState(() { - // this.isView = !this.isView; - // }); - // }, - // ) - // ], - // ), - isView == true - ? Column(children: [ - SizedBox( - height: 10, - ), - Container( - height: 65.0, - decoration: ShapeDecoration( - shape: RoundedRectangleBorder( - side: BorderSide( - width: 1.0, - style: BorderStyle.solid, - color: HexColor("#CCCCCC")), - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - ), - ), - 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: - DropdownButtonHideUnderline( - child: DropdownButton( - isExpanded: true, - value: _selectedType, - iconSize: 25, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return PATIENT_TYPE_Des.map( - (item) { - return Row( - mainAxisSize: - MainAxisSize.max, - children: [ - !projectsProvider - .isArabic - ? AppText( - item['text'], - fontSize: SizeConfig - .textMultiplier * - 2.1, - ) - : AppText( - item['text_ar'], - fontSize: SizeConfig - .textMultiplier * - 2.1, - ), - ], - ); - }).toList(); - }, - onChanged: (String newValue) => - { - setState(() { - _selectedType = newValue; - selectedPatientType = - int.parse( - _selectedType); - }) - }, - items: PATIENT_TYPE_Des.map( - (item) { - !projectsProvider.isArabic - ? itemText = item['text'] - : itemText = - item['text_ar']; - return DropdownMenuItem( - child: Text( - itemText, - textAlign: TextAlign.end, - ), - value: item['val'], - ); - }).toList(), - )), - ), - ], - ), - ), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - labelText: TranslationBase.of(context) - .firstName, - borderColor: Colors.white, - onSaved: (value) { - value == null || value == '' - ? _patientSearchFormValues - .setFirstName = "0" - : _patientSearchFormValues - .setFirstName = value; - - if (value != null && - value - .toString() - .trim() - .isEmpty) { - _patientSearchFormValues - .setFirstName = "0"; - } - }, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_LETTERS), - ), - SizedBox( - height: 10, - ), - if (_selectedType != '7') - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - labelText: TranslationBase.of(context) - .phoneNumber, - borderColor: Colors.white, - textInputType: TextInputType.number, - textInputAction: TextInputAction.done, - inputFormatter: ONLY_NUMBERS, - focusNode: _nodeText1, - onSaved: (value) { - value == null || value == '' - ? _patientSearchFormValues - .setPatientMobileNumber = - "0" - : _patientSearchFormValues - .setPatientMobileNumber = - value; - - if (value != null && - value - .toString() - .trim() - .isEmpty) { - _patientSearchFormValues - .setPatientMobileNumber = "0"; - } - }, - ), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - labelText: TranslationBase.of(context) - .middleName, - borderColor: Colors.white, - onSaved: (value) { - value == null || value == '' - ? _patientSearchFormValues - .setMiddleName = "0" - : _patientSearchFormValues - .setMiddleName = value; - if (value != null && - value - .toString() - .trim() - .isEmpty) { - _patientSearchFormValues - .setMiddleName = "0"; - } - }, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_LETTERS), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - labelText: TranslationBase.of(context) - .lastName, - borderColor: Colors.white, - onSaved: (value) { - value == null || value == '' - ? _patientSearchFormValues - .setLastName = "0" - : _patientSearchFormValues - .setLastName = value; - if (value != null && - value - .toString() - .trim() - .isEmpty) { - _patientSearchFormValues - .setLastName = "0"; - } - }, - inputFormatter: ONLY_LETTERS), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - labelText: TranslationBase.of(context) - .patientID, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - focusNode: _nodeText2, - onSaved: (value) { - value == null || value == '' - ? _patientSearchFormValues - .setPatientID = 0 - : _patientSearchFormValues - .setPatientID = - int.parse(value); - if (value != null && - value - .trim() - .toString() - .isEmpty) { - _patientSearchFormValues - .setPatientID = 0; - } - }), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - labelText: TranslationBase.of(context) - .patientFile, - borderColor: Colors.white, - textInputType: TextInputType.number, - focusNode: _nodeText3, - inputFormatter: ONLY_NUMBERS, - onSaved: (value) {}, - ), - ), - (!(_selectedType == '2' || - _selectedType == '4')) - ? DynamicElements( - _patientSearchFormValues, - isFormSubmitted) - : SizedBox( - height: 0, - ), - SizedBox( - height: 10, - ), - Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: - HexColor("#CCCCCC"))), - height: 25, - width: 25, - child: Checkbox( - value: onlyArrived, - checkColor: HexColor("#2A930A"), - activeColor: Colors.white, - onChanged: (bool newValue) { - setState(() { - onlyArrived = newValue; - }); - }), - ), - SizedBox( - width: 12, - ), - AppText( - TranslationBase.of(context) - .onlyArrivedPatient, - fontSize: - SizeConfig.textMultiplier * - 2), - ])), - SizedBox( - height: 10, - ), - ]) - : SizedBox( - height: 0, - ), - ], - ), - ), - ), - ], - ), - ), - Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of(context).search, - color: Colors.red[800], - onPressed: () { - _validateInputs(); - }, - ), - ], - ), - ), - ], - ), - ]), - ), - ); - } -} diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart deleted file mode 100644 index 586d0238..00000000 --- a/lib/screens/patients/patients_screen.dart +++ /dev/null @@ -1,1005 +0,0 @@ -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; -import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; -import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/models/patient/patient_arrival/get_patient_arrival_list_request_model.dart'; -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/routes.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/helpers.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/patients/PatientCard.dart'; -import 'package:doctor_app_flutter/widgets/patients/clinic_list_dropdwon.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/errors/dr_app_embedded_error.dart'; -import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; -import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:intl/intl.dart'; -import 'package:provider/provider.dart'; - -import '../../config/size_config.dart'; -import '../../widgets/shared/app_scaffold_widget.dart'; - -class PatientsScreen extends StatefulWidget { - final patientSearchForm; - final selectedType; - final isAppbar; - final arrivalType; - final isView; - PatientsScreen( - {this.patientSearchForm, - this.selectedType, - this.isAppbar = true, - this.arrivalType, - this.isView}); - @override - _PatientsScreenState createState() => _PatientsScreenState(); -} - -class _PatientsScreenState extends State { - List lItems; - - List parsed; - - List date; - List unFilterDate; - - int clinicId; - AuthViewModel authProvider; - - Color sideColor = Colors.black; - List responseModelList; - List responseModelList2; - final String url = "assets/images/"; - final String avatarMale = "user_male.svg"; //'working_male.svg';//'user.svg'; - final String avatarFemale = 'user_female.svg'; - final String assetName = 'assets/image.svg'; - - List _locations = []; //['All', 'Today', 'Tomorrow', 'Next Week']; - - int _activeLocation = 0; - bool isInpatient = false; - bool _isInit = true; - String patientType; - bool isSearch = false; - String patientTypeTitle; - var _isLoading = true; - var selectedFilter = 1; - bool _isError = false; - String error = ""; - String arrivalType; - ProjectViewModel projectsProvider; - var isView; - final _controller = TextEditingController(); - - PatientModel patient; - var _patientSearchFormValues = PatientModel( - FirstName: "0", - MiddleName: "0", - LastName: "0", - PatientMobileNumber: "0", - PatientIdentificationID: "0", - PatientID: 0, - From: DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd') - .toString(), - To: DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd') - .toString(), - LanguageID: 2, - stamp: "2020-03-02T13:56:39.170Z", - IPAdress: "11.11.11.11", - VersionID: 5.5, - Channel: 9, - TokenID: "2Fi7HoIHB0eDyekVa6tCJg==", - SessionID: "5G0yXn0Jnq", - IsLoginForDoctorApp: true, - PatientOutSA: false); - searchData(String str) { - this.responseModelList = this.responseModelList2; - var strExist = str.length > 0 ? true : false; - if (strExist) { - List filterData = []; - - for (var i = 0; i < responseModelList2.length; i++) { - String firstName = responseModelList[i].firstName.toUpperCase(); - String lastName = responseModelList[i].lastName.toUpperCase(); - String mobile = responseModelList[i].mobileNumber.toUpperCase(); - String patientID = responseModelList[i].patientId.toString(); - - if (firstName.contains(str.toUpperCase()) || - lastName.contains(str.toUpperCase()) || - mobile.contains(str) || - patientID.contains(str)) { - filterData.add(responseModelList[i]); - } - } - - setState(() { - this.responseModelList = filterData; - }); - } else { - setState(() { - this.responseModelList = this.responseModelList2; - }); - } - } - - convertDate(String str) { - String timeConvert; - const start = "/Date("; - - const end = "+0300)"; - - final startIndex = str.indexOf(start); - - final endIndex = str.indexOf(end, startIndex + start.length); - - var date = new DateTime.fromMillisecondsSinceEpoch( - int.parse(str.substring(startIndex + start.length, endIndex))); - - String newDateformat = date.year.toString() + - "/" + - date.month.toString().padLeft(2, '0') + - "/" + - date.day.toString().padLeft(2, '0') + - " " + - "-" + - " " + - date.hour.toString().padLeft(2, '0') + - ":" + - date.minute.toString().toString().padLeft(2, '0'); - - return newDateformat.toString(); - } - - convertDateFormat(String str) { - String timeConvert; - const start = "/Date("; - const end = "+0300)"; - - final startIndex = str.indexOf(start); - final endIndex = str.indexOf(end, startIndex + start.length); - - var date = new DateTime.fromMillisecondsSinceEpoch( - int.parse(str.substring(startIndex + start.length, endIndex))); - String newDate = date.year.toString() + - "-" + - date.month.toString().padLeft(2, '0') + - "-" + - date.day.toString().padLeft(2, '0'); - - return newDate.toString(); - } - - filterBooking(String str) { - this.responseModelList = this.responseModelList2; - - var strExist = str.length > 0 ? true : false; - if (true) { - List filterDate = []; - String patiantAppointment = ""; - for (var i = 0; i < responseModelList2.length; i++) { - try { - if (responseModelList[i].appointmentDate == "") { - patiantAppointment = responseModelList[i].arrivedOn; - } else { - patiantAppointment = - convertDateFormat(responseModelList[i].appointmentDate); - } - if (patiantAppointment != null) { - String dateAppointment = checkDate(patiantAppointment); - - if (dateAppointment.contains(str) || str == 'All') { - filterDate.add(responseModelList[i]); - } - } - } catch (e) { - print(e); - } - } - - setState(() { - this.responseModelList = filterDate; - }); - } else { - setState(() { - this.responseModelList = this.responseModelList2; - }); - } - } - - String checkDate(String dateString) { - DateTime checkedTime = DateTime.parse(dateString); - DateTime currentTime = DateTime.now(); - - if ((currentTime.year == checkedTime.year) && - (currentTime.month == checkedTime.month) && - (currentTime.day == checkedTime.day)) { - return TranslationBase.of(context).today; - } else if ((currentTime.year == checkedTime.year) && - (currentTime.month == checkedTime.month)) { - if ((currentTime.day - checkedTime.day) == 1) { - return TranslationBase.of(context).yesterday; - } else if ((currentTime.day - checkedTime.day) == -1) { - return TranslationBase.of(context).tomorrow; - } - - if ((currentTime.day - checkedTime.day) <= -2) { - return TranslationBase.of(context).nextWeek; - } else { - return TranslationBase.of(context).all; - } - } - return TranslationBase.of(context).all; - } - - @override - Widget build(BuildContext context) { - authProvider = Provider.of(context); - _locations = [ - TranslationBase.of(context).today, - TranslationBase.of(context).tomorrow, - TranslationBase.of(context).nextWeek, - ]; - //TranslationBase.of(context).all, - projectsProvider = Provider.of(context); - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - - patient = widget.patientSearchForm != null - ? widget.patientSearchForm - : routeArgs['patientSearchForm']; - - patientType = widget.selectedType != null - ? widget.selectedType - : routeArgs['selectedType']; - arrivalType = widget.arrivalType != null - ? widget.arrivalType - : routeArgs['arrivalType']; - if (routeArgs != null && routeArgs.containsKey("isSearch")) { - isSearch = routeArgs['isSearch']; - } - if (routeArgs != null && routeArgs.containsKey("isSearch")) { - isView = routeArgs['isView']; - //patient.Searchtype = 1; - } - if (routeArgs != null && routeArgs.containsKey('activeFilter')) { - _activeLocation = routeArgs['activeFilter']; - } - if (routeArgs != null && routeArgs.containsKey('isInpatient')) { - isInpatient = routeArgs['isInpatient']; - } - - if (!projectsProvider.isArabic) - patientTypeTitle = SERVICES_PATIANT_HEADER[int.parse(patientType)]; - else - patientTypeTitle = SERVICES_PATIANT_HEADER_AR[int.parse(patientType)]; - - return BaseView( - onModelReady: (model) { - // TODO : change all the logic here to make it work with the model and remove future - int val2 = int.parse(patientType); - GetPatientArrivalListRequestModel getPatientArrivalListRequestModel; - if (val2 == 7) { - getPatientArrivalListRequestModel = GetPatientArrivalListRequestModel( - from: patient.From, - to: patient.To, - pageIndex: 0, - pageSize: 0, - patientMRN: patient.getPatientID); - } - - model - .getPatientList( - val2 == 7 - ? getPatientArrivalListRequestModel.toJson() - : patient, - patientType, - isView: isView) - .then((res) { - setState(() { - if (res != null && res['MessageStatus'] == 1) { - if (val2 == 7) { - if (res[SERVICES_PATIANT2[val2]] == null) { - _isError = true; - _isLoading = false; - this.error = error.toString(); - } else { - var localList = []; - if (res["patientArrivalList"]["entityList"] == null) { - res["patientArrivalList"]["entityList"] = []; - } - res["patientArrivalList"]["entityList"].forEach((v) { - Map mergedPatient = { - ...v, - ...v["patientDetails"] - }; - localList.add(mergedPatient); - }); - lItems = localList; - } - } else { - if (isView == false && val2 == 1) { - lItems = res['GetPatientFileInformation_PRMList'] - .where((i) => - i['PatientTypeDescription'] == 'Permanent File') - .toList(); - } else { - lItems = res[SERVICES_PATIANT2[val2]]; - } - } - parsed = lItems; - responseModelList = new ModelResponse.fromJson(parsed).list; - if (val2 == 7) { - responseModelList.sort((a, b) { - if (b.startTime != null && b.startTime != null) { - try { - DateTime now = DateTime.now(); - DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm"); - String formattedDate = - DateFormat('yyyy-MM-dd ' + a.startTime).format(now); - DateTime dateTimeA = dateFormat.parse(formattedDate); - String formattedDateB = - DateFormat('yyyy-MM-dd ' + b.startTime).format(now); - DateTime dateTimeB = dateFormat.parse(formattedDateB); - var adate = dateTimeA; //a.startTime; - var bdate = dateTimeB; - return adate.compareTo(bdate); - } on Exception catch (_) { - print('never reached'); - var adate = a.startTime; //a.startTime; - var bdate = b.startTime; - return adate.compareTo(bdate); - } - } else { - var adate = convertDateFormat(a.appointmentDate); - var bdate = convertDateFormat(b.appointmentDate); - return bdate.compareTo(adate); - } - }); - } - responseModelList2 = responseModelList; - _isError = false; - } else { - _isError = true; - error = model.error ?? - res['ErrorEndUserMessage'] ?? - res['ErrorMessage']; - } - - _isLoading = false; - }); - }).catchError((error) { - setState(() { - _isError = true; - _isLoading = false; - this.error = error.toString(); - }); - }); - }, - builder: (_, model, w) => AppScaffold( - appBarTitle: isSearch? "Search Patient": patientTypeTitle, - isShowAppBar: widget.isAppbar, - isLoading: _isLoading, - body: _isLoading - ? Container() - : _isError - ? DrAppEmbeddedError(error: error) - : lItems == null || lItems.length == 0 - ? Column( - children: [ - Column(children: [ - // Container( - // width: SizeConfig.screenWidth * 0.9, - // height: 75, - // decoration: BoxDecoration( - // borderRadius: - // BorderRadius.all(Radius.circular(6.0)), - // border: Border.all( - // width: 1.0, - // color: HexColor("#CCCCCC"), - // ), - // color: Colors.white), - // child: Column( - // crossAxisAlignment: - // CrossAxisAlignment.start, - // children: [ - // Padding( - // padding: EdgeInsets.only( - // left: 10, top: 10), - // child: AppText( - // TranslationBase.of(context) - // .searchPatientName, - // fontSize: 13, - // )), - // AppTextFormField( - // // focusNode: focusProject, - // controller: _controller, - // borderColor: Colors.white, - // prefix: IconButton( - // icon: Icon( - // DoctorApp.filter_1, - // color: Colors.black, - // ), - // iconSize: 20, - // padding: - // EdgeInsets.only(bottom: 30), - // ), - // onChanged: (String str) { - // this.searchData(str); - // }), - // ])), - - // Container( - // width: SizeConfig.screenWidth * 0.9, - // height: SizeConfig.screenHeight * 0.08, - // child: TextField( - // controller: _controller, - // onChanged: (String str) { - // this.searchData(str); - // }, - // decoration: buildInputDecoration( - // context, - // TranslationBase.of(context) - // .searchPatientName), - // ), - // ), - SizedBox( - height: 10.0, - ), - if (int.parse(patientType) == 7) - Container( - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - color: Colors.white, - border: Border.all(color: Colors.grey), - borderRadius: BorderRadius.circular(10)), - child: ClinicList( - clinicId: clinicId, - onClinicChange: (newValue) { - clinicId = newValue; - changeClinic(newValue, context, model); - }, - )), - Padding( - padding: EdgeInsets.only( - top: MediaQuery.of(context).size.height * - 0.03), - // child: _locationBar(context) - child: - SERVICES_PATIANT2[int.parse(patientType)] == - "List_MyOutPatient" - ? _locationBar(context, model) - : Container(), - ) - ]), - Container( - margin: EdgeInsets.only( - top: MediaQuery.of(context).size.height * 0.10), - child: Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 100, - ), - Image.asset('assets/images/no-data.png'), - Padding( - padding: const EdgeInsets.all(8.0), - child: AppText(TranslationBase.of(context) - .youDontHaveAnyPatient), - ) - ], - ), - ), - ), - ], - ) - : Container( - color: Colors.grey[200], - child: ListView( - scrollDirection: Axis.vertical, - children: [ - Container( - child: lItems == null - ? Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Center( - child: Padding( - padding: const EdgeInsets.fromLTRB( - 0, 0, 0, 0), //250 - child: - DrAppCircularProgressIndeicator(), - )), - ), - ], - ) - : Column( - children: [ - SizedBox(height: 18.5), - - Container( - width: SizeConfig.screenWidth * 0.9, - height: 75, - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"), - ), - color: Colors.white), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - left: 10, top: 10), - child: AppText( - TranslationBase.of( - context) - .searchPatientName, - fontSize: 13, - )), - AppTextFormField( - // focusNode: focusProject, - controller: _controller, - borderColor: Colors.white, - prefix: IconButton( - icon: Icon( - DoctorApp.filter_1, - color: Colors.black, - ), - iconSize: 20, - padding: - EdgeInsets.only( - bottom: 30), - ), - onChanged: (String str) { - this.searchData(str); - }), - ])), - // Container( - // width: SizeConfig.screenWidth * 0.9, - // height: - // SizeConfig.screenHeight * 0.08, - // child: TextField( - // controller: _controller, - // onChanged: (String str) { - // this.searchData(str); - // }, - // decoration: buildInputDecoration( - // context, - // TranslationBase.of(context) - // .searchPatientName), - // ), - // ), - SizedBox( - height: 10.0, - ), - // if (int.parse(patientType) == 7) - // Container( - // padding: EdgeInsets.all(5), - // decoration: BoxDecoration( - // color: Colors.white, - // border: Border.all( - // color: Colors.grey), - // borderRadius: - // BorderRadius.circular(10)), - // child: ClinicList( - // clinicId: clinicId, - // onClinicChange: (newValue) { - // clinicId = newValue; - // changeClinic( - // newValue, context, model); - // }, - // )), - Padding( - padding: EdgeInsets.only( - top: MediaQuery.of(context) - .size - .height * - 0.03), - // child: _locationBar(context) - child: SERVICES_PATIANT2[ - int.parse(patientType)] == - "List_MyOutPatient" - ? _locationBar(context, model) - : Container(), - ), - SizedBox( - height: 10.0, - ), - Container( - child: (responseModelList.length > - 0) - ? Column( - // mainAxisAlignment: MainAxisAlignment.center, - children: responseModelList - .map((PatiantInformtion - item) { - return PatientCard( - patientInfo: item, - patientType: - patientType, - arrivalType: - arrivalType, - isInpatient: - isInpatient, - onTap: () { - Navigator.of(context) - .pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": item, - "patientType": - patientType, - "from": patient - .getFrom, - "to": patient - .getTo, - "isSearch": - isSearch, - "isInpatient": - isInpatient, - "arrivalType": - arrivalType, - "isInpatient": - isInpatient - }); - }, - ); - }).toList(), - ) - : Center( - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - SizedBox( - height: 100, - ), - Image.asset( - 'assets/images/no-data.png'), - Padding( - padding: - const EdgeInsets - .all(8.0), - child: AppText( - TranslationBase.of( - context) - .youDontHaveAnyPatient), - ) - ], - ), - )), - ], - ), - ) - ], - ), - ), - ), - ); - } - - changeClinic(clinicId, BuildContext context, model) async { - GifLoaderDialogUtils.showMyDialog(context); - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); - ProfileReqModel docInfo = new ProfileReqModel( - doctorID: doctorProfile.doctorID, - clinicID: clinicId, - license: true, - projectID: doctorProfile.projectID, - tokenID: '', - languageID: 2); - - authProvider - .getDocProfiles(docInfo.toJson(), allowChangeProfile: false) - .then((profileList) async { - print(profileList['DoctorProfileList'][0]); - int val2 = int.parse(patientType); - - GetPatientArrivalListRequestModel getPatientArrivalListRequestModel = - GetPatientArrivalListRequestModel( - from: patient.From, - to: patient.To, - clinicID: profileList['DoctorProfileList'][0]['ClinicID'], - doctorID: - profileList['DoctorProfileList'][0]['DoctorID'].toString(), - patientMRN: patient.getPatientID, - pageIndex: 0, - pageSize: 0); - - model - .getPatientList( - getPatientArrivalListRequestModel.toJson(), patientType) - .then((res) { - setState(() { - if (res != null && res['MessageStatus'] == 1) { - if (val2 == 7) { - if (res[SERVICES_PATIANT2[val2]] == null) { - _isError = true; - _isLoading = false; - this.error = error.toString(); - } else { - var localList = []; - if (res["patientArrivalList"]["entityList"] == null) { - res["patientArrivalList"]["entityList"] = []; - } - res["patientArrivalList"]["entityList"].forEach((v) { - Map mergedPatient = { - ...v, - ...v["patientDetails"] - }; - localList.add(mergedPatient); - }); - lItems = localList; - } - } - parsed = lItems; - responseModelList = new ModelResponse.fromJson(parsed).list; - responseModelList.sort((a, b) { - DateTime now = DateTime.now(); - DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm"); - String formattedDate = - DateFormat('yyyy-MM-dd ' + a.startTime).format(now); - DateTime dateTimeA = dateFormat.parse(formattedDate); - String formattedDateB = - DateFormat('yyyy-MM-dd ' + b.startTime).format(now); - DateTime dateTimeB = dateFormat.parse(formattedDateB); - var adate = dateTimeA; //a.startTime; - var bdate = dateTimeB; - return adate.compareTo(bdate); - }); - responseModelList2 = responseModelList; - _isError = false; - } else { - _isError = true; - error = model.error ?? - res['ErrorEndUserMessage'] ?? - res['ErrorMessage']; - } - - _isLoading = false; - }); - GifLoaderDialogUtils.hideDialog(context); - }).catchError((error) { - Helpers.showErrorToast(error.toString()); - GifLoaderDialogUtils.hideDialog(context); - }); - }).catchError((err) { - GifLoaderDialogUtils.hideDialog(context); - Helpers.showErrorToast(err); - }); - } - - Widget _locationBar(BuildContext _context, model) { - return Container( - height: MediaQuery.of(context).size.height * 0.0619, - width: SizeConfig.screenWidth * 0.94, - decoration: BoxDecoration( - color: Color(0Xffffffff), - borderRadius: BorderRadius.circular(12.5), - // border: Border.all( - // width: 0.5, - // ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: _locations.map((item) { - bool _isActive = _locations[_activeLocation] == item ? true : false; - return Column(mainAxisSize: MainAxisSize.min, children: [ - InkWell( - child: Center( - child: Container( - height: MediaQuery.of(context).size.height * 0.058, - width: SizeConfig.screenWidth * 0.2334, - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(12.5), - topRight: Radius.circular(12.5), - topLeft: Radius.circular(9.5), - bottomLeft: Radius.circular(9.5)), - color: _isActive ? HexColor("#B8382B") : Colors.white, - ), - child: Center( - child: Text( - item, - style: TextStyle( - fontSize: 12, - color: _isActive - ? Colors.white - : Colors.black, //Colors.black, - - fontWeight: FontWeight.normal, - ), - ), - )), - ), - onTap: () { - //filterBooking(item.toString()); - - setState(() { - _activeLocation = _locations.indexOf(item); - }); - filterPatient(item.toString(), model); - }), - _isActive - ? Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(10), - topRight: Radius.circular(10)), - color: Colors.white), - alignment: Alignment.center, - height: 1, - width: SizeConfig.screenWidth * 0.23, - ) - : Container() - ]); - }).toList(), - ), - ); - } - - filterPatient(item, model) { - if (item == 'Tomorrow') { - _patientSearchFormValues.To = DateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, - DateTime.now().day + 1), - 'yyyy-MM-dd'); - _patientSearchFormValues.From = DateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, - DateTime.now().day + 1), - 'yyyy-MM-dd'); - } else if (item == 'Next Week') { - _patientSearchFormValues.From = DateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, - DateTime.now().day + 1), - 'yyyy-MM-dd'); - - _patientSearchFormValues.To = DateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, - DateTime.now().day + 6), - 'yyyy-MM-dd'); - } else { - _patientSearchFormValues.From = DateUtils.convertDateToFormat( - DateTime( - DateTime.now().year, DateTime.now().month, DateTime.now().day), - 'yyyy-MM-dd'); - _patientSearchFormValues.To = DateUtils.convertDateToFormat( - DateTime( - DateTime.now().year, DateTime.now().month, DateTime.now().day), - 'yyyy-MM-dd'); - } - searchPatient(model); - // Navigator.of(context).pop(); - // Navigator.of(context).pushNamed(PATIENTS, arguments: { - // "patientSearchForm": _patientSearchFormValues, - // "selectedType": "7", - // "arrivalType": "1", - // "activeFilter": _activeLocation - // }); - } - - searchPatient(model) { - GifLoaderDialogUtils.showMyDialog(context); - int val2 = int.parse(patientType); - GetPatientArrivalListRequestModel getPatientArrivalListRequestModel; - if (val2 == 0) { - patient = PatientModel( - From: _patientSearchFormValues.From, - To: _patientSearchFormValues.To, - FirstName: "0", - MiddleName: "0", - LastName: "0", - PatientMobileNumber: "0", - PatientIdentificationID: "0", - PatientID: 0, - ); - } - - model - .getPatientList( - val2 == 7 ? getPatientArrivalListRequestModel.toJson() : patient, - patientType, - isView: isView) - .then((res) { - setState(() { - GifLoaderDialogUtils.hideDialog(context); - if (res != null && res['MessageStatus'] == 1) { - if (val2 == 7) { - if (res[SERVICES_PATIANT2[val2]] == null) { - _isError = true; - _isLoading = false; - this.error = error.toString(); - } else { - var localList = []; - if (res["patientArrivalList"]["entityList"] == null) { - res["patientArrivalList"]["entityList"] = []; - } - res["patientArrivalList"]["entityList"].forEach((v) { - Map mergedPatient = { - ...v, - ...v["patientDetails"] - }; - localList.add(mergedPatient); - }); - lItems = localList; - } - } else { - if (isView == false && val2 == 1) { - lItems = res['GetPatientFileInformation_PRMList'] - .where((i) => i['PatientTypeDescription'] == 'Permanent File') - .toList(); - } else { - lItems = res[SERVICES_PATIANT2[val2]]; - } - } - parsed = lItems; - responseModelList = new ModelResponse.fromJson(parsed).list; - if (val2 == 7) { - responseModelList.sort((a, b) { - if (b.startTime != null && b.startTime != null) { - try { - DateTime now = DateTime.now(); - DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm"); - String formattedDate = - DateFormat('yyyy-MM-dd ' + a.startTime).format(now); - DateTime dateTimeA = dateFormat.parse(formattedDate); - String formattedDateB = - DateFormat('yyyy-MM-dd ' + b.startTime).format(now); - DateTime dateTimeB = dateFormat.parse(formattedDateB); - var adate = dateTimeA; //a.startTime; - var bdate = dateTimeB; - return adate.compareTo(bdate); - } on Exception catch (_) { - print('never reached'); - var adate = a.startTime; //a.startTime; - var bdate = b.startTime; - return adate.compareTo(bdate); - } - } else { - var adate = convertDateFormat(a.appointmentDate); - var bdate = convertDateFormat(b.appointmentDate); - return bdate.compareTo(adate); - } - }); - } - responseModelList2 = responseModelList; - _isError = false; - } else { - _isError = true; - error = - model.error ?? res['ErrorEndUserMessage'] ?? res['ErrorMessage']; - } - - _isLoading = false; - }); - }).catchError((error) { - GifLoaderDialogUtils.hideDialog(context); - setState(() { - _isError = true; - _isLoading = false; - this.error = error.toString(); - }); - }); - } -}