diff --git a/lib/config/config.dart b/lib/config/config.dart index edb34b5e..41601b9f 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 = @@ -102,6 +102,11 @@ const ARRIVED_PATIENT_URL = const ADD_SICK_LEAVE = 'Services/DoctorApplication.svc/REST/PostSickLeave'; const GET_SICK_LEAVE = 'Services/DoctorApplication.svc/REST/GetAllSickLeaves'; const EXTEND_SICK_LEAVE = 'Services/DoctorApplication.svc/REST/ExtendSickLeave'; + +const GET_OFFTIME = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList'; + +const GET_RESCHEDULE_LEAVE = + 'Services/DoctorApplication.svc/REST/GetAllSickLeaves'; const GET_PRESCRIPTION_LIST = 'Services/DoctorApplication.svc/REST/GetPrescription'; @@ -120,9 +125,12 @@ const GET_MASTER_LOOKUP_LIST = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList'; const POST_ALLERGY = 'Services/DoctorApplication.svc/REST/PostAllergies'; const POST_HISTORY = 'Services/DoctorApplication.svc/REST/PostHistory'; -const POST_CHIEF_COMPLAINT = 'Services/DoctorApplication.svc/REST/PostChiefcomplaint'; -const POST_PHYSICAL_EXAM = 'Services/DoctorApplication.svc/REST/PostPhysicalExam'; -const POST_PROGRESS_NOTE = '/Services/DoctorApplication.svc/REST/PostProgressNote'; +const POST_CHIEF_COMPLAINT = + 'Services/DoctorApplication.svc/REST/PostChiefcomplaint'; +const POST_PHYSICAL_EXAM = + 'Services/DoctorApplication.svc/REST/PostPhysicalExam'; +const POST_PROGRESS_NOTE = + '/Services/DoctorApplication.svc/REST/PostProgressNote'; var selectedPatientType = 1; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 50d32393..72fa1a26 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -353,4 +353,12 @@ const Map> localizedValues = { 'instruction': {'en': 'Instructions', 'ar': 'إرشادات'}, 'addMedication': {'en': 'ADD MEDICATION', 'ar': 'اضف الدواء'}, 'route': {'en': 'Route', 'ar': 'المسار'}, + 'reschedule-leave': { + 'en': 'Reschedule and leaves', + 'ar': 'إعادة الجدولة والأوراق' + }, + 'no-reschedule-leave': { + 'en': 'No Reschedule and leaves', + 'ar': 'لا إعادة جدولة ويغادر' + } }; diff --git a/lib/core/service/sickleave_service.dart b/lib/core/service/sickleave_service.dart index 70d9a3e4..926187dd 100644 --- a/lib/core/service/sickleave_service.dart +++ b/lib/core/service/sickleave_service.dart @@ -8,7 +8,9 @@ import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.d class SickLeaveService extends BaseService { Map get sickLeavestatisitics => _statistics; Map _statistics = {}; + var offTime = []; + get getOffTimeList => offTime; List get getAllSickLeave => _getAllsickLeave; List _getAllsickLeave = []; Future getStatistics(appoNo, patientMRN) async { @@ -90,4 +92,57 @@ class SickLeaveService extends BaseService { body: {'PatientMRN': 3120772}, ); } + + Future getRescheduleLeave() async { + hasError = false; + await baseAppClient.post( + GET_RESCHEDULE_LEAVE, + onSuccess: (dynamic response, int statusCode) { + Future.value(response); + _getAllsickLeave.clear(); + // response['SickLeavesList']['entityList'].forEach((v) { + // _getAllsickLeave.add(GetAllSickLeaveResponse.fromJson(v)); + // }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: {'PatientMRN': 3120772}, + ); + } + + Future getOffTime() async { + hasError = false; + + await baseAppClient.post( + GET_OFFTIME, + onSuccess: (dynamic response, int statusCode) { + offTime = []; + offTime = response[' ']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: {"MasterInput": 2013}, + ); + } + + Future getReasons(id) async { + hasError = false; + + await baseAppClient.post( + GET_OFFTIME, + onSuccess: (dynamic response, int statusCode) { + offTime = []; + offTime = response[' ']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: {"MasterInput": id}, + ); + } } diff --git a/lib/core/viewModel/sick_leave_view_model.dart b/lib/core/viewModel/sick_leave_view_model.dart index a11d43ec..2e07d3b0 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -12,6 +12,7 @@ class SickLeaveViewModel extends BaseViewModel { SickLeaveService _sickLeaveService = locator(); get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics; get getAllSIckLeave => _sickLeaveService.getAllSickLeave; + get allOffTime => _sickLeaveService.getOffTimeList; Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { setState(ViewState.Busy); await _sickLeaveService.addSickLeave(addSickLeaveRequest); @@ -51,4 +52,34 @@ class SickLeaveViewModel extends BaseViewModel { } else setState(ViewState.Idle); } + + Future getRescheduleLeave() async { + setState(ViewState.Busy); + await _sickLeaveService.getRescheduleLeave(); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getOffTime() async { + setState(ViewState.Busy); + await _sickLeaveService.getOffTime(); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getReasons(id) async { + setState(ViewState.Busy); + await _sickLeaveService.getReasons(id); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } } diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index b6bbc6cf..cb36225f 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/core/viewModel/hospital_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/referral/my-referral-patient-screen.dart'; +import 'package:doctor_app_flutter/screens/reschedule-leaves/add-rescheduleleave.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; @@ -184,7 +185,9 @@ class _DashboardScreenState extends State { ), Container( color: Colors.white, - height: this.isExpanded ? 150 : 110, + height: this.isExpanded + ? MediaQuery.of(context).size.height * 0.19 + : MediaQuery.of(context).size.height * 0.12, ), ], ), @@ -953,6 +956,41 @@ class _DashboardScreenState extends State { SizedBox( height: 20, ), + Row( + children: [ + DashboardItem( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Icon( + Icons.rule_folder, + size: 50, + color: Colors.black, + ), + AppText( + TranslationBase.of(context).rescheduleLeaves, + color: Colors.black, + textAlign: TextAlign.center, + ) + ], + ), + hasBorder: true, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + AddRescheduleLeavScreen(), + // MyReferredPatient(), + ), + ); + }, + ) + ], + ), + SizedBox( + height: 20, + ), ], ), ), diff --git a/lib/screens/reschedule-leaves/add-rescheduleleave.dart b/lib/screens/reschedule-leaves/add-rescheduleleave.dart new file mode 100644 index 00000000..8963f306 --- /dev/null +++ b/lib/screens/reschedule-leaves/add-rescheduleleave.dart @@ -0,0 +1,193 @@ +import 'package:doctor_app_flutter/config/size_config.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/sickleave/get_all_sickleave_response.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/reschedule-leaves/reschedule_leave.dart'; +import 'package:doctor_app_flutter/screens/sick-leave/sick_leave.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/card_with_bgNew_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class AddRescheduleLeavScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getRescheduleLeave(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).rescheduleLeaves, + body: model.getAllSIckLeave.length > 0 + ? SingleChildScrollView( + child: Column( + children: model.getAllSIckLeave + .map((GetAllSickLeaveResponse item) { + return CardWithBgWidgetNew( + widget: Column( + children: [ + Container( + padding: EdgeInsets.only(left: 10, right: 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) + .approved + : item.status == 2 + ? TranslationBase + .of(context) + .extended + : TranslationBase + .of(context) + .pending, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + color: item.status == 1 + ? Colors.green + : Colors.yellow[800], + ), + Row( + children: [ + AppText( + TranslationBase.of( + context) + .leaveStartDate + + ' ', + fontWeight: + FontWeight.bold, + ), + Flexible( + child: Text( + item.startDate, + overflow: + TextOverflow.ellipsis, + )) + ], + ), + AppText( + item.noOfDays.toString() + + ' ' + + TranslationBase.of( + context) + .daysSickleave, + fontWeight: FontWeight.bold, + ), + Row(children: [ + AppText( + item.remarks, + ) + ]), + ], + ), + SizedBox( + width: 20, + ), + ], + ), + ), + (item.status == 1 || item.status == 2) + ? Expanded( + flex: 1, + child: IconButton( + icon: Icon( + Icons.open_in_full, + size: 40, + ), + // color: Colors.green, //Colors.black, + onPressed: () => { + // openSickLeave(context, true, + // extendedData: item) + }, + )) + : SizedBox(), + ], + )), + SizedBox( + height: 20, + ), + Divider( + height: 1, + ), + ], + )); + }).toList(), + ), + ) + : new Builder(builder: (context) { + return Center( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: EdgeInsets.all(40), + decoration: BoxDecoration( + border: Border.all( + color: HexColor('#B8382C'), width: 4), + borderRadius: + BorderRadius.all(Radius.circular(100))), + child: IconButton( + icon: Icon( + Icons.add, + size: 35, + ), + onPressed: () { + openLeave( + context, + false, + ); + }), + ), + Padding( + child: AppText( + TranslationBase.of(context).noReScheduleLeave, + fontWeight: FontWeight.bold, + ), + padding: EdgeInsets.all(10), + ), + AppText( + TranslationBase.of(context).applyNow, + fontWeight: FontWeight.bold, + color: HexColor('#B8382C'), + ) + ], + ), + )); + }), + )); + } + + openLeave(BuildContext context, isExtend, + {GetAllSickLeaveResponse extendedData}) { + showModalBottomSheet( + context: context, + builder: (context) { + return new Container( + child: RescheduleLeaveScreen( + // appointmentNo: extendedData.appointmentNo, + // patientMRN: extendedData.patientMRN, + // isExtended: isExtend, + // extendedData: extendedData, + )); + }); + } +} diff --git a/lib/screens/reschedule-leaves/reschedule_leave.dart b/lib/screens/reschedule-leaves/reschedule_leave.dart new file mode 100644 index 00000000..6de0779e --- /dev/null +++ b/lib/screens/reschedule-leaves/reschedule_leave.dart @@ -0,0 +1,315 @@ +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/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/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/util/text_validator.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.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_text_form_field.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/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:intl/intl.dart'; +import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; + +Helpers helpers = Helpers(); + +class RescheduleLeaveScreen extends StatefulWidget { + RescheduleLeaveScreen(); + @override + _RescheduleLeaveScreen createState() => _RescheduleLeaveScreen(); +} + +class _RescheduleLeaveScreen 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.now(), + ).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.getOffTime(), + builder: (_, model2, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: Center( + child: Container( + margin: EdgeInsets.only(top: 10), + child: FractionallySizedBox( + widthFactor: 0.9, + child: ListView( + children: [ + 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"))), + 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: [ + // AppText( + // TranslationBase.of(context).clinicName, + // fontSize: 10, + // ), + 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( + focusColor: Colors.grey, + isExpanded: true, + value: getClinicName( + model) ?? + "", + iconSize: 40, + 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(), + ))), + ), + ], + ) + ], + ), + )), + 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"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + new IgnorePointer( + ignoring: true, + child: AppTextFormField( + readOnly: true, + hintText: profile['DoctorName'], + borderColor: Colors.white, + onSaved: (value) {}, + inputFormatter: ONLY_NUMBERS)) + ], + ), + ), + + 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"))), + 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: [ + 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( + focusColor: Colors.grey, + isExpanded: true, + value: getClinicName( + model) ?? + "", + iconSize: 40, + 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(), + ))), + ), + ], + ) + ], + ), + )), + + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context).add, + onPressed: () {}, + ), + ], + ), + ), + // Column( + // children: [ + // Texts(TranslationBase.of(context) + // .previousSickLeaveIssue + + // ' ') + // ], + // ) + ], + ), + ), + ), + ), + ))); + } + + 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/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 59eda9e0..4841f0f5 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -387,9 +387,13 @@ class TranslationBase { String get indication => localizedValues['indication'][locale.languageCode]; String get duration => localizedValues['duration'][locale.languageCode]; String get instruction => localizedValues['instruction'][locale.languageCode]; + String get rescheduleLeaves => + localizedValues['reschedule-leave'][locale.languageCode]; String get addMedication => localizedValues['addMedication'][locale.languageCode]; String get route => localizedValues['route'][locale.languageCode]; + String get noReScheduleLeave => + localizedValues['no-reschedule-leave'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {