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 8b1438f0..2b3062ee 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 @@ -27,12 +27,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(); @@ -56,8 +53,6 @@ class SickLeaveService extends BaseService { Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { hasError = false; - if(_sickLeaveResponse!= null) - _sickLeaveResponse.clear(); await baseAppClient.post( ADD_SICK_LEAVE, onSuccess: (dynamic response, int statusCode) { @@ -80,7 +75,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 a4332534..bc7c9568 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -10,8 +10,7 @@ class SickLeaveViewModel extends BaseViewModel { SickLeaveService _sickLeaveService = locator(); 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; @@ -32,11 +31,11 @@ class SickLeaveViewModel extends BaseViewModel { } 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); } 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 index dc52b86e..df03db37 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -279,11 +279,6 @@ class AddSickLeavScreen extends StatelessWidget { openSickLeave(BuildContext context, isExtend, {GetAllSickLeaveResponse extendedData}) { - // showModalBottomSheet( - // context: context, - // builder: (context) { - // return new Container( - // child: Navigator.push( context, FadePage( diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index 9cbd94f1..3b496d16 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -48,14 +48,14 @@ class SickLeaveScreen extends StatefulWidget { class _SickLeaveScreenState extends State { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); TextEditingController _toDateController = new TextEditingController(); - TextEditingController _numberOfController = new TextEditingController(); + TextEditingController _numberOfDayController = new TextEditingController(); TextEditingController _clinicController = new TextEditingController(); TextEditingController _doctorController = new TextEditingController(); TextEditingController _remarkController = new TextEditingController(); - String _selectedClinic; Map profile = {}; AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); + bool isFormSubmitted = false; void _presentDatePicker(id) { showDatePicker( @@ -100,299 +100,266 @@ class _SickLeaveScreenState extends State { 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: [ - SizedBox( - height: 30, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: widget.extendedData != null - ? widget.extendedData.noOfDays.toString() - : TranslationBase.of(context).sickLeave + - ' ' + - TranslationBase.of(context).days, - maxLines: 1, - minLines: 1, - dropDownColor: Colors.white, - - isTextFieldHasSuffix: true, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _numberOfController, - onChanged: (value) { - addSickLeave.noOfDays = value; - if (widget.extendedData != null) { - widget.extendedData.noOfDays = - int.parse(value); - } - }, - // validationError: isFormSubmitted && - // _selectedMedicationFrequency == - // null - // ? TranslationBase - // .of(context) - // .emptyMessage - // : null, - ), - SizedBox( - height: 10, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - onClick: () { - _presentDatePicker('_selectedToDate'); - }, - hintText: widget.extendedData != null - ? widget.extendedData.startDate - : 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) { - addSickLeave.startDate = value; - if (widget.extendedData != null) { - widget.extendedData.startDate = value; - } - }, - ), - - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: - TranslationBase.of(context).clinicName, - enabled: false, - maxLines: 1, - minLines: 1, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _clinicController, - onChanged: (value) {}, - ), - SizedBox( - height: 10, - ), - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'] != - null - ? AppText( - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'], - fontWeight: FontWeight.bold, - textAlign: TextAlign.start, - fontSize: 15, - ) - : SizedBox( - height: 10, - ), - - SizedBox( - height: 10, - ), - - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: - TranslationBase.of(context).doctorName, - 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: widget.extendedData != null - ? widget.extendedData.remarks - : TranslationBase.of(context).remarks, - maxLines: 30, - minLines: 5, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - controller: _remarkController, - onChanged: (value) { - addSickLeave.remarks = value; - if (widget.extendedData != null) { - widget.extendedData.remarks = value; - } - }, - ), - - ], - ), - ), - ), - ), - bottomSheet: model2.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( + 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: 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 { - GifLoaderDialogUtils.showMyDialog( - context); - addSickLeave.patientMRN = widget - .patient.patientMRN - .toString(); - addSickLeave.appointmentNo = - widget.patient.appointmentNo - .toString(); - await model2 - .addSickLeave(addSickLeave); - if (model2.state == - ViewState.ErrorLocal) { - Helpers.showErrorToast( - model2.error); - } else { - DrAppToastMsg.showSuccesToast( - TranslationBase.of(context) - .replySuccessfully); - } + child: ListView( + children: [ + SizedBox( + height: 30, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: widget.extendedData != null + ? widget.extendedData.noOfDays.toString() + : TranslationBase.of(context).sickLeave + + ' ' + + TranslationBase.of(context).days, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _numberOfDayController, + onChanged: (value) { + setState(() { + addSickLeave.noOfDays = value; + }); - GifLoaderDialogUtils.hideDialog( - context); + if (widget.extendedData != null) { + widget.extendedData.noOfDays = + int.parse(value); + } + }, + validationError: isFormSubmitted && + (addSickLeave.noOfDays == null) + ? TranslationBase.of(context) + .pleaseEnterNoOfDays + : null, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + onClick: () { + _presentDatePicker('_selectedToDate'); + }, + hintText: widget.extendedData != null + ? widget.extendedData.startDate + : 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; + }); + if (widget.extendedData != null) { + widget.extendedData.startDate = value; } - } catch (err) { - print(err); - } - } - }, + }, + validationError: isFormSubmitted && + (addSickLeave.startDate == null) + ? TranslationBase.of(context) + .pleaseEnterDate + : null, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: + TranslationBase.of(context).clinicName, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _clinicController, + onChanged: (value) {}, + ), + SizedBox( + height: 10, + ), + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'] != + null + ? AppText( + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'], + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + fontSize: 15, + ) + : SizedBox( + height: 10, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: + TranslationBase.of(context).doctorName, + 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: widget.extendedData != null + ? widget.extendedData.remarks + : TranslationBase.of(context).remarks, + maxLines: 30, + minLines: 5, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + controller: _remarkController, + onChanged: (value) { + setState(() { + addSickLeave.remarks = value; + }); + if (widget.extendedData != null) { + widget.extendedData.remarks = value; + } + }, + validationError: isFormSubmitted && + (addSickLeave.remarks == null) + ? TranslationBase.of(context) + .pleaseEnterRemarks + : null, + ), + ], ), ), - SizedBox( - height: 5, - ), - ], + ), ), - ) - - ), + bottomSheet: model2.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: widget.isExtended == true + ? TranslationBase.of(context).extend + : TranslationBase.of(context) + .addSickLeaverequest, + color: Colors.green, + onPressed: () async { + submitForm(model2); + }), + ), + SizedBox( + height: 5, + ), + ], + ), + )), ))); } - 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); + submitForm(SickLeaveViewModel model2) async { + { + if (widget.isExtended) { + + GifLoaderDialogUtils.showMyDialog(context); + await model2.extendSickLeave(widget.extendedData); if (model2.state == ViewState.ErrorLocal) { Helpers.showErrorToast(model2.error); } else { DrAppToastMsg.showSuccesToast( TranslationBase.of(context).replySuccessfully); + Navigator.of(context).popUntil((route) { + return route.settings.name == PATIENTS_PROFILE; + }); + Navigator.of(context) + .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); } GifLoaderDialogUtils.hideDialog(context); - Navigator.of(context).popUntil((route) { - return route.settings.name == PATIENTS_PROFILE; - }); - Navigator.of(context) - .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); + } else { + try { + setState(() { + isFormSubmitted = true; + }); + if (addSickLeave.noOfDays == null || + addSickLeave.startDate == null || + addSickLeave.remarks == null) { + return; + } else { + GifLoaderDialogUtils.showMyDialog(context); + addSickLeave.patientMRN = widget.patient.patientMRN.toString(); + addSickLeave.appointmentNo = + widget.patient.appointmentNo.toString(); + await model2.addSickLeave(addSickLeave); + if (model2.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model2.error); + } else { + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context).replySuccessfully); + } + + GifLoaderDialogUtils.hideDialog(context); + } + } catch (err) { + print(err); + } } - } catch (err) { - print(err); } } diff --git a/pubspec.lock b/pubspec.lock index 0229e774..43aefcb2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -141,6 +141,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "7.1.0" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.1" characters: dependency: transitive description: @@ -433,6 +440,20 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_blurhash: + dependency: transitive + description: + name: flutter_blurhash + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" flutter_device_type: dependency: "direct main" description: @@ -595,6 +616,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" + image: + dependency: transitive + description: + name: image + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.19" imei_plugin: dependency: "direct main" description: @@ -664,7 +692,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.4" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -693,6 +721,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + octo_image: + dependency: transitive + description: + name: octo_image + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" open_iconic_flutter: dependency: transitive description: @@ -728,6 +763,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.4" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.28" path_provider_linux: dependency: transitive description: @@ -735,6 +777,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.1+2" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+8" path_provider_platform_interface: dependency: transitive description: @@ -854,6 +903,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.5" + rxdart: + dependency: transitive + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.25.0" scratch_space: dependency: transitive description: @@ -950,13 +1006,27 @@ packages: relative: true source: path version: "0.0.0" + sqflite: + dependency: transitive + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.2+4" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3+3" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.2" + version: "1.10.0-nullsafety.1" sticky_headers: dependency: "direct main" description: @@ -985,6 +1055,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.1" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0+2" term_glyph: dependency: transitive description: @@ -1154,5 +1231,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <=2.11.0-213.1.beta" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.10.2 <2.11.0" + flutter: ">=1.22.2 <2.0.0"