diff --git a/lib/config/config.dart b/lib/config/config.dart index b8e34330..407d4ff6 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -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 = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 46af5dea..9b91015f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -243,15 +243,15 @@ const Map> localizedValues = { }, "no-sickleve": {"en": "No sick leave available", "ar": "لا توجد إجازة مرضية"}, "applynow": {"en": "Apply Now", "ar": "التقدم بطلب الآن"}, - "add-sickleave": {"en": "ADD SICK LEAVE", "ar": "أضف إجازة مرضية"}, + "add-sickleave": {"en": "Add Sick Leave", "ar": "أضف إجازة مرضية"}, "add": {"en": "Add", "ar": "أضف"}, "approved": {"en": "Approved", "ar": "موافق"}, "extended": {"en": "Extended", "ar": "تمديد"}, "pending": {"en": "Pending", "ar": "قيد الانتظار"}, "leave-start-date": {"en": "Leave start date", "ar": "تاريخ بدء المغادرة"}, - "days-sick-leave": {"en": "DAYS OF SICK LEAVE", "ar": "أيام الإجازة المرضية"}, + "days-sick-leave": {"en": "Leave Days: ", "ar": "أيام الإجازة "}, "extend": {"en": "Extend", "ar": "تمديد"}, - "extend-sickleave": {"en": "EXTEND SICK LEAVE", "ar": "قم بتمديد الإجازة المرضية"}, + "extend-sickleave": {"en": "Extend Sick Leave", "ar": "قم بتمديد الإجازة المرضية"}, "chiefComplaintLength": { "en": "Chief Complaint length should be greater than 25", "ar": "يجب أن يكون طول شكوى الرئيسية أكبر من 25" diff --git a/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart b/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart index e1fca881..070fd862 100644 --- a/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart +++ b/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart @@ -7,11 +7,12 @@ import 'package:doctor_app_flutter/core/viewModel/leave_rechdule_response.dart'; import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/extend_sick_leave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; +import 'package:doctor_app_flutter/models/sickleave/sick_leave_statisitics_model.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; class SickLeaveService extends BaseService { - Map get sickLeavestatisitics => _statistics; - Map _statistics = {}; + SickLeaveStatisticsModel get sickLeavestatisitics => _statistics; + SickLeaveStatisticsModel _statistics = SickLeaveStatisticsModel(); List get getOffTimeList => offTime; List offTime = []; List get getReasons => reasonse; @@ -27,12 +28,9 @@ class SickLeaveService extends BaseService { dynamic get postReschedule => _postReschedule; dynamic _postReschedule; - dynamic get sickLeaveResponse => _sickLeaveResponse; - dynamic _sickLeaveResponse; List getAllSickLeavePatient = List(); List getAllSickLeaveDoctor = List(); - //getAllSickLeavePatient.addAll(getAllSickLeaveDoctor); SickLeavePatientRequestModel _sickLeavePatientRequestModel = SickLeavePatientRequestModel(); GetSickLeaveDoctorRequestModel _sickLeaveDoctorRequestModel = GetSickLeaveDoctorRequestModel(); @@ -43,8 +41,8 @@ class SickLeaveService extends BaseService { GET_SICKLEAVE_STATISTIC, onSuccess: (dynamic response, int statusCode) { print(response); - _statistics = {}; - _statistics = response['SickLeaveStatistics']; + + _statistics = SickLeaveStatisticsModel.fromJson(response['SickLeaveStatistics']); }, onFailure: (String error, int statusCode) { hasError = true; @@ -55,20 +53,14 @@ class SickLeaveService extends BaseService { } Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { - // addSickLeaveRequest.appointmentNo = '2016054661'; - // addSickLeaveRequest.patientMRN = '3120746'; hasError = false; - _sickLeaveResponse.clear(); await baseAppClient.post( ADD_SICK_LEAVE, onSuccess: (dynamic response, int statusCode) { - _sickLeaveResponse = response; - return Future.value(response); }, onFailure: (String error, int statusCode) { - DrAppToastMsg.showErrorToast(error); - // hasError = true; - // super.error = error; + hasError = true; + super.error = error; }, body: addSickLeaveRequest.toJson(), ); @@ -84,7 +76,6 @@ class SickLeaveService extends BaseService { await baseAppClient.post( EXTEND_SICK_LEAVE, onSuccess: (dynamic response, int statusCode) { - _sickLeaveResponse = response; return Future.value(response); }, onFailure: (String error, int statusCode) { diff --git a/lib/core/viewModel/sick_leave_view_model.dart b/lib/core/viewModel/sick_leave_view_model.dart index e80318f6..7a7f4575 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -1,42 +1,56 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/service/patient/patient_service.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/sick_leave/sickleave_service.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; +import 'package:doctor_app_flutter/models/sickleave/sick_leave_statisitics_model.dart'; import '../../locator.dart'; import 'base_view_model.dart'; class SickLeaveViewModel extends BaseViewModel { SickLeaveService _sickLeaveService = locator(); - get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics; + PatientService _patientService = locator(); + + SickLeaveStatisticsModel get sickLeaveStatistics => + _sickLeaveService.sickLeavestatisitics; + get getAllSIckLeave => _sickLeaveService.getAllSickLeave; - //get getAllSIckLeavePatient => _sickLeaveService.getAllSickLeavePatient; - get sickleaveResponse => _sickLeaveService.sickLeaveResponse; List get allOffTime => _sickLeaveService.getOffTimeList; + List get allReasons => _sickLeaveService.getReasons; + List get coveringDoctors => _sickLeaveService.coveringDoctorsList; + List get sickLeaveDoctor => _sickLeaveService.getAllSickLeaveDoctor; + get getReschduleLeave => _sickLeaveService.getAllRescheduleLeave; + get postSechedule => _sickLeaveService.postReschedule; - get getAllSIckLeavePatient => - [..._sickLeaveService.getAllSickLeavePatient, ..._sickLeaveService.getAllSickLeaveDoctor]; + + get getAllSIckLeavePatient => [ + ..._sickLeaveService.getAllSickLeavePatient, + ..._sickLeaveService.getAllSickLeaveDoctor + ]; + Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _sickLeaveService.addSickLeave(addSickLeaveRequest); if (_sickLeaveService.hasError) { error = _sickLeaveService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } Future extendSickLeave(GetAllSickLeaveResponse extendSickLeaveRequest) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _sickLeaveService.extendSickLeave(extendSickLeaveRequest); if (_sickLeaveService.hasError) { error = _sickLeaveService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } @@ -61,12 +75,36 @@ class SickLeaveViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getSickLeavePatient(patientMRN) async { - setState(ViewState.Busy); + Future getSickLeavePatient(patientMRN, {bool isLocalBusy = false}) async { + if (isLocalBusy) + setState(ViewState.BusyLocal); + else + setState(ViewState.Busy); await _sickLeaveService.getSickLeavePatient(patientMRN); if (_sickLeaveService.hasError) { error = _sickLeaveService.error; setState(ViewState.ErrorLocal); + + } else + setState(ViewState.Idle); + } + + Future getSickLeaveForPatient(PatiantInformtion patient, {bool isLocalBusy = false}) async { + if (isLocalBusy) + setState(ViewState.BusyLocal); + else + setState(ViewState.Busy); + var patientMRN = patient.patientMRN ?? patient.patientId; + var services = [_sickLeaveService.getSickLeavePatient(patientMRN),_sickLeaveService.getSickLeaveDoctor(patientMRN) ]; + + final results = await Future.wait(services); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + // if (isLocalBusy) + setState(ViewState.ErrorLocal); + // else + // setState(ViewState.Error); + } else setState(ViewState.Idle); } diff --git a/lib/models/sickleave/sick_leave_statisitics_model.dart b/lib/models/sickleave/sick_leave_statisitics_model.dart new file mode 100644 index 00000000..f679807c --- /dev/null +++ b/lib/models/sickleave/sick_leave_statisitics_model.dart @@ -0,0 +1,24 @@ +class SickLeaveStatisticsModel { + String recommendedSickLeaveDays; + int totalLeavesByAllClinics; + int totalLeavesByDoctor; + + SickLeaveStatisticsModel( + {this.recommendedSickLeaveDays, + this.totalLeavesByAllClinics, + this.totalLeavesByDoctor}); + + SickLeaveStatisticsModel.fromJson(Map json) { + recommendedSickLeaveDays = json['recommendedSickLeaveDays']; + totalLeavesByAllClinics = json['totalLeavesByAllClinics']; + totalLeavesByDoctor = json['totalLeavesByDoctor']; + } + + Map toJson() { + final Map data = new Map(); + data['recommendedSickLeaveDays'] = this.recommendedSickLeaveDays; + data['totalLeavesByAllClinics'] = this.totalLeavesByAllClinics; + data['totalLeavesByDoctor'] = this.totalLeavesByDoctor; + return data; + } +} diff --git a/lib/routes.dart b/lib/routes.dart index 712db98c..47fccec3 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/root_page.dart'; import 'package:doctor_app_flutter/screens/live_care/end_call_screen.dart'; import 'package:doctor_app_flutter/screens/medical-file/health_summary_page.dart'; +import 'package:doctor_app_flutter/screens/patient-sick-leave/patient_sick_leave_screen.dart'; import 'package:doctor_app_flutter/screens/patients/ECGPage.dart'; import 'package:doctor_app_flutter/screens/patients/insurance_approval_screen_patient.dart'; import 'package:doctor_app_flutter/screens/patients/profile/lab_result/all_lab_special_result_page.dart'; @@ -15,8 +16,6 @@ import 'package:doctor_app_flutter/screens/patients/profile/referral/refer-patie import 'package:doctor_app_flutter/screens/patients/profile/soap_update/update_soap_index.dart'; import 'package:doctor_app_flutter/screens/prescription/prescriptions_page.dart'; import 'package:doctor_app_flutter/screens/procedures/procedure_screen.dart'; -import 'package:doctor_app_flutter/screens/sick-leave/add-sickleave.dart'; -import 'package:doctor_app_flutter/screens/sick-leave/show-sickleave.dart'; import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart'; import './screens/auth/login_screen.dart'; @@ -65,7 +64,6 @@ const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; const String ORDER_PRESCRIPTION_NEW = 'prescription/prescription_new'; const String ORDER_PROCEDURE = 'procedure/procedure'; const String ADD_SICKLEAVE = 'add-sickleave'; -const String SHOW_SICKLEAVE = 'show-sickleave'; const String RADIOLOGY_PATIENT = 'radiology-patient'; const String ALL_SPECIAL_LAB_RESULT = 'all-special_lab'; @@ -103,8 +101,7 @@ var routes = { isUpdate: true, ), IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), - ADD_SICKLEAVE: (_) => AddSickLeavScreen(), - SHOW_SICKLEAVE: (_) => ShowSickLeaveScreen(), + ADD_SICKLEAVE: (_) => PatientSickLeaveScreen(), ORDER_PRESCRIPTION_NEW: (_) => PrescriptionsPage(), ORDER_PROCEDURE: (_) => ProcedureScreen(), MY_REFERRAL_DETAIL: (_) => MyReferralDetailScreen(), diff --git a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart new file mode 100644 index 00000000..3141e475 --- /dev/null +++ b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart @@ -0,0 +1,341 @@ +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/viewstate.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; +import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.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/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.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/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:intl/intl.dart'; + +Helpers helpers = Helpers(); + +class AddPatientSickLeaveScreen extends StatefulWidget { + final appointmentNo; + final patientMRN; + final PatiantInformtion patient; + final SickLeaveViewModel previousModel; + + AddPatientSickLeaveScreen( + {this.appointmentNo, + this.patientMRN, + this.patient, this.previousModel}); + + @override + _AddPatientSickLeaveScreenState createState() => + _AddPatientSickLeaveScreenState(); +} + +class _AddPatientSickLeaveScreenState extends State { + DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); + TextEditingController _toDateController = new TextEditingController(); + TextEditingController _numberOfDayController = new TextEditingController(); + TextEditingController _clinicController = new TextEditingController(); + TextEditingController _doctorController = new TextEditingController(); + TextEditingController _remarkController = new TextEditingController(); + DateTime currentDate; + + AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); + bool isFormSubmitted = false; + void _presentDatePicker() { + showDatePicker( + context: context, + initialDate: currentDate??DateTime.now(), + firstDate: DateTime(DateTime.now().year-1), + lastDate: DateTime(DateTime.now().year+1), + ).then((pickedDate) { + if (pickedDate == null) { + return; + } + setState(() { + final df = new DateFormat('yyyy-MM-dd'); + addSickLeave.startDate = df.format(pickedDate); + currentDate = pickedDate; + _toDateController.text = AppDateUtils.getDayMonthYearDateFormatted(pickedDate,isMonthShort: true ); + }); + }); + } + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) async { + await model.getDoctorProfile(); + _clinicController.text = model.doctorProfile.clinicDescription; + _doctorController.text = model.doctorProfile.doctorName; + await model.preSickLeaveStatistics( + widget.appointmentNo, widget.patientMRN); + }, + builder: (_, model, w) => GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: AppScaffold( + baseViewModel: model, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addSickLeave, + ), + isShowAppBar: true, + body: Center( + child: Container( + margin: EdgeInsets.only(top: 10), + child: FractionallySizedBox( + widthFactor: 0.9, + child: ListView( + children: [ + SizedBox( + height: 30, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: TranslationBase.of(context).sickLeave + + ' ' + + TranslationBase.of(context).days, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + inputType:TextInputType.number, + controller: _numberOfDayController, + onChanged: (value) { + if(value.isNotEmpty) + setState(() { + addSickLeave.noOfDays = value; + }); + + }, + validationError: isFormSubmitted && + (addSickLeave.noOfDays == null) + ? TranslationBase.of(context) + .pleaseEnterNoOfDays + : null, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + onClick: () { + Helpers.hideKeyboard(context); + _presentDatePicker(); + }, + hintText: TranslationBase.of(context) + .sickLeaveDate, + enabled: false, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon(Icons.calendar_today)), + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _toDateController, + onChanged: (value) { + setState(() { + addSickLeave.startDate = value; + }); + + }, + validationError: isFormSubmitted && + (addSickLeave.startDate == null) + ? TranslationBase.of(context) + .pleaseEnterDate + : null, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: TranslationBase.of(context).clinic, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _clinicController, + onChanged: (value) {}, + ), + SizedBox( + height: 10, + ), + model.sickLeaveStatistics.recommendedSickLeaveDays!= + null + ? Row( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + SizedBox( + width: 10, + ), + Icon( + DoctorApp.warning, + size: 20, + color: IN_PROGRESS_COLOR, + ), + SizedBox( + width: 10, + ), + Expanded( + child: AppText( + model.sickLeaveStatistics.recommendedSickLeaveDays, + textAlign: TextAlign.start, + fontSize: 12, + color: IN_PROGRESS_COLOR, + ), + ), + ], + ) + : SizedBox( + height: 10, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: TranslationBase.of(context).doctor, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _doctorController, + onChanged: (value) {}, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: TranslationBase.of(context).remarks, + maxLines: 30, + minLines: 5, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + controller: _remarkController, + onChanged: (value) { + setState(() { + addSickLeave.remarks = value; + }); + }, + ), + ], + ), + ), + ), + ), + bottomSheet: model.state == ViewState.Busy || + model.state == ViewState.Busy + ? Container( + height: 0, + ) + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all( + color: HexColor('#707070'), width: 0), + ), + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 12 : 10), + width: double.infinity, + child: Column( + children: [ + SizedBox( + height: 10, + ), + FractionallySizedBox( + widthFactor: 0.9, + child: AppButton( + title: TranslationBase.of(context) + .addSickLeaverequest, + color: Colors.green, + onPressed: () async { + submitForm(model); + }), + ), + SizedBox( + height: 5, + ), + ], + ), + )), + )); + } + + submitForm(SickLeaveViewModel model) async { + { + try { + setState(() { + isFormSubmitted = true; + }); + if (addSickLeave.noOfDays == null || + addSickLeave.startDate == null ) { + return; + } else { + GifLoaderDialogUtils.showMyDialog(context); + addSickLeave.patientMRN = widget.patient.patientMRN.toString(); + addSickLeave.appointmentNo = + widget.patient.appointmentNo.toString(); + await model.addSickLeave(addSickLeave); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } else { + await widget.previousModel + .getSickLeaveForPatient(widget.patient, isLocalBusy: true); + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context).replySuccessfully); + Navigator.of(context).pop(); + } + + GifLoaderDialogUtils.hideDialog(context); + } + } catch (err) { + print(err); + } + + } + } + +} diff --git a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart new file mode 100644 index 00000000..fa6228f1 --- /dev/null +++ b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart @@ -0,0 +1,298 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_patient_model.dart'; +import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; +import 'package:doctor_app_flutter/locator.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/patient-sick-leave/add_patient_sick_leave_screen.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/profile/add-order/addNewOrder.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.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/card_with_bg_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; +import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class PatientSickLeaveScreen extends StatelessWidget { + PatiantInformtion patient; + + @override + Widget build(BuildContext context) { + ProjectViewModel projectsProvider = Provider.of(context); + + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + patient = routeArgs['patient']; + bool isInpatient = routeArgs['isInpatient']; + return BaseView( + onModelReady: (model) async { + await model.getSickLeaveForPatient(patient); + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + backgroundColor: Colors.grey[100], + appBar: PatientProfileAppBar( + patient, + isInpatient: isInpatient, + ), + body: Column(children: [ + patient.patientStatusType == 43 + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: SizeConfig.isHeightVeryShort + ? 30 + : SizeConfig.isHeightShort + ? 35 + : 10, + ), + if (!projectsProvider.isArabic) + AppText( + TranslationBase.of(context).patient, + fontSize: + SizeConfig.getTextMultiplierBasedOnWidth() * + (SizeConfig.isWidthLarge ? 3 : 4), + fontWeight: FontWeight.w700, + letterSpacing: -0.72, + color: Color(0xFF2E303A), + ), + AppText( + TranslationBase.of(context).sickLeave, + fontSize: + SizeConfig.getTextMultiplierBasedOnWidth() * + (SizeConfig.isWidthLarge ? 6 : 6), + fontWeight: FontWeight.bold, + letterSpacing: -1.44, + color: Color(0xFF2E303A), + ), + ], + ), + ), + AddNewOrder( + label: TranslationBase.of(context).noSickLeaveApplied, + onTap: () async { + await locator().logEvent( + eventCategory: "Add Sick Leave Screen" + "Leave Screen", + eventAction: "apply For Sick Leave", + ); + openSickLeave(context, model); + }), + ], + ) + : SizedBox(), + model.getAllSIckLeavePatient.length > 0 + ? Expanded( + child: FractionallySizedBox( + widthFactor: 0.95, + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.getAllSIckLeavePatient.length, + itemBuilder: (BuildContext ctxt, int index) { + SickLeavePatientModel item = + model.getAllSIckLeavePatient[index]; + return Column( + children: [ + CardWithBgWidget( + padding: 0, + marginLeft: 10, + marginSymmetric: 10, + hasBorder: false, + bgColor: Colors.black, + widget: Container( + color: Colors.white, + padding: EdgeInsets.all(20), + child: InkWell( + child: Column( + children: [ + if(item.doctorName != null) + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Expanded( + // width: MediaQuery.of(context).size.width*0.51, + child: AppText( + Helpers.capitalize( + item.doctorName ?? ""), + fontSize: 18, + color: Color(0xff2e303a), + fontWeight: FontWeight.w700, + fontFamily: 'Poppins', + textOverflow: + TextOverflow.ellipsis, + ), + ), + ]), + SizedBox( + height: 10, + ), + Row( + children: [ + ClipRRect( + borderRadius: + BorderRadius.circular(50.0), + child: CachedNetworkImage( + imageUrl: item + .doctorImageURL ?? + "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", + height: 30, + width: 30, + errorWidget: + (context, url, error) => + AppText( + 'No Image', + fontSize: 10, + ), + ), + ), + SizedBox( + width: 10, + ), + Column( + children: [ + CustomRow( + label: TranslationBase.of( + context) + .daysSickleave + + ": ", + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + value: (item.sickLeaveDays + .toString() != + null && + item.sickLeaveDays + .toString() != + "null") + ? item.sickLeaveDays + .toString() + : item.noOfDays + .toString(), + ), + CustomRow( + label: TranslationBase.of( + context) + .startDate + + ' ' ?? + "", + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + value: AppDateUtils + .getDayMonthYearDateFormatted( + item.startDate.contains( + "/Date(") + ? AppDateUtils + .convertStringToDate( + item + .startDate) + : DateTime.parse( + item.startDate), + ), + ), + CustomRow( + label: TranslationBase.of( + context) + .endDate + + ' ' ?? + "", + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + value: AppDateUtils + .getDayMonthYearDateFormatted( + item.startDate.contains( + "/Date(") + ? AppDateUtils + .convertStringToDate( + item.endDate ?? + "") + .add( + Duration( + days: item + .noOfDays ?? + item.sickLeaveDays), + ) + : DateTime.parse( + item.startDate ?? + "") + .add( + Duration( + days: + item.noOfDays ?? + ""), + ), + ), + ), + ], + crossAxisAlignment: + CrossAxisAlignment.start, + ), + ], + ), + ], + ), + ), + ), + ), + ], + ); + }), + ), + ) + : patient.patientStatusType != 43 + ? ErrorMessage( + error: TranslationBase.of(context).noSickLeave, + ) + : SizedBox(), + SizedBox( + height: 100, + ) + ]), + ), + ); + } + + openSickLeave(BuildContext context, model) { + Navigator.push( + context, + SlideUpPageRoute( + fullscreenDialog: true, + widget: AddPatientSickLeaveScreen( + appointmentNo: patient.appointmentNo, + patientMRN: patient.patientMRN, + patient: patient, + previousModel: model, + ), + ), + ); + } +} diff --git a/lib/screens/patients/profile/note/progress_note_screen.dart b/lib/screens/patients/profile/note/progress_note_screen.dart index c43b1ab8..054817c2 100644 --- a/lib/screens/patients/profile/note/progress_note_screen.dart +++ b/lib/screens/patients/profile/note/progress_note_screen.dart @@ -496,7 +496,7 @@ class _ProgressNoteState extends State { isArabic: projectViewModel .isArabic, - isMonthshort: true) + isMonthShort: true) : AppDateUtils .getDayMonthYearDateFormatted( DateTime.now(), diff --git a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart index db31fb95..72330be3 100644 --- a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart +++ b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart @@ -46,7 +46,7 @@ class _AddMedicationState extends State { GetMedicationResponseModel _selectedMedication; GlobalKey key = - new GlobalKey>(); + new GlobalKey>(); bool isFormSubmitted = false; @override @@ -54,424 +54,395 @@ class _AddMedicationState extends State { ProjectViewModel projectViewModel = Provider.of(context); return FractionallySizedBox( child: BaseView( - onModelReady: (model) async { - model.onAddMedicationStart(); - }, - builder: (_, model, w) => - AppScaffold( - baseViewModel: model, - isShowAppBar: true, - appBar: BottomSheetTitle( - title: TranslationBase - .of(context) - .addMedication, - ), - body: Center( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( + onModelReady: (model) async { + model.onAddMedicationStart(); + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addMedication, + ), + body: Center( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( height: 10, ), Expanded( child: FractionallySizedBox( - widthFactor: 0.9, - child: SingleChildScrollView( - child: Column( + widthFactor: 0.9, + child: SingleChildScrollView( + child: Column( children: [ - SizedBox( - height: SizeConfig.heightMultiplier * ( - SizeConfig.isHeightVeryShort ?2:SizeConfig.isHeightShort? - 2:2), - ), - Container( - // height: screenSize.height * 0.070, - child: InkWell( - onTap: model.allMedicationList != null - ? () { - setState(() { - _selectedMedication = null; - }); - } - : null, - child: _selectedMedication == null - ? CustomAutoCompleteTextField( - isShowError: isFormSubmitted && - _selectedMedication == null, - child: AutoCompleteTextField< - GetMedicationResponseModel>( - decoration: TextFieldsUtils - .textFieldSelectorDecoration( - TranslationBase - .of( - context) - .searchMedicineNameHere, - null, - true, - suffixIcon: - Icons.search), - itemSubmitted: (item) => - setState(() => - _selectedMedication = - item), - key: key, - suggestions: - model.allMedicationList, - itemBuilder: (context, - suggestion) => - new Padding( - child: AppText(suggestion - .description + - '/' + - suggestion - .genericName), - padding: - EdgeInsets.all( - 8.0)), - itemSorter: (a, b) => 1, - itemFilter: (suggestion, - input) => - suggestion.genericName.toLowerCase() - .startsWith(input.toLowerCase()) || - suggestion.description - .toLowerCase() - .startsWith(input - .toLowerCase()) || - suggestion.keywords - .toLowerCase() - .startsWith(input - .toLowerCase()), - ), - ) - : AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: _selectedMedication != - null - ? _selectedMedication - .description + - (' (${_selectedMedication.genericName} )') - : TranslationBase - .of( - context) - .searchMedicineNameHere, - minLines: 1, - maxLines: 1, - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon( - Icons.search, - color: Colors.grey.shade600, - )), - enabled: false, - ), - ), - ), - - if(_selectedMedication != null) - Column( - children: [ - SizedBox( - height: 3, - ), - Container( - width: MediaQuery - .of(context) - .size - .width * 0.7, - child: AppText( - _selectedMedication.description + - (' (${_selectedMedication.genericName} )'), - color: Color(0xFF575757), - fontSize: 10, - fontWeight: FontWeight.w700, - letterSpacing: -0.4, - ), - ), - ], - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - enabled: false, - onClick: model.medicationDoseTimeList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model - .medicationDoseTimeList, - okText: - TranslationBase - .of(context) - .ok, - selectedValue: - _selectedMedicationDose, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationDose = - selectedValue; - - doseController - .text = projectViewModel - .isArabic - ? _selectedMedicationDose - .nameAr - : _selectedMedicationDose - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase - .of(context) - .doseTime, - maxLines: 1, - minLines: 1, - isTextFieldHasSuffix: true, - controller: doseController, - validationError: isFormSubmitted && - _selectedMedicationDose == null - ? TranslationBase - .of(context) - .emptyMessage - : null, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - enabled: false, - isTextFieldHasSuffix: true, - onClick: model.medicationStrengthList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model - .medicationStrengthList, - okText: - TranslationBase - .of(context) - .ok, - selectedValue: - _selectedMedicationStrength, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationStrength = - selectedValue; + SizedBox( + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort + ? 2 + : SizeConfig.isHeightShort + ? 2 + : 2), + ), + Container( + // height: screenSize.height * 0.070, + child: InkWell( + onTap: model.allMedicationList != null + ? () { + setState(() { + _selectedMedication = null; + }); + } + : null, + child: _selectedMedication == null + ? CustomAutoCompleteTextField( + isShowError: isFormSubmitted && + _selectedMedication == null, + child: AutoCompleteTextField< + GetMedicationResponseModel>( + decoration: TextFieldsUtils + .textFieldSelectorDecoration( + TranslationBase.of( + context) + .searchMedicineNameHere, + null, + true, + suffixIcon: + Icons.search), + itemSubmitted: (item) => + setState(() => + _selectedMedication = + item), + key: key, + suggestions: + model.allMedicationList, + itemBuilder: (context, + suggestion) => + new Padding( + child: AppText(suggestion + .description + + '/' + + suggestion + .genericName), + padding: EdgeInsets.all( + 8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, + input) => + suggestion.genericName.toLowerCase().startsWith( + input.toLowerCase()) || + suggestion.description + .toLowerCase() + .startsWith(input + .toLowerCase()) || + suggestion.keywords + .toLowerCase() + .startsWith(input + .toLowerCase()), + ), + ) + : AppTextFieldCustom( + height: + Helpers.getTextFieldHeight(), + hintText: _selectedMedication != + null + ? _selectedMedication + .description + + (' (${_selectedMedication.genericName} )') + : TranslationBase.of(context) + .searchMedicineNameHere, + minLines: 1, + maxLines: 1, + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon( + Icons.search, + color: Colors.grey.shade600, + )), + enabled: false, + ), + ), + ), + if (_selectedMedication != null) + Column( + children: [ + SizedBox( + height: 3, + ), + Container( + width: MediaQuery.of(context) + .size + .width * + 0.7, + child: AppText( + _selectedMedication.description + + (' (${_selectedMedication.genericName} )'), + color: Color(0xFF575757), + fontSize: 10, + fontWeight: FontWeight.w700, + letterSpacing: -0.4, + ), + ), + ], + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + enabled: false, + onClick: model.medicationDoseTimeList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: + model.medicationDoseTimeList, + okText: + TranslationBase.of(context) + .ok, + selectedValue: + _selectedMedicationDose, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationDose = + selectedValue; - strengthController - .text = projectViewModel - .isArabic - ? _selectedMedicationStrength - .nameAr - : _selectedMedicationStrength - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase - .of(context) - .strength, - maxLines: 1, - minLines: 1, - controller: strengthController, - validationError: isFormSubmitted && - _selectedMedicationStrength == - null - ? TranslationBase - .of(context) - .emptyMessage - : null, - ), - SizedBox( - height: 5, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - enabled: false, - isTextFieldHasSuffix: true, - onClick: model.medicationRouteList != null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model.medicationRouteList, - selectedValue: - _selectedMedicationRoute, - okText: - TranslationBase - .of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationRoute = - selectedValue; + doseController + .text = projectViewModel + .isArabic + ? _selectedMedicationDose + .nameAr + : _selectedMedicationDose + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).doseTime, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + controller: doseController, + validationError: isFormSubmitted && + _selectedMedicationDose == null + ? TranslationBase.of(context) + .emptyMessage + : null, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + enabled: false, + isTextFieldHasSuffix: true, + onClick: model.medicationStrengthList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: + model.medicationStrengthList, + okText: + TranslationBase.of(context) + .ok, + selectedValue: + _selectedMedicationStrength, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationStrength = + selectedValue; - routeController - .text = projectViewModel - .isArabic - ? _selectedMedicationRoute - .nameAr - : _selectedMedicationRoute - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase - .of(context) - .route, - maxLines: 1, - minLines: 1, - controller: routeController, - validationError: isFormSubmitted && - _selectedMedicationRoute == null - ? TranslationBase - .of(context) - .emptyMessage - : null, - ), - SizedBox( - height: 5, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - onClick: model.medicationFrequencyList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model - .medicationFrequencyList, - okText: - TranslationBase - .of(context) - .ok, - selectedValue: - _selectedMedicationFrequency, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationFrequency = - selectedValue; + strengthController + .text = projectViewModel + .isArabic + ? _selectedMedicationStrength + .nameAr + : _selectedMedicationStrength + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).strength, + maxLines: 1, + minLines: 1, + controller: strengthController, + validationError: isFormSubmitted && + _selectedMedicationStrength == null + ? TranslationBase.of(context) + .emptyMessage + : null, + ), + SizedBox( + height: 5, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + enabled: false, + isTextFieldHasSuffix: true, + onClick: model.medicationRouteList != null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: model.medicationRouteList, + selectedValue: + _selectedMedicationRoute, + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationRoute = + selectedValue; - frequencyController - .text = projectViewModel - .isArabic - ? _selectedMedicationFrequency - .nameAr - : _selectedMedicationFrequency - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase - .of(context) - .frequency, - enabled: false, - maxLines: 1, - minLines: 1, - isTextFieldHasSuffix: true, - controller: frequencyController, - validationError: isFormSubmitted && - _selectedMedicationFrequency == - null - ? TranslationBase - .of(context) - .emptyMessage - : null, - ), - SizedBox( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 20 : SizeConfig - .isHeightShort ? 15 : 10), - ), + routeController + .text = projectViewModel + .isArabic + ? _selectedMedicationRoute + .nameAr + : _selectedMedicationRoute + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: TranslationBase.of(context).route, + maxLines: 1, + minLines: 1, + controller: routeController, + validationError: isFormSubmitted && + _selectedMedicationRoute == null + ? TranslationBase.of(context) + .emptyMessage + : null, + ), + SizedBox( + height: 5, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + onClick: model.medicationFrequencyList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: + model.medicationFrequencyList, + okText: + TranslationBase.of(context) + .ok, + selectedValue: + _selectedMedicationFrequency, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationFrequency = + selectedValue; - ], + frequencyController + .text = projectViewModel + .isArabic + ? _selectedMedicationFrequency + .nameAr + : _selectedMedicationFrequency + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).frequency, + enabled: false, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + controller: frequencyController, + validationError: isFormSubmitted && + _selectedMedicationFrequency == null + ? TranslationBase.of(context) + .emptyMessage + : null, + ), + SizedBox( + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort + ? 20 + : SizeConfig.isHeightShort + ? 15 + : 10), + ), + ], + ), + )), ), - )), + ]), ), - ]), - ), - ), - bottomSheet: model.state != ViewState.Idle - ? Container( - height: 0, - ) - : BottomSheetDialogButton( - label: - TranslationBase.of(context).addMedication, - onTap: () { - setState(() { - isFormSubmitted = true; - }); - if (_selectedMedication != null && - _selectedMedicationDose != null && - _selectedMedicationStrength != null && - _selectedMedicationRoute != null && - _selectedMedicationFrequency != null) { - widget.medicationController.text = widget - .medicationController.text + - '${_selectedMedication.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; - Navigator.of(context).pop(); - } - }, - ) - ) - , - ) - , + ), + bottomSheet: model.state != ViewState.Idle + ? Container( + height: 0, + ) + : BottomSheetDialogButton( + label: TranslationBase.of(context).addMedication, + onTap: () { + setState(() { + isFormSubmitted = true; + }); + if (_selectedMedication != null && + _selectedMedicationDose != null && + _selectedMedicationStrength != null && + _selectedMedicationRoute != null && + _selectedMedicationFrequency != null) { + widget.medicationController.text = widget + .medicationController.text + + '${_selectedMedication.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; + Navigator.of(context).pop(); + } + }, + )), + ), ); } } diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart deleted file mode 100644 index 3cdeb180..00000000 --- a/lib/screens/sick-leave/add-sickleave.dart +++ /dev/null @@ -1,329 +0,0 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_patient_model.dart'; -import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; - -import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; -import 'package:doctor_app_flutter/locator.dart'; -import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/sick-leave/sick_leave.dart'; -import 'package:doctor_app_flutter/util/date-utils.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.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/rounded_container_widget.dart'; -import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; - -class AddSickLeavScreen extends StatelessWidget { - PatiantInformtion patient; - - @override - Widget build(BuildContext context) { - ProjectViewModel projectsProvider = Provider.of(context); - - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - patient = routeArgs['patient']; - bool isInpatient = routeArgs['isInpatient']; - return BaseView( - onModelReady: (model) async { - await model - .getSickLeavePatient(patient.patientMRN ?? patient.patientId); - await model - .getSickLeaveDoctor(patient.patientMRN ?? patient.patientId); - }, - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: true, - backgroundColor: Colors.grey[100], - appBar: PatientProfileAppBar( - patient, - isInpatient: isInpatient, - ), - body: SingleChildScrollView( - child: Column(children: [ - patient.patientStatusType == 43 - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (!projectsProvider.isArabic) - AppText( - TranslationBase.of(context).patient, - fontWeight: FontWeight.bold, - ), - AppText( - TranslationBase.of(context).sickLeave, - fontSize: 24, - fontWeight: FontWeight.bold, - ), - ], - )), - InkWell( - onTap: () async { - await locator().logEvent( - eventCategory: "Add Sick Leave Screen" - "Leave Screen", - eventAction: "apply For Sick Leave", - ); - openSickLeave( - context, - false, - ); - }, - child: Container( - width: SizeConfig.screenWidth, - margin: EdgeInsets.only( - left: 20, right: 20, top: 10, bottom: 10), - padding: EdgeInsets.all(20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: HexColor('#EAEAEA')), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - child: Container( - decoration: BoxDecoration( - color: Colors.grey, - borderRadius: - BorderRadius.circular(10)), - padding: EdgeInsets.all(3), - child: IconButton( - icon: Icon( - Icons.add, - size: 35, - color: Colors.white, - ), - // onPressed: () { - // openSickLeave( - // context, - // false, - // ); - // }, - ), - )), - Padding( - child: AppText( - TranslationBase.of(context) - .noSickLeaveApplied, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: 16, - textAlign: TextAlign.center, - color: HexColor('#7E7E7E')), - padding: EdgeInsets.all(10), - ), - ], - )), - ), - ], - ) - : SizedBox(), - model.getAllSIckLeavePatient.length > 0 - ? Column( - children: model.getAllSIckLeavePatient - .map((SickLeavePatientModel item) { - return RoundedContainer( - margin: EdgeInsets.all(10), - child: Column( - children: [ - Container( - // decoration: BoxDecoration( - // border: Border( - // left: BorderSide( - // // color: item.status == 1 - // // ? Colors.yellow[800] - // // : item.status == 2 - // // ? Colors.green - // // : Colors.black, - // color: Colors.red, - // width: 5.0, - // ))), - padding: EdgeInsets.all(10), - child: Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - flex: 4, - child: Wrap( - // mainAxisAlignment: - // MainAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all(3), - child: AppText( - item.doctorName ?? "", - // item.status == 1 - // ? TranslationBase.of( - // context) - // .hold - // : item.status == 2 - // ? TranslationBase - // .of( - // context) - // .active - // : TranslationBase - // .of(context) - // .all, - fontWeight: - FontWeight.bold, - // color: item.status == 1 - // ? Colors.yellow[800] - // : item.status == 2 - // ? Colors.green - // : Colors.black, - color: Colors.red, - ), - ), - Row( - children: [ - AppText(TranslationBase - .of(context) - .daysSickleave + - ": "), - AppText( - (item.sickLeaveDays - .toString() != - null && - item.sickLeaveDays - .toString() != - "null") - ? item.sickLeaveDays - .toString() - : item.noOfDays - .toString(), - fontWeight: - FontWeight.bold, - ), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of( - context) - .startDate + - ' ' ?? - "", - ), - Flexible( - child: AppText( - AppDateUtils.getDayMonthYearDateFormatted(item - .startDate - .contains( - "/Date(") - ? AppDateUtils - .convertStringToDate(item - .startDate) - : DateTime.parse( - item.startDate)), - fontWeight: - FontWeight.bold, - ), - ) - ], - ), - Row( - children: [ - AppText( - TranslationBase.of( - context) - .endDate + - ' ' ?? - "", - ), - Flexible( - child: AppText( - AppDateUtils.getDayMonthYearDateFormatted(item - .startDate - .contains( - "/Date(") - ? AppDateUtils.convertStringToDate( - item.endDate ?? - "") - .add(Duration( - days: item.noOfDays ?? - item - .sickLeaveDays)) - : DateTime.parse( - item.startDate ?? "") - .add(Duration(days: item.noOfDays ?? ""))), - fontWeight: - FontWeight.bold, - ), - ) - ], - ), - ], - ), - SizedBox( - width: 20, - ), - ], - ), - ), - ], - )), - ], - )); - }).toList(), - ) - : patient.patientStatusType != 43 - ? 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).noSickLeave), - ) - ], - ), - ) - : SizedBox() - ])))); - } - - openSickLeave(BuildContext context, isExtend, - {GetAllSickLeaveResponse extendedData}) { - // showModalBottomSheet( - // context: context, - // builder: (context) { - // return new Container( - // child: - Navigator.push( - context, - FadePage( - page: SickLeaveScreen( - appointmentNo: isExtend == true - ? extendedData.appointmentNo - : patient.appointmentNo, - //extendedData.appointmentNo, - patientMRN: isExtend == true - ? extendedData.patientMRN - : patient.patientMRN, - isExtended: isExtend, - extendedData: extendedData, - patient: patient))); - } -} diff --git a/lib/screens/sick-leave/show-sickleave.dart b/lib/screens/sick-leave/show-sickleave.dart deleted file mode 100644 index 726524d8..00000000 --- a/lib/screens/sick-leave/show-sickleave.dart +++ /dev/null @@ -1,198 +0,0 @@ -import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; -import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/util/date-utils.dart'; -import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.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/rounded_container_widget.dart'; -import 'package:flutter/material.dart'; - -class ShowSickLeaveScreen extends StatelessWidget { - PatiantInformtion patient; - - @override - Widget build(BuildContext context) { - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - patient = routeArgs['patient']; - return BaseView( - onModelReady: (model) => - model.getSickLeave(patient.patientMRN ?? patient.patientId), - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: true, - backgroundColor: Colors.grey[100], - appBar: PatientProfileAppBar( - patient, - ), - body: SingleChildScrollView( - child: Column( - children: [ - // PatientProfileHeaderNewDesign( - // patient, routeArgs['patientType'], routeArgs['arrivalType']), - model.getAllSIckLeave.length > 0 - ? Column( - children: model.getAllSIckLeave - .map((GetAllSickLeaveResponse item) { - return RoundedContainer( - margin: EdgeInsets.all(10), - child: Column( - children: [ - Container( - decoration: BoxDecoration( - border: Border( - left: BorderSide( - color: item.status == 1 - ? Colors.yellow[800] - : item.status == 2 - ? Colors.green - : Colors.black, - width: 5.0, - ))), - padding: EdgeInsets.all(10), - child: Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - flex: 4, - child: Wrap( - // mainAxisAlignment: - // MainAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all(3), - child: AppText( - item.status == 1 - ? TranslationBase.of( - context) - .hold - : item.status == 2 - ? TranslationBase - .of( - context) - .active - : TranslationBase - .of(context) - .all, - fontWeight: - FontWeight.bold, - color: item.status == 1 - ? Colors.yellow[800] - : item.status == 2 - ? Colors.green - : Colors.black, - ), - ), - Row( - children: [ - AppText( - TranslationBase.of( - context) - .daysSickleave), - AppText( - item.noOfDays - .toString(), - fontWeight: - FontWeight.bold, - ), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of( - context) - .startDate + - ' ', - ), - Flexible( - child: AppText( - AppDateUtils - .convertStringToDateFormat( - item.startDate, - 'dd-MMM-yyyy'), - fontWeight: - FontWeight.bold, - )) - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - AppText( - item.remarks ?? "", - ), - (item.status == 1) - ? IconButton( - icon: Image.asset( - 'assets/images/edit.png'), - - // color: Colors.green, //Colors.black, - onPressed: () => - { - if (item.status == - 1) - { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .sickleaveonhold) - } - // else - // { - // openSickLeave( - // context, - // true, - // extendedData: - // item) - // } - }, - ) - : SizedBox() - ]), - ], - ), - SizedBox( - width: 20, - ), - ], - ), - ), - ], - )), - ], - )); - }).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).noSickLeave), - ) - ], - ), - ) - ], - ), - ), - ), - ); - } -} diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart deleted file mode 100644 index be8e38f1..00000000 --- a/lib/screens/sick-leave/sick_leave.dart +++ /dev/null @@ -1,429 +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/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; -import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; -import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; -import 'package:doctor_app_flutter/routes.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/sick-leave/add-sickleave.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; -import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; -import 'package:doctor_app_flutter/util/helpers.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/text_fields/app_text_form_field.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:intl/intl.dart'; - -Helpers helpers = Helpers(); - -class SickLeaveScreen extends StatefulWidget { - final bool isExtended; - final GetAllSickLeaveResponse extendedData; - final appointmentNo; - final patientMRN; - final patient; - SickLeaveScreen({this.appointmentNo, this.patientMRN, this.isExtended = false, this.extendedData, this.patient}); - @override - _SickLeaveScreenState createState() => _SickLeaveScreenState(); -} - -class _SickLeaveScreenState extends State { - DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - TextEditingController _toDateController = new TextEditingController(); - String _selectedClinic; - Map profile = {}; - AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); - void _presentDatePicker(id) { - showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(2019), - lastDate: DateTime(2050), - ).then((pickedDate) { - if (pickedDate == null) { - return; - } - setState(() { - // var selectedDate = DateFormat.yMd().format(pickedDate); - final df = new DateFormat('yyyy-MM-dd'); - addSickLeave.startDate = df.format(pickedDate); - - _toDateController.text = addSickLeave.startDate; - //addSickLeave.startDate = selectedDate; - }); - }); - } - - @override - void initState() { - getProfile(); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) => model.getClinicsList(), - builder: (_, model, w) => BaseView( - onModelReady: (model2) => model2.preSickLeaveStatistics(widget.appointmentNo, widget.patientMRN), - builder: (_, model2, w) => GestureDetector( - onTap: () { - FocusScope.of(context).requestFocus(new FocusNode()); - }, - child: AppScaffold( - baseViewModel: model2, - appBarTitle: widget.isExtended == true - ? TranslationBase.of(context).extendSickLeave - : TranslationBase.of(context).addSickLeave, - isShowAppBar: true, - body: Center( - child: Container( - margin: EdgeInsets.only(top: 10), - child: FractionallySizedBox( - widthFactor: 0.9, - child: ListView( - children: [ - // Padding( - // child: AppText( - // widget.isExtended == true - // ? TranslationBase.of(context) - // .extendSickLeave - // : TranslationBase.of(context) - // .addSickLeave, - // fontWeight: FontWeight.bold, - // ), - // padding: EdgeInsets.all(10)), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"), - ), - color: Colors.white), - padding: EdgeInsets.all(5), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.only(top: 5, left: 10, right: 10), - child: AppText(TranslationBase.of(context).sickLeave + - ' ' + - TranslationBase.of(context).days)), - AppTextFormField( - borderColor: Colors.white, - onChanged: (value) { - addSickLeave.noOfDays = value; - if (widget.extendedData != null) { - widget.extendedData.noOfDays = int.parse(value); - } - }, - hintText: - widget.extendedData != null ? widget.extendedData.noOfDays.toString() : '', - // validator: (value) { - // return TextValidator().validateName(value); - // }, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS) - ]), - ), - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - color: Colors.white, - ), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 5, left: 10, right: 10), - child: AppText( - TranslationBase.of(context).sickLeaveDate, - )), - AppTextFormField( - hintText: widget.extendedData != null ? widget.extendedData.startDate : '', - borderColor: Colors.white, - prefix: IconButton(icon: Icon(Icons.calendar_today)), - textInputType: TextInputType.number, - controller: _toDateController, - onTap: () { - _presentDatePicker('_selectedToDate'); - }, - inputFormatter: ONLY_DATE, - onChanged: (value) { - addSickLeave.startDate = value; - if (widget.extendedData != null) { - widget.extendedData.startDate = value; - } - }), - ], - )), - Container( - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - color: Colors.white, - ), - 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: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 5), - child: AppText( - TranslationBase.of(context).clinicName, - )), - Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButtonHideUnderline( - child: new IgnorePointer( - ignoring: true, - child: DropdownButton( - isExpanded: true, - value: getClinicName(model) ?? "", - iconSize: 0, - elevation: 16, - selectedItemBuilder: (BuildContext context) { - return model.getClinicNameList().map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item, - fontSize: SizeConfig.textMultiplier * 2.1, - color: Colors.grey, - ), - ], - ); - }).toList(); - }, - onChanged: (newValue) => {}, - items: model.getClinicNameList().map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: TextAlign.end, - ), - ); - }).toList(), - ))), - ), - ], - ) - ], - ), - )), - model2.sickLeaveStatistics['recommendedSickLeaveDays'] != null - ? Padding( - child: AppText( - model2.sickLeaveStatistics['recommendedSickLeaveDays'], - fontWeight: FontWeight.bold, - textAlign: TextAlign.start, - ), - padding: EdgeInsets.all(10), - ) - : SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - color: Colors.white, - ), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 5, left: 10, right: 10), - child: AppText( - TranslationBase.of(context).doctorName, - )), - new IgnorePointer( - ignoring: true, - child: AppTextFormField( - readOnly: true, - hintText: profile['DoctorName'], - borderColor: Colors.white, - onSaved: (value) {}, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_NUMBERS)) - ], - ), - ), - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - color: Colors.white, - ), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 5, left: 10, right: 10), - child: AppText( - TranslationBase.of(context).remarks, - )), - TextField( - maxLines: 3, - decoration: InputDecoration( - contentPadding: EdgeInsets.all(20.0), - border: InputBorder.none, - hintText: widget.extendedData != null ? widget.extendedData.remarks : ''), - onChanged: (value) { - addSickLeave.remarks = value; - if (widget.extendedData != null) { - widget.extendedData.remarks = value; - } - }, - ) - ], - ), - ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: widget.isExtended == true - ? TranslationBase.of(context).extend - : TranslationBase.of(context).addSickLeaverequest, - color: Colors.green, - onPressed: () async { - if (widget.isExtended) { - await model2.extendSickLeave(widget.extendedData); - - DrAppToastMsg.showSuccesToast( - model2.sickleaveResponse['ListSickLeavesToExtent']['success']); - Navigator.of(context).popUntil((route) { - return route.settings.name == PATIENTS_PROFILE; - }); - Navigator.of(context) - .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); - //print(value); - //}); - } else { - try { - if (addSickLeave.noOfDays == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterNoOfDays); - } else if (addSickLeave.remarks == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterRemarks); - } else if (addSickLeave.startDate == null) { - DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterDate); - } else { - addSickLeave.patientMRN = widget.patient.patientMRN.toString(); - addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); - await model2.addSickLeave(addSickLeave); - - if (model2.sickleaveResponse['SickLeavesList']['success'] != null) - DrAppToastMsg.showSuccesToast( - model2.sickleaveResponse['SickLeavesList']['success']); - } - // Navigator.push( - // context, - // MaterialPageRoute(builder: (context) => AddSickLeavScreen()), - // ); - - // Navigator.of(context).popUntil((route) { - // return route.settings.name == PATIENTS_PROFILE; - // }); - // Navigator.of(context) - // .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); - } catch (err) { - print(err); - } - } - }, - ), - ], - ), - ), - // Column( - // children: [ - // AppText(TranslationBase.of(context) - // .previousSickLeaveIssue + - // ' ') - // ], - // ) - ], - ), - ), - ), - ), - ), - ))); - } - - void _validateInputs(model2) async { - try { - if (addSickLeave.noOfDays == null) { - DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterNoOfDays); - } else if (addSickLeave.remarks == null) { - DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterRemarks); - } else if (addSickLeave.startDate == null) { - DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterDate); - } else { - addSickLeave.patientMRN = widget.patient.patientMRN.toString(); - addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); - await model2.addSickLeave(addSickLeave).then((value) => print(value)); - - DrAppToastMsg.showSuccesToast(model2.sickleaveResponse['ListSickLeavesToExtent']['success']); - Navigator.of(context).popUntil((route) { - return route.settings.name == PATIENTS_PROFILE; - }); - Navigator.of(context).pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); - } - } catch (err) { - print(err); - } - } - - getProfile() async { - Map p = await sharedPref.getObj(DOCTOR_PROFILE); - setState(() { - this.profile = p; - }); - } - - getClinicName(model) { - var clinicInfo = model.clinicsList.where((i) => i['ClinicID'] == this.profile['ClinicID']).toList(); - return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : ""; - } -} diff --git a/lib/util/date-utils.dart b/lib/util/date-utils.dart index c4819ad9..89564833 100644 --- a/lib/util/date-utils.dart +++ b/lib/util/date-utils.dart @@ -297,11 +297,11 @@ class AppDateUtils { /// get data formatted like 26 Apr 2020 /// [dateTime] convert DateTime to data formatted static String getDayMonthYearDateFormatted(DateTime dateTime, - {bool isArabic = false, bool isMonthshort = false}) { + {bool isArabic = false, bool isMonthShort = false}) { if (dateTime != null) return dateTime.day.toString() + " " + - "${isArabic ? getMonthArabic(dateTime.month) : isMonthshort ? getMonth(dateTime.month).toString().substring(0, 3) : getMonth(dateTime.month)}" + + "${isArabic ? getMonthArabic(dateTime.month) : isMonthShort ? getMonth(dateTime.month).toString().substring(0, 3) : getMonth(dateTime.month)}" + " " + dateTime.year.toString(); else diff --git a/lib/widgets/shared/text_fields/app-textfield-custom.dart b/lib/widgets/shared/text_fields/app-textfield-custom.dart index da3ee466..cd97c8d4 100644 --- a/lib/widgets/shared/text_fields/app-textfield-custom.dart +++ b/lib/widgets/shared/text_fields/app-textfield-custom.dart @@ -30,8 +30,6 @@ class AppTextFieldCustom extends StatefulWidget { final bool isPrscription; final bool isSecure; final bool focus; - - ///TODO Rename it to isCustomSearchablFiels final bool isSearchTextField; AppTextFieldCustom({