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 index 439c9e26..68e29870 100644 --- a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart @@ -36,9 +36,7 @@ class AddPatientSickLeaveScreen extends StatefulWidget { final SickLeaveViewModel previousModel; AddPatientSickLeaveScreen( - {this.appointmentNo, - this.patientMRN, - this.patient, this.previousModel}); + {this.appointmentNo, this.patientMRN, this.patient, this.previousModel}); @override _AddPatientSickLeaveScreenState createState() => @@ -59,9 +57,9 @@ class _AddPatientSickLeaveScreenState extends State { void _presentDatePicker() { showDatePicker( context: context, - initialDate: currentDate??DateTime.now(), - firstDate: DateTime(DateTime.now().year-1), - lastDate: DateTime(DateTime.now().year+1), + initialDate: currentDate ?? DateTime.now(), + firstDate: DateTime(DateTime.now().year - 1), + lastDate: DateTime(DateTime.now().year + 1), ).then((pickedDate) { if (pickedDate == null) { return; @@ -70,7 +68,9 @@ class _AddPatientSickLeaveScreenState extends State { final df = new DateFormat('yyyy-MM-dd'); addSickLeave.startDate = df.format(pickedDate); currentDate = pickedDate; - _toDateController.text = AppDateUtils.getDayMonthYearDateFormatted(pickedDate,isMonthShort: true ); + _toDateController.text = AppDateUtils.getDayMonthYearDateFormatted( + pickedDate, + isMonthShort: true); }); }); } @@ -91,256 +91,251 @@ class _AddPatientSickLeaveScreenState extends State { 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, + 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( - width: 10, + height: 30, ), - Icon( - DoctorApp.warning, - size: 20, - color: IN_PROGRESS_COLOR, + 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( - width: 10, + height: 10, ), - Expanded( - child: AppText( - model.sickLeaveStatistics.recommendedSickLeaveDays, - textAlign: TextAlign.start, - fontSize: 12, - color: IN_PROGRESS_COLOR, - ), + 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; + }); + }, + ), + SizedBox( + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 12 : 10) + + 20, ), ], - ) - : 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; - }); - }, ), - - SizedBox( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 12 : 10) +20, - ), - ], + ), ), ), - ), - ), - 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: AppGlobal.appGreenColor, - onPressed: () async { - submitForm(model); - }), - ), - SizedBox( - height: 5, - ), - ], - ), - )), - )); + 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: AppGlobal.appGreenColor, + onPressed: () async { + submitForm(model); + }), + ), + SizedBox( + height: 5, + ), + ], + ), + )), + )); } submitForm(SickLeaveViewModel model) async { { - try { - setState(() { - isFormSubmitted = true; - }); - if (addSickLeave.noOfDays == null || - addSickLeave.startDate == null ) { - return; + 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 { - 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); + await widget.previousModel + .getSickLeaveForPatient(widget.patient, isLocalBusy: true); + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context).replySuccessfully); + Navigator.of(context).pop(); } - } catch (err) { - print(err); - } + GifLoaderDialogUtils.hideDialog(context); + } + } catch (err) { + print(err); + } } } - } diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart index d6c19372..f5134c1c 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart @@ -2,13 +2,14 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:flutter/material.dart'; -class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget { - BottomSheetTitle({ - Key key, this.title, +class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget { + BottomSheetTitle({ + Key key, + this.title, }) : super(key: key); final String title; - double headerHeight = SizeConfig.heightMultiplier*15; + double headerHeight = SizeConfig.heightMultiplier * 15; @override Widget build(BuildContext context) { return Container( @@ -20,29 +21,25 @@ class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget { height: headerHeight, child: Center( child: Container( - padding: EdgeInsets.only( - left: 10, right: 10), - margin: EdgeInsets.only(top: headerHeight *0.5), + padding: EdgeInsets.only(left: 10, right: 10), + margin: EdgeInsets.only(top: headerHeight * 0.5), child: Column( children: [ Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ RichText( text: TextSpan( - style: TextStyle( - fontSize:20, - color: Colors.black), + style: TextStyle(fontSize: 20, color: Colors.black), children: [ new TextSpan( - text: title, style: TextStyle( color: Color(0xFF2B353E), - fontWeight: FontWeight.bold, + fontWeight: FontWeight.w700, fontFamily: 'Poppins', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth()*6)), + letterSpacing: -1.44, + fontSize: 24.0)), ], ), ), @@ -51,7 +48,7 @@ class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget { Navigator.pop(context); }, child: Icon(DoctorApp.close_1, - size:SizeConfig.getTextMultiplierBasedOnWidth()*5, + size: SizeConfig.getTextMultiplierBasedOnWidth() * 5, color: Color(0xFF2B353E))) ], ), @@ -63,5 +60,5 @@ class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget { } @override - Size get preferredSize => Size(double.maxFinite,headerHeight); + Size get preferredSize => Size(double.maxFinite, headerHeight); } diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 9cd5121a..8c07afcf 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -37,7 +37,8 @@ import 'package:provider/provider.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; -addPrescriptionForm(context, PrescriptionViewModel model, PatiantInformtion patient, prescription) { +addPrescriptionForm(context, PrescriptionViewModel model, + PatiantInformtion patient, prescription) { showModalBottomSheet( isScrollControlled: true, context: context, @@ -62,7 +63,8 @@ postPrescription( String icdCode, PatiantInformtion patient, String patientType}) async { - PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); + PostPrescriptionReqModel postProcedureReqModel = + new PostPrescriptionReqModel(); List prescriptionList = List(); postProcedureReqModel.appointmentNo = patient.appointmentNo; @@ -126,7 +128,8 @@ class _PrescriptionFormWidgetState extends State { DateTime selectedDate; int strengthChar; GetMedicationResponseModel _selectedMedication; - GlobalKey key = new GlobalKey>(); + GlobalKey key = + new GlobalKey>(); TextEditingController drugIdController = TextEditingController(); TextEditingController doseController = TextEditingController(); @@ -170,7 +173,8 @@ class _PrescriptionFormWidgetState extends State { onVoiceText() async { new SpeechToText(context: context).showAlertDialog(context); var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; - bool available = await speech.initialize(onStatus: statusListener, onError: errorListener); + bool available = await speech.initialize( + onStatus: statusListener, onError: errorListener); if (available) { speech.listen( onResult: resultListener, @@ -213,7 +217,8 @@ class _PrescriptionFormWidgetState extends State { } Future initSpeechState() async { - bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); + bool hasSpeech = await speech.initialize( + onError: errorListener, onStatus: statusListener); print(hasSpeech); if (!mounted) return; } @@ -259,13 +264,15 @@ class _PrescriptionFormWidgetState extends State { initialChildSize: 0.98, maxChildSize: 0.98, minChildSize: 0.9, - builder: (BuildContext context, ScrollController scrollController) { + builder: + (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height * 1.65, color: Color(0xffF8F8F8), child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), + padding: EdgeInsets.symmetric( + horizontal: 12.0, vertical: 10.0), child: Column( children: [ Column( @@ -287,8 +294,11 @@ class _PrescriptionFormWidgetState extends State { widthFactor: 0.9, child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), padding: EdgeInsets.all(10), child: AppTextFormField( onTap: () { @@ -296,7 +306,8 @@ class _PrescriptionFormWidgetState extends State { visbiltySearch = true; }, borderColor: Colors.white, - hintText: TranslationBase.of(context).searchMedicineNameHere, + hintText: TranslationBase.of(context) + .searchMedicineNameHere, controller: myController, onSaved: (value) {}, onFieldSubmitted: (value) { @@ -322,9 +333,12 @@ class _PrescriptionFormWidgetState extends State { children: [ // TODO change it secondary button and add loading AppButton( - title: TranslationBase.of(context).search, + title: TranslationBase.of( + context) + .search, onPressed: () async { - await searchMedicine(context, model); + await searchMedicine( + context, model); }, ), ], @@ -333,23 +347,44 @@ class _PrescriptionFormWidgetState extends State { ), if (myController.text != '') Container( - height: MediaQuery.of(context).size.height * 0.5, + height: MediaQuery.of(context) + .size + .height * + 0.5, child: ListView.builder( - padding: const EdgeInsets.only(top: 20), + padding: const EdgeInsets.only( + top: 20), scrollDirection: Axis.vertical, - itemCount: model.allMedicationList == null - ? 0 - : model.allMedicationList.length, - itemBuilder: (BuildContext context, int index) { + itemCount: + model.allMedicationList == + null + ? 0 + : model + .allMedicationList + .length, + itemBuilder: + (BuildContext context, + int index) { return InkWell( child: MedicineItemWidget( - label: model.allMedicationList[index].description), + label: model + .allMedicationList[ + index] + .description), onTap: () { - model.getItem(itemID: model.allMedicationList[index].itemId); - visbiltyPrescriptionForm = true; + model.getItem( + itemID: model + .allMedicationList[ + index] + .itemId); + visbiltyPrescriptionForm = + true; visbiltySearch = false; - _selectedMedication = model.allMedicationList[index]; - uom = _selectedMedication.uom; + _selectedMedication = + model.allMedicationList[ + index]; + uom = _selectedMedication + .uom; }, ); }, @@ -368,53 +403,68 @@ class _PrescriptionFormWidgetState extends State { child: Column( children: [ AppText( - _selectedMedication?.description ?? "", + _selectedMedication?.description ?? + "", bold: true, ), Container( child: Row( children: [ AppText( - TranslationBase.of(context).orderType, + TranslationBase.of(context) + .orderType, fontWeight: FontWeight.w600, ), Radio( - activeColor: Color(0xFFB9382C), + activeColor: + Color(0xFFB9382C), value: 1, groupValue: selectedType, onChanged: (value) { setSelectedType(value); }, ), - Text(TranslationBase.of(context).regular), + Text(TranslationBase.of(context) + .regular), ], ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), Container( width: double.infinity, child: Row( children: [ Container( - width: MediaQuery.of(context).size.width * 0.35, + width: MediaQuery.of(context) + .size + .width * + 0.35, child: AppTextFieldCustom( - height: 40, - validationError: strengthError, + //height: 40, + validationError: + strengthError, hintText: 'Strength', isTextFieldHasSuffix: false, enabled: true, - controller: strengthController, + controller: + strengthController, onChanged: (String value) { setState(() { - strengthChar = value.length; + strengthChar = + value.length; }); if (strengthChar >= 5) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).only5DigitsAllowedForStrength, + DrAppToastMsg + .showErrorToast( + TranslationBase.of( + context) + .only5DigitsAllowedForStrength, ); } }, - inputType: TextInputType.numberWithOptions( + inputType: TextInputType + .numberWithOptions( decimal: true, ), ), @@ -423,15 +473,23 @@ class _PrescriptionFormWidgetState extends State { width: 5.0, ), PrescriptionTextFiled( - width: MediaQuery.of(context).size.width * 0.517, - element: model.itemMedicineListUnit.length == 1 - ? model.itemMedicineListUnit[0] + width: MediaQuery.of(context) + .size + .width * + 0.510, + element: model + .itemMedicineListUnit + .length == + 1 + ? model + .itemMedicineListUnit[0] : units, elementError: unitError, keyName: 'description', keyId: 'parameterCode', - hintText: 'Select', - elementList: model.itemMedicineListUnit, + hintText: 'Unit', + elementList: model + .itemMedicineListUnit, okFunction: (selectedValue) { setState(() { units = selectedValue; @@ -442,10 +500,14 @@ class _PrescriptionFormWidgetState extends State { ], ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), PrescriptionTextFiled( - elementList: model.itemMedicineListRoute, - element: model.itemMedicineListRoute.length == 1 + elementList: + model.itemMedicineListRoute, + element: model.itemMedicineListRoute + .length == + 1 ? model.itemMedicineListRoute[0] : route, elementError: routeError, @@ -457,40 +519,58 @@ class _PrescriptionFormWidgetState extends State { route['isDefault'] = true; }); }, - hintText: TranslationBase.of(context).route, + hintText: + TranslationBase.of(context) + .route, ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), PrescriptionTextFiled( - hintText: TranslationBase.of(context).frequency, + hintText: + TranslationBase.of(context) + .frequency, elementError: frequencyError, element: frequency, - elementList: model.itemMedicineList, + elementList: + model.itemMedicineList, keyId: 'parameterCode', keyName: 'description', okFunction: (selectedValue) { setState(() { frequency = selectedValue; frequency['isDefault'] = true; - if (_selectedMedication != null && + if (_selectedMedication != + null && duration != null && frequency != null && - strengthController.text != null) { + strengthController.text != + null) { model.getBoxQuantity( - freq: frequency['parameterCode'], - duration: duration['id'], - itemCode: _selectedMedication.itemId, - strength: double.parse(strengthController.text)); + freq: frequency[ + 'parameterCode'], + duration: + duration['id'], + itemCode: + _selectedMedication + .itemId, + strength: double.parse( + strengthController + .text)); return; } }); }), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), PrescriptionTextFiled( - hintText: TranslationBase.of(context).doseTime, + hintText: + TranslationBase.of(context) + .doseTime, elementError: doseTimeError, element: doseTime, - elementList: model.medicationDoseTimeList, + elementList: + model.medicationDoseTimeList, keyId: 'id', keyName: 'nameEn', okFunction: (selectedValue) { @@ -498,8 +578,10 @@ class _PrescriptionFormWidgetState extends State { doseTime = selectedValue; }); }), - SizedBox(height: spaceBetweenTextFileds), - if (model.patientAssessmentList.isNotEmpty) + SizedBox( + height: spaceBetweenTextFileds), + if (model + .patientAssessmentList.isNotEmpty) Container( height: screenSize.height * 0.070, width: double.infinity, @@ -507,25 +589,49 @@ class _PrescriptionFormWidgetState extends State { child: Row( children: [ Container( - width: MediaQuery.of(context).size.width * 0.29, + width: + MediaQuery.of(context) + .size + .width * + 0.29, child: TextField( - decoration: textFieldSelectorDecoration( - model.patientAssessmentList[0].icdCode10ID.toString(), - indication != null ? indication['name'] : null, - false), + decoration: + textFieldSelectorDecoration( + model + .patientAssessmentList[ + 0] + .icdCode10ID + .toString(), + indication != null + ? indication[ + 'name'] + : null, + false), enabled: true, readOnly: true, ), ), Container( - width: MediaQuery.of(context).size.width * 0.59, + width: + MediaQuery.of(context) + .size + .width * + 0.57, color: Colors.white, child: TextField( maxLines: 5, - decoration: textFieldSelectorDecoration( - model.patientAssessmentList[0].asciiDesc.toString(), - indication != null ? indication['name'] : null, - false), + decoration: + textFieldSelectorDecoration( + model + .patientAssessmentList[ + 0] + .asciiDesc + .toString(), + indication != null + ? indication[ + 'name'] + : null, + false), enabled: true, readOnly: true, ), @@ -533,47 +639,63 @@ class _PrescriptionFormWidgetState extends State { ], ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), Container( height: screenSize.height * 0.070, color: Colors.white, child: InkWell( - onTap: () => selectDate(context, widget.model), + onTap: () => selectDate( + context, widget.model), child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).date, - selectedDate != null - ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" - : null, - true, - suffixIcon: Icon( - Icons.calendar_today, - color: Colors.black, - )), + decoration: + textFieldSelectorDecoration( + TranslationBase.of( + context) + .date, + selectedDate != null + ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + : null, + true, + suffixIcon: Icon( + Icons.calendar_today, + color: Colors.black, + )), enabled: false, ), ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), PrescriptionTextFiled( element: duration, elementError: durationError, - hintText: TranslationBase.of(context).duration, - elementList: model.medicationDurationList, + hintText: + TranslationBase.of(context) + .duration, + elementList: + model.medicationDurationList, keyName: 'nameEn', keyId: 'id', okFunction: (selectedValue) { setState(() { duration = selectedValue; - if (_selectedMedication != null && + if (_selectedMedication != + null && duration != null && frequency != null && - strengthController.text != null) { + strengthController.text != + null) { model.getBoxQuantity( - freq: frequency['parameterCode'], + freq: frequency[ + 'parameterCode'], duration: duration['id'], - itemCode: _selectedMedication.itemId, - strength: double.parse(strengthController.text), + itemCode: + _selectedMedication + .itemId, + strength: double.parse( + strengthController + .text), ); box = model.boxQuintity; @@ -582,38 +704,53 @@ class _PrescriptionFormWidgetState extends State { }); }, ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), Container( color: Colors.white, child: AppTextFieldCustom( hintText: "UOM", isTextFieldHasSuffix: false, - dropDownText: uom != null ? uom : null, + dropDownText: + uom != null ? uom : null, enabled: false, ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), Container( color: Colors.white, child: AppTextFieldCustom( - hintText: TranslationBase.of(context).boxQuantity, + hintText: + TranslationBase.of(context) + .boxQuantity, isTextFieldHasSuffix: false, - dropDownText: box != null ? model.boxQuintity.toString() : null, + dropDownText: box != null + ? model.boxQuintity.toString() + : null, enabled: false, ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: + HexColor("#CCCCCC"))), child: Stack( children: [ TextFields( maxLines: 6, minLines: 4, - hintText: TranslationBase.of(context).instruction, - controller: instructionController, + hintText: TranslationBase.of( + context) + .instruction, + controller: + instructionController, //keyboardType: TextInputType.number, ), Positioned( @@ -626,51 +763,77 @@ class _PrescriptionFormWidgetState extends State { size: 35, ), onPressed: () { - initSpeechState().then((value) => {onVoiceText()}); + initSpeechState().then( + (value) => + {onVoiceText()}); }, ), ), ], ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox( + height: spaceBetweenTextFileds), Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), child: Wrap( alignment: WrapAlignment.center, children: [ AppButton( color: Color(0xff359846), - title: TranslationBase.of(context).addMedication, + title: TranslationBase.of( + context) + .addMedication, fontWeight: FontWeight.w600, onPressed: () async { - await locator().logEvent( - eventCategory: "Add Prescription Form", - eventAction: "Add Prescription", + await locator< + AnalyticsService>() + .logEvent( + eventCategory: + "Add Prescription Form", + eventAction: + "Add Prescription", ); if (duration != null && doseTime != null && frequency != null && selectedDate != null && - strengthController.text != "") { - if (_selectedMedication.isNarcotic == true) { - DrAppToastMsg.showErrorToast(TranslationBase.of(context) - .narcoticMedicineCanOnlyBePrescribedFromVida); + strengthController + .text != + "") { + if (_selectedMedication + .isNarcotic == + true) { + DrAppToastMsg.showErrorToast( + TranslationBase.of( + context) + .narcoticMedicineCanOnlyBePrescribedFromVida); Navigator.pop(context); return; } - if (double.parse(strengthController.text) > 1000.0) { - DrAppToastMsg.showErrorToast( - "1000 is the MAX for the strength"); + if (double.parse( + strengthController + .text) > + 1000.0) { + DrAppToastMsg + .showErrorToast( + "1000 is the MAX for the strength"); return; } - if (double.parse(strengthController.text) < 0.0) { - DrAppToastMsg.showErrorToast("strength can't be zero"); + if (double.parse( + strengthController + .text) < + 0.0) { + DrAppToastMsg + .showErrorToast( + "strength can't be zero"); return; } - if (formKey.currentState.validate()) { + if (formKey.currentState + .validate()) { Navigator.pop(context); openDrugToDrug(model); { @@ -759,32 +922,52 @@ class _PrescriptionFormWidgetState extends State { } else { setState(() { if (duration == null) { - durationError = TranslationBase.of(context).fieldRequired; + durationError = + TranslationBase.of( + context) + .fieldRequired; } else { durationError = null; } if (doseTime == null) { - doseTimeError = TranslationBase.of(context).fieldRequired; + doseTimeError = + TranslationBase.of( + context) + .fieldRequired; } else { doseTimeError = null; } if (route == null) { - routeError = TranslationBase.of(context).fieldRequired; + routeError = + TranslationBase.of( + context) + .fieldRequired; } else { routeError = null; } if (frequency == null) { - frequencyError = TranslationBase.of(context).fieldRequired; + frequencyError = + TranslationBase.of( + context) + .fieldRequired; } else { frequencyError = null; } if (units == null) { - unitError = TranslationBase.of(context).fieldRequired; + unitError = + TranslationBase.of( + context) + .fieldRequired; } else { unitError = null; } - if (strengthController.text == "") { - strengthError = TranslationBase.of(context).fieldRequired; + if (strengthController + .text == + "") { + strengthError = + TranslationBase.of( + context) + .fieldRequired; } else { strengthError = null; } @@ -834,7 +1017,8 @@ class _PrescriptionFormWidgetState extends State { } } - InputDecoration textFieldSelectorDecoration(String hintText, String selectedText, bool isDropDown, + InputDecoration textFieldSelectorDecoration( + String hintText, String selectedText, bool isDropDown, {Icon suffixIcon}) { return InputDecoration( focusedBorder: OutlineInputBorder( @@ -885,7 +1069,9 @@ class _PrescriptionFormWidgetState extends State { child: Column( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - DrugToDrug(widget.patient, getPriscriptionforDrug(widget.prescriptionList, model), + DrugToDrug( + widget.patient, + getPriscriptionforDrug(widget.prescriptionList, model), model.patientAssessmentList), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), @@ -896,23 +1082,28 @@ class _PrescriptionFormWidgetState extends State { postPrescription( icdCode: model.patientAssessmentList.isNotEmpty - ? model.patientAssessmentList[0].icdCode10ID.isEmpty + ? model.patientAssessmentList[0].icdCode10ID + .isEmpty ? "test" - : model.patientAssessmentList[0].icdCode10ID.toString() + : model.patientAssessmentList[0].icdCode10ID + .toString() : "test", dose: strengthController.text, doseUnit: model.itemMedicineListUnit.length == 1 - ? model.itemMedicineListUnit[0]['parameterCode'].toString() + ? model.itemMedicineListUnit[0]['parameterCode'] + .toString() : units['parameterCode'].toString(), patient: widget.patient, doseTimeIn: doseTime['id'].toString(), model: widget.model, duration: duration['id'].toString(), frequency: model.itemMedicineList.length == 1 - ? model.itemMedicineList[0]['parameterCode'].toString() + ? model.itemMedicineList[0]['parameterCode'] + .toString() : frequency['parameterCode'].toString(), route: model.itemMedicineListRoute.length == 1 - ? model.itemMedicineListRoute[0]['parameterCode'].toString() + ? model.itemMedicineListRoute[0]['parameterCode'] + .toString() : route['parameterCode'].toString(), drugId: _selectedMedication.itemId.toString(), strength: strengthController.text, @@ -931,7 +1122,8 @@ class _PrescriptionFormWidgetState extends State { }); } - getPriscriptionforDrug(List prescriptionList, MedicineViewModel model) { + getPriscriptionforDrug( + List prescriptionList, MedicineViewModel model) { var prescriptionDetails = []; if (prescriptionList.length > 0) { prescriptionList[0].entityList.forEach((element) { diff --git a/pubspec.lock b/pubspec.lock index 3f1537d3..c20dff3c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -664,7 +664,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.2" + version: "0.6.3-nullsafety.1" json_annotation: dependency: transitive description: @@ -706,7 +706,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.4" mime: dependency: transitive description: @@ -1040,7 +1040,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.2" sticky_headers: dependency: "direct main" description: @@ -1245,5 +1245,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.2 <2.11.0" + dart: ">=2.10.2 <=2.11.0-213.1.beta" flutter: ">=1.22.2 <2.0.0"