From cb67dcc9e105fa649898d7f9d462985426888f9f Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 26 Apr 2021 13:21:29 +0300 Subject: [PATCH 1/4] first step from search --- lib/config/config.dart | 1 + lib/core/enum/patient_type.dart | 2 + lib/core/model/PatientSearchRequestModel.dart | 27 +- .../service/patient/out_patient_service.dart | 45 ++ .../viewModel/PatientSearchViewModel.dart | 33 + lib/locator.dart | 2 + lib/screens/home/home_screen.dart | 39 + .../patient_search_screen_new.dart | 302 ++++++++ .../patient_search/patients_screen_new.dart | 732 ++++++++++++++++++ lib/widgets/patients/PatientCard.dart | 203 ++--- 10 files changed, 1276 insertions(+), 110 deletions(-) create mode 100644 lib/core/enum/patient_type.dart create mode 100644 lib/core/service/patient/out_patient_service.dart create mode 100644 lib/screens/patients/patient_search/patient_search_screen_new.dart create mode 100644 lib/screens/patients/patient_search/patients_screen_new.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 5c704152..09f4f586 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -277,6 +277,7 @@ const GET_INSURANCE_IN_PATIENT = "Services/DoctorApplication.svc/REST/GetApprovalStatusForInpatient"; const GET_SICK_LEAVE_PATIENT = "Services/Patients.svc/REST/GetPatientSickLeave"; +const GET_MY_OUT_PATIENT = "Services/DoctorApplication.svc/REST/GetMyOutPatient"; var selectedPatientType = 1; diff --git a/lib/core/enum/patient_type.dart b/lib/core/enum/patient_type.dart new file mode 100644 index 00000000..efea543c --- /dev/null +++ b/lib/core/enum/patient_type.dart @@ -0,0 +1,2 @@ +enum PatientType { inPatient, OutPatient } + diff --git a/lib/core/model/PatientSearchRequestModel.dart b/lib/core/model/PatientSearchRequestModel.dart index 72b1aa9e..7691cadb 100644 --- a/lib/core/model/PatientSearchRequestModel.dart +++ b/lib/core/model/PatientSearchRequestModel.dart @@ -8,17 +8,20 @@ class PatientSearchRequestModel { int patientID; String from; String to; + int searchType; + String mobileNo; + String identificationNo; PatientSearchRequestModel( - {this.doctorID, - this.firstName, - this.middleName, - this.lastName, - this.patientMobileNumber, - this.patientIdentificationID, - this.patientID, - this.from, - this.to}); + {this.doctorID =0, + this.firstName ="0", + this.middleName="0", + this.lastName="0", + this.patientMobileNumber="0", + this.patientIdentificationID="0", + this.patientID =0, + this.from="0", + this.to="0"}); PatientSearchRequestModel.fromJson(Map json) { doctorID = json['DoctorID']; @@ -30,6 +33,9 @@ class PatientSearchRequestModel { patientID = json['PatientID']; from = json['From']; to = json['To']; + searchType = json['SearchType']; + mobileNo = json['MobileNo']; + identificationNo = json['IdentificationNo']; } Map toJson() { @@ -43,6 +49,9 @@ class PatientSearchRequestModel { data['PatientID'] = this.patientID; data['From'] = this.from; data['To'] = this.to; + data['SearchType'] = this.searchType; + data['MobileNo'] = this.mobileNo; + data['IdentificationNo'] = this.identificationNo; return data; } } diff --git a/lib/core/service/patient/out_patient_service.dart b/lib/core/service/patient/out_patient_service.dart new file mode 100644 index 00000000..606bfc5d --- /dev/null +++ b/lib/core/service/patient/out_patient_service.dart @@ -0,0 +1,45 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; +import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; + +class OutPatientService extends BaseService { + List _patientList = []; + List get patientList => _patientList; + + + Future getOutPatient(PatientSearchRequestModel patientSearchRequestModel) async { + hasError = false; + await baseAppClient.post( + GET_MY_OUT_PATIENT, + onSuccess: (dynamic response, int statusCode) { + _patientList.clear(); + response['List_MyOutPatient'].forEach((v) { + _patientList.add(PatiantInformtion.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patientSearchRequestModel.toJson(), + ); + } + Future getPatientFileInformation(PatientSearchRequestModel patientSearchRequestModel) async { + hasError = false; + await baseAppClient.post( + PRM_SEARCH_PATIENT, + onSuccess: (dynamic response, int statusCode) { + _patientList.clear(); + response['GetPatientFileInformation_PRMList'].forEach((v) { + _patientList.add(PatiantInformtion.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: patientSearchRequestModel.toJson(), + ); + } +} diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index ea0e5cec..455e8788 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -1,5 +1,38 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; +import 'package:doctor_app_flutter/core/service/patient/out_patient_service.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; + +import '../../locator.dart'; import 'base_view_model.dart'; class PatientSearchViewModel extends BaseViewModel{ + OutPatientService _outPatientService = locator(); + + List get patientList => _outPatientService.patientList; + + getOutPatient(PatientSearchRequestModel patientSearchRequestModel) async { + setState(ViewState.Busy); + await _outPatientService.getOutPatient( + patientSearchRequestModel); + if (_outPatientService.hasError) { + error = _outPatientService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + + getPatientFileInformation(PatientSearchRequestModel patientSearchRequestModel) async { + setState(ViewState.Busy); + await _outPatientService.getPatientFileInformation( + patientSearchRequestModel); + if (_outPatientService.hasError) { + error = _outPatientService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } } \ No newline at end of file diff --git a/lib/locator.dart b/lib/locator.dart index 3aabd46b..a52482a4 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -27,6 +27,7 @@ import 'core/service/patient-admission-request-service.dart'; import 'core/service/patient-doctor-referral-service.dart'; import 'core/service/patient-ucaf-service.dart'; import 'core/service/patient-vital-signs-service.dart'; +import 'core/service/patient/out_patient_service.dart'; import 'core/service/prescriptions_service.dart'; import 'core/service/radiology_service.dart'; import 'core/service/referral_patient_service.dart'; @@ -80,6 +81,7 @@ void setupLocator() { locator.registerLazySingleton(() => ReferralService()); locator.registerLazySingleton(() => MyReferralInPatientService()); locator.registerLazySingleton(() => DischargedPatientService()); + locator.registerLazySingleton(() => OutPatientService()); /// View Model locator.registerFactory(() => DoctorReplayViewModel()); diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 39fc7a8c..47bc1d0b 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -16,6 +16,7 @@ import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart' import 'package:doctor_app_flutter/screens/medicine/search_medicine_patient_screen.dart'; import 'package:doctor_app_flutter/screens/patients/DischargedPatientPage.dart'; import 'package:doctor_app_flutter/screens/patients/ReferralDischargedPatientPage.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_screen_new.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/referral/patient_referral_screen.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; @@ -464,6 +465,44 @@ class _HomeScreenState extends State { child: new ListView( scrollDirection: Axis.horizontal, children: [ + HomePageCard( + color: Colors.black, + margin: EdgeInsets.all(5), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 10, left: 10, right: 0), + child: Icon( + DoctorApp.search, + size: 32, + color: Colors.white, + )), + Container( + padding: EdgeInsets.all(10), + child: AppText( + "New:"+TranslationBase.of(context) + .searchPatient, + color: Colors.white, + textAlign: TextAlign.start, + fontSize: 13, + )) + ], + ), + hasBorder: false, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PatientSearchScreenNew(), + )); + }, + ), HomePageCard( color: Colors.red[800], margin: EdgeInsets.all(5), diff --git a/lib/screens/patients/patient_search/patient_search_screen_new.dart b/lib/screens/patients/patient_search/patient_search_screen_new.dart new file mode 100644 index 00000000..f383cf40 --- /dev/null +++ b/lib/screens/patients/patient_search/patient_search_screen_new.dart @@ -0,0 +1,302 @@ +import 'package:doctor_app_flutter/core/enum/patient_type.dart'; +import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; +import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.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/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'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class PatientSearchScreenNew extends StatefulWidget { + @override + _PatientSearchScreenNewState createState() => _PatientSearchScreenNewState(); +} + +class _PatientSearchScreenNewState extends State { + bool showOther = false; + bool isFormSubmitted = false; + TextEditingController patientFileInfoController = TextEditingController(); + TextEditingController firstNameInfoController = TextEditingController(); + TextEditingController middleNameInfoController = TextEditingController(); + TextEditingController lastNameFileInfoController = TextEditingController(); + PatientType selectedPatientType = PatientType.inPatient; + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) async {}, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: false, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + body: SingleChildScrollView( + child: Center( + child: Column( + children: [ + BottomSheetTitle( + title: TranslationBase.of(context).searchPatient), + FractionallySizedBox( + widthFactor: 0.9, + child: Container( + color: Theme.of(context).scaffoldBackgroundColor, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 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, + ), + Container( + margin: + EdgeInsets.only(left: 0, right: 0, top: 15), + child: AppTextFieldCustom( + hintText: TranslationBase.of(context) + .patpatientIDMobilenationalientID, + isTextFieldHasSuffix: false, + maxLines: 1, + minLines: 1, + hasBorder: true, + controller: patientFileInfoController, + validationError: (isFormSubmitted && ( + patientFileInfoController + .text.isEmpty && + firstNameInfoController + .text.isEmpty && + middleNameInfoController + .text.isEmpty && + lastNameFileInfoController + .text.isEmpty)) + ? TranslationBase.of(context).emptyMessage + : null, + ), + ), + 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, + ), + ])), + ), + ], + ), + ), + ), + bottomSheet: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + height: MediaQuery.of(context).size.height * 0.1, + width: double.infinity, + child: Column( + children: [ + SizedBox( + height: 10, + ), + Container( + child: FractionallySizedBox( + widthFactor: .80, + child: Center( + child: AppButton( + fontWeight: FontWeight.w700, + title: TranslationBase.of(context).search, + onPressed: () { + onSubmitSearch(); + }, + color: Colors.red[800], + ), + ), + ), + ), + SizedBox( + height: 5, + ), + ], + ), + ), + ), + ); + } + + onSubmitSearch() { + GifLoaderDialogUtils.showMyDialog(context); + setState(() { + isFormSubmitted = true; + }); + PatientSearchRequestModel patientSearchRequestModel = + PatientSearchRequestModel(); + if (showOther) { + patientSearchRequestModel.firstName = firstNameInfoController.text.trim().isEmpty?"0":firstNameInfoController.text.trim(); + patientSearchRequestModel.middleName = middleNameInfoController.text.trim().isEmpty?"0":middleNameInfoController.text.trim(); + patientSearchRequestModel.lastName = lastNameFileInfoController.text.isEmpty?"0":lastNameFileInfoController.text.trim(); + } + + if (patientFileInfoController.text.isNotEmpty) { + if (patientFileInfoController.text.length == 10 && + (patientFileInfoController.text[0] == '2' || + patientFileInfoController.text[0] == '1')) { + patientSearchRequestModel.identificationNo = + patientFileInfoController.text; + patientSearchRequestModel.searchType = 2; + patientSearchRequestModel.patientID = 0; + } else if ((patientFileInfoController.text.length == 10 || + patientFileInfoController.text.length == 9) && + ((patientFileInfoController.text[0] == '0' && + patientFileInfoController.text[1] == '5') || + patientFileInfoController.text[0] == '5')) { + patientSearchRequestModel.mobileNo = patientFileInfoController.text; + patientSearchRequestModel.searchType = 0; + } else { + patientSearchRequestModel.patientID = + int.parse(patientFileInfoController.text); + patientSearchRequestModel.searchType = 1; + } + } + + GifLoaderDialogUtils.hideDialog(context); + + if (patientFileInfoController.text.isNotEmpty || + firstNameInfoController.text.isNotEmpty || + middleNameInfoController.text.isNotEmpty || + lastNameFileInfoController.text.isNotEmpty) { + setState(() { + isFormSubmitted = false; + }); + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => PatientsScreenNew( + selectedPatientType: selectedPatientType, + patientSearchRequestModel: patientSearchRequestModel, + isSearchWithKeyInfo: + patientFileInfoController.text.isNotEmpty ? true : false, + ), + ), + ); + } + } +} diff --git a/lib/screens/patients/patient_search/patients_screen_new.dart b/lib/screens/patients/patient_search/patients_screen_new.dart new file mode 100644 index 00000000..5b3b5a77 --- /dev/null +++ b/lib/screens/patients/patient_search/patients_screen_new.dart @@ -0,0 +1,732 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/patient_type.dart'; +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/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_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; +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'; + +// ignore: must_be_immutable +class PatientsScreenNew extends StatefulWidget { + final patientSearchForm; + final selectedType; + final isAppbar; + final arrivalType; + final isView; + final PatientType selectedPatientType; + final PatientSearchRequestModel patientSearchRequestModel; + final bool isSearchWithKeyInfo; + + PatientsScreenNew( + {this.patientSearchForm, + this.selectedType, + this.isAppbar = true, + this.arrivalType, + this.isView, + this.selectedPatientType, + this.patientSearchRequestModel, + this.isSearchWithKeyInfo = true}); + + @override + _PatientsScreenNewState createState() => _PatientsScreenNewState(); +} + +class _PatientsScreenNewState 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; + 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: 1.2, + 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; + }); + } + } + + 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(); + } + + @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']; + // } + // 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) async { + if(widget.isSearchWithKeyInfo) { + await model.getPatientFileInformation(widget.patientSearchRequestModel); + } else { + // ignore: unrelated_type_equality_checks + if(widget.selectedPatientType == PatientType.OutPatient) { + await model.getOutPatient(widget.patientSearchRequestModel); + } else { + // TODO handel inPatient case + } + } + }, + builder: (_, model, w) => AppScaffold( + appBarTitle: "Search Patient", + isShowAppBar: widget.isAppbar, + // isLoading: _isLoading, + baseViewModel: model, + body: model.patientList.isEmpty + ? Column( + children: [ + Column(children: [ + SizedBox( + height: 10.0, + ), + if (widget.selectedPatientType == PatientType.OutPatient) + 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: + widget.selectedPatientType == PatientType.OutPatient + ? _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:model.patientList.isEmpty + ? 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); + }), + ])), + SizedBox( + height: 10.0, + ), + Padding( + padding: EdgeInsets.only( + top: MediaQuery.of(context) + .size + .height * + 0.03), + // child: _locationBar(context) + child: widget.selectedPatientType == PatientType.OutPatient? _locationBar(context, model) + : Container(), + ), + SizedBox( + height: 10.0, + ), + Container( + child: (model.patientList.isNotEmpty) + ? Column( + // mainAxisAlignment: MainAxisAlignment.center, + children: model.patientList + .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); + } + + 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(); + }); + }); + } +} diff --git a/lib/widgets/patients/PatientCard.dart b/lib/widgets/patients/PatientCard.dart index 5dcedc7e..dad33425 100644 --- a/lib/widgets/patients/PatientCard.dart +++ b/lib/widgets/patients/PatientCard.dart @@ -35,18 +35,18 @@ class PatientCard extends StatelessWidget { color: Colors.white, ), child: Stack(children: [ - if (SERVICES_PATIANT2[int.parse(patientType)] != "List_MyInPatient") - Container( - height: MediaQuery.of(context).size.height * .20, - width: 5, - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - bottomLeft: Radius.circular(10)), - color: patientInfo.patientStatusType == 43 - ? Colors.green[500] - : Colors.red[800], - )), + // if (SERVICES_PATIANT2[int.parse(patientType)] != "List_MyInPatient") + // Container( + // height: MediaQuery.of(context).size.height * .20, + // width: 5, + // decoration: BoxDecoration( + // borderRadius: BorderRadius.only( + // topLeft: Radius.circular(10), + // bottomLeft: Radius.circular(10)), + // color: patientInfo.patientStatusType == 43 + // ? Colors.green[500] + // : Colors.red[800], + // )), Container( padding: EdgeInsets.only(left: 10, right: 0, bottom: 0), child: InkWell( @@ -55,48 +55,48 @@ class PatientCard extends StatelessWidget { SizedBox( height: 10, ), - SERVICES_PATIANT2[int.parse(patientType)] == - "List_MyOutPatient" - ? Padding( - padding: EdgeInsets.only(left: 12.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - patientInfo.patientStatusType == 43 - ? AppText( - TranslationBase.of(context).arrivedP, - color: Colors.green, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: 12, - ) - : AppText( - TranslationBase.of(context).notArrived, - color: Colors.red[800], - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: 12, - ), - this.arrivalType == '1' - ? AppText( - patientInfo.startTime != null - ? patientInfo.startTime - : patientInfo.startTimes, - fontFamily: 'Poppins', - fontWeight: FontWeight.w600, - ) - : patientInfo.arrivedOn != null - ? AppText( - DateUtils.convertStringToDateFormat( - patientInfo.arrivedOn, - 'MM-dd-yyyy HH:mm'), - fontFamily: 'Poppins', - fontWeight: FontWeight.w600, - ) - : SizedBox() - ], - )) - : SizedBox(), + // SERVICES_PATIANT2[int.parse(patientType)] == + // "List_MyOutPatient" + // ? Padding( + // padding: EdgeInsets.only(left: 12.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // patientInfo.patientStatusType == 43 + // ? AppText( + // TranslationBase.of(context).arrivedP, + // color: Colors.green, + // fontWeight: FontWeight.bold, + // fontFamily: 'Poppins', + // fontSize: 12, + // ) + // : AppText( + // TranslationBase.of(context).notArrived, + // color: Colors.red[800], + // fontWeight: FontWeight.bold, + // fontFamily: 'Poppins', + // fontSize: 12, + // ), + // this.arrivalType == '1' + // ? AppText( + // patientInfo.startTime != null + // ? patientInfo.startTime + // : patientInfo.startTimes, + // fontFamily: 'Poppins', + // fontWeight: FontWeight.w600, + // ) + // : patientInfo.arrivedOn != null + // ? AppText( + // DateUtils.convertStringToDateFormat( + // patientInfo.arrivedOn, + // 'MM-dd-yyyy HH:mm'), + // fontFamily: 'Poppins', + // fontWeight: FontWeight.w600, + // ) + // : SizedBox() + // ], + // )) + // : SizedBox(), Padding( padding: EdgeInsets.only(left: 12.0), child: Row( @@ -213,32 +213,32 @@ class PatientCard extends StatelessWidget { ), ), ), - if (SERVICES_PATIANT2[int.parse(patientType)] != - "List_MyInPatient") - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 2.0 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: - TranslationBase.of(context).age + - " : ", - style: TextStyle(fontSize: 14)), - new TextSpan( - text: - "${DateUtils.getAgeByBirthday(patientInfo.dateofBirth, context)}", - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 15)), - ], - ), - ), - ), + // if (SERVICES_PATIANT2[int.parse(patientType)] != + // "List_MyInPatient") + // Container( + // child: RichText( + // text: new TextSpan( + // style: new TextStyle( + // fontSize: 2.0 * SizeConfig.textMultiplier, + // color: Colors.black, + // fontFamily: 'Poppins', + // ), + // children: [ + // new TextSpan( + // text: + // TranslationBase.of(context).age + + // " : ", + // style: TextStyle(fontSize: 14)), + // new TextSpan( + // text: + // "${DateUtils.getAgeByBirthday(patientInfo.dateofBirth, context)}", + // style: TextStyle( + // fontWeight: FontWeight.w700, + // fontSize: 15)), + // ], + // ), + // ), + // ), if (isInpatient == true) Container( child: RichText( @@ -370,27 +370,28 @@ class PatientCard extends StatelessWidget { //) ])) ]), - SERVICES_PATIANT2[int.parse(patientType)] == - "List_MyOutPatient" - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( - padding: EdgeInsets.all(4), - child: Image.asset( - patientInfo.appointmentType == - 'Regular' && - patientInfo.visitTypeId == 100 - ? 'assets/images/livecare.png' - : patientInfo.appointmentType == - 'Walkin' - ? 'assets/images/walkin.png' - : 'assets/images/booked.png', - height: 25, - width: 35, - )), - ]) - : (isInpatient == true) + // SERVICES_PATIANT2[int.parse(patientType)] == + // "List_MyOutPatient" + // ? Row( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Container( + // padding: EdgeInsets.all(4), + // child: Image.asset( + // patientInfo.appointmentType == + // 'Regular' && + // patientInfo.visitTypeId == 100 + // ? 'assets/images/livecare.png' + // : patientInfo.appointmentType == + // 'Walkin' + // ? 'assets/images/walkin.png' + // : 'assets/images/booked.png', + // height: 25, + // width: 35, + // )), + // ]) + // : + (isInpatient == true) ? Row( mainAxisAlignment: MainAxisAlignment.end, children: [ From 20f7664b4c47d9c3e4c09746b0fe31c06054d474 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 26 Apr 2021 15:09:39 +0300 Subject: [PATCH 2/4] fix issue --- .../viewModel/PatientSearchViewModel.dart | 77 +++++- lib/screens/home/home_screen.dart | 63 ++--- .../patient_search_screen_new.dart | 2 +- ...n_new.dart => patients_screen_search.dart} | 251 +++++------------- .../patients/patient_search/time_bar.dart | 102 +++++++ 5 files changed, 264 insertions(+), 231 deletions(-) rename lib/screens/patients/patient_search/{patients_screen_new.dart => patients_screen_search.dart} (75%) create mode 100644 lib/screens/patients/patient_search/time_bar.dart diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 455e8788..fc37cbed 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -1,7 +1,9 @@ +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'; import 'package:doctor_app_flutter/core/service/patient/out_patient_service.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -11,19 +13,29 @@ class PatientSearchViewModel extends BaseViewModel{ List get patientList => _outPatientService.patientList; - getOutPatient(PatientSearchRequestModel patientSearchRequestModel) async { - setState(ViewState.Busy); + getOutPatient(PatientSearchRequestModel patientSearchRequestModel , {bool isLocalBusy = false}) async { + if(isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + await _outPatientService.getOutPatient( patientSearchRequestModel); if (_outPatientService.hasError) { error = _outPatientService.error; + if(isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } setState(ViewState.Error); } else { setState(ViewState.Idle); } } - getPatientFileInformation(PatientSearchRequestModel patientSearchRequestModel) async { + getPatientFileInformation(PatientSearchRequestModel patientSearchRequestModel, {bool isLocalBusy = false}) async { setState(ViewState.Busy); await _outPatientService.getPatientFileInformation( patientSearchRequestModel); @@ -35,4 +47,63 @@ class PatientSearchViewModel extends BaseViewModel{ } } + + + getPatientBasedOnDate ( + {item, PatientSearchRequestModel patientSearchRequestModel, PatientType selectedPatientType, + bool isSearchWithKeyInfo })async { + String dateTo; + String dateFrom; + if (item == 'Tomorrow') { + dateTo = DateUtils.convertDateToFormat( + DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day + 1), + 'yyyy-MM-dd'); + dateFrom = DateUtils.convertDateToFormat( + DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day + 1), + 'yyyy-MM-dd'); + } else if (item == 'Next Week') { + + + dateTo = DateUtils.convertDateToFormat( + DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day + 6), + 'yyyy-MM-dd'); + + dateFrom = DateUtils.convertDateToFormat( + DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day + 1), + 'yyyy-MM-dd'); + } else { + dateFrom = DateUtils.convertDateToFormat( + DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day), + 'yyyy-MM-dd'); + dateTo= DateUtils.convertDateToFormat( + DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day), + 'yyyy-MM-dd'); + } + PatientSearchRequestModel currentModel = PatientSearchRequestModel(); + currentModel.patientID = patientSearchRequestModel.patientID; + currentModel.firstName = patientSearchRequestModel.firstName; + currentModel.lastName = patientSearchRequestModel.lastName; + currentModel.middleName = patientSearchRequestModel.middleName; + currentModel.from = dateFrom; + currentModel.to = dateTo; + + + if(isSearchWithKeyInfo) { + await getPatientFileInformation(currentModel); + } else { + if(selectedPatientType == PatientType.OutPatient) { + await getOutPatient(currentModel, isLocalBusy: true); + } else { + // TODO handel inPatient case + } + } + + } + } \ No newline at end of file diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 47bc1d0b..f81cb803 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -465,44 +465,6 @@ class _HomeScreenState extends State { child: new ListView( scrollDirection: Axis.horizontal, children: [ - HomePageCard( - color: Colors.black, - margin: EdgeInsets.all(5), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Icon( - DoctorApp.search, - size: 32, - color: Colors.white, - )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - "New:"+TranslationBase.of(context) - .searchPatient, - color: Colors.white, - textAlign: TextAlign.start, - fontSize: 13, - )) - ], - ), - hasBorder: false, - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - PatientSearchScreenNew(), - )); - }, - ), HomePageCard( color: Colors.red[800], margin: EdgeInsets.all(5), @@ -574,15 +536,22 @@ class _HomeScreenState extends State { ), hasBorder: false, onTap: () { - getRequestHeader(false); - Navigator.of(context) - .pushNamed(PATIENTS, arguments: { - "patientSearchForm": - _patientSearchFormValues, - "selectedType": "0", - "arrivalType": "1", - "isInpatient": false - }); + // getRequestHeader(false); + // Navigator.of(context) + // .pushNamed(PATIENTS, arguments: { + // "patientSearchForm": + // _patientSearchFormValues, + // "selectedType": "0", + // "arrivalType": "1", + // "isInpatient": false + // }); + + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PatientSearchScreenNew(), + )); }, ), HomePageCard( diff --git a/lib/screens/patients/patient_search/patient_search_screen_new.dart b/lib/screens/patients/patient_search/patient_search_screen_new.dart index f383cf40..7da76ec2 100644 --- a/lib/screens/patients/patient_search/patient_search_screen_new.dart +++ b/lib/screens/patients/patient_search/patient_search_screen_new.dart @@ -2,7 +2,7 @@ import 'package:doctor_app_flutter/core/enum/patient_type.dart'; import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.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/patients_screen_search.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'; diff --git a/lib/screens/patients/patient_search/patients_screen_new.dart b/lib/screens/patients/patient_search/patients_screen_search.dart similarity index 75% rename from lib/screens/patients/patient_search/patients_screen_new.dart rename to lib/screens/patients/patient_search/patients_screen_search.dart index 5b3b5a77..d78f41d2 100644 --- a/lib/screens/patients/patient_search/patients_screen_new.dart +++ b/lib/screens/patients/patient_search/patients_screen_search.dart @@ -15,7 +15,7 @@ import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart'; import 'package:doctor_app_flutter/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/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.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'; @@ -23,7 +23,6 @@ import 'package:doctor_app_flutter/widgets/patients/clinic_list_dropdwon.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; -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'; @@ -92,27 +91,6 @@ class _PatientsScreenNewState extends State { 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: 1.2, - Channel: 9, - TokenID: "2Fi7HoIHB0eDyekVa6tCJg==", - SessionID: "5G0yXn0Jnq", - IsLoginForDoctorApp: true, - PatientOutSA: false); - searchData(String str) { this.responseModelList = this.responseModelList2; var strExist = str.length > 0 ? true : false; @@ -217,8 +195,7 @@ class _PatientsScreenNewState extends State { }, builder: (_, model, w) => AppScaffold( appBarTitle: "Search Patient", - isShowAppBar: widget.isAppbar, - // isLoading: _isLoading, + isShowAppBar: false, baseViewModel: model, body: model.patientList.isEmpty ? Column( @@ -227,18 +204,20 @@ class _PatientsScreenNewState extends State { SizedBox( height: 10.0, ), - if (widget.selectedPatientType == PatientType.OutPatient) - 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); + if (widget.selectedPatientType == + PatientType.OutPatient && + !widget.isSearchWithKeyInfo) + 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( @@ -247,7 +226,8 @@ class _PatientsScreenNewState extends State { 0.03), // child: _locationBar(context) child: - widget.selectedPatientType == PatientType.OutPatient + (widget.selectedPatientType == PatientType.OutPatient && + widget.isSearchWithKeyInfo) ? _locationBar(context, model) : Container(), ) @@ -298,6 +278,47 @@ class _PatientsScreenNewState extends State { ) : Column( children: [ + + Container( + padding: EdgeInsets.only( + left: 0, right: 5, bottom: 5, top: 5), + decoration: BoxDecoration( + color: Colors.white, + ), + height: 115, + child: Container( + padding: EdgeInsets.only( + left: 10, right: 10), + margin: EdgeInsets.only(top: 60), + child: Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + RichText( + text: TextSpan( + style: TextStyle( + fontSize:20, + color: Colors.black), + children: [ + new TextSpan( + + text: "Search for 1111", + style: TextStyle( + color: Color(0xFF2B353E), + fontWeight: FontWeight.bold, + fontFamily: 'Poppins', + fontSize: 22)), + ], + ), + ), + ], + ), + ], + ), + ), + ), SizedBox(height: 18.5), Container( width: SizeConfig.screenWidth * 0.9, @@ -351,7 +372,9 @@ class _PatientsScreenNewState extends State { .height * 0.03), // child: _locationBar(context) - child: widget.selectedPatientType == PatientType.OutPatient? _locationBar(context, model) + child: widget.selectedPatientType == + PatientType.OutPatient && !widget.isSearchWithKeyInfo + ? _locationBar(context, model) : Container(), ), SizedBox( @@ -522,6 +545,7 @@ class _PatientsScreenNewState extends State { }); } + //TODO Replace it with time bar. Widget _locationBar(BuildContext _context, model) { return Container( height: MediaQuery.of(context).size.height * 0.0619, @@ -567,13 +591,17 @@ class _PatientsScreenNewState extends State { ), )), ), - onTap: () { - //filterBooking(item.toString()); - + onTap: () async { setState(() { _activeLocation = _locations.indexOf(item); }); - filterPatient(item.toString(), model); + GifLoaderDialogUtils.showMyDialog(context); + await model.getPatientBasedOnDate(item: item, + selectedPatientType: widget.selectedPatientType, + patientSearchRequestModel: widget + .patientSearchRequestModel, + isSearchWithKeyInfo: widget.isSearchWithKeyInfo); + GifLoaderDialogUtils.hideDialog(context); }), _isActive ? Container( @@ -592,141 +620,4 @@ class _PatientsScreenNewState extends State { ), ); } - - 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); - } - - 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(); - }); - }); - } } diff --git a/lib/screens/patients/patient_search/time_bar.dart b/lib/screens/patients/patient_search/time_bar.dart new file mode 100644 index 00000000..0d376b02 --- /dev/null +++ b/lib/screens/patients/patient_search/time_bar.dart @@ -0,0 +1,102 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/patient_type.dart'; +import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; +import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class TimeBar extends StatefulWidget { + final PatientSearchViewModel model; + final PatientType selectedPatientType; + final PatientSearchRequestModel patientSearchRequestModel; + final bool isSearchWithKeyInfo; + + + const TimeBar({Key key, this.model, this.selectedPatientType, this.patientSearchRequestModel, this.isSearchWithKeyInfo}) : super(key: key); + @override + _TimeBarState createState() => _TimeBarState(); +} + +class _TimeBarState extends State { + + + @override + Widget build(BuildContext context) { + List _locations = [ + TranslationBase.of(context).today, + TranslationBase.of(context).tomorrow, + TranslationBase.of(context).nextWeek, + ]; + int _activeLocation = 0; + 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: () async{ + setState(() { + _activeLocation = _locations.indexOf(item); + }); + GifLoaderDialogUtils.showMyDialog(context); + await widget.model.getPatientBasedOnDate(item:item,selectedPatientType:widget.selectedPatientType, patientSearchRequestModel:widget.patientSearchRequestModel, isSearchWithKeyInfo:widget.isSearchWithKeyInfo); + GifLoaderDialogUtils.hideDialog(context); + }), + _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(), + ), + ); + } +} From 963e4b637357144594ff81305817c6f5d08e1702 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 26 Apr 2021 15:11:49 +0300 Subject: [PATCH 3/4] fix issue --- .../patients/patient_search/patient_search_screen_new.dart | 2 +- .../{patients_screen_search.dart => patients_screen_new.dart} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/screens/patients/patient_search/{patients_screen_search.dart => patients_screen_new.dart} (100%) diff --git a/lib/screens/patients/patient_search/patient_search_screen_new.dart b/lib/screens/patients/patient_search/patient_search_screen_new.dart index 7da76ec2..f383cf40 100644 --- a/lib/screens/patients/patient_search/patient_search_screen_new.dart +++ b/lib/screens/patients/patient_search/patient_search_screen_new.dart @@ -2,7 +2,7 @@ import 'package:doctor_app_flutter/core/enum/patient_type.dart'; import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search/patients_screen_search.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patients_screen_new.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'; diff --git a/lib/screens/patients/patient_search/patients_screen_search.dart b/lib/screens/patients/patient_search/patients_screen_new.dart similarity index 100% rename from lib/screens/patients/patient_search/patients_screen_search.dart rename to lib/screens/patients/patient_search/patients_screen_new.dart From cc7d64e9d158e6125833a4ffdee19ad41b2bf115 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 26 Apr 2021 15:24:13 +0300 Subject: [PATCH 4/4] fix merge issue --- lib/core/viewModel/PatientSearchViewModel.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 9548f306..74c4c363 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -111,9 +111,11 @@ class PatientSearchViewModel extends BaseViewModel{ } } -class PatientSearchViewModel extends BaseViewModel { + + + PatientInPatientService _inPatientService = - locator(); + locator(); List get _inPatientList => _inPatientService.inPatientList; List filteredInPatientItems = List(); @@ -156,4 +158,5 @@ class PatientSearchViewModel extends BaseViewModel { } } + }