From f57a5bbceff7520402077a9cd26fcb1623cebc94 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 1 Apr 2021 14:20:16 +0300 Subject: [PATCH] working on referral page --- lib/config/config.dart | 4 +- lib/config/localized_values.dart | 2 +- .../referral/refer-patient-screen.dart | 494 +++++++++--------- 3 files changed, 244 insertions(+), 256 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 06768cbc..0f743276 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -4,8 +4,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index c6ee6aa1..b0e473f9 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -333,7 +333,7 @@ const Map> localizedValues = { 'branch': {'en': "Branch", 'ar': 'الفرع'}, 'chooseAppointment': {'en': "Choose Appointment", 'ar': 'اختر موعد'}, 'appointmentNo': {'en': "Appointment # : ", 'ar': '# الموعد:'}, - 'refer': {'en': "REFER", 'ar': 'إحالة'}, + 'refer': {'en': "Refer", 'ar': 'إحالة'}, 'rejected': {'en': "Rejected", 'ar': 'مرفوض'}, 'sameBranch': {'en': "Same Branch", 'ar': 'نفس الفرع'}, 'otherBranch': {'en': "Other Branch", 'ar': 'فرع آخر'}, diff --git a/lib/screens/patients/profile/referral/refer-patient-screen.dart b/lib/screens/patients/profile/referral/refer-patient-screen.dart index 6f053089..43c1382e 100644 --- a/lib/screens/patients/profile/referral/refer-patient-screen.dart +++ b/lib/screens/patients/profile/referral/refer-patient-screen.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; @@ -9,6 +10,8 @@ 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/patient-referral-item-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-header-new-design.dart'; +import 'package:doctor_app_flutter/widgets/shared/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -46,6 +49,8 @@ class _PatientMakeReferralScreenState extends State { Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; patient = routeArgs['patient']; + String patientType = routeArgs['patientType']; + String arrivalType = routeArgs['arrivalType']; referToList = List(); dynamic sameBranch = { @@ -66,46 +71,69 @@ class _PatientMakeReferralScreenState extends State { builder: (_, model, w) => AppScaffold( baseViewModel: model, appBarTitle: TranslationBase.of(context).referPatient, + isShowAppBar: false, body: SingleChildScrollView( child: Container( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - /*if (model.state == ViewState.BusyLocal) - Container( - color: Colors.white, - width: 50, - height: 50, - child: AppLoaderWidget( - containerColor: Colors.white, - )),*/ Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - PatientPageHeaderWidget(patient), - const Divider( - color: Color(0xffCCCCCC), - height: 1, - thickness: 2, - indent: 0, - endIndent: 0, + PatientProfileHeaderNewDesign( + patient, patientType, arrivalType), + Container( + margin: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "${TranslationBase.of(context).refer}", + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 1.6, + fontWeight: FontWeight.w600, + ), + AppText( + "${TranslationBase.of(context).patient}", + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 3, + fontWeight: FontWeight.bold, + ) + ], + ), ), model.patientReferral.length == 0 - ? ReferralForm(model, screenSize) + ? referralForm(model, screenSize) : PatientReferralItemWidget( - "${model.patientReferral[model.patientReferral.length -1].patientID}", - patientName: model.patientReferral[model.patientReferral.length -1].patientName, + "${model.patientReferral[model.patientReferral.length - 1].patientID}", + patientName: model + .patientReferral[ + model.patientReferral.length - 1] + .patientName, referralStatus: - "${model.patientReferral[model.patientReferral.length -1].referralStatus}", + "${model.patientReferral[model.patientReferral.length - 1].referralStatus}", isReferredTo: true, isSameBranch: model - .patientReferral[model.patientReferral.length -1].isReferralDoctorSameBranch, - referralDoctorName: - model.patientReferral[model.patientReferral.length -1].referredByDoctorInfo, + .patientReferral[ + model.patientReferral.length - 1] + .isReferralDoctorSameBranch, + referralDoctorName: model + .patientReferral[ + model.patientReferral.length - 1] + .referredByDoctorInfo, clinicDescription: null, - remark: model.patientReferral[model.patientReferral.length -1].remarksFromSource, - referredOn: model.patientReferral[model.patientReferral.length -1].referredOn, - answerFromTarget: - model.patientReferral[model.patientReferral.length -1].answerFromTarget, + remark: model + .patientReferral[ + model.patientReferral.length - 1] + .remarksFromSource, + referredOn: model + .patientReferral[ + model.patientReferral.length - 1] + .referredOn, + answerFromTarget: model + .patientReferral[ + model.patientReferral.length - 1] + .answerFromTarget, ), ], ), @@ -114,7 +142,8 @@ class _PatientMakeReferralScreenState extends State { margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: AppButton( title: TranslationBase.of(context).refer, - color: HexColor("#B8382B"), + fontWeight: FontWeight.w700, + color: HexColor("#359846"), onPressed: () { if (appointmentDate == null || _selectedBranch == null || @@ -145,262 +174,221 @@ class _PatientMakeReferralScreenState extends State { ); } - Widget ReferralForm(PatientReferralViewModel model, Size screenSize) { + Widget referralForm(PatientReferralViewModel model, Size screenSize) { return Container( - margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16), + margin: EdgeInsets.symmetric(vertical: 0, horizontal: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox( - height: 16, - ), - AppText( - TranslationBase.of(context).referPatient, - fontWeight: FontWeight.bold, - fontSize: 16, - ), - SizedBox( - height: 16, - ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: referToList != null - ? () { - ListSelectDialog dialog = ListSelectDialog( - list: referToList, - attributeName: 'name', - attributeValueId: 'id', - okText: TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - _referTo = selectedValue; - _selectedBranch = null; - _selectedClinic = null; - _selectedDoctor = null; - model.getDoctorBranch().then((value) async { - _selectedBranch = value; - if (_referTo['id'] == 1) { - GifLoaderDialogUtils.showMyDialog(context); - await model - .getClinics(_selectedBranch['facilityId']) - .then((_) => - GifLoaderDialogUtils.hideDialog( - context)); - if (model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(model.error); - } + AppTextFieldCustom( + height: screenSize.height * 0.075, + hintText: TranslationBase.of(context).branch, + dropDownText: _referTo != null ? _referTo['name'] : null, + enabled: false, + isDropDown: true, + onClick: referToList != null + ? () { + ListSelectDialog dialog = ListSelectDialog( + list: referToList, + attributeName: 'name', + attributeValueId: 'id', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _referTo = selectedValue; + _selectedBranch = null; + _selectedClinic = null; + _selectedDoctor = null; + model.getDoctorBranch().then((value) async { + _selectedBranch = value; + if (_referTo['id'] == 1) { + GifLoaderDialogUtils.showMyDialog(context); + await model + .getClinics(_selectedBranch['facilityId']) + .then((_) => + GifLoaderDialogUtils.hideDialog(context)); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error); } - }); + } else { + _selectedBranch = null; + } }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).referTo, - _referTo != null ? _referTo['name'] : null, - true), - enabled: false, - ), - ), + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, ), SizedBox( height: 10, ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.branchesList != null && - model.branchesList.length > 0 && - _referTo != null && - _referTo['id'] == 2 - ? () { - ListSelectDialog dialog = ListSelectDialog( - list: model.branchesList, - attributeName: 'facilityName', - attributeValueId: 'facilityId', - okText: TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() async { - _selectedBranch = selectedValue; - _selectedClinic = null; - _selectedDoctor = null; - GifLoaderDialogUtils.showMyDialog(context); - await model - .getClinics(_selectedBranch['facilityId']) - .then((_) => - GifLoaderDialogUtils.hideDialog(context)); - if (model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(model.error); - } - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).branch, - _selectedBranch != null - ? _selectedBranch['facilityName'] - : null, - true), - enabled: false, - ), - ), + AppTextFieldCustom( + height: screenSize.height * 0.075, + hintText: TranslationBase.of(context).hospital, + dropDownText: _selectedBranch != null + ? _selectedBranch['facilityName'] + : null, + enabled: false, + isDropDown: true, + onClick: model.branchesList != null && + model.branchesList.length > 0 && + _referTo != null && + _referTo['id'] == 2 + ? () { + ListSelectDialog dialog = ListSelectDialog( + list: model.branchesList, + attributeName: 'facilityName', + attributeValueId: 'facilityId', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() async { + _selectedBranch = selectedValue; + _selectedClinic = null; + _selectedDoctor = null; + GifLoaderDialogUtils.showMyDialog(context); + await model + .getClinics(_selectedBranch['facilityId']) + .then((_) => + GifLoaderDialogUtils.hideDialog(context)); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error); + } + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, ), SizedBox( height: 10, ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: _selectedBranch != null && - model.clinicsList != null && - model.clinicsList.length > 0 - ? () { - ListSelectDialog dialog = ListSelectDialog( - list: model.clinicsList, - attributeName: 'ClinicDescription', - attributeValueId: 'ClinicID', - usingSearch: true, - hintSearchText: - TranslationBase.of(context).clinicSearch, - okText: TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() async { - _selectedDoctor = null; - _selectedClinic = selectedValue; - GifLoaderDialogUtils.showMyDialog(context); - await model - .getClinicDoctors( - _selectedClinic['ClinicID'].toString()) - .then((_) => - GifLoaderDialogUtils.hideDialog(context)); - if (model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(model.error); - } - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).clinic, - _selectedClinic != null - ? _selectedClinic['ClinicDescription'] - : null, - true), - enabled: false, - ), - ), + AppTextFieldCustom( + height: screenSize.height * 0.075, + hintText: TranslationBase.of(context).clinic, + dropDownText: _selectedClinic != null + ? _selectedClinic['ClinicDescription'] + : null, + enabled: false, + isDropDown: true, + onClick: _selectedBranch != null && + model.clinicsList != null && + model.clinicsList.length > 0 + ? () { + ListSelectDialog dialog = ListSelectDialog( + list: model.clinicsList, + attributeName: 'ClinicDescription', + attributeValueId: 'ClinicID', + usingSearch: true, + hintSearchText: TranslationBase.of(context).clinicSearch, + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() async { + _selectedDoctor = null; + _selectedClinic = selectedValue; + GifLoaderDialogUtils.showMyDialog(context); + await model + .getClinicDoctors( + _selectedClinic['ClinicID'].toString()) + .then((_) => + GifLoaderDialogUtils.hideDialog(context)); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error); + } + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, ), SizedBox( height: 10, ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: _selectedClinic != null && - model.doctorsList != null && - model.doctorsList.length > 0 - ? () { - ListSelectDialog dialog = ListSelectDialog( - list: model.doctorsList, - attributeName: 'DoctorName', - attributeValueId: 'DoctorID', - usingSearch: true, - hintSearchText: - TranslationBase.of(context).doctorSearch, - okText: TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - _selectedDoctor = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).doctor, - _selectedDoctor != null - ? _selectedDoctor['DoctorName'] - : null, - true), - enabled: false, - ), - ), + AppTextFieldCustom( + height: screenSize.height * 0.075, + hintText: TranslationBase.of(context).doctor, + dropDownText: + _selectedDoctor != null ? _selectedDoctor['DoctorName'] : null, + enabled: false, + isDropDown: true, + onClick: _selectedClinic != null && + model.doctorsList != null && + model.doctorsList.length > 0 + ? () { + ListSelectDialog dialog = ListSelectDialog( + list: model.doctorsList, + attributeName: 'DoctorName', + attributeValueId: 'DoctorID', + usingSearch: true, + hintSearchText: TranslationBase.of(context).doctorSearch, + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedDoctor = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, ), SizedBox( height: 10, ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: () => _selectDate(context, model), - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).chooseAppointment, - appointmentDate != null - ? "${DateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}" - : null, - true, - suffixIcon: Icon( - Icons.calendar_today, - color: Colors.black, - )), - enabled: false, - ), + AppTextFieldCustom( + height: screenSize.height * 0.075, + hintText: TranslationBase.of(context).date, + dropDownText: appointmentDate != null + ? "${DateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}" + : null, + enabled: false, + isDropDown: true, + suffixIcon: Icon( + Icons.calendar_today, + color: Colors.black, ), + onClick: (){ + _selectDate(context, model); + }, ), SizedBox( height: 10, ), - Container( - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).remarks, null, false), - enabled: true, + AppTextFieldCustom( + hintText: + TranslationBase.of(context).dietTypeRemarks, controller: _remarksController, - // inputFormatters: [ - // FilteringTextInputFormatter.allow(RegExp(ONLY_LETTERS)) - // ], - keyboardType: TextInputType.text, + inputType: TextInputType.multiline, minLines: 4, maxLines: 6, - )), + ), ], ), );