From 994b43a59093c47088c85d2407cab574fbae7097 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Mon, 24 Jan 2022 13:07:39 +0200 Subject: [PATCH 01/25] Fix the form in prescription screen --- .../doctor_replay/doctor_reply_screen.dart | 12 +- .../In_patient/in_patient_screen.dart | 11 +- .../out_patient/out_patient_screen.dart | 11 +- .../referral/patient_referral_screen.dart | 17 +-- .../prescription/add_prescription_form.dart | 16 ++- lib/util/helpers.dart | 100 ---------------- lib/util/tab_helper.dart | 113 ++++++++++++++++++ .../shared/dialogs/dailog-list-select.dart | 2 +- 8 files changed, 151 insertions(+), 131 deletions(-) create mode 100644 lib/util/tab_helper.dart diff --git a/lib/screens/doctor/doctor_replay/doctor_reply_screen.dart b/lib/screens/doctor/doctor_replay/doctor_reply_screen.dart index 1583161a..685c4903 100644 --- a/lib/screens/doctor/doctor_replay/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_replay/doctor_reply_screen.dart @@ -5,7 +5,7 @@ import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; - +import 'package:doctor_app_flutter/util/tab_helper.dart'; import 'all_doctor_questions.dart'; import 'not_replaied_Doctor_Questions.dart'; @@ -72,7 +72,7 @@ class _DoctorReplyScreenState extends State preferredSize: Size.fromHeight( MediaQuery.of(context).size.height * 0.070), child: Container( - color: Helpers.getBgTabColor(), + color: TabHelper.getBgTabColor(), child: TabBar( isScrollable: false, controller: _tabController, @@ -136,8 +136,8 @@ Widget tabWidget( return Center( child: Container( - height: Helpers.getTabHeight(context), - decoration: Helpers.getBoxTabsBoxDecoration( + height: TabHelper.getTabHeight(context), + decoration: TabHelper.getBoxTabsBoxDecoration( isActive: isActive, isFirst: isFirst, isMiddle: isMiddle, @@ -146,9 +146,9 @@ Widget tabWidget( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Helpers.getTabText(title: title, isActive: isActive), + TabHelper.getTabText(title: title, isActive: isActive), if (counter != -1) - Helpers.getTabCounter(isActive: isActive, counter: counter) + TabHelper.getTabCounter(isActive: isActive, counter: counter) ], ), ), diff --git a/lib/screens/patients/In_patient/in_patient_screen.dart b/lib/screens/patients/In_patient/in_patient_screen.dart index a2ef497a..5f7aecf2 100644 --- a/lib/screens/patients/In_patient/in_patient_screen.dart +++ b/lib/screens/patients/In_patient/in_patient_screen.dart @@ -14,6 +14,7 @@ import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../../util/tab_helper.dart'; import '../DischargedPatientPage.dart'; import 'in_patient_list_page.dart'; @@ -123,7 +124,7 @@ class _InPatientScreenState extends State color: Colors.white), child: Container( margin: EdgeInsets.only(top: 9), - color: Helpers.getBgTabColor(), + color: TabHelper.getBgTabColor(), child: TabBar( isScrollable: false, controller: _tabController, @@ -214,8 +215,8 @@ class _InPatientScreenState extends State return Center( child: Container( - height: Helpers.getTabHeight(context), - decoration: Helpers.getBoxTabsBoxDecoration( + height: TabHelper.getTabHeight(context), + decoration: TabHelper.getBoxTabsBoxDecoration( isActive: isActive, isFirst: isFirst, isMiddle: isMiddle, @@ -224,9 +225,9 @@ class _InPatientScreenState extends State child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Helpers.getTabText(title: title, isActive: isActive), + TabHelper.getTabText(title: title, isActive: isActive), if (counter != -1) - Helpers.getTabCounter(isActive: isActive, counter: counter) + TabHelper.getTabCounter(isActive: isActive, counter: counter) ], ), ), diff --git a/lib/screens/patients/out_patient/out_patient_screen.dart b/lib/screens/patients/out_patient/out_patient_screen.dart index d6db782d..619bf32d 100644 --- a/lib/screens/patients/out_patient/out_patient_screen.dart +++ b/lib/screens/patients/out_patient/out_patient_screen.dart @@ -21,6 +21,7 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; +import '../../../util/tab_helper.dart'; import 'filter_date_page.dart'; // ignore: must_be_immutable @@ -102,8 +103,8 @@ class _OutPatientsScreenState extends State { children: [ Container( // color: Colors.red, - height: Helpers.getTabHeight(context), - color: Helpers.getBgTabColor(), + height: TabHelper.getTabHeight(context), + color: TabHelper.getBgTabColor(), child: Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, @@ -138,7 +139,7 @@ class _OutPatientsScreenState extends State { child: Center( child: Container( height: screenSize.height * 0.070, - decoration: Helpers.getBoxTabsBoxDecoration( + decoration: TabHelper.getBoxTabsBoxDecoration( isActive: _isActive, isFirst: _times.indexOf(item) == 0, isLast: @@ -150,12 +151,12 @@ class _OutPatientsScreenState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Helpers.getTabText( + TabHelper.getTabText( title: item, isActive: _isActive), _isActive && _activeLocation != 0 && model.state == ViewState.Idle - ? Helpers.getTabCounter( + ? TabHelper.getTabCounter( isActive: _isActive, counter: model.filterData.length) : Container(), diff --git a/lib/screens/patients/profile/referral/patient_referral_screen.dart b/lib/screens/patients/profile/referral/patient_referral_screen.dart index 687f1463..c620de1c 100644 --- a/lib/screens/patients/profile/referral/patient_referral_screen.dart +++ b/lib/screens/patients/profile/referral/patient_referral_screen.dart @@ -10,6 +10,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../../../util/tab_helper.dart'; import '../../ReferralDischargedPatientPage.dart'; import 'my-referral-inpatient-screen.dart'; @@ -60,8 +61,8 @@ class _PatientReferralScreen extends State Size.fromHeight(MediaQuery.of(context).size.height * 0.070), child: Center( child: Container( - height: Helpers.getTabHeight(context), - color: Helpers.getBgTabColor(), + height: TabHelper.getTabHeight(context), + color: TabHelper.getBgTabColor(), child: Center( child: TabBar( isScrollable: false, @@ -75,36 +76,36 @@ class _PatientReferralScreen extends State unselectedLabelColor: Colors.grey[800], tabs: [ Container( - decoration: Helpers.getBoxTabsBoxDecoration( + decoration: TabHelper.getBoxTabsBoxDecoration( isActive: index == 0, isFirst: true, projectViewModel: projectsProvider), child: Center( - child: Helpers.getTabText( + child: TabHelper.getTabText( title: TranslationBase.of(context) .myReferredPatient, isActive: index == 0)), ), Center( child: Container( - decoration: Helpers.getBoxTabsBoxDecoration( + decoration: TabHelper.getBoxTabsBoxDecoration( isActive: index == 1, isMiddle: true, projectViewModel: projectsProvider), child: Center( - child: Helpers.getTabText( + child: TabHelper.getTabText( title: TranslationBase.of(context).referral, isActive: index == 1)), ), ), Center( child: Container( - decoration: Helpers.getBoxTabsBoxDecoration( + decoration: TabHelper.getBoxTabsBoxDecoration( isActive: index == 2, isLast: true, projectViewModel: projectsProvider), child: Center( - child: Helpers.getTabText( + child: TabHelper.getTabText( title: TranslationBase.of(context).discharged, isActive: index == 2), ), diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index a8ee8cb8..f79f9ba3 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -405,16 +405,22 @@ class _PrescriptionFormWidgetState extends State { AppText( _selectedMedication?.description ?? "", - bold: true, + fontWeight: FontWeight.w600, + ), + SizedBox( + height: 15.0, ), Container( child: Row( + mainAxisAlignment: MainAxisAlignment.start, children: [ + SizedBox(width: 6,), AppText( TranslationBase.of(context) .orderType, - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w500, ), + SizedBox(width: 18,), Radio( activeColor: Color(0xFFB9382C), @@ -429,8 +435,6 @@ class _PrescriptionFormWidgetState extends State { ], ), ), - SizedBox( - height: spaceBetweenTextFileds), Container( width: double.infinity, child: Row( @@ -441,7 +445,7 @@ class _PrescriptionFormWidgetState extends State { .width * 0.35, child: AppTextFieldCustom( - //height: 40, + height: 38, validationError: strengthError, hintText: 'Strength', @@ -480,7 +484,7 @@ class _PrescriptionFormWidgetState extends State { element: model .itemMedicineListUnit .length == - 1 + 1 ? model .itemMedicineListUnit[0] : units, diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 3d9a0b1d..a91f36b1 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -327,107 +327,7 @@ class Helpers { return kpi; } - static getBoxTabsBoxDecoration( - {bool isFirst = false, - bool isMiddle = false, - bool isLast = false, - bool isActive = false, - double radius = 6.0, - ProjectViewModel projectViewModel}) { - return BoxDecoration( - color: isActive ? AppGlobal.appRedColor : Color(0xFFEAEAEA), - shape: BoxShape.rectangle, - borderRadius: BorderRadius.only( - topRight: projectViewModel.isArabic - ? Radius.circular(isActive - ? isLast || isMiddle - ? radius - : 0 - : 0) - : Radius.circular(isActive - ? isFirst || isMiddle - ? radius - : 0 - : 0), - topLeft: projectViewModel.isArabic - ? Radius.circular(isActive - ? isFirst || isMiddle - ? radius - : 0 - : 0) - : Radius.circular(isActive - ? isLast || isMiddle - ? radius - : 0 - : 0), - bottomRight: projectViewModel.isArabic - ? Radius.circular(isActive - ? isLast || isMiddle - ? radius - : 0 - : 0) - : Radius.circular(isActive - ? isFirst || isMiddle - ? radius - : 0 - : 0), - bottomLeft: projectViewModel.isArabic - ? Radius.circular(isActive - ? isFirst || isMiddle - ? radius - : 0 - : 0) - : Radius.circular(isActive - ? isLast || isMiddle - ? radius - : 0 - : 0)), - ); - } - - static getBgTabColor() { - return Color(0xFFEAEAEA); - } - - static getTabText({ - String title, - bool isActive = false, - }) { - return AppText( - title, - fontSize: SizeConfig.textMultiplier * 1.8, - color: isActive ? Colors.white : AppGlobal.appTextColor, - letterSpacing: -0.48, - fontWeight: FontWeight.w600, - ); - } - - static getTabHeight(BuildContext context) { - final screenSize = MediaQuery.of(context).size; - return screenSize.height * 0.07; - } - static getTabCounter({bool isActive: false, int counter}) { - return Container( - margin: EdgeInsets.all(4), - width: 15, - height: 15, - decoration: BoxDecoration( - color: isActive ? Colors.white : AppGlobal.appRedColor, - shape: BoxShape.circle, - ), - child: Center( - child: FittedBox( - child: AppText( - "$counter", - fontSize: SizeConfig.textMultiplier * 1.5, - color: !isActive ? Colors.white : AppGlobal.appRedColor, - fontWeight: FontWeight.w700, - ), - ), - ), - ); - } static String convertToTitleCase(String text) { if (text == null) { diff --git a/lib/util/tab_helper.dart b/lib/util/tab_helper.dart new file mode 100644 index 00000000..c4a023d4 --- /dev/null +++ b/lib/util/tab_helper.dart @@ -0,0 +1,113 @@ + +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +import '../config/config.dart'; +import '../config/size_config.dart'; +import '../core/viewModel/project_view_model.dart'; +import '../widgets/shared/app_texts_widget.dart'; + +class TabHelper { + + static getBoxTabsBoxDecoration( + {bool isFirst = false, + bool isMiddle = false, + bool isLast = false, + bool isActive = false, + double radius = 6.0, + ProjectViewModel projectViewModel}) { + return BoxDecoration( + color: isActive ? AppGlobal.appRedColor : Color(0xFFEAEAEA), + shape: BoxShape.rectangle, + borderRadius: BorderRadius.only( + topRight: projectViewModel.isArabic + ? Radius.circular(isActive + ? isLast || isMiddle + ? radius + : 0 + : 0) + : Radius.circular(isActive + ? isFirst || isMiddle + ? radius + : 0 + : 0), + topLeft: projectViewModel.isArabic + ? Radius.circular(isActive + ? isFirst || isMiddle + ? radius + : 0 + : 0) + : Radius.circular(isActive + ? isLast || isMiddle + ? radius + : 0 + : 0), + bottomRight: projectViewModel.isArabic + ? Radius.circular(isActive + ? isLast || isMiddle + ? radius + : 0 + : 0) + : Radius.circular(isActive + ? isFirst || isMiddle + ? radius + : 0 + : 0), + bottomLeft: projectViewModel.isArabic + ? Radius.circular(isActive + ? isFirst || isMiddle + ? radius + : 0 + : 0) + : Radius.circular(isActive + ? isLast || isMiddle + ? radius + : 0 + : 0)), + ); + } + + static getBgTabColor() { + return Color(0xFFEAEAEA); + } + + static getTabText({ + String title, + bool isActive = false, + }) { + return AppText( + title, + fontSize: SizeConfig.textMultiplier * 1.8, + color: isActive ? Colors.white : AppGlobal.appTextColor, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ); + } + + static getTabHeight(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + return screenSize.height * 0.07; + } + + static getTabCounter({bool isActive: false, int counter}) { + return Container( + margin: EdgeInsets.all(4), + width: 15, + height: 15, + decoration: BoxDecoration( + color: isActive ? Colors.white : AppGlobal.appRedColor, + shape: BoxShape.circle, + ), + child: Center( + child: FittedBox( + child: AppText( + "$counter", + fontSize: SizeConfig.textMultiplier * 1.5, + color: !isActive ? Colors.white : AppGlobal.appRedColor, + fontWeight: FontWeight.w700, + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/widgets/shared/dialogs/dailog-list-select.dart b/lib/widgets/shared/dialogs/dailog-list-select.dart index bebd644d..1030e2f9 100644 --- a/lib/widgets/shared/dialogs/dailog-list-select.dart +++ b/lib/widgets/shared/dialogs/dailog-list-select.dart @@ -104,7 +104,7 @@ class _ListSelectDialogState extends State { .selectedValue[widget.attributeValueId] .toString(), value: item[widget.attributeValueId].toString(), - activeColor: Colors.blue.shade700, + activeColor: Color(0xFFB9382C), selected: item[widget.attributeValueId] .toString() == widget.selectedValue[widget.attributeValueId] From 182f890e927c21be1be18bcdd55d213a8f658840 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Mon, 24 Jan 2022 15:36:33 +0200 Subject: [PATCH 02/25] Fix the form in prescription screen --- .../patients/insurance_approvals_details.dart | 6 +- .../out_patient/filter_date_page.dart | 4 +- .../profile/UCAF/page-stepper-widget.dart | 10 +- .../AddVerifyMedicalReport.dart | 4 +- .../profile/notes/note/update_note.dart | 2 +- .../update_operation_report.dart | 4 +- .../pharmacy_intervention_screen.dart | 3 +- .../refer-patient-screen-in-patient.dart | 2 +- .../bottom_sheet_dialog_button.dart | 4 +- .../steper/status_Label.dart | 4 +- .../steper/steps_widget.dart | 13 +- .../register_patient/RegisterPatientPage.dart | 4 +- .../prescription/add_prescription_form.dart | 37 ++- .../prescription_checkout_screen.dart | 2 +- .../procedures/add-favourite-procedure.dart | 3 +- .../procedures/add-procedure-page.dart | 3 +- .../procedures/procedure_checkout_screen.dart | 4 +- lib/screens/procedures/update-procedure.dart | 2 +- lib/widgets/patients/dynamic_elements.dart | 166 ------------ lib/widgets/shared/doctor_card_insurance.dart | 6 +- .../shared/text_fields/new_text_Field.dart | 237 ------------------ 21 files changed, 87 insertions(+), 433 deletions(-) delete mode 100644 lib/widgets/patients/dynamic_elements.dart delete mode 100644 lib/widgets/shared/text_fields/new_text_Field.dart diff --git a/lib/screens/patients/insurance_approvals_details.dart b/lib/screens/patients/insurance_approvals_details.dart index de530c3d..708c5549 100644 --- a/lib/screens/patients/insurance_approvals_details.dart +++ b/lib/screens/patients/insurance_approvals_details.dart @@ -14,6 +14,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../config/config.dart'; + class InsuranceApprovalsDetails extends StatefulWidget { PatiantInformtion patient; int indexInsurance; @@ -106,7 +108,7 @@ class _InsuranceApprovalsDetailsState extends State { "Approved" || "${model.insuranceApprovalInPatient[indexInsurance].approvalStatusDescption}" == "تمت الموافقة" - ? Color(0xff359846) + ? AppGlobal.appGreenColor : Color(0xffD02127) : Color(0xffD02127), letterSpacing: -0.4, @@ -484,7 +486,7 @@ class _InsuranceApprovalsDetailsState extends State { null ? "${model.insuranceApproval[indexInsurance].approvalStatusDescption}" == "Approved" - ? Color(0xff359846) + ? AppGlobal.appGreenColor : Color(0xffD02127) : Color(0xffD02127), ), diff --git a/lib/screens/patients/out_patient/filter_date_page.dart b/lib/screens/patients/out_patient/filter_date_page.dart index 14ae707b..d03f19ee 100644 --- a/lib/screens/patients/out_patient/filter_date_page.dart +++ b/lib/screens/patients/out_patient/filter_date_page.dart @@ -12,6 +12,8 @@ import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../../config/config.dart'; + class FilterDatePage extends StatefulWidget { final OutPatientFilterType outPatientFilterType; final PatientSearchViewModel patientSearchViewModel; @@ -144,7 +146,7 @@ class _FilterDatePageState extends State { child: AppButton( title: TranslationBase.of(context).search, padding: 10, - color: Color(0xFF359846), + color: AppGlobal.appGreenColor, onPressed: () async { if (widget.patientSearchViewModel.selectedFromDate == null || diff --git a/lib/screens/patients/profile/UCAF/page-stepper-widget.dart b/lib/screens/patients/profile/UCAF/page-stepper-widget.dart index 628f6663..d43dafb2 100644 --- a/lib/screens/patients/profile/UCAF/page-stepper-widget.dart +++ b/lib/screens/patients/profile/UCAF/page-stepper-widget.dart @@ -3,6 +3,8 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; +import '../../../../config/config.dart'; + /// * /// By Mousa Zaid Mousa Abuzaid /// At 13/4/2021 @@ -102,14 +104,14 @@ class StepWidget extends StatelessWidget { ? Color(0xFFCC9B14) : status == StepStatus.Locked ? Color(0xFFE3E3E3) - : Color(0xFF359846), + : AppGlobal.appGreenColor, shape: BoxShape.circle, border: Border.all( color: status == StepStatus.InProgress ? Color(0xFFCC9B14) : status == StepStatus.Locked ? Color(0xFFE3E3E3) - : Color(0xFF359846), + : AppGlobal.appGreenColor, width: 1), ), child: Center( @@ -127,7 +129,7 @@ class StepWidget extends StatelessWidget { width: dividerWidth, height: 2, color: status == StepStatus.Completed - ? Color(0xFF359846) + ? AppGlobal.appGreenColor : Color(0xFFCCCCCC), ), ], @@ -178,7 +180,7 @@ class StepWidget extends StatelessWidget { ? Color(0xFFCC9B14) : status == StepStatus.Locked ? Color(0xFF969696) - : Color(0xFF359846), + : AppGlobal.appGreenColor, ), ) ], diff --git a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart index 9bd1da29..18452142 100644 --- a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart +++ b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; import 'package:html_editor_enhanced/html_editor.dart'; import 'package:permission_handler/permission_handler.dart'; +import '../../../../config/config.dart'; + class AddVerifyMedicalReport extends StatefulWidget { final PatiantInformtion patient; final String patientType; @@ -157,7 +159,7 @@ class _AddVerifyMedicalReportState extends State { title: widget.status == MedicalReportStatus.ADD ? TranslationBase.of(context).add : TranslationBase.of(context).verify, - color: Color(0xff359846), + color: AppGlobal.appGreenColor, fontWeight: FontWeight.w700, onPressed: () async { txtOfMedicalReport = diff --git a/lib/screens/patients/profile/notes/note/update_note.dart b/lib/screens/patients/profile/notes/note/update_note.dart index 85b33f5e..4f0f9d58 100644 --- a/lib/screens/patients/profile/notes/note/update_note.dart +++ b/lib/screens/patients/profile/notes/note/update_note.dart @@ -201,7 +201,7 @@ class _UpdateNoteOrderState extends State { ? TranslationBase.of(context).noteUpdate : TranslationBase.of(context).noteAdd) + TranslationBase.of(context).progressNote, - color: Color(0xff359846), + color: AppGlobal.appGreenColor, // disabled: progressNoteController.text.isEmpty, fontWeight: FontWeight.w700, onPressed: () async { diff --git a/lib/screens/patients/profile/operation_report/update_operation_report.dart b/lib/screens/patients/profile/operation_report/update_operation_report.dart index 12f6739c..1abefd75 100644 --- a/lib/screens/patients/profile/operation_report/update_operation_report.dart +++ b/lib/screens/patients/profile/operation_report/update_operation_report.dart @@ -20,6 +20,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; +import '../../../../config/config.dart'; + class UpdateOperationReport extends StatefulWidget { final GetReservationsResponseModel reservation; @@ -532,7 +534,7 @@ class _UpdateOperationReportState extends State { : TranslationBase.of(context).noteAdd) + " " + TranslationBase.of(context).operationReports, - color: Color(0xff359846), + color: AppGlobal.appGreenColor, // disabled: operationReportsController.text.isEmpty, fontWeight: FontWeight.w700, onPressed: () async { diff --git a/lib/screens/patients/profile/pharmacy-intervention/pharmacy_intervention_screen.dart b/lib/screens/patients/profile/pharmacy-intervention/pharmacy_intervention_screen.dart index 96ae8052..09136556 100644 --- a/lib/screens/patients/profile/pharmacy-intervention/pharmacy_intervention_screen.dart +++ b/lib/screens/patients/profile/pharmacy-intervention/pharmacy_intervention_screen.dart @@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dar import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../../../config/config.dart'; import '../../../../core/viewModel/profile/intervention_medication_view_model.dart'; import '../../../../models/patient/patiant_info_model.dart'; import '../../../base/base_view.dart'; @@ -163,7 +164,7 @@ class _PharmacyInterventionScreenState child: AppButton( title: TranslationBase.of(context).search, padding: 5, - color: Color(0xFF359846), + color: AppGlobal.appGreenColor, onPressed: () async { Navigator.push( context, diff --git a/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart b/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart index 500378f9..12c27fe5 100644 --- a/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart +++ b/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart @@ -515,7 +515,7 @@ class _PatientMakeInPatientReferralScreenState child: AppButton( title: TranslationBase.of(context).refer, fontWeight: FontWeight.w700, - color: Color(0XFF359846), + color: AppGlobal.appGreenColor, onPressed: () async { setState(() { if (_referTo == null) { diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart index 92275fb4..440e1e3e 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart @@ -3,6 +3,8 @@ import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dar import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../../../../config/config.dart'; + class BottomSheetDialogButton extends StatelessWidget { final Function onTap; final String label; @@ -33,7 +35,7 @@ class BottomSheetDialogButton extends StatelessWidget { child: Center( child: AppButton( title: label, - color: Color(0xFF359846), + color: AppGlobal.appGreenColor, onPressed: onTap, ), ), diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/steper/status_Label.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/steper/status_Label.dart index d43168e3..95b3d061 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/steper/status_Label.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/steper/status_Label.dart @@ -4,6 +4,8 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../../../../../config/config.dart'; + class StatusLabel extends StatelessWidget { const StatusLabel({ Key key, @@ -43,7 +45,7 @@ class StatusLabel extends StatelessWidget { color: stepId == selectedStepId ? Color(0xFFCC9B14) : stepId < selectedStepId - ? Color(0xFF359846) + ? AppGlobal.appGreenColor : Color(0xFF969696), ), ), diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/steper/steps_widget.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/steper/steps_widget.dart index bd31e4ce..38c3f481 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/steper/steps_widget.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/steper/steps_widget.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; +import '../../../../../../config/config.dart'; import 'Step_details_widget.dart'; class StepsWidget extends StatelessWidget { @@ -85,7 +86,7 @@ class StepsWidget extends StatelessWidget { color: index == 0 ? Color(0xFFCC9B14) : index > 0 - ? Color(0xFF359846) + ? AppGlobal.appGreenColor : Color(0xFFCCCCCC), ), child: Center( @@ -137,7 +138,7 @@ class StepsWidget extends StatelessWidget { color: index == 1 ? Color(0xFFCC9B14) : index > 1 - ? Color(0xFF359846) + ? AppGlobal.appGreenColor : Color(0xFFCCCCCC), ), child: Center( @@ -192,7 +193,7 @@ class StepsWidget extends StatelessWidget { color: index == 2 ? Color(0xFFCC9B14) : index > 2 - ? Color(0xFF359846) + ? AppGlobal.appGreenColor : Color(0xFFCCCCCC), ), child: Center( @@ -245,7 +246,7 @@ class StepsWidget extends StatelessWidget { color: index == 3 ? Color(0xFFCC9B14) : index > 3 - ? Color(0xFF359846) + ? AppGlobal.appGreenColor : Color(0xFFCCCCCC), ), child: Center( @@ -323,7 +324,7 @@ class StepsWidget extends StatelessWidget { color: index == 0 ? Color(0xFFCC9B14) : index > 0 - ? Color(0xFF359846) + ? AppGlobal.appGreenColor : Color(0xFFCCCCCC), ), child: Center( @@ -375,7 +376,7 @@ class StepsWidget extends StatelessWidget { color: index == 1 ? Color(0xFFCC9B14) : index > 1 - ? Color(0xFF359846) + ? AppGlobal.appGreenColor : Color(0xFFCCCCCC), ), child: Center( diff --git a/lib/screens/patients/register_patient/RegisterPatientPage.dart b/lib/screens/patients/register_patient/RegisterPatientPage.dart index 59747e37..671511b9 100644 --- a/lib/screens/patients/register_patient/RegisterPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterPatientPage.dart @@ -158,8 +158,8 @@ class _RegisterPatientPageState extends State hasBorder: true, vPadding: 12, hPadding: 8, - borderColor: Color(0xFF359846), - color: Color(0xFF359846), + borderColor: AppGlobal.appGreenColor, + color: AppGlobal.appGreenColor, fontColor: Colors.white, onPressed: () {}, ), diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index f79f9ba3..d10124f9 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -118,6 +118,7 @@ class _PrescriptionFormWidgetState extends State { int selectedType; TextEditingController strengthController = TextEditingController(); + TextEditingController unitController = TextEditingController(); TextEditingController indicationController = TextEditingController(); TextEditingController instructionController = TextEditingController(); @@ -476,6 +477,40 @@ class _PrescriptionFormWidgetState extends State { SizedBox( width: 5.0, ), + // Container( + // width: MediaQuery.of(context) + // .size + // .width * + // 0.35, + // child: AppTextFieldCustom( + // height: 38, + // validationError: + // unitError, + // hintText: 'Unit', + // isTextFieldHasSuffix: false, + // enabled: true, + // controller: + // unitController, + // onChanged: (selectedValue) { + // setState(() { + // units = selectedValue; + // units['isDefault'] = true; + // }); + // if (strengthChar >= 5) { + // DrAppToastMsg + // .showErrorToast( + // TranslationBase.of( + // context) + // .only5DigitsAllowedForStrength, + // ); + // } + // }, + // inputType: TextInputType + // .numberWithOptions( + // decimal: true, + // ), + // ), + // ), PrescriptionTextFiled( width: MediaQuery.of(context) .size @@ -484,7 +519,7 @@ class _PrescriptionFormWidgetState extends State { element: model .itemMedicineListUnit .length == - 1 + 1 ? model .itemMedicineListUnit[0] : units, diff --git a/lib/screens/prescription/prescription_checkout_screen.dart b/lib/screens/prescription/prescription_checkout_screen.dart index f94c3b52..997a7554 100644 --- a/lib/screens/prescription/prescription_checkout_screen.dart +++ b/lib/screens/prescription/prescription_checkout_screen.dart @@ -638,7 +638,7 @@ class _PrescriptionCheckOutScreenState alignment: WrapAlignment.center, children: [ AppButton( - color: Color(0xff359846), + color: AppGlobal.appGreenColor, title: TranslationBase.of(context) .addMedication, fontWeight: FontWeight.w600, diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index 0a2a943e..2a218ff0 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -16,6 +16,7 @@ import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../config/config.dart'; import 'ProcedureType.dart'; class AddFavouriteProcedure extends StatefulWidget { @@ -100,7 +101,7 @@ class _AddFavouriteProcedureState extends State { AppButton( title: widget.procedureType.getAddButtonTitle(context) ?? TranslationBase.of(context).addSelectedProcedures, - color: Color(0xff359846), + color: AppGlobal.appGreenColor, disabled: model.templateList.length == 0 ? true : false, fontWeight: FontWeight.w700, onPressed: () { diff --git a/lib/screens/procedures/add-procedure-page.dart b/lib/screens/procedures/add-procedure-page.dart index e0b7374f..df4c3c37 100644 --- a/lib/screens/procedures/add-procedure-page.dart +++ b/lib/screens/procedures/add-procedure-page.dart @@ -12,6 +12,7 @@ import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; +import '../../config/config.dart'; import 'ProcedureType.dart'; import 'entity_list_checkbox_search_widget.dart'; @@ -183,7 +184,7 @@ class _AddProcedurePageState extends State { AppButton( title: procedureType.getAddButtonTitle(context), fontWeight: FontWeight.w700, - color: Color(0xff359846), + color: AppGlobal.appGreenColor, onPressed: () async { if (entityList.isEmpty == true) { DrAppToastMsg.showErrorToast( diff --git a/lib/screens/procedures/procedure_checkout_screen.dart b/lib/screens/procedures/procedure_checkout_screen.dart index 7c8b1074..9ce5b898 100644 --- a/lib/screens/procedures/procedure_checkout_screen.dart +++ b/lib/screens/procedures/procedure_checkout_screen.dart @@ -14,6 +14,8 @@ import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dar import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../config/config.dart'; + class ProcedureCheckOutScreen extends StatefulWidget { final List items; final ProcedureViewModel model; @@ -214,7 +216,7 @@ class _ProcedureCheckOutScreenState extends State { AppButton( title: widget.addButtonTitle ?? TranslationBase.of(context).addSelectedProcedures, - color: Color(0xff359846), + color: AppGlobal.appGreenColor, fontWeight: FontWeight.w700, onPressed: () async { List entityList = List(); diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart index a1f3615e..0bf6a872 100644 --- a/lib/screens/procedures/update-procedure.dart +++ b/lib/screens/procedures/update-procedure.dart @@ -297,7 +297,7 @@ class _UpdateProcedureWidgetState extends State { //alignment: WrapAlignment.center, children: [ AppButton( - color: Color(0xff359846), + color: AppGlobal.appGreenColor, title: TranslationBase.of(context) .updateProcedure .toUpperCase(), diff --git a/lib/widgets/patients/dynamic_elements.dart b/lib/widgets/patients/dynamic_elements.dart deleted file mode 100644 index bca60f5b..00000000 --- a/lib/widgets/patients/dynamic_elements.dart +++ /dev/null @@ -1,166 +0,0 @@ -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/models/patient/patient_model.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; -import 'package:doctor_app_flutter/widgets/shared/user-guid/custom_validation_error.dart'; -import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:intl/intl.dart'; - -class DynamicElements extends StatefulWidget { - final PatientModel _patientSearchFormValues; - final bool isFormSubmitted; - - DynamicElements(this._patientSearchFormValues, this.isFormSubmitted); - - @override - _DynamicElementsState createState() => _DynamicElementsState(); -} - -class _DynamicElementsState extends State { - TextEditingController _toDateController = new TextEditingController(); - TextEditingController _fromDateController = new TextEditingController(); - - void _presentDatePicker(id) { - showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(2019), - lastDate: DateTime.now(), - ).then((pickedDate) { - if (pickedDate == null) { - return; - } - setState(() { - print(id); - var selectedDate = DateFormat.yMd().format(pickedDate); - - if (id == '_selectedFromDate') { - // _fromDateController.text = selectedDate; - selectedDate = pickedDate.year.toString() + - "-" + - pickedDate.month.toString().padLeft(2, '0') + - "-" + - pickedDate.day.toString().padLeft(2, '0'); - - _fromDateController.text = selectedDate; - } else { - selectedDate = pickedDate.year.toString() + - "-" + - pickedDate.month.toString().padLeft(2, '0') + - "-" + - pickedDate.day.toString().padLeft(2, '0'); - - _toDateController.text = selectedDate; - // _toDateController.text = selectedDate; - } - }); - }); - } - - @override - Widget build(BuildContext context) { - final screenSize = MediaQuery.of(context).size; - InputDecoration textFieldSelectorDecoration( - {String hintText, - String selectedText, - bool isDropDown, - IconData icon}) { - return InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(icon ?? Icons.arrow_drop_down) : null, - hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.shade600, - ), - ); - } - - return LayoutBuilder( - builder: (ctx, constraints) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 10, - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - borderColor: Colors.white, - onTap: () => _presentDatePicker('_selectedFromDate'), - hintText: TranslationBase.of(context).fromDate, - controller: _fromDateController, - inputFormatter: ONLY_DATE, - onSaved: (value) { - if (_fromDateController.text.toString().trim().isEmpty) { - widget._patientSearchFormValues.From = "0"; - } else { - widget._patientSearchFormValues.From = - _fromDateController.text.replaceAll("/", "-"); - } - }, - readOnly: true, - )), - SizedBox( - height: 5, - ), - if (widget._patientSearchFormValues.From == "0" && - widget.isFormSubmitted) - CustomValidationError(), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - borderRadius: BorderRadius.all(Radius.circular(6.0))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - readOnly: true, - borderColor: Colors.white, - hintText: TranslationBase.of(context).toDate, - controller: _toDateController, - onTap: () { - _presentDatePicker('_selectedToDate'); - }, - inputFormatter: ONLY_DATE, - onSaved: (value) { - if (_toDateController.text.toString().trim().isEmpty) { - widget._patientSearchFormValues.To = "0"; - } else { - widget._patientSearchFormValues.To = - _toDateController.text.replaceAll("/", "-"); - } - }, - )), - if (widget._patientSearchFormValues.To == "0" && - widget.isFormSubmitted) - CustomValidationError(), - SizedBox( - height: 10, - ), - ], - ); - }, - ); - } -} diff --git a/lib/widgets/shared/doctor_card_insurance.dart b/lib/widgets/shared/doctor_card_insurance.dart index abb8efcc..dbcd8556 100644 --- a/lib/widgets/shared/doctor_card_insurance.dart +++ b/lib/widgets/shared/doctor_card_insurance.dart @@ -9,6 +9,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../config/config.dart'; + class DoctorCardInsurance extends StatelessWidget { final String doctorName; final String approvalNo; @@ -63,7 +65,7 @@ class DoctorCardInsurance extends StatelessWidget { ), color: approvalStatus == "Approved" || approvalStatus == "تمت الموافقة" - ? Color(0xff359846) + ? AppGlobal.appGreenColor : Color(0xffD02127), ), ), @@ -84,7 +86,7 @@ class DoctorCardInsurance extends StatelessWidget { "$approvalStatus", color: approvalStatus == "Approved" || approvalStatus == "تمت الموافقة" - ? Color(0xff359846) + ? AppGlobal.appGreenColor : Color(0xffD02127), letterSpacing: -0.4, fontSize: diff --git a/lib/widgets/shared/text_fields/new_text_Field.dart b/lib/widgets/shared/text_fields/new_text_Field.dart deleted file mode 100644 index 77cd0262..00000000 --- a/lib/widgets/shared/text_fields/new_text_Field.dart +++ /dev/null @@ -1,237 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:hexcolor/hexcolor.dart'; - -class NumberTextInputFormatter extends TextInputFormatter { - @override - TextEditingValue formatEditUpdate( - TextEditingValue oldValue, TextEditingValue newValue) { - final int newTextLength = newValue.text.length; - int selectionIndex = newValue.selection.end; - int usedSubstringIndex = 0; - final StringBuffer newText = StringBuffer(); - if (newTextLength >= 1) { - newText.write('('); - if (newValue.selection.end >= 1) selectionIndex++; - } - if (newTextLength >= 4) { - newText.write(newValue.text.substring(0, usedSubstringIndex = 3) + ') '); - if (newValue.selection.end >= 3) selectionIndex += 2; - } - if (newTextLength >= 7) { - newText.write(newValue.text.substring(3, usedSubstringIndex = 6) + '-'); - if (newValue.selection.end >= 6) selectionIndex++; - } - if (newTextLength >= 11) { - newText.write(newValue.text.substring(6, usedSubstringIndex = 10) + ' '); - if (newValue.selection.end >= 10) selectionIndex++; - } - // Dump the rest. - if (newTextLength >= usedSubstringIndex) - newText.write(newValue.text.substring(usedSubstringIndex)); - return TextEditingValue( - text: newText.toString(), - selection: TextSelection.collapsed(offset: selectionIndex), - ); - } -} - -final _mobileFormatter = NumberTextInputFormatter(); - -class NewTextFields extends StatefulWidget { - NewTextFields( - {Key key, - this.type, - this.hintText, - this.suffixIcon, - this.autoFocus, - this.onChanged, - this.initialValue, - this.minLines, - this.maxLines, - this.inputFormatters, - this.padding, - this.focus = false, - this.maxLengthEnforced = true, - this.suffixIconColor, - this.inputAction, - this.onSubmit, - this.keepPadding = true, - this.textCapitalization = TextCapitalization.none, - this.controller, - this.keyboardType, - this.validator, - this.borderOnlyError = false, - this.onSaved, - this.onSuffixTap, - this.readOnly: false, - this.maxLength, - this.prefixIcon, - this.bare = false, - this.onTap, - this.fontSize = 15.0, - this.fontWeight = FontWeight.w500, - this.autoValidate = false, - this.hintColor, - this.isEnabled = true}) - : super(key: key); - - final String hintText; - - // final String initialValue; - final String type; - final bool autoFocus; - final IconData suffixIcon; - final Color suffixIconColor; - final Icon prefixIcon; - final VoidCallback onTap; - final TextEditingController controller; - final TextInputType keyboardType; - final FormFieldValidator validator; - final Function onSaved; - final Function onSuffixTap; - final Function onChanged; - final Function onSubmit; - final bool readOnly; - final int maxLength; - final int minLines; - final int maxLines; - final bool maxLengthEnforced; - final bool bare; - final bool isEnabled; - final TextInputAction inputAction; - final double fontSize; - final FontWeight fontWeight; - final bool keepPadding; - final TextCapitalization textCapitalization; - final List inputFormatters; - final bool autoValidate; - final EdgeInsets padding; - final bool focus; - final bool borderOnlyError; - final Color hintColor; - final String initialValue; - - @override - _NewTextFieldsState createState() => _NewTextFieldsState(); -} - -class _NewTextFieldsState extends State { - final FocusNode _focusNode = FocusNode(); - bool focus = false; - bool view = false; - - @override - void initState() { - super.initState(); - _focusNode.addListener(() { - setState(() { - focus = _focusNode.hasFocus; - }); - }); - } - - @override - void didUpdateWidget(NewTextFields oldWidget) { - if (widget.focus) _focusNode.requestFocus(); - super.didUpdateWidget(oldWidget); - } - - @override - void dispose() { - _focusNode.dispose(); - super.dispose(); - } - - bool _determineReadOnly() { - if (widget.readOnly != null && widget.readOnly) { - _focusNode.unfocus(); - return true; - } else { - return false; - } - } - - @override - Widget build(BuildContext context) { - return AnimatedContainer( - duration: Duration(milliseconds: 300), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(color: HexColor('#707070'), width: 0.30), - color: Colors.white), - child: Container( - margin: EdgeInsets.only(top: 8), - padding: EdgeInsets.only(top: 8), - child: TextFormField( - enabled: widget.isEnabled, - initialValue: widget.initialValue, - keyboardAppearance: Theme.of(context).brightness, - scrollPhysics: BouncingScrollPhysics(), - // autovalidate: widget.autoValidate, - textCapitalization: widget.textCapitalization, - onFieldSubmitted: widget.inputAction == TextInputAction.next - ? (widget.onSubmit != null - ? widget.onSubmit - : (val) { - _focusNode.nextFocus(); - }) - : widget.onSubmit, - textInputAction: widget.inputAction, - minLines: widget.minLines ?? 1, - maxLines: widget.maxLines ?? 1, - maxLengthEnforced: widget.maxLengthEnforced, - onChanged: widget.onChanged, - focusNode: _focusNode, - maxLength: widget.maxLength ?? null, - controller: widget.controller, - keyboardType: widget.keyboardType, - readOnly: _determineReadOnly(), - obscureText: widget.type == "password" && !view ? true : false, - autofocus: widget.autoFocus ?? false, - validator: widget.validator, - onSaved: widget.onSaved, - style: Theme.of(context).textTheme.bodyText1.copyWith( - fontSize: widget.fontSize, - fontWeight: widget.fontWeight, - color: Color(0xFF575757), - fontFamily: 'Poppins'), - inputFormatters: widget.keyboardType == TextInputType.phone - ? [ - // WhitelistingTextInputFormatter.digitsOnly, - _mobileFormatter, - ] - : widget.inputFormatters, - decoration: InputDecoration( - labelText: widget.hintText, - labelStyle: TextStyle( - color: Color(0xFF2E303A), - fontSize: 15, - fontWeight: FontWeight.w700), - errorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context).errorColor.withOpacity(0.5), - width: 1.0), - borderRadius: BorderRadius.circular(12.0)), - focusedErrorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context).errorColor.withOpacity(0.5), - width: 1.0), - borderRadius: BorderRadius.circular(8.0)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.white, width: 1.0), - borderRadius: BorderRadius.circular(12)), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.white, width: 1.0), - borderRadius: BorderRadius.circular(12)), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.white, width: 1.0), - borderRadius: BorderRadius.circular(12), - ), - ), - ), - ), - ); - } -} From 7afe24c2bc1644a01dcec9dd1aab4d27d08aff03 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Tue, 25 Jan 2022 16:53:36 +0200 Subject: [PATCH 03/25] Refactor add_prescription_form --- lib/core/viewModel/medicine_view_model.dart | 91 ++++ .../live-care_transfer_to_admin.dart | 10 +- .../medicine/medicine_search_screen.dart | 6 +- .../profile/notes/note/update_note.dart | 10 +- .../update_operation_report.dart | 2 +- .../referral/AddReplayOnReferralPatient.dart | 10 +- .../refer-patient-screen-in-patient.dart | 10 +- .../add_prescription_form.dart | 428 +++++++++--------- .../{ => add_prescription}/drugtodrug.dart | 0 .../update_prescription_form.dart | 0 .../prescription_authorazation_form.dart | 1 - .../prescription_checkout_screen.dart | 46 +- .../prescription_details_page.dart | 168 ------- .../prescription/prescription_items_page.dart | 3 + .../prescription/prescription_warnings.dart | 168 ------- .../prescription/prescriptions_page.dart | 3 +- .../base_add_procedure_tab_page.dart | 2 +- .../entity_list_checkbox_search_widget.dart | 4 +- .../procedures/entity_list_fav_procedure.dart | 3 +- lib/screens/procedures/update-procedure.dart | 4 +- .../shared/dialogs/dailog-list-select.dart | 4 +- .../shared/text_fields/html_rich_editor.dart | 2 +- 22 files changed, 358 insertions(+), 617 deletions(-) rename lib/screens/prescription/{ => add_prescription}/add_prescription_form.dart (85%) rename lib/screens/prescription/{ => add_prescription}/drugtodrug.dart (100%) rename lib/screens/prescription/{ => add_prescription}/update_prescription_form.dart (100%) delete mode 100644 lib/screens/prescription/prescription_authorazation_form.dart delete mode 100644 lib/screens/prescription/prescription_details_page.dart delete mode 100644 lib/screens/prescription/prescription_warnings.dart diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 6b63d999..7505265e 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/prescription/medicine_service.dart'; @@ -7,12 +8,20 @@ import 'package:doctor_app_flutter/core/service/patient_medical_file/prescriptio import 'package:doctor_app_flutter/core/service/patient_medical_file/procedure/procedure_service.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; +import 'package:flutter/cupertino.dart'; import '../../locator.dart'; +import '../model/Prescriptions/prescription_model.dart'; import 'base_view_model.dart'; class MedicineViewModel extends BaseViewModel { bool hasError = false; + // dynamic route; + // dynamic frequency; + // dynamic duration; + // dynamic units; + + MedicineService _medicineService = locator(); ProcedureService _procedureService = locator(); PrescriptionService _prescriptionService = locator(); @@ -21,6 +30,8 @@ class MedicineViewModel extends BaseViewModel { _procedureService.templateList; List templateList = List(); + GetMedicationResponseModel _selectedMedication; + get pharmacyItemsList => _medicineService.pharmacyItemsList; get searchText => _medicineService.searchText; @@ -56,6 +67,10 @@ class MedicineViewModel extends BaseViewModel { List get itemMedicineListUnit => _prescriptionService.itemMedicineListUnit; + + + + Future getItem({int itemID}) async { //hasError = false; //_insuranceCardService.clearInsuranceCard(); @@ -90,6 +105,82 @@ class MedicineViewModel extends BaseViewModel { print(templateList.length.toString()); } + + + + getPrescriptionForDrug( + List prescriptionList, + MedicineViewModel model, + ) { + var prescriptionDetails = []; + if (prescriptionList.length > 0) { + prescriptionList[0].entityList.forEach((element) { + if (element.mediSpanGPICode != null) { + prescriptionDetails.add({ + 'DrugId': element.mediSpanGPICode, + 'DrugName': element.medicationName, + 'Dose': element.doseDailyQuantity, + 'DoseType': element.doseDailyUnitID, + 'Unit': element.uom, + 'FrequencyType': element.frequencyID, + 'Duration': element.doseDurationDays, + 'RouteID': element.routeID, + 'IsScreen': element.isSIG + }); + } + }); + } + // if (_selectedMedication.mediSpanGPICode != null) { + // prescriptionDetails.add({ + // 'DrugId': _selectedMedication.mediSpanGPICode, + // 'DrugName': _selectedMedication.description, + // // 'Dose': strengthController.text, + // 'DoseType': model.itemMedicineListUnit.length == 1 + // ? model.itemMedicineListUnit[0]['parameterCode'].toString() + // : units['parameterCode'].toString(), + // 'Unit': model.itemMedicineListUnit.length == 1 + // ? model.itemMedicineListUnit[0]['description'] + // : units['description'], + // 'FrequencyType': model.itemMedicineList.length == 1 + // ? model.itemMedicineList[0]['parameterCode'].toString() + // : frequency['parameterCode'].toString(), + // 'Duration': duration['id'].toString(), + // 'RouteID': model.itemMedicineListRoute.length == 1 + // ? model.itemMedicineListRoute[0]['parameterCode'].toString() + // : route['parameterCode'].toString(), + // 'IsScreen': true + // }); + // } + return prescriptionDetails; + } + + + + Future getAssessmentList ({ + PatiantInformtion patientInfo, + bool isBusyLocal = false + }) async { + patientAssessmentList.map((element) { + return element.icdCode10ID; + }); + GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( + patientMRN: patientInfo.patientMRN, + episodeID: patientInfo.episodeNo.toString(), + editedBy: '', + doctorID: '', + appointmentNo: patientInfo.appointmentNo); + if (medicationStrengthList.length == 0) { + await getMedicationStrength(); + } + if (medicationDurationList.length == 0) { + await getMedicationDuration(); + } + if (medicationDoseTimeList.length == 0) { + await getMedicationDoseTime(); + } + await getPatientAssessment(getAssessmentReqModel); + } + Future getProcedureTemplate({String categoryID}) async { hasError = false; setState(ViewState.Busy); diff --git a/lib/screens/live_care/live-care_transfer_to_admin.dart b/lib/screens/live_care/live-care_transfer_to_admin.dart index 921666e8..4cd9a3a0 100644 --- a/lib/screens/live_care/live-care_transfer_to_admin.dart +++ b/lib/screens/live_care/live-care_transfer_to_admin.dart @@ -32,7 +32,7 @@ class LivaCareTransferToAdmin extends StatefulWidget { class _LivaCareTransferToAdminState extends State { stt.SpeechToText speech = stt.SpeechToText(); - var reconizedWord; + var recognizedWord; var event = RobotProvider(); ProjectViewModel projectViewModel; @@ -168,7 +168,7 @@ class _LivaCareTransferToAdminState extends State { } void statusListener(String status) { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } void requestPermissions() async { @@ -178,14 +178,14 @@ class _LivaCareTransferToAdminState extends State { } void resultListener(result) { - reconizedWord = result.recognizedWords; - event.setValue({"searchText": reconizedWord}); + recognizedWord = result.recognizedWords; + event.setValue({"searchText": recognizedWord}); if (result.finalResult == true) { setState(() { SpeechToText.closeAlertDialog(context); speech.stop(); - noteController.text += reconizedWord + '\n'; + noteController.text += recognizedWord + '\n'; }); } else { print(result.finalResult); diff --git a/lib/screens/medicine/medicine_search_screen.dart b/lib/screens/medicine/medicine_search_screen.dart index a845bde2..aef2ff05 100644 --- a/lib/screens/medicine/medicine_search_screen.dart +++ b/lib/screens/medicine/medicine_search_screen.dart @@ -58,7 +58,7 @@ class _MedicineSearchState extends State { double level = 0.0; double minSoundLevel = 50000; double maxSoundLevel = -50000; - String reconizedWord; + String recognizedWord; @override void didChangeDependencies() { @@ -264,9 +264,9 @@ class _MedicineSearchState extends State { void resultListener(SpeechRecognitionResult result) { setState(() { // lastWords = "${result.recognizedWords} - ${result.finalResult}"; - reconizedWord = result.recognizedWords; + recognizedWord = result.recognizedWords; lastStatus = ''; - myController.text = reconizedWord; + myController.text = recognizedWord; Future.delayed(const Duration(seconds: 2), () { // searchMedicine(context); }); diff --git a/lib/screens/patients/profile/notes/note/update_note.dart b/lib/screens/patients/profile/notes/note/update_note.dart index f1395bff..10b3c30d 100644 --- a/lib/screens/patients/profile/notes/note/update_note.dart +++ b/lib/screens/patients/profile/notes/note/update_note.dart @@ -51,7 +51,7 @@ class _UpdateNoteOrderState extends State { int selectedType; bool isSubmitted = false; stt.SpeechToText speech = stt.SpeechToText(); - var reconizedWord; + var recognizedWord; var event = RobotProvider(); ProjectViewModel projectViewModel; @@ -296,7 +296,7 @@ class _UpdateNoteOrderState extends State { } void statusListener(String status) { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } void requestPermissions() async { @@ -306,14 +306,14 @@ class _UpdateNoteOrderState extends State { } void resultListener(result) { - reconizedWord = result.recognizedWords; - event.setValue({"searchText": reconizedWord}); + recognizedWord = result.recognizedWords; + event.setValue({"searchText": recognizedWord}); if (result.finalResult == true) { setState(() { SpeechToText.closeAlertDialog(context); speech.stop(); - progressNoteController.text += reconizedWord + '\n'; + progressNoteController.text += recognizedWord + '\n'; }); } else { print(result.finalResult); diff --git a/lib/screens/patients/profile/operation_report/update_operation_report.dart b/lib/screens/patients/profile/operation_report/update_operation_report.dart index 2ea38254..882bacc8 100644 --- a/lib/screens/patients/profile/operation_report/update_operation_report.dart +++ b/lib/screens/patients/profile/operation_report/update_operation_report.dart @@ -47,7 +47,7 @@ class _UpdateOperationReportState extends State { int selectedType; bool isSubmitted = false; stt.SpeechToText speech = stt.SpeechToText(); - var reconizedWord; + var recognizedWord; var event = RobotProvider(); ProjectViewModel projectViewModel; diff --git a/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart b/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart index 0c2c4d8d..835339ea 100644 --- a/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart +++ b/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart @@ -46,7 +46,7 @@ class _AddReplayOnReferralPatientState int replay = 1; int reject = 2; stt.SpeechToText speech = stt.SpeechToText(); - var reconizedWord; + var recognizedWord; var event = RobotProvider(); TextEditingController replayOnReferralController = TextEditingController(); @@ -248,7 +248,7 @@ class _AddReplayOnReferralPatientState void errorListener(SpeechRecognitionError error) {} void statusListener(String status) { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } void requestPermissions() async { @@ -258,13 +258,13 @@ class _AddReplayOnReferralPatientState } void resultListener(result) { - reconizedWord = result.recognizedWords; - event.setValue({"searchText": reconizedWord}); + recognizedWord = result.recognizedWords; + event.setValue({"searchText": recognizedWord}); if (result.finalResult == true) { setState(() { SpeechToText.closeAlertDialog(context); - replayOnReferralController.text += reconizedWord + '\n'; + replayOnReferralController.text += recognizedWord + '\n'; }); } } diff --git a/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart b/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart index ad78e895..8b229479 100644 --- a/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart +++ b/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart @@ -49,7 +49,7 @@ class _PatientMakeInPatientReferralScreenState String doctorError; String frequencyError; stt.SpeechToText speech = stt.SpeechToText(); - var reconizedWord; + var recognizedWord; var event = RobotProvider(); @override @@ -88,7 +88,7 @@ class _PatientMakeInPatientReferralScreenState } void statusListener(String status) { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } void requestPermissions() async { @@ -98,14 +98,14 @@ class _PatientMakeInPatientReferralScreenState } void resultListener(result) { - reconizedWord = result.recognizedWords; - event.setValue({"searchText": reconizedWord}); + recognizedWord = result.recognizedWords; + event.setValue({"searchText": recognizedWord}); if (result.finalResult == true) { setState(() { SpeechToText.closeAlertDialog(context); speech.stop(); - _remarksController.text += reconizedWord + '\n'; + _remarksController.text += recognizedWord + '\n'; }); } else { print(result.finalResult); diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription/add_prescription_form.dart similarity index 85% rename from lib/screens/prescription/add_prescription_form.dart rename to lib/screens/prescription/add_prescription/add_prescription_form.dart index 6e5c57fb..be614389 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription/add_prescription_form.dart @@ -15,7 +15,7 @@ import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/prescription/drugtodrug.dart'; +import 'package:doctor_app_flutter/screens/prescription/add_prescription/drugtodrug.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_text_filed.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; @@ -122,8 +122,8 @@ class _PrescriptionFormWidgetState extends State { TextEditingController indicationController = TextEditingController(); TextEditingController instructionController = TextEditingController(); - bool visbiltyPrescriptionForm = false; - bool visbiltySearch = true; + bool visibilityPrescriptionForm = false; + bool visibilitySearch = true; final myController = TextEditingController(); DateTime selectedDate; @@ -137,10 +137,10 @@ class _PrescriptionFormWidgetState extends State { final searchController = TextEditingController(); stt.SpeechToText speech = stt.SpeechToText(); var event = RobotProvider(); - var reconizedWord; + var recognizedWord; final GlobalKey formKey = GlobalKey(); - final double spaceBetweenTextFileds = 12; + final double spaceBetweenTextFields = 12; dynamic route; dynamic frequency; dynamic duration; @@ -151,19 +151,19 @@ class _PrescriptionFormWidgetState extends State { dynamic box; dynamic x; - @override - void initState() { - requestPermissions(); - event.controller.stream.listen((p) { - if (p['startPopUp'] == 'true') { - if (this.mounted) { - initSpeechState().then((value) => {onVoiceText()}); - } - } - }); - selectedType = 1; - super.initState(); - } + // @override + // void initState() { + // requestPermissions(); + // event.controller.stream.listen((p) { + // if (p['startPopUp'] == 'true') { + // if (this.mounted) { + // initSpeechState().then((value) => {onVoiceText()}); + // } + // } + // }); + // selectedType = 1; + // super.initState(); + // } setSelectedType(int val) { setState(() { @@ -193,24 +193,24 @@ class _PrescriptionFormWidgetState extends State { } void statusListener(String status) { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } - void requestPermissions() async { - Map statuses = await [ - Permission.microphone, - ].request(); - } + // void requestPermissions() async { + // Map statuses = await [ + // Permission.microphone, + // ].request(); + // } void resultListener(result) { - reconizedWord = result.recognizedWords; - event.setValue({"searchText": reconizedWord}); + recognizedWord = result.recognizedWords; + event.setValue({"searchText": recognizedWord}); if (result.finalResult == true) { setState(() { SpeechToText.closeAlertDialog(context); speech.stop(); - instructionController.text += reconizedWord + '\n'; + instructionController.text += recognizedWord + '\n'; }); } else { print(result.finalResult); @@ -227,42 +227,21 @@ class _PrescriptionFormWidgetState extends State { @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; - ProjectViewModel projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) async { - /// TODO Elham* Move this to view model - x = model.patientAssessmentList.map((element) { - return element.icdCode10ID; - }); - GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( - patientMRN: widget.patient.patientMRN, - episodeID: widget.patient.episodeNo.toString(), - editedBy: '', - doctorID: '', - appointmentNo: widget.patient.appointmentNo); - if (model.medicationStrengthList.length == 0) { - await model.getMedicationStrength(); - } - if (model.medicationDurationList.length == 0) { - await model.getMedicationDuration(); - } - if (model.medicationDoseTimeList.length == 0) { - await model.getMedicationDoseTime(); - } - await model.getPatientAssessment(getAssessmentReqModel); - }, + onModelReady: (model) => model.getAssessmentList( + patientInfo: widget.patient + ), builder: ( BuildContext context, MedicineViewModel model, - Widget child, - ) => + Widget child,) => NetworkBaseView( - baseViewModel: model, - child: GestureDetector( - onTap: () { + baseViewModel: model, + child: GestureDetector( + onTap: () { FocusScope.of(context).requestFocus(new FocusNode()); - }, - child: DraggableScrollableSheet( + }, + child: DraggableScrollableSheet( initialChildSize: 0.98, maxChildSize: 0.98, minChildSize: 0.9, @@ -285,7 +264,7 @@ class _PrescriptionFormWidgetState extends State { ], ), SizedBox( - height: spaceBetweenTextFileds, + height: spaceBetweenTextFields, ), Container( child: Form( @@ -304,8 +283,8 @@ class _PrescriptionFormWidgetState extends State { padding: EdgeInsets.all(10), child: AppTextFormField( onTap: () { - visbiltyPrescriptionForm = false; - visbiltySearch = true; + visibilityPrescriptionForm = false; + visibilitySearch = true; }, borderColor: Colors.white, hintText: TranslationBase.of(context) @@ -323,7 +302,7 @@ class _PrescriptionFormWidgetState extends State { height: 15.0, ), Visibility( - visible: visbiltySearch, + visible: visibilitySearch, child: Container( child: Column( children: [ @@ -378,9 +357,9 @@ class _PrescriptionFormWidgetState extends State { .allMedicationList[ index] .itemId); - visbiltyPrescriptionForm = + visibilityPrescriptionForm = true; - visbiltySearch = false; + visibilitySearch = false; _selectedMedication = model.allMedicationList[ index]; @@ -396,10 +375,10 @@ class _PrescriptionFormWidgetState extends State { ), ), SizedBox( - height: spaceBetweenTextFileds, + height: spaceBetweenTextFields, ), Visibility( - visible: visbiltyPrescriptionForm, + visible: visibilityPrescriptionForm, child: Container( child: Column( children: [ @@ -424,7 +403,7 @@ class _PrescriptionFormWidgetState extends State { SizedBox(width: 18,), Radio( activeColor: - Color(0xFFB9382C), + AppGlobal.appRedColor, value: 1, groupValue: selectedType, onChanged: (value) { @@ -540,14 +519,14 @@ class _PrescriptionFormWidgetState extends State { ), ), SizedBox( - height: spaceBetweenTextFileds), + height: spaceBetweenTextFields), PrescriptionTextFiled( elementList: model.itemMedicineListRoute, element: model.itemMedicineListRoute .length == 1 - ? model.itemMedicineListRoute[0] + ? route = model.itemMedicineListRoute[0] : route, elementError: routeError, keyId: 'parameterCode', @@ -563,45 +542,37 @@ class _PrescriptionFormWidgetState extends State { .route, ), SizedBox( - height: spaceBetweenTextFileds), + height: spaceBetweenTextFields), PrescriptionTextFiled( - hintText: - TranslationBase.of(context) - .frequency, + hintText: TranslationBase.of(context).frequency, elementError: frequencyError, - element: frequency, - elementList: - model.itemMedicineList, + // element: frequency, + element: model.itemMedicineListRoute + .length == + 1 + ? frequency = model.itemMedicineListRoute[0] + : frequency, + elementList: model.itemMedicineList, keyId: 'parameterCode', keyName: 'description', okFunction: (selectedValue) { setState(() { frequency = selectedValue; frequency['isDefault'] = true; - if (_selectedMedication != - null && - duration != null && - frequency != null && - strengthController.text != - null) { + if (_selectedMedication != null && duration != null && frequency != 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), + height: spaceBetweenTextFields), PrescriptionTextFiled( hintText: TranslationBase.of(context) @@ -618,7 +589,7 @@ class _PrescriptionFormWidgetState extends State { }); }), SizedBox( - height: spaceBetweenTextFileds), + height: spaceBetweenTextFields), if (model .patientAssessmentList.isNotEmpty) Container( @@ -633,21 +604,19 @@ class _PrescriptionFormWidgetState extends State { .size .width * 0.29, - child: TextField( - decoration: - textFieldSelectorDecoration( + child: AppTextFieldCustom( + hintText: model .patientAssessmentList[ 0] .icdCode10ID .toString(), - indication != null - ? indication[ - 'name'] - : null, - false), + // indication != null + // ? indication[ + // 'name'] + // : null, + enabled: true, - readOnly: true, ), ), Container( @@ -657,57 +626,68 @@ class _PrescriptionFormWidgetState extends State { .width * 0.57, color: Colors.white, - child: TextField( + child: AppTextFieldCustom( maxLines: 5, - decoration: - textFieldSelectorDecoration( + hintText: model .patientAssessmentList[ 0] .asciiDesc .toString(), - indication != null - ? indication[ - 'name'] - : null, - false), + // indication != null + // ? indication[ + // 'name'] + // : null, enabled: true, - readOnly: true, ), ), ], ), ), SizedBox( - height: spaceBetweenTextFileds), + height: spaceBetweenTextFields), Container( - height: screenSize.height * 0.070, - color: Colors.white, + color: Colors.transparent, child: InkWell( onTap: () => selectDate( context, widget.model), - /// TODO Elham* Use customTextFields for all TextFields here - 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, - )), + child: AppTextFieldCustom( + validationError: + strengthError, + hintText: 'Date', + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon( + Icons.calendar_today, + color: Colors.black,), + ), + dropDownText: selectedDate != null + ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + : null, enabled: false, + controller: strengthController, ), + + // 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, + // )), + // enabled: false, + // ), ), ), SizedBox( - height: spaceBetweenTextFileds), - /// TODO Elham* Use customTextFields for all + height: spaceBetweenTextFields), PrescriptionTextFiled( element: duration, elementError: durationError, @@ -746,7 +726,7 @@ class _PrescriptionFormWidgetState extends State { }, ), SizedBox( - height: spaceBetweenTextFileds), + height: spaceBetweenTextFields), Container( color: Colors.white, child: AppTextFieldCustom( @@ -758,7 +738,7 @@ class _PrescriptionFormWidgetState extends State { ), ), SizedBox( - height: spaceBetweenTextFileds), + height: spaceBetweenTextFields), Container( color: Colors.white, child: AppTextFieldCustom( @@ -773,7 +753,8 @@ class _PrescriptionFormWidgetState extends State { ), ), SizedBox( - height: spaceBetweenTextFileds), + height: spaceBetweenTextFields + ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( @@ -814,7 +795,7 @@ class _PrescriptionFormWidgetState extends State { ), ), SizedBox( - height: spaceBetweenTextFileds), + height: spaceBetweenTextFields), Container( margin: EdgeInsets.all( SizeConfig.widthMultiplier * 5), @@ -1058,49 +1039,48 @@ class _PrescriptionFormWidgetState extends State { }); } } - /// TODO Elham* Use it from the textfeild utils - InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown, - {Icon suffixIcon}) { - return InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown - ? suffixIcon != null - ? suffixIcon - : Icon( - Icons.keyboard_arrow_down_sharp, - color: Color(0xff2E303A), - ) - : null, - hintStyle: TextStyle( - fontSize: 13, - color: Color(0xff2E303A), - fontFamily: 'Poppins', - fontWeight: FontWeight.w600, - ), - labelText: selectedText != null ? '$hintText\n$selectedText' : null, - labelStyle: TextStyle( - fontSize: 13, - color: Color(0xff2E303A), - fontFamily: 'Poppins', - fontWeight: FontWeight.w600, - ), - ); - } + // InputDecoration textFieldSelectorDecoration( + // String hintText, String selectedText, bool isDropDown, + // {Icon suffixIcon}) { + // return InputDecoration( + // focusedBorder: OutlineInputBorder( + // borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + // borderRadius: BorderRadius.circular(8), + // ), + // enabledBorder: OutlineInputBorder( + // borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), + // borderRadius: BorderRadius.circular(8), + // ), + // disabledBorder: OutlineInputBorder( + // borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), + // borderRadius: BorderRadius.circular(8), + // ), + // hintText: selectedText != null ? selectedText : hintText, + // suffixIcon: isDropDown + // ? suffixIcon != null + // ? suffixIcon + // : Icon( + // Icons.keyboard_arrow_down_sharp, + // color: Color(0xff2E303A), + // ) + // : null, + // hintStyle: TextStyle( + // fontSize: 13, + // color: Color(0xff2E303A), + // fontFamily: 'Poppins', + // fontWeight: FontWeight.w600, + // ), + // labelText: selectedText != null ? '$hintText\n$selectedText' : null, + // labelStyle: TextStyle( + // fontSize: 13, + // color: Color(0xff2E303A), + // fontFamily: 'Poppins', + // fontWeight: FontWeight.w600, + // ), + // ); + // } - openDrugToDrug(model) { + openDrugToDrug(MedicineViewModel model) { showModalBottomSheet( context: context, builder: (context) { @@ -1114,7 +1094,9 @@ class _PrescriptionFormWidgetState extends State { children: [ DrugToDrug( widget.patient, - getPriscriptionforDrug(widget.prescriptionList, model), + model.getPrescriptionForDrug( + widget.prescriptionList, model + ), model.patientAssessmentList), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), @@ -1158,57 +1140,53 @@ class _PrescriptionFormWidgetState extends State { )) ], )), - - //], - //) ); }); } - /// TODO Elham* Move this to view model - getPriscriptionforDrug( - List prescriptionList, MedicineViewModel model) { - var prescriptionDetails = []; - if (prescriptionList.length > 0) { - prescriptionList[0].entityList.forEach((element) { - if (element.mediSpanGPICode != null) { - prescriptionDetails.add({ - 'DrugId': element.mediSpanGPICode, - 'DrugName': element.medicationName, - 'Dose': element.doseDailyQuantity, - 'DoseType': element.doseDailyUnitID, - 'Unit': element.uom, - 'FrequencyType': element.frequencyID, - 'Duration': element.doseDurationDays, - 'RouteID': element.routeID, - 'IsScreen': element.isSIG - }); - } - }); - } - if (_selectedMedication.mediSpanGPICode != null) { - prescriptionDetails.add({ - 'DrugId': _selectedMedication.mediSpanGPICode, - 'DrugName': _selectedMedication.description, - 'Dose': strengthController.text, - 'DoseType': model.itemMedicineListUnit.length == 1 - ? model.itemMedicineListUnit[0]['parameterCode'].toString() - : units['parameterCode'].toString(), - 'Unit': model.itemMedicineListUnit.length == 1 - ? model.itemMedicineListUnit[0]['description'] - : units['description'], - 'FrequencyType': model.itemMedicineList.length == 1 - ? model.itemMedicineList[0]['parameterCode'].toString() - : frequency['parameterCode'].toString(), - 'Duration': duration['id'].toString(), - 'RouteID': model.itemMedicineListRoute.length == 1 - ? model.itemMedicineListRoute[0]['parameterCode'].toString() - : route['parameterCode'].toString(), - 'IsScreen': true - }); - } - return prescriptionDetails; - } + // getPrescriptionForDrug( + // List prescriptionList, MedicineViewModel model) { + // var prescriptionDetails = []; + // if (prescriptionList.length > 0) { + // prescriptionList[0].entityList.forEach((element) { + // if (element.mediSpanGPICode != null) { + // prescriptionDetails.add({ + // 'DrugId': element.mediSpanGPICode, + // 'DrugName': element.medicationName, + // 'Dose': element.doseDailyQuantity, + // 'DoseType': element.doseDailyUnitID, + // 'Unit': element.uom, + // 'FrequencyType': element.frequencyID, + // 'Duration': element.doseDurationDays, + // 'RouteID': element.routeID, + // 'IsScreen': element.isSIG + // }); + // } + // }); + // } + // if (_selectedMedication.mediSpanGPICode != null) { + // prescriptionDetails.add({ + // 'DrugId': _selectedMedication.mediSpanGPICode, + // 'DrugName': _selectedMedication.description, + // 'Dose': strengthController.text, + // 'DoseType': model.itemMedicineListUnit.length == 1 + // ? model.itemMedicineListUnit[0]['parameterCode'].toString() + // : units['parameterCode'].toString(), + // 'Unit': model.itemMedicineListUnit.length == 1 + // ? model.itemMedicineListUnit[0]['description'] + // : units['description'], + // 'FrequencyType': model.itemMedicineList.length == 1 + // ? model.itemMedicineList[0]['parameterCode'].toString() + // : frequency['parameterCode'].toString(), + // 'Duration': duration['id'].toString(), + // 'RouteID': model.itemMedicineListRoute.length == 1 + // ? model.itemMedicineListRoute[0]['parameterCode'].toString() + // : route['parameterCode'].toString(), + // 'IsScreen': true + // }); + // } + // return prescriptionDetails; + // } searchMedicine(context, MedicineViewModel model) async { FocusScope.of(context).unfocus(); diff --git a/lib/screens/prescription/drugtodrug.dart b/lib/screens/prescription/add_prescription/drugtodrug.dart similarity index 100% rename from lib/screens/prescription/drugtodrug.dart rename to lib/screens/prescription/add_prescription/drugtodrug.dart diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/add_prescription/update_prescription_form.dart similarity index 100% rename from lib/screens/prescription/update_prescription_form.dart rename to lib/screens/prescription/add_prescription/update_prescription_form.dart diff --git a/lib/screens/prescription/prescription_authorazation_form.dart b/lib/screens/prescription/prescription_authorazation_form.dart deleted file mode 100644 index 8b137891..00000000 --- a/lib/screens/prescription/prescription_authorazation_form.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/screens/prescription/prescription_checkout_screen.dart b/lib/screens/prescription/prescription_checkout_screen.dart index 076f7051..dfeea9f6 100644 --- a/lib/screens/prescription/prescription_checkout_screen.dart +++ b/lib/screens/prescription/prescription_checkout_screen.dart @@ -114,8 +114,8 @@ class _PrescriptionCheckOutScreenState TextEditingController indicationController = TextEditingController(); TextEditingController instructionController = TextEditingController(); - bool visbiltyPrescriptionForm = true; - bool visbiltySearch = true; + bool visibilityPrescriptionForm = true; + bool visibilitySearch = true; final myController = TextEditingController(); DateTime selectedDate; @@ -129,10 +129,10 @@ class _PrescriptionCheckOutScreenState final searchController = TextEditingController(); stt.SpeechToText speech = stt.SpeechToText(); var event = RobotProvider(); - var reconizedWord; + var recognizedWord; final GlobalKey formKey = GlobalKey(); - final double spaceBetweenTextFileds = 12; + final double spaceBetweenTextFields = 12; dynamic route; dynamic frequency; dynamic duration; @@ -179,7 +179,7 @@ class _PrescriptionCheckOutScreenState } void statusListener(String status) { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } void requestPermissions() async { @@ -189,14 +189,14 @@ class _PrescriptionCheckOutScreenState } void resultListener(result) { - reconizedWord = result.recognizedWords; - event.setValue({"searchText": reconizedWord}); + recognizedWord = result.recognizedWords; + event.setValue({"searchText": recognizedWord}); if (result.finalResult == true) { setState(() { SpeechToText.closeAlertDialog(context); speech.stop(); - instructionController.text += reconizedWord + '\n'; + instructionController.text += recognizedWord + '\n'; }); } else { print(result.finalResult); @@ -299,7 +299,7 @@ class _PrescriptionCheckOutScreenState ], ), SizedBox( - height: spaceBetweenTextFileds, + height: spaceBetweenTextFields, ), Container( child: Form( @@ -316,10 +316,10 @@ class _PrescriptionCheckOutScreenState ), ), SizedBox( - height: spaceBetweenTextFileds, + height: spaceBetweenTextFields, ), Visibility( - visible: visbiltyPrescriptionForm, + visible: visibilityPrescriptionForm, child: Container( child: Column( children: [ @@ -337,7 +337,7 @@ class _PrescriptionCheckOutScreenState fontWeight: FontWeight.w600, ), Radio( - activeColor: Color(0xFFB9382C), + activeColor: AppGlobal.appRedColor, value: 1, groupValue: selectedType, onChanged: (value) { @@ -349,7 +349,7 @@ class _PrescriptionCheckOutScreenState ], ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), Container( width: double.infinity, child: Row( @@ -410,7 +410,7 @@ class _PrescriptionCheckOutScreenState ], ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), PrescriptionTextFiled( elementList: model.itemMedicineListRoute, @@ -427,7 +427,7 @@ class _PrescriptionCheckOutScreenState hintText: TranslationBase.of(context).route, ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), PrescriptionTextFiled( hintText: TranslationBase.of(context) .frequency, @@ -460,7 +460,7 @@ class _PrescriptionCheckOutScreenState } }); }), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), PrescriptionTextFiled( hintText: TranslationBase.of(context) .doseTime, @@ -475,7 +475,7 @@ class _PrescriptionCheckOutScreenState doseTime = selectedValue; }); }), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), if (model .patientAssessmentList.isNotEmpty) Container( @@ -533,7 +533,7 @@ class _PrescriptionCheckOutScreenState ], ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), Container( height: screenSize.height * 0.070, color: Colors.white, @@ -556,7 +556,7 @@ class _PrescriptionCheckOutScreenState ), ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), PrescriptionTextFiled( element: duration, elementError: durationError, @@ -590,9 +590,9 @@ class _PrescriptionCheckOutScreenState }); }, ), - SizedBox(height: spaceBetweenTextFileds), - SizedBox(height: spaceBetweenTextFileds), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), + SizedBox(height: spaceBetweenTextFields), + SizedBox(height: spaceBetweenTextFields), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( @@ -630,7 +630,7 @@ class _PrescriptionCheckOutScreenState ], ), ), - SizedBox(height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFields), Container( margin: EdgeInsets.all( SizeConfig.widthMultiplier * 5), diff --git a/lib/screens/prescription/prescription_details_page.dart b/lib/screens/prescription/prescription_details_page.dart deleted file mode 100644 index 623cee90..00000000 --- a/lib/screens/prescription/prescription_details_page.dart +++ /dev/null @@ -1,168 +0,0 @@ -import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.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:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -class PrescriptionDetailsPage extends StatelessWidget { - final PrescriptionReport prescriptionReport; - - PrescriptionDetailsPage({Key key, this.prescriptionReport}); - - @override - Widget build(BuildContext context) { - return AppScaffold( - isShowAppBar: true, - appBarTitle: TranslationBase.of(context).prescriptions, - body: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - padding: EdgeInsets.all(8.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - border: Border.all(color: Colors.grey[200], width: 0.5), - ), - child: Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(5)), - child: Image.network( - prescriptionReport.imageSRCUrl, - fit: BoxFit.cover, - width: 60, - height: 70, - ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: AppText( - prescriptionReport.itemDescription.isNotEmpty - ? prescriptionReport.itemDescription - : prescriptionReport.itemDescriptionN), - ), - ), - ) - ], - ), - ), - Container( - color: Colors.white, - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - child: Table( - border: TableBorder.symmetric( - inside: BorderSide(width: 0.5), - outside: BorderSide(width: 0.5)), - children: [ - TableRow( - children: [ - Container( - color: Colors.white, - height: 30, - width: double.infinity, - child: Center( - child: AppText( - TranslationBase.of(context).route, - fontSize: 14, - ))), - Container( - color: Colors.white, - height: 30, - width: double.infinity, - child: Center( - child: AppText( - TranslationBase.of(context).frequency, - fontSize: 14, - ))), - Container( - color: Colors.white, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 4), - child: Center( - child: AppText( - "${TranslationBase.of(context).dailyDoses}", - fontSize: 14, - ))), - Container( - color: Colors.white, - height: 30, - width: double.infinity, - child: Center( - child: AppText( - TranslationBase.of(context).duration, - fontSize: 14, - ))), - ], - ), - TableRow( - children: [ - Container( - color: Colors.white, - height: 50, - width: double.infinity, - child: - Center(child: Text(prescriptionReport.routeN))), - Container( - color: Colors.white, - height: 50, - width: double.infinity, - child: Center( - child: - Text(prescriptionReport.frequencyN ?? ''))), - Container( - color: Colors.white, - height: 50, - width: double.infinity, - child: Center( - child: Text( - '${prescriptionReport.doseDailyQuantity}'))), - Container( - color: Colors.white, - height: 50, - width: double.infinity, - child: - Center(child: Text('${prescriptionReport.days}'))) - ], - ), - ], - ), - ), - Container( - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - width: double.infinity, - color: Colors.white, - padding: EdgeInsets.all(5), - child: Center( - child: Column( - children: [ - AppText(TranslationBase.of(context).notes), - SizedBox( - height: 5, - ), - Divider( - height: 0.5, - color: Colors.grey[300], - ), - SizedBox( - height: 5, - ), - AppText(prescriptionReport.remarks ?? ''), - ], - ), - ), - ) - ], - ), - ), - ); - } -} diff --git a/lib/screens/prescription/prescription_items_page.dart b/lib/screens/prescription/prescription_items_page.dart index 0f356e0e..bf1632fd 100644 --- a/lib/screens/prescription/prescription_items_page.dart +++ b/lib/screens/prescription/prescription_items_page.dart @@ -51,6 +51,7 @@ class PrescriptionItemsPage extends StatelessWidget { children: [ if (!prescriptions.isInOutPatient) ...List.generate( + // TODO Elham* List.generate to list.builder model.prescriptionReportList.length, (index) => Container( decoration: BoxDecoration( @@ -204,6 +205,7 @@ class PrescriptionItemsPage extends StatelessWidget { )) else ...List.generate( + // TODO Elham* List.generate to list.builder model.prescriptionReportEnhList.length, (index) => Container( decoration: BoxDecoration( @@ -211,6 +213,7 @@ class PrescriptionItemsPage extends StatelessWidget { color: Colors.white, ), margin: EdgeInsets.all(12), + // TODO Elham* use custom card child: Padding( padding: const EdgeInsets.all(8.0), child: Column( diff --git a/lib/screens/prescription/prescription_warnings.dart b/lib/screens/prescription/prescription_warnings.dart deleted file mode 100644 index c91ce9c9..00000000 --- a/lib/screens/prescription/prescription_warnings.dart +++ /dev/null @@ -1,168 +0,0 @@ -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; -import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; - -void prescriptionWarning(context) { - showModalBottomSheet( - context: context, - isScrollControlled: true, - builder: (BuildContext bc) { - return SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Container( - height: 600, - child: Column( - children: [ - ...List.generate( - 5, - (index) => Container( - child: ExpansionTile( - title: AppText('Prescription warning and alerts(0)'), - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - AppText( - 'DOSESCREENINGRESULTFORETCETC', - color: Color(0XFFB8382C), - ) - ], - ) - ], - ), - ), - ), - SizedBox( - height: 10.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: - Border.all(width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: 'Remarks', - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox( - height: 95.0, - ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: 'CONTINUE', - onPressed: () { - Navigator.pop(context); - authorizationForm(context); - }, - ), - ], - ), - ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - color: Colors.white, - title: 'remove', - fontColor: Colors.red, - onPressed: () { - Navigator.pop(context); - prescriptionWarning(context); - }, - ), - ], - ), - ), - ], - ), - ), - )); - }); -} - -void authorizationForm(context) { - showModalBottomSheet( - context: context, - isScrollControlled: true, - builder: (BuildContext bc) { - return Container( - height: 500, - child: Form( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Prescription authorization'.toUpperCase(), - fontWeight: FontWeight.w900, - ), - SizedBox( - height: 30.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: 'Auth ID', - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox( - height: 12.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: 'Password', - borderColor: Colors.white, - textInputType: TextInputType.text, - inputFormatter: ONLY_LETTERS, - obscureText: true, - ), - ), - SizedBox( - height: 190.0, - ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: 'CONTINUE', - onPressed: () { - Navigator.pop(context); - authorizationForm(context); - }, - ), - ], - ), - ), - ], - ), - ), - )); - }); -} diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 3b914d69..b02d1861 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -101,7 +101,8 @@ class PrescriptionsPage extends StatelessWidget { label: TranslationBase.of(context) .applyForNewPrescriptionsOrder, ), - ...List.generate( + ...List.generate + ( model.prescriptionsList.length, (index) => InkWell( onTap: () => Navigator.push( diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index 66d42a0d..90ca0e55 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -3,7 +3,7 @@ import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/prescription/add_prescription_form.dart'; +import 'package:doctor_app_flutter/screens/prescription/add_prescription/add_prescription_form.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/network_base_view.dart'; diff --git a/lib/screens/procedures/entity_list_checkbox_search_widget.dart b/lib/screens/procedures/entity_list_checkbox_search_widget.dart index 361ec695..7038fbc9 100644 --- a/lib/screens/procedures/entity_list_checkbox_search_widget.dart +++ b/lib/screens/procedures/entity_list_checkbox_search_widget.dart @@ -9,6 +9,8 @@ import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../config/config.dart'; + class EntityListCheckboxSearchWidget extends StatefulWidget { final ProcedureViewModel model; final Function addSelectedHistories; @@ -229,7 +231,7 @@ class _EntityListCheckboxSearchWidgetState : Center( child: Container( child: AppText("Sorry , No Match", - color: Color(0xFFB9382C)), + color: AppGlobal.appRedColor), ), ) ], diff --git a/lib/screens/procedures/entity_list_fav_procedure.dart b/lib/screens/procedures/entity_list_fav_procedure.dart index 494540b1..3fc6ca32 100644 --- a/lib/screens/procedures/entity_list_fav_procedure.dart +++ b/lib/screens/procedures/entity_list_fav_procedure.dart @@ -8,6 +8,7 @@ import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../config/config.dart'; import 'ExpansionProcedure.dart'; class EntityListCheckboxSearchFavProceduresWidget extends StatefulWidget { @@ -125,7 +126,7 @@ class _EntityListCheckboxSearchFavProceduresWidgetState : Center( child: Container( child: AppText("Sorry , No Match", - color: Color(0xFFB9382C)), + color: AppGlobal.appRedColor), ), ) ], diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart index 01b0787c..a7e0d22f 100644 --- a/lib/screens/procedures/update-procedure.dart +++ b/lib/screens/procedures/update-procedure.dart @@ -247,7 +247,7 @@ class _UpdateProcedureWidgetState extends State { children: [ AppText(TranslationBase.of(context).orderType), Radio( - activeColor: Color(0xFFB9382C), + activeColor: AppGlobal.appRedColor, value: 0, groupValue: selectedType, onChanged: (value) { @@ -256,7 +256,7 @@ class _UpdateProcedureWidgetState extends State { ), Text('routine'), Radio( - activeColor: Color(0xFFB9382C), + activeColor: AppGlobal.appRedColor, groupValue: selectedType, value: 1, onChanged: (value) { diff --git a/lib/widgets/shared/dialogs/dailog-list-select.dart b/lib/widgets/shared/dialogs/dailog-list-select.dart index 1030e2f9..01849e5b 100644 --- a/lib/widgets/shared/dialogs/dailog-list-select.dart +++ b/lib/widgets/shared/dialogs/dailog-list-select.dart @@ -2,6 +2,8 @@ import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:flutter/material.dart'; +import '../../../config/config.dart'; + class ListSelectDialog extends StatefulWidget { final List list; final String attributeName; @@ -104,7 +106,7 @@ class _ListSelectDialogState extends State { .selectedValue[widget.attributeValueId] .toString(), value: item[widget.attributeValueId].toString(), - activeColor: Color(0xFFB9382C), + activeColor: AppGlobal.appRedColor, selected: item[widget.attributeValueId] .toString() == widget.selectedValue[widget.attributeValueId] diff --git a/lib/widgets/shared/text_fields/html_rich_editor.dart b/lib/widgets/shared/text_fields/html_rich_editor.dart index 79e9829f..d249ead0 100644 --- a/lib/widgets/shared/text_fields/html_rich_editor.dart +++ b/lib/widgets/shared/text_fields/html_rich_editor.dart @@ -134,7 +134,7 @@ class _HtmlRichEditorState extends State { } void statusListener(String status) { - recognizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } void requestPermissions() async { From f769189beeb33eb6313f1f6d4fadd0955389d33b Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Tue, 25 Jan 2022 16:54:08 +0200 Subject: [PATCH 04/25] Refactor add_prescription_form --- .../add_prescription/add_drug_widget.dart | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 lib/screens/prescription/add_prescription/add_drug_widget.dart diff --git a/lib/screens/prescription/add_prescription/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug_widget.dart new file mode 100644 index 00000000..4d00be0b --- /dev/null +++ b/lib/screens/prescription/add_prescription/add_drug_widget.dart @@ -0,0 +1,110 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import '../../../core/model/Prescriptions/prescription_model.dart'; +import '../../../core/model/patient/patiant_info_model.dart'; +import '../../../core/model/search_drug/get_medication_response_model.dart'; +import '../../../core/viewModel/prescription_view_model.dart'; +import '../../../widgets/shared/buttons/app_buttons_widget.dart'; +import 'add_prescription_form.dart'; +import 'drugtodrug.dart'; + +class AddDrugWidget extends StatefulWidget { + final PatiantInformtion patient; + final List prescriptionList; + final PrescriptionViewModel model; + + + const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.model}) : super(key: key); + + @override + _AddDrugWidgetState createState() => _AddDrugWidgetState(); +} + +class _AddDrugWidgetState extends State { + + TextEditingController strengthController = TextEditingController(); + dynamic route; + dynamic frequency; + dynamic duration; + dynamic doseTime; + dynamic indication; + dynamic units; + dynamic uom; + dynamic box; + dynamic x; + + @override + Widget build(BuildContext context) { + MedicineViewModel model; + GetMedicationResponseModel _selectedMedication; + TextEditingController indicationController = TextEditingController(); + TextEditingController instructionController = TextEditingController(); + DateTime selectedDate; + + return Container( + height: SizeConfig.realScreenHeight * .8, + width: SizeConfig.realScreenWidth, + child: SingleChildScrollView( + child: Column( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + DrugToDrug( + widget.patient, + model.getPrescriptionForDrug( + widget.prescriptionList, model + ), + model.patientAssessmentList), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), + child: AppButton( + title: TranslationBase.of(context).addMedication, + onPressed: () { + Navigator.pop(context); + + postPrescription( + icdCode: model.patientAssessmentList.isNotEmpty + ? model.patientAssessmentList[0].icdCode10ID + .isEmpty + ? "test" + : model.patientAssessmentList[0].icdCode10ID + .toString() + : "test", + dose: strengthController.text, + doseUnit: model.itemMedicineListUnit.length == 1 + ? 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() + : frequency['parameterCode'].toString(), + route: model.itemMedicineListRoute.length == 1 + ? model.itemMedicineListRoute[0]['parameterCode'] + .toString() + : route['parameterCode'].toString(), + drugId: _selectedMedication.itemId.toString(), + strength: strengthController.text, + indication: indicationController.text, + instruction: instructionController.text, + doseTime: selectedDate, + ); + }, + )) + ], + )), + + //], + //) + ); + + + + } +} From 113fb42d681167fda05aef0ea5282b6843f1208c Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Sun, 30 Jan 2022 09:58:11 +0200 Subject: [PATCH 05/25] refactor some files in prescription screen --- lib/core/viewModel/medicine_view_model.dart | 90 ++++- .../viewModel/prescription_view_model.dart | 18 +- .../add_prescription/add_drug_widget.dart | 43 +-- .../add_prescription_form.dart | 343 ++++-------------- 4 files changed, 167 insertions(+), 327 deletions(-) diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 7505265e..2482a30d 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -8,20 +8,16 @@ import 'package:doctor_app_flutter/core/service/patient_medical_file/prescriptio import 'package:doctor_app_flutter/core/service/patient_medical_file/procedure/procedure_service.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; -import 'package:flutter/cupertino.dart'; - +import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import '../../locator.dart'; +import '../../util/dr_app_toast_msg.dart'; +import '../../util/helpers.dart'; +import '../model/Prescriptions/post_prescrition_req_model.dart'; import '../model/Prescriptions/prescription_model.dart'; import 'base_view_model.dart'; class MedicineViewModel extends BaseViewModel { bool hasError = false; - // dynamic route; - // dynamic frequency; - // dynamic duration; - // dynamic units; - - MedicineService _medicineService = locator(); ProcedureService _procedureService = locator(); PrescriptionService _prescriptionService = locator(); @@ -30,8 +26,6 @@ class MedicineViewModel extends BaseViewModel { _procedureService.templateList; List templateList = List(); - GetMedicationResponseModel _selectedMedication; - get pharmacyItemsList => _medicineService.pharmacyItemsList; get searchText => _medicineService.searchText; @@ -72,8 +66,6 @@ class MedicineViewModel extends BaseViewModel { Future getItem({int itemID}) async { - //hasError = false; - //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); await _prescriptionService.getItem(itemID: itemID); if (_prescriptionService.hasError) { @@ -155,6 +147,56 @@ class MedicineViewModel extends BaseViewModel { } + postPrescription( + {String duration, + String doseTimeIn, + String dose, + String drugId, + String strength, + String route, + String frequency, + String indication, + String instruction, + PrescriptionViewModel model, + DateTime doseTime, + String doseUnit, + String icdCode, + PatiantInformtion patient, + String patientType}) async { + PostPrescriptionReqModel postProcedureReqModel = + new PostPrescriptionReqModel(); + List prescriptionList = List(); + + postProcedureReqModel.appointmentNo = patient.appointmentNo; + postProcedureReqModel.clinicID = patient.clinicId; + postProcedureReqModel.episodeID = patient.episodeNo; + postProcedureReqModel.patientMRN = patient.patientMRN; + + prescriptionList.add(PrescriptionRequestModel( + covered: true, + dose: double.parse(dose), + itemId: drugId.isEmpty ? 1 : int.parse(drugId), + doseUnitId: int.parse(doseUnit), + route: route.isEmpty ? 1 : int.parse(route), + frequency: frequency.isEmpty ? 1 : int.parse(frequency), + remarks: instruction, + approvalRequired: true, + icdcode10Id: icdCode.toString(), + doseTime: doseTimeIn.isEmpty ? 1 : int.parse(doseTimeIn), + duration: duration.isEmpty ? 1 : int.parse(duration), + doseStartDate: doseTime.toIso8601String())); + postProcedureReqModel.prescriptionRequestModel = prescriptionList; + await model.postPrescription(postProcedureReqModel, patient.patientMRN); + + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } else if (model.state == ViewState.Idle) { + model.getPrescriptions(patient); + DrAppToastMsg.showSuccesToast('Medication has been added'); + } + } + + Future getAssessmentList ({ PatiantInformtion patientInfo, @@ -216,7 +258,8 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getMedicationList({String drug}) async { + Future getMedicationList({String drug, bool isLocalBusy = true}) + async { setState(ViewState.Busy); await _prescriptionService.getMedicationList(drug: drug); if (_prescriptionService.hasError) { @@ -226,6 +269,27 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } + // async { + // if (isLocalBusy) { + // setState(ViewState.Busy); + // } else { + // setState(ViewState.BusyLocal); + // } + // + // await _prescriptionService.getMedicationList(drug: drug); + // if (_prescriptionService.hasError) { + // error = _prescriptionService.error; + // if (isLocalBusy) { + // setState(ViewState.ErrorLocal); + // } else { + // setState(ViewState.Error); + // } + // } else { + // //filterData = _prescriptionService.patientList; + // setState(ViewState.Idle); + // } + // } + Future getPatientAssessment( GetAssessmentReqModel getAssessmentReqModel) async { setState(ViewState.Busy); diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index a0044f9f..480e8bad 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -96,7 +96,7 @@ class PrescriptionViewModel extends BaseViewModel { Future getPrescription({int mrn}) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionService.getPrescription(mrn: mrn); if (_prescriptionService.hasError) { error = _prescriptionService.error; @@ -109,7 +109,7 @@ class PrescriptionViewModel extends BaseViewModel { PostPrescriptionReqModel postProcedureReqModel, int mrn) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionService.postPrescription(postProcedureReqModel); if (_prescriptionService.hasError) { error = _prescriptionService.error; @@ -121,7 +121,7 @@ class PrescriptionViewModel extends BaseViewModel { } Future getMedicationList({String drug}) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionService.getMedicationList(drug: drug); if (_prescriptionService.hasError) { error = _prescriptionService.error; @@ -134,7 +134,7 @@ class PrescriptionViewModel extends BaseViewModel { PostPrescriptionReqModel updatePrescriptionReqModel, int mrn) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionService.updatePrescription(updatePrescriptionReqModel); if (_prescriptionService.hasError) { error = _prescriptionService.error; @@ -164,7 +164,7 @@ class PrescriptionViewModel extends BaseViewModel { PatiantInformtion patient, List prescription) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionService.getDrugToDrug( vital, lstAssessments, allergy, patient, prescription); if (_prescriptionService.hasError) { @@ -182,7 +182,7 @@ class PrescriptionViewModel extends BaseViewModel { getPrescriptionReport( {Prescriptions prescriptions, @required PatiantInformtion patient}) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionsService.getPrescriptionReport( prescriptions: prescriptions, patient: patient); if (_prescriptionsService.hasError) { @@ -195,7 +195,7 @@ class PrescriptionViewModel extends BaseViewModel { getListPharmacyForPrescriptions( {int itemId, @required PatiantInformtion patient}) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionsService.getListPharmacyForPrescriptions( itemId: itemId, patient: patient); if (_prescriptionsService.hasError) { @@ -270,7 +270,7 @@ class PrescriptionViewModel extends BaseViewModel { } getPrescriptions(PatiantInformtion patient, {String patientType}) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionsService.getPrescriptions(patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; @@ -287,7 +287,7 @@ class PrescriptionViewModel extends BaseViewModel { } getMedicationForInPatient(PatiantInformtion patient) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _prescriptionsService.getMedicationForInPatient(patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; diff --git a/lib/screens/prescription/add_prescription/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug_widget.dart index 4d00be0b..19968858 100644 --- a/lib/screens/prescription/add_prescription/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug_widget.dart @@ -14,10 +14,13 @@ import 'drugtodrug.dart'; class AddDrugWidget extends StatefulWidget { final PatiantInformtion patient; final List prescriptionList; - final PrescriptionViewModel model; + final MedicineViewModel medicineModel; + final PrescriptionViewModel modelPrescription; - const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.model}) : super(key: key); + + + const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel, this.modelPrescription}) : super(key: key); @override _AddDrugWidgetState createState() => _AddDrugWidgetState(); @@ -38,12 +41,12 @@ class _AddDrugWidgetState extends State { @override Widget build(BuildContext context) { - MedicineViewModel model; GetMedicationResponseModel _selectedMedication; TextEditingController indicationController = TextEditingController(); TextEditingController instructionController = TextEditingController(); DateTime selectedDate; + return Container( height: SizeConfig.realScreenHeight * .8, width: SizeConfig.realScreenWidth, @@ -53,10 +56,10 @@ class _AddDrugWidgetState extends State { children: [ DrugToDrug( widget.patient, - model.getPrescriptionForDrug( - widget.prescriptionList, model + widget.medicineModel.getPrescriptionForDrug( + widget.prescriptionList, widget.medicineModel ), - model.patientAssessmentList), + widget.medicineModel.patientAssessmentList), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), child: AppButton( @@ -64,29 +67,29 @@ class _AddDrugWidgetState extends State { onPressed: () { Navigator.pop(context); - postPrescription( - icdCode: model.patientAssessmentList.isNotEmpty - ? model.patientAssessmentList[0].icdCode10ID + widget.medicineModel.postPrescription( + icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty + ? widget.medicineModel.patientAssessmentList[0].icdCode10ID .isEmpty ? "test" - : model.patientAssessmentList[0].icdCode10ID + : widget.medicineModel.patientAssessmentList[0].icdCode10ID .toString() : "test", dose: strengthController.text, - doseUnit: model.itemMedicineListUnit.length == 1 - ? model.itemMedicineListUnit[0]['parameterCode'] + doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1 + ? widget.medicineModel.itemMedicineListUnit[0]['parameterCode'] .toString() : units['parameterCode'].toString(), patient: widget.patient, doseTimeIn: doseTime['id'].toString(), - model: widget.model, + model: widget.modelPrescription, duration: duration['id'].toString(), - frequency: model.itemMedicineList.length == 1 - ? model.itemMedicineList[0]['parameterCode'] + frequency: widget.medicineModel.itemMedicineList.length == 1 + ? widget.medicineModel.itemMedicineList[0]['parameterCode'] .toString() : frequency['parameterCode'].toString(), - route: model.itemMedicineListRoute.length == 1 - ? model.itemMedicineListRoute[0]['parameterCode'] + route: widget.medicineModel.itemMedicineListRoute.length == 1 + ? widget.medicineModel.itemMedicineListRoute[0]['parameterCode'] .toString() : route['parameterCode'].toString(), drugId: _selectedMedication.itemId.toString(), @@ -99,12 +102,6 @@ class _AddDrugWidgetState extends State { )) ], )), - - //], - //) ); - - - } } diff --git a/lib/screens/prescription/add_prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription/add_prescription_form.dart index be614389..f3c95e57 100644 --- a/lib/screens/prescription/add_prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription/add_prescription_form.dart @@ -37,64 +37,58 @@ 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) { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext bc) { - return PrescriptionFormWidget(model, patient, prescription); - }); -} - -postPrescription( - {String duration, - String doseTimeIn, - String dose, - String drugId, - String strength, - String route, - String frequency, - String indication, - String instruction, - PrescriptionViewModel model, - DateTime doseTime, - String doseUnit, - String icdCode, - PatiantInformtion patient, - String patientType}) async { - PostPrescriptionReqModel postProcedureReqModel = - new PostPrescriptionReqModel(); - List prescriptionList = List(); - - postProcedureReqModel.appointmentNo = patient.appointmentNo; - postProcedureReqModel.clinicID = patient.clinicId; - postProcedureReqModel.episodeID = patient.episodeNo; - postProcedureReqModel.patientMRN = patient.patientMRN; - - prescriptionList.add(PrescriptionRequestModel( - covered: true, - dose: double.parse(dose), - itemId: drugId.isEmpty ? 1 : int.parse(drugId), - doseUnitId: int.parse(doseUnit), - route: route.isEmpty ? 1 : int.parse(route), - frequency: frequency.isEmpty ? 1 : int.parse(frequency), - remarks: instruction, - approvalRequired: true, - icdcode10Id: icdCode.toString(), - doseTime: doseTimeIn.isEmpty ? 1 : int.parse(doseTimeIn), - duration: duration.isEmpty ? 1 : int.parse(duration), - doseStartDate: doseTime.toIso8601String())); - postProcedureReqModel.prescriptionRequestModel = prescriptionList; - await model.postPrescription(postProcedureReqModel, patient.patientMRN); - - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } else if (model.state == ViewState.Idle) { - model.getPrescriptions(patient); - DrAppToastMsg.showSuccesToast('Medication has been added'); - } -} +import 'add_drug_widget.dart'; + + +// +// postPrescription( +// {String duration, +// String doseTimeIn, +// String dose, +// String drugId, +// String strength, +// String route, +// String frequency, +// String indication, +// String instruction, +// PrescriptionViewModel model, +// DateTime doseTime, +// String doseUnit, +// String icdCode, +// PatiantInformtion patient, +// String patientType}) async { +// PostPrescriptionReqModel postProcedureReqModel = +// new PostPrescriptionReqModel(); +// List prescriptionList = List(); +// +// postProcedureReqModel.appointmentNo = patient.appointmentNo; +// postProcedureReqModel.clinicID = patient.clinicId; +// postProcedureReqModel.episodeID = patient.episodeNo; +// postProcedureReqModel.patientMRN = patient.patientMRN; +// +// prescriptionList.add(PrescriptionRequestModel( +// covered: true, +// dose: double.parse(dose), +// itemId: drugId.isEmpty ? 1 : int.parse(drugId), +// doseUnitId: int.parse(doseUnit), +// route: route.isEmpty ? 1 : int.parse(route), +// frequency: frequency.isEmpty ? 1 : int.parse(frequency), +// remarks: instruction, +// approvalRequired: true, +// icdcode10Id: icdCode.toString(), +// doseTime: doseTimeIn.isEmpty ? 1 : int.parse(doseTimeIn), +// duration: duration.isEmpty ? 1 : int.parse(duration), +// doseStartDate: doseTime.toIso8601String())); +// postProcedureReqModel.prescriptionRequestModel = prescriptionList; +// await model.postPrescription(postProcedureReqModel, patient.patientMRN); +// +// if (model.state == ViewState.ErrorLocal) { +// Helpers.showErrorToast(model.error); +// } else if (model.state == ViewState.Idle) { +// model.getPrescriptions(patient); +// DrAppToastMsg.showSuccesToast('Medication has been added'); +// } +// } class PrescriptionFormWidget extends StatefulWidget { final PrescriptionViewModel model; @@ -196,6 +190,7 @@ class _PrescriptionFormWidgetState extends State { recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } + // void requestPermissions() async { // void requestPermissions() async { // Map statuses = await [ // Permission.microphone, @@ -234,6 +229,7 @@ class _PrescriptionFormWidgetState extends State { builder: ( BuildContext context, MedicineViewModel model, + Widget child,) => NetworkBaseView( baseViewModel: model, @@ -858,89 +854,7 @@ class _PrescriptionFormWidgetState extends State { if (formKey.currentState .validate()) { Navigator.pop(context); - openDrugToDrug(model); - { - // postProcedure( - // icdCode: model - // .patientAssessmentList - // .isNotEmpty - // ? model - // .patientAssessmentList[ - // 0] - // .icdCode10ID - // .isEmpty - // ? "test" - // : model - // .patientAssessmentList[ - // 0] - // .icdCode10ID - // .toString() - // : "test", - // // icdCode: model - // // .patientAssessmentList - // // .map((value) => value - // // .icdCode10ID - // // .trim()) - // // .toList() - // // .join(' '), - // dose: strengthController - // .text, - // doseUnit: model - // .itemMedicineListUnit - // .length == - // 1 - // ? 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() - // : frequency[ - // 'parameterCode'] - // .toString(), - // route: model.itemMedicineListRoute - // .length == - // 1 - // ? model - // .itemMedicineListRoute[ - // 0][ - // 'parameterCode'] - // .toString() - // : route['parameterCode'] - // .toString(), - // drugId: - // _selectedMedication - // .itemId - // .toString(), - // strength: - // strengthController - // .text, - // indication: - // indicationController - // .text, - // instruction: - // instructionController - // .text, - // doseTime: selectedDate, - // ); - } + openDrugToDrug(model, widget.model); } } else { setState(() { @@ -996,7 +910,6 @@ class _PrescriptionFormWidgetState extends State { } }); } - formKey.currentState.save(); }, ), @@ -1039,154 +952,20 @@ class _PrescriptionFormWidgetState extends State { }); } } - // InputDecoration textFieldSelectorDecoration( - // String hintText, String selectedText, bool isDropDown, - // {Icon suffixIcon}) { - // return InputDecoration( - // focusedBorder: OutlineInputBorder( - // borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - // borderRadius: BorderRadius.circular(8), - // ), - // enabledBorder: OutlineInputBorder( - // borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), - // borderRadius: BorderRadius.circular(8), - // ), - // disabledBorder: OutlineInputBorder( - // borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), - // borderRadius: BorderRadius.circular(8), - // ), - // hintText: selectedText != null ? selectedText : hintText, - // suffixIcon: isDropDown - // ? suffixIcon != null - // ? suffixIcon - // : Icon( - // Icons.keyboard_arrow_down_sharp, - // color: Color(0xff2E303A), - // ) - // : null, - // hintStyle: TextStyle( - // fontSize: 13, - // color: Color(0xff2E303A), - // fontFamily: 'Poppins', - // fontWeight: FontWeight.w600, - // ), - // labelText: selectedText != null ? '$hintText\n$selectedText' : null, - // labelStyle: TextStyle( - // fontSize: 13, - // color: Color(0xff2E303A), - // fontFamily: 'Poppins', - // fontWeight: FontWeight.w600, - // ), - // ); - // } - openDrugToDrug(MedicineViewModel model) { + openDrugToDrug(MedicineViewModel model, PrescriptionViewModel modelPrescription) { showModalBottomSheet( context: context, builder: (context) { - /// TODO Elham* Move this to widget - return Container( - height: SizeConfig.realScreenHeight * .8, - width: SizeConfig.realScreenWidth, - child: SingleChildScrollView( - child: Column( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - DrugToDrug( - widget.patient, - model.getPrescriptionForDrug( - widget.prescriptionList, model - ), - model.patientAssessmentList), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), - child: AppButton( - title: TranslationBase.of(context).addMedication, - onPressed: () { - Navigator.pop(context); - - postPrescription( - icdCode: model.patientAssessmentList.isNotEmpty - ? model.patientAssessmentList[0].icdCode10ID - .isEmpty - ? "test" - : model.patientAssessmentList[0].icdCode10ID - .toString() - : "test", - dose: strengthController.text, - doseUnit: model.itemMedicineListUnit.length == 1 - ? 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() - : frequency['parameterCode'].toString(), - route: model.itemMedicineListRoute.length == 1 - ? model.itemMedicineListRoute[0]['parameterCode'] - .toString() - : route['parameterCode'].toString(), - drugId: _selectedMedication.itemId.toString(), - strength: strengthController.text, - indication: indicationController.text, - instruction: instructionController.text, - doseTime: selectedDate, - ); - }, - )) - ], - )), + return AddDrugWidget( + patient: widget.patient, + medicineModel: model, + modelPrescription: modelPrescription, + prescriptionList: widget.prescriptionList, ); }); } - // getPrescriptionForDrug( - // List prescriptionList, MedicineViewModel model) { - // var prescriptionDetails = []; - // if (prescriptionList.length > 0) { - // prescriptionList[0].entityList.forEach((element) { - // if (element.mediSpanGPICode != null) { - // prescriptionDetails.add({ - // 'DrugId': element.mediSpanGPICode, - // 'DrugName': element.medicationName, - // 'Dose': element.doseDailyQuantity, - // 'DoseType': element.doseDailyUnitID, - // 'Unit': element.uom, - // 'FrequencyType': element.frequencyID, - // 'Duration': element.doseDurationDays, - // 'RouteID': element.routeID, - // 'IsScreen': element.isSIG - // }); - // } - // }); - // } - // if (_selectedMedication.mediSpanGPICode != null) { - // prescriptionDetails.add({ - // 'DrugId': _selectedMedication.mediSpanGPICode, - // 'DrugName': _selectedMedication.description, - // 'Dose': strengthController.text, - // 'DoseType': model.itemMedicineListUnit.length == 1 - // ? model.itemMedicineListUnit[0]['parameterCode'].toString() - // : units['parameterCode'].toString(), - // 'Unit': model.itemMedicineListUnit.length == 1 - // ? model.itemMedicineListUnit[0]['description'] - // : units['description'], - // 'FrequencyType': model.itemMedicineList.length == 1 - // ? model.itemMedicineList[0]['parameterCode'].toString() - // : frequency['parameterCode'].toString(), - // 'Duration': duration['id'].toString(), - // 'RouteID': model.itemMedicineListRoute.length == 1 - // ? model.itemMedicineListRoute[0]['parameterCode'].toString() - // : route['parameterCode'].toString(), - // 'IsScreen': true - // }); - // } - // return prescriptionDetails; - // } searchMedicine(context, MedicineViewModel model) async { FocusScope.of(context).unfocus(); From 2b38293d61c418f0650a94ab8e48153297570622 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Mon, 31 Jan 2022 17:07:54 +0200 Subject: [PATCH 06/25] Refactor add_prescription_form --- lib/core/viewModel/medicine_view_model.dart | 165 ++-- .../add_prescription_form.dart | 852 +----------------- .../prescription_form_widget.dart | 739 +++++++++++++++ .../search_preescription_widget.dart | 153 ++++ .../base_add_procedure_tab_page.dart | 6 +- 5 files changed, 1026 insertions(+), 889 deletions(-) create mode 100644 lib/screens/prescription/add_prescription/prescription_form_widget.dart create mode 100644 lib/screens/prescription/add_prescription/search_preescription_widget.dart diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 2482a30d..2ec86367 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -9,9 +9,11 @@ import 'package:doctor_app_flutter/core/service/patient_medical_file/procedure/p import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:flutter/cupertino.dart'; import '../../locator.dart'; import '../../util/dr_app_toast_msg.dart'; import '../../util/helpers.dart'; +import '../../widgets/shared/loader/gif_loader_dialog_utils.dart'; import '../model/Prescriptions/post_prescrition_req_model.dart'; import '../model/Prescriptions/prescription_model.dart'; import 'base_view_model.dart'; @@ -22,6 +24,7 @@ class MedicineViewModel extends BaseViewModel { ProcedureService _procedureService = locator(); PrescriptionService _prescriptionService = locator(); + List get procedureTemplate => _procedureService.templateList; List templateList = List(); @@ -122,27 +125,6 @@ class MedicineViewModel extends BaseViewModel { } }); } - // if (_selectedMedication.mediSpanGPICode != null) { - // prescriptionDetails.add({ - // 'DrugId': _selectedMedication.mediSpanGPICode, - // 'DrugName': _selectedMedication.description, - // // 'Dose': strengthController.text, - // 'DoseType': model.itemMedicineListUnit.length == 1 - // ? model.itemMedicineListUnit[0]['parameterCode'].toString() - // : units['parameterCode'].toString(), - // 'Unit': model.itemMedicineListUnit.length == 1 - // ? model.itemMedicineListUnit[0]['description'] - // : units['description'], - // 'FrequencyType': model.itemMedicineList.length == 1 - // ? model.itemMedicineList[0]['parameterCode'].toString() - // : frequency['parameterCode'].toString(), - // 'Duration': duration['id'].toString(), - // 'RouteID': model.itemMedicineListRoute.length == 1 - // ? model.itemMedicineListRoute[0]['parameterCode'].toString() - // : route['parameterCode'].toString(), - // 'IsScreen': true - // }); - // } return prescriptionDetails; } @@ -200,11 +182,13 @@ class MedicineViewModel extends BaseViewModel { Future getAssessmentList ({ PatiantInformtion patientInfo, - bool isBusyLocal = false + bool isLocalBusy = false }) async { - patientAssessmentList.map((element) { - return element.icdCode10ID; - }); + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( patientMRN: patientInfo.patientMRN, episodeID: patientInfo.episodeNo.toString(), @@ -220,7 +204,17 @@ class MedicineViewModel extends BaseViewModel { if (medicationDoseTimeList.length == 0) { await getMedicationDoseTime(); } - await getPatientAssessment(getAssessmentReqModel); + await getPatientAssessment(getAssessmentReqModel, isLocalBusy: true); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } + } else { + setState(ViewState.Idle); + } } Future getProcedureTemplate({String categoryID}) async { @@ -258,56 +252,92 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getMedicationList({String drug, bool isLocalBusy = true}) - async { - setState(ViewState.Busy); + + getMedicationList( + {String drug, bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + await getDoctorProfile(isGetProfile: true); await _prescriptionService.getMedicationList(drug: drug); if (_prescriptionService.hasError) { error = _prescriptionService.error; - setState(ViewState.Error); - } else + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } + } else { setState(ViewState.Idle); + } } - // async { - // if (isLocalBusy) { - // setState(ViewState.Busy); - // } else { - // setState(ViewState.BusyLocal); - // } - // - // await _prescriptionService.getMedicationList(drug: drug); - // if (_prescriptionService.hasError) { - // error = _prescriptionService.error; - // if (isLocalBusy) { - // setState(ViewState.ErrorLocal); - // } else { - // setState(ViewState.Error); - // } - // } else { - // //filterData = _prescriptionService.patientList; - // setState(ViewState.Idle); - // } - // } - Future getPatientAssessment( - GetAssessmentReqModel getAssessmentReqModel) async { - setState(ViewState.Busy); + GetAssessmentReqModel getAssessmentReqModel ,{bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } await _prescriptionService.getPatientAssessment(getAssessmentReqModel); if (_prescriptionService.hasError) { error = _prescriptionService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } - Future getMedicationStrength() async { - setState(ViewState.Busy); + Future onInitiateAllPrescription({ + PrescriptionViewModel model, + PatiantInformtion patient, + ProcedureTempleteDetailsModel groupProcedures, + BuildContext context, + bool isLocalBusy = true + } + ) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + model.getItem( + itemID: int.parse( + groupProcedures.aliasN.replaceAll("item code ;", ""))); + + GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( + patientMRN: patient.patientMRN, + episodeID: patient.episodeNo.toString(), + editedBy: '', + doctorID: '', + appointmentNo: patient.appointmentNo); + if (medicationStrengthList.length == 0) { + await getMedicationStrength(); + } + if (medicationDurationList.length == 0) { + await getMedicationDuration(); + } + if (medicationDoseTimeList.length == 0) { + await getMedicationDoseTime(); + } + // await model.getPatientAssessment(getAssessmentReqModel); + // GifLoaderDialogUtils.showMyDialog(context); + await getPatientAssessment(getAssessmentReqModel); + // GifLoaderDialogUtils.hideDialog(context); + } + + Future getMedicationStrength({bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } await _prescriptionService .getMasterLookup(MasterKeysService.MedicationStrength); if (_prescriptionService.hasError) { error = _prescriptionService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } @@ -334,9 +364,12 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getMedicationDoseTime() async { - setState(ViewState.Busy); - await _prescriptionService + Future getMedicationDoseTime({bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } await _prescriptionService .getMasterLookup(MasterKeysService.MedicationDoseTime); if (_prescriptionService.hasError) { error = _prescriptionService.error; @@ -356,13 +389,17 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getMedicationDuration() async { - setState(ViewState.Busy); + Future getMedicationDuration({bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } await _prescriptionService .getMasterLookup(MasterKeysService.MedicationDuration); if (_prescriptionService.hasError) { error = _prescriptionService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } diff --git a/lib/screens/prescription/add_prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription/add_prescription_form.dart index f3c95e57..3201a6ed 100644 --- a/lib/screens/prescription/add_prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription/add_prescription_form.dart @@ -16,6 +16,8 @@ import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/drugtodrug.dart'; +import 'package:doctor_app_flutter/screens/prescription/add_prescription/prescription_form_widget.dart'; +import 'package:doctor_app_flutter/screens/prescription/add_prescription/search_preescription_widget.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_text_filed.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; @@ -25,6 +27,7 @@ import 'package:doctor_app_flutter/widgets/medicine/medicine_item_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; @@ -39,69 +42,19 @@ import 'package:speech_to_text/speech_to_text.dart' as stt; import 'add_drug_widget.dart'; - -// -// postPrescription( -// {String duration, -// String doseTimeIn, -// String dose, -// String drugId, -// String strength, -// String route, -// String frequency, -// String indication, -// String instruction, -// PrescriptionViewModel model, -// DateTime doseTime, -// String doseUnit, -// String icdCode, -// PatiantInformtion patient, -// String patientType}) async { -// PostPrescriptionReqModel postProcedureReqModel = -// new PostPrescriptionReqModel(); -// List prescriptionList = List(); -// -// postProcedureReqModel.appointmentNo = patient.appointmentNo; -// postProcedureReqModel.clinicID = patient.clinicId; -// postProcedureReqModel.episodeID = patient.episodeNo; -// postProcedureReqModel.patientMRN = patient.patientMRN; -// -// prescriptionList.add(PrescriptionRequestModel( -// covered: true, -// dose: double.parse(dose), -// itemId: drugId.isEmpty ? 1 : int.parse(drugId), -// doseUnitId: int.parse(doseUnit), -// route: route.isEmpty ? 1 : int.parse(route), -// frequency: frequency.isEmpty ? 1 : int.parse(frequency), -// remarks: instruction, -// approvalRequired: true, -// icdcode10Id: icdCode.toString(), -// doseTime: doseTimeIn.isEmpty ? 1 : int.parse(doseTimeIn), -// duration: duration.isEmpty ? 1 : int.parse(duration), -// doseStartDate: doseTime.toIso8601String())); -// postProcedureReqModel.prescriptionRequestModel = prescriptionList; -// await model.postPrescription(postProcedureReqModel, patient.patientMRN); -// -// if (model.state == ViewState.ErrorLocal) { -// Helpers.showErrorToast(model.error); -// } else if (model.state == ViewState.Idle) { -// model.getPrescriptions(patient); -// DrAppToastMsg.showSuccesToast('Medication has been added'); -// } -// } - -class PrescriptionFormWidget extends StatefulWidget { - final PrescriptionViewModel model; +class AddPrescriptionForm extends StatefulWidget { + final PrescriptionViewModel prescriptionViewModel; final PatiantInformtion patient; final List prescriptionList; - PrescriptionFormWidget(this.model, this.patient, this.prescriptionList); + + AddPrescriptionForm(this.prescriptionViewModel, this.patient, this.prescriptionList, ); @override - _PrescriptionFormWidgetState createState() => _PrescriptionFormWidgetState(); + _AddPrescriptionFormState createState() => _AddPrescriptionFormState(); } -class _PrescriptionFormWidgetState extends State { +class _AddPrescriptionFormState extends State { String routeError; String frequencyError; String doseTimeError; @@ -117,12 +70,13 @@ class _PrescriptionFormWidgetState extends State { TextEditingController instructionController = TextEditingController(); bool visibilityPrescriptionForm = false; - bool visibilitySearch = true; final myController = TextEditingController(); DateTime selectedDate; int strengthChar; GetMedicationResponseModel _selectedMedication; + MedicineViewModel medicineViewModel; + GlobalKey key = new GlobalKey>(); @@ -145,91 +99,21 @@ class _PrescriptionFormWidgetState extends State { dynamic box; dynamic x; - // @override - // void initState() { - // requestPermissions(); - // event.controller.stream.listen((p) { - // if (p['startPopUp'] == 'true') { - // if (this.mounted) { - // initSpeechState().then((value) => {onVoiceText()}); - // } - // } - // }); - // selectedType = 1; - // super.initState(); - // } - - setSelectedType(int val) { - setState(() { - selectedType = val; - }); - } - - 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); - if (available) { - speech.listen( - onResult: resultListener, - listenMode: stt.ListenMode.confirmation, - localeId: lang == 'en' ? 'en-US' : 'ar-SA', - ); - } else { - print("The user has denied the use of speech recognition."); - } - } - - void errorListener(SpeechRecognitionError error) { - event.setValue({"searchText": 'null'}); - print(error); - } - - void statusListener(String status) { - recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; - } - - // void requestPermissions() async { - // void requestPermissions() async { - // Map statuses = await [ - // Permission.microphone, - // ].request(); - // } - - void resultListener(result) { - recognizedWord = result.recognizedWords; - event.setValue({"searchText": recognizedWord}); - - if (result.finalResult == true) { - setState(() { - SpeechToText.closeAlertDialog(context); - speech.stop(); - instructionController.text += recognizedWord + '\n'; - }); - } else { - print(result.finalResult); - } - } - - Future initSpeechState() async { - bool hasSpeech = await speech.initialize( - onError: errorListener, onStatus: statusListener); - print(hasSpeech); - if (!mounted) return; - } + PatiantInformtion patient; @override Widget build(BuildContext context) { - final screenSize = MediaQuery.of(context).size; return BaseView( - onModelReady: (model) => model.getAssessmentList( - patientInfo: widget.patient - ), + onModelReady: (model) async { + // // await getPatientAssessment(getAssessmentReqModel); + // model.onInitiateAllPrescription(groupProcedures: widget.groupProcedures, patient: widget.patient); + await model.getAssessmentList(patientInfo: widget.patient,isLocalBusy: true); + + + }, builder: ( BuildContext context, MedicineViewModel model, - Widget child,) => NetworkBaseView( baseViewModel: model, @@ -267,659 +151,24 @@ class _PrescriptionFormWidgetState extends State { key: formKey, child: Column( children: [ - FractionallySizedBox( - widthFactor: 0.9, - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - onTap: () { - visibilityPrescriptionForm = false; - visibilitySearch = true; - }, - borderColor: Colors.white, - hintText: TranslationBase.of(context) - .searchMedicineNameHere, - controller: myController, - onSaved: (value) {}, - onFieldSubmitted: (value) { - searchMedicine(context, model); - }, - inputFormatter: ONLY_LETTERS, - ), - ), - ), - SizedBox( - height: 15.0, - ), - Visibility( - visible: visibilitySearch, - child: Container( - child: Column( - children: [ - FractionallySizedBox( - widthFactor: 0.8, - child: Container( - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of( - context) - .search, - onPressed: () async { - await searchMedicine( - context, model); - }, - ), - ], - ), - ), - ), - if (myController.text != '') - Container( - height: MediaQuery.of(context) - .size - .height * - 0.5, - child: ListView.builder( - padding: const EdgeInsets.only( - top: 20), - scrollDirection: Axis.vertical, - itemCount: - model.allMedicationList == - null - ? 0 - : model - .allMedicationList - .length, - itemBuilder: - (BuildContext context, - int index) { - return InkWell( - child: MedicineItemWidget( - label: model - .allMedicationList[ - index] - .description), - onTap: () { - model.getItem( - itemID: model - .allMedicationList[ - index] - .itemId); - visibilityPrescriptionForm = - true; - visibilitySearch = false; - _selectedMedication = - model.allMedicationList[ - index]; - uom = _selectedMedication - .uom; - }, - ); - }, - ), - ), - ], - ), - ), + SearchPrescriptionWidget( + spaceBetweenTextFields: spaceBetweenTextFields, + medicineViewModel: model, + prescriptionViewModel: widget.prescriptionViewModel, ), - SizedBox( - height: spaceBetweenTextFields, - ), - Visibility( - visible: visibilityPrescriptionForm, - child: Container( + + Container( child: Column( children: [ - AppText( - _selectedMedication?.description ?? - "", - fontWeight: FontWeight.w600, - ), - SizedBox( - height: 15.0, - ), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox(width: 6,), - AppText( - TranslationBase.of(context) - .orderType, - fontWeight: FontWeight.w500, - ), - SizedBox(width: 18,), - Radio( - activeColor: - AppGlobal.appRedColor, - value: 1, - groupValue: selectedType, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text(TranslationBase.of(context) - .regular), - ], - ), - ), - Container( - width: double.infinity, - child: Row( - children: [ - Container( - width: MediaQuery.of(context) - .size - .width * - 0.35, - child: AppTextFieldCustom( - height: 38, - validationError: - strengthError, - hintText: 'Strength', - isTextFieldHasSuffix: false, - enabled: true, - controller: - strengthController, - onChanged: (String value) { - setState(() { - strengthChar = - value.length; - }); - if (strengthChar >= 5) { - DrAppToastMsg - .showErrorToast( - TranslationBase.of( - context) - .only5DigitsAllowedForStrength, - ); - } - }, - inputType: TextInputType - .numberWithOptions( - decimal: true, - ), - ), - ), - SizedBox( - width: 5.0, - ), - // Container( - // width: MediaQuery.of(context) - // .size - // .width * - // 0.35, - // child: AppTextFieldCustom( - // height: 38, - // validationError: - // unitError, - // hintText: 'Unit', - // isTextFieldHasSuffix: false, - // enabled: true, - // controller: - // unitController, - // onChanged: (selectedValue) { - // setState(() { - // units = selectedValue; - // units['isDefault'] = true; - // }); - // if (strengthChar >= 5) { - // DrAppToastMsg - // .showErrorToast( - // TranslationBase.of( - // context) - // .only5DigitsAllowedForStrength, - // ); - // } - // }, - // inputType: TextInputType - // .numberWithOptions( - // decimal: true, - // ), - // ), - // ), - PrescriptionTextFiled( - width: MediaQuery.of(context) - .size - .width * - 0.510, - element: model - .itemMedicineListUnit - .length == - 1 - ? model - .itemMedicineListUnit[0] - : units, - elementError: unitError, - keyName: 'description', - keyId: 'parameterCode', - hintText: 'Unit', - elementList: model - .itemMedicineListUnit, - okFunction: (selectedValue) { - setState(() { - units = selectedValue; - units['isDefault'] = true; - }); - }, - ), - ], - ), - ), - SizedBox( - height: spaceBetweenTextFields), - PrescriptionTextFiled( - elementList: - model.itemMedicineListRoute, - element: model.itemMedicineListRoute - .length == - 1 - ? route = model.itemMedicineListRoute[0] - : route, - elementError: routeError, - keyId: 'parameterCode', - keyName: 'description', - okFunction: (selectedValue) { - setState(() { - route = selectedValue; - route['isDefault'] = true; - }); - }, - hintText: - TranslationBase.of(context) - .route, - ), - SizedBox( - height: spaceBetweenTextFields), - PrescriptionTextFiled( - hintText: TranslationBase.of(context).frequency, - elementError: frequencyError, - // element: frequency, - element: model.itemMedicineListRoute - .length == - 1 - ? frequency = model.itemMedicineListRoute[0] - : frequency, - elementList: model.itemMedicineList, - keyId: 'parameterCode', - keyName: 'description', - okFunction: (selectedValue) { - setState(() { - frequency = selectedValue; - frequency['isDefault'] = true; - if (_selectedMedication != null && duration != null && frequency != null && strengthController.text != null) { - model.getBoxQuantity( - freq: frequency['parameterCode'], - duration: duration['id'], - itemCode: _selectedMedication.itemId, - strength: double.parse(strengthController.text) - ); - - return; - } - }); - }), - SizedBox( - height: spaceBetweenTextFields), - PrescriptionTextFiled( - hintText: - TranslationBase.of(context) - .doseTime, - elementError: doseTimeError, - element: doseTime, - elementList: - model.medicationDoseTimeList, - keyId: 'id', - keyName: 'nameEn', - okFunction: (selectedValue) { - setState(() { - doseTime = selectedValue; - }); - }), - SizedBox( - height: spaceBetweenTextFields), - if (model - .patientAssessmentList.isNotEmpty) - Container( - height: screenSize.height * 0.070, - width: double.infinity, - color: Colors.white, - child: Row( - children: [ - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.29, - child: AppTextFieldCustom( - hintText: - model - .patientAssessmentList[ - 0] - .icdCode10ID - .toString(), - // indication != null - // ? indication[ - // 'name'] - // : null, - - enabled: true, - ), - ), - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.57, - color: Colors.white, - child: AppTextFieldCustom( - maxLines: 5, - hintText: - model - .patientAssessmentList[ - 0] - .asciiDesc - .toString(), - // indication != null - // ? indication[ - // 'name'] - // : null, - enabled: true, - ), - ), - ], - ), - ), - SizedBox( - height: spaceBetweenTextFields), - Container( - color: Colors.transparent, - child: InkWell( - onTap: () => selectDate( - context, widget.model), - child: AppTextFieldCustom( - validationError: - strengthError, - hintText: 'Date', - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon( - Icons.calendar_today, - color: Colors.black,), - ), - dropDownText: selectedDate != null - ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" - : null, - enabled: false, - controller: strengthController, - ), - - // 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, - // )), - // enabled: false, - // ), - ), - ), - SizedBox( - height: spaceBetweenTextFields), - PrescriptionTextFiled( - element: duration, - elementError: durationError, - hintText: - TranslationBase.of(context) - .duration, - elementList: - model.medicationDurationList, - keyName: 'nameEn', - keyId: 'id', - okFunction: (selectedValue) { - setState(() { - duration = selectedValue; - if (_selectedMedication != - null && - duration != null && - frequency != null && - strengthController.text != - null) { - model.getBoxQuantity( - freq: frequency[ - 'parameterCode'], - duration: duration['id'], - itemCode: - _selectedMedication - .itemId, - strength: double.parse( - strengthController - .text), - ); - box = model.boxQuintity; - - return; - } - }); - }, - ), - SizedBox( - height: spaceBetweenTextFields), - Container( - color: Colors.white, - child: AppTextFieldCustom( - hintText: "UOM", - isTextFieldHasSuffix: false, - dropDownText: - uom != null ? uom : null, - enabled: false, - ), - ), - SizedBox( - height: spaceBetweenTextFields), - Container( - color: Colors.white, - child: AppTextFieldCustom( - hintText: - TranslationBase.of(context) - .boxQuantity, - isTextFieldHasSuffix: false, - dropDownText: box != null - ? model.boxQuintity.toString() - : null, - enabled: false, - ), - ), - SizedBox( - height: spaceBetweenTextFields - ), - Container( - decoration: BoxDecoration( - 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, - //keyboardType: TextInputType.number, - ), - Positioned( - top: 0, - right: 15, - child: IconButton( - icon: Icon( - DoctorApp.speechtotext, - color: Colors.black, - size: 35, - ), - onPressed: () { - initSpeechState().then( - (value) => - {onVoiceText()}); - }, - ), - ), - ], - ), - ), - SizedBox( - height: spaceBetweenTextFields), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - color: Color(0xff359846), - title: TranslationBase.of( - context) - .addMedication, - fontWeight: FontWeight.w600, - onPressed: () async { - /// TODO Elham* Use it to separate function - 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); - Navigator.pop(context); - return; - } - - 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"); - return; - } - - if (formKey.currentState - .validate()) { - Navigator.pop(context); - openDrugToDrug(model, widget.model); - } - } else { - setState(() { - if (duration == null) { - durationError = - TranslationBase.of( - context) - .fieldRequired; - } else { - durationError = null; - } - if (doseTime == null) { - doseTimeError = - TranslationBase.of( - context) - .fieldRequired; - } else { - doseTimeError = null; - } - if (route == null) { - routeError = - TranslationBase.of( - context) - .fieldRequired; - } else { - routeError = null; - } - if (frequency == null) { - frequencyError = - TranslationBase.of( - context) - .fieldRequired; - } else { - frequencyError = null; - } - if (units == null) { - unitError = - TranslationBase.of( - context) - .fieldRequired; - } else { - unitError = null; - } - if (strengthController - .text == - "") { - strengthError = - TranslationBase.of( - context) - .fieldRequired; - } else { - strengthError = null; - } - }); - } - formKey.currentState.save(); - }, - ), - ], - ), + PrescriptionFormWidget( + patient: widget.patient, + prescriptionViewModel: widget.prescriptionViewModel, + medicineViewModel: model, + prescriptionList: widget.prescriptionList, ), ], ), ), - ), ], ), ), @@ -934,45 +183,4 @@ class _PrescriptionFormWidgetState extends State { ), ); } - - selectDate(BuildContext context, PrescriptionViewModel model) async { - Helpers.hideKeyboard(context); - DateTime selectedDate; - selectedDate = DateTime.now(); - final DateTime picked = await showDatePicker( - context: context, - initialDate: selectedDate, - firstDate: DateTime.now(), - lastDate: DateTime(2040), - initialEntryMode: DatePickerEntryMode.calendar, - ); - if (picked != null && picked != selectedDate) { - setState(() { - this.selectedDate = picked; - }); - } - } - - openDrugToDrug(MedicineViewModel model, PrescriptionViewModel modelPrescription) { - showModalBottomSheet( - context: context, - builder: (context) { - return AddDrugWidget( - patient: widget.patient, - medicineModel: model, - modelPrescription: modelPrescription, - prescriptionList: widget.prescriptionList, - ); - }); - } - - - searchMedicine(context, MedicineViewModel model) async { - FocusScope.of(context).unfocus(); - if (myController.text.length < 3) { - Helpers.showErrorToast(TranslationBase.of(context).moreThan3Letter); - return; - } - await model.getMedicationList(drug: myController.text); - } } diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart new file mode 100644 index 00000000..b75aa52b --- /dev/null +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -0,0 +1,739 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; +import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; +import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; +import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; +import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/locator.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescription_text_filed.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:speech_to_text/speech_recognition_error.dart'; +import 'package:speech_to_text/speech_to_text.dart' as stt; +import 'add_drug_widget.dart'; + + + +class PrescriptionFormWidget extends StatefulWidget { + final PatiantInformtion patient; + final List prescriptionList; + final PrescriptionViewModel prescriptionViewModel; + final MedicineViewModel medicineViewModel; + + + const PrescriptionFormWidget({Key key, this.patient, this.prescriptionList, + this.prescriptionViewModel, this.medicineViewModel,}); + + @override + _PrescriptionFormWidgetState createState() => _PrescriptionFormWidgetState(); +} + +class _PrescriptionFormWidgetState extends State { + String routeError; + String frequencyError; + String doseTimeError; + String durationError; + String unitError; + String strengthError; + + int selectedType; + + TextEditingController strengthController = TextEditingController(); + TextEditingController unitController = TextEditingController(); + TextEditingController indicationController = TextEditingController(); + TextEditingController instructionController = TextEditingController(); + + bool visibilityPrescriptionForm = false; + bool visibilitySearch = true; + + final myController = TextEditingController(); + DateTime selectedDate; + int strengthChar; + GetMedicationResponseModel _selectedMedication; + PrescriptionViewModel prescriptionViewModel; + + GlobalKey key = + new GlobalKey>(); + + TextEditingController drugIdController = TextEditingController(); + TextEditingController doseController = TextEditingController(); + final searchController = TextEditingController(); + stt.SpeechToText speech = stt.SpeechToText(); + var event = RobotProvider(); + var recognizedWord; + + final GlobalKey formKey = GlobalKey(); + final double spaceBetweenTextFields = 12; + dynamic route; + dynamic frequency; + dynamic duration; + dynamic doseTime; + dynamic indication; + dynamic units; + dynamic uom; + dynamic box; + dynamic x; + + + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + + 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); + if (available) { + speech.listen( + onResult: resultListener, + listenMode: stt.ListenMode.confirmation, + localeId: lang == 'en' ? 'en-US' : 'ar-SA', + ); + } else { + print("The user has denied the use of speech recognition."); + } + } + + void errorListener(SpeechRecognitionError error) { + event.setValue({"searchText": 'null'}); + print(error); + } + + void statusListener(String status) { + recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; + } + + // void requestPermissions() async { + // void requestPermissions() async { + // Map statuses = await [ + // Permission.microphone, + // ].request(); + // } + + void resultListener(result) { + recognizedWord = result.recognizedWords; + event.setValue({"searchText": recognizedWord}); + + if (result.finalResult == true) { + setState(() { + SpeechToText.closeAlertDialog(context); + speech.stop(); + instructionController.text += recognizedWord + '\n'; + }); + } else { + print(result.finalResult); + } + } + + Future initSpeechState() async { + bool hasSpeech = await speech.initialize( + onError: errorListener, onStatus: statusListener); + print(hasSpeech); + if (!mounted) return; + } + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + return Visibility( + visible: visibilitySearch, + child: Column( + children: [ + AppText( + _selectedMedication?.description ?? + "", + fontWeight: FontWeight.w600, + ), + SizedBox( + height: 15.0, + ), + Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox(width: 6,), + AppText( + TranslationBase.of(context) + .orderType, + fontWeight: FontWeight.w500, + ), + SizedBox(width: 18,), + Radio( + activeColor: + AppGlobal.appRedColor, + value: 1, + groupValue: selectedType, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context) + .regular), + ], + ), + ), + Container( + width: double.infinity, + child: Row( + children: [ + Container( + width: MediaQuery.of(context) + .size + .width * + 0.35, + child: AppTextFieldCustom( + height: 38, + validationError: + strengthError, + hintText: 'Strength', + isTextFieldHasSuffix: false, + enabled: true, + controller: + strengthController, + onChanged: (String value) { + setState(() { + strengthChar = + value.length; + }); + if (strengthChar >= 5) { + DrAppToastMsg + .showErrorToast( + TranslationBase.of( + context) + .only5DigitsAllowedForStrength, + ); + } + }, + inputType: TextInputType + .numberWithOptions( + decimal: true, + ), + ), + ), + SizedBox( + width: 5.0, + ), + // Container( + // width: MediaQuery.of(context) + // .size + // .width * + // 0.35, + // child: AppTextFieldCustom( + // height: 38, + // validationError: + // unitError, + // hintText: 'Unit', + // isTextFieldHasSuffix: false, + // enabled: true, + // controller: + // unitController, + // onChanged: (selectedValue) { + // setState(() { + // units = selectedValue; + // units['isDefault'] = true; + // }); + // if (strengthChar >= 5) { + // DrAppToastMsg + // .showErrorToast( + // TranslationBase.of( + // context) + // .only5DigitsAllowedForStrength, + // ); + // } + // }, + // inputType: TextInputType + // .numberWithOptions( + // decimal: true, + // ), + // ), + // ), + PrescriptionTextFiled( + width: MediaQuery.of(context) + .size + .width * + 0.510, + element: widget.medicineViewModel + .itemMedicineListUnit + .length == + 1 + ? widget.medicineViewModel + .itemMedicineListUnit[0] + : units, + elementError: unitError, + keyName: 'description', + keyId: 'parameterCode', + hintText: 'Unit', + elementList: widget.medicineViewModel + .itemMedicineListUnit, + okFunction: (selectedValue) { + setState(() { + units = selectedValue; + units['isDefault'] = true; + }); + }, + ), + ], + ), + ), + SizedBox( + height: spaceBetweenTextFields), + PrescriptionTextFiled( + elementList: + widget.medicineViewModel.itemMedicineListRoute, + element: widget.medicineViewModel.itemMedicineListRoute + .length == + 1 + ? route = widget.medicineViewModel.itemMedicineListRoute[0] + : route, + elementError: routeError, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + route['isDefault'] = true; + }); + }, + hintText: + TranslationBase.of(context) + .route, + ), + SizedBox( + height: spaceBetweenTextFields), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).frequency, + elementError: frequencyError, + // element: frequency, + element: widget.medicineViewModel.itemMedicineListRoute + .length == + 1 + ? frequency = widget.medicineViewModel.itemMedicineListRoute[0] + : frequency, + elementList: widget.medicineViewModel.itemMedicineList, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + frequency = selectedValue; + frequency['isDefault'] = true; + if (_selectedMedication != null && duration != null && frequency != null && strengthController.text != null) { + widget.medicineViewModel.getBoxQuantity( + freq: frequency['parameterCode'], + duration: duration['id'], + itemCode: _selectedMedication.itemId, + strength: double.parse(strengthController.text) + ); + + return; + } + }); + }), + SizedBox( + height: spaceBetweenTextFields), + PrescriptionTextFiled( + hintText: + TranslationBase.of(context) + .doseTime, + elementError: doseTimeError, + element: doseTime, + elementList: + widget.medicineViewModel.medicationDoseTimeList, + keyId: 'id', + keyName: 'nameEn', + okFunction: (selectedValue) { + setState(() { + doseTime = selectedValue; + }); + }), + SizedBox( + height: spaceBetweenTextFields), + if (widget.medicineViewModel + .patientAssessmentList.isNotEmpty) + Container( + height: screenSize.height * 0.070, + width: double.infinity, + color: Colors.white, + child: Row( + children: [ + Container( + width: + MediaQuery.of(context) + .size + .width * + 0.29, + child: AppTextFieldCustom( + hintText: + widget.medicineViewModel + .patientAssessmentList[ + 0] + .icdCode10ID + .toString(), + // indication != null + // ? indication[ + // 'name'] + // : null, + + enabled: true, + ), + ), + Container( + width: + MediaQuery.of(context) + .size + .width * + 0.57, + color: Colors.white, + child: AppTextFieldCustom( + maxLines: 5, + hintText: + widget.medicineViewModel + .patientAssessmentList[ + 0] + .asciiDesc + .toString(), + // indication != null + // ? indication[ + // 'name'] + // : null, + enabled: true, + ), + ), + ], + ), + ), + SizedBox( + height: spaceBetweenTextFields), + Container( + color: Colors.transparent, + child: InkWell( + onTap: () => selectDate( + context, widget.prescriptionViewModel), + child: AppTextFieldCustom( + validationError: + strengthError, + hintText: 'Date', + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon( + Icons.calendar_today, + color: Colors.black,), + ), + dropDownText: selectedDate != null + ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + : null, + enabled: false, + controller: strengthController, + ), + + // 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, + // )), + // enabled: false, + // ), + ), + ), + SizedBox( + height: spaceBetweenTextFields), + PrescriptionTextFiled( + element: duration, + elementError: durationError, + hintText: + TranslationBase.of(context) + .duration, + elementList: + widget.medicineViewModel.medicationDurationList, + keyName: 'nameEn', + keyId: 'id', + okFunction: (selectedValue) { + setState(() { + duration = selectedValue; + if (_selectedMedication != + null && + duration != null && + frequency != null && + strengthController.text != + null) { + widget.medicineViewModel.getBoxQuantity( + freq: frequency[ + 'parameterCode'], + duration: duration['id'], + itemCode: + _selectedMedication + .itemId, + strength: double.parse( + strengthController + .text), + ); + box = widget.medicineViewModel.boxQuintity; + + return; + } + }); + }, + ), + SizedBox( + height: spaceBetweenTextFields), + Container( + color: Colors.white, + child: AppTextFieldCustom( + hintText: "UOM", + isTextFieldHasSuffix: false, + dropDownText: + uom != null ? uom : null, + enabled: false, + ), + ), + SizedBox( + height: spaceBetweenTextFields), + Container( + color: Colors.white, + child: AppTextFieldCustom( + hintText: + TranslationBase.of(context) + .boxQuantity, + isTextFieldHasSuffix: false, + dropDownText: box != null + ? widget.medicineViewModel.boxQuintity.toString() + : null, + enabled: false, + ), + ), + SizedBox( + height: spaceBetweenTextFields + ), + Container( + decoration: BoxDecoration( + 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, + //keyboardType: TextInputType.number, + ), + Positioned( + top: 0, + right: 15, + child: IconButton( + icon: Icon( + DoctorApp.speechtotext, + color: Colors.black, + size: 35, + ), + onPressed: () { + initSpeechState().then( + (value) => + {onVoiceText()}); + }, + ), + ), + ], + ), + ), + SizedBox( + height: spaceBetweenTextFields), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + color: Color(0xff359846), + title: TranslationBase.of( + context) + .addMedication, + fontWeight: FontWeight.w600, + onPressed: () async { + addMedicationButton( widget.medicineViewModel); + }, + ), + ], + ), + ), + ], + ), + ); + } + + selectDate(BuildContext context, PrescriptionViewModel model) async { + Helpers.hideKeyboard(context); + DateTime selectedDate; + selectedDate = DateTime.now(); + final DateTime picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime.now(), + lastDate: DateTime(2040), + initialEntryMode: DatePickerEntryMode.calendar, + ); + if (picked != null && picked != selectedDate) { + setState(() { + this.selectedDate = picked; + }); + } + } + + openDrugToDrug(MedicineViewModel model, PrescriptionViewModel modelPrescription) { + showModalBottomSheet( + context: context, + builder: (context) { + return AddDrugWidget( + patient: widget.patient, + medicineModel: model, + modelPrescription: modelPrescription, + prescriptionList: widget.prescriptionList, + ); + }); + } + + + addMedicationButton(MedicineViewModel model) async { + 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); + Navigator.pop(context); + return; + } + + 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"); + return; + } + + if (formKey.currentState + .validate()) { + Navigator.pop(context); + openDrugToDrug(model, widget.prescriptionViewModel); + } + } else { + setState(() { + if (duration == null) { + durationError = + TranslationBase.of( + context) + .fieldRequired; + } else { + durationError = null; + } + if (doseTime == null) { + doseTimeError = + TranslationBase.of( + context) + .fieldRequired; + } else { + doseTimeError = null; + } + if (route == null) { + routeError = + TranslationBase.of( + context) + .fieldRequired; + } else { + routeError = null; + } + if (frequency == null) { + frequencyError = + TranslationBase.of( + context) + .fieldRequired; + } else { + frequencyError = null; + } + if (units == null) { + unitError = + TranslationBase.of( + context) + .fieldRequired; + } else { + unitError = null; + } + if (strengthController + .text == + "") { + strengthError = + TranslationBase.of( + context) + .fieldRequired; + } else { + strengthError = null; + } + }); + } + formKey.currentState.save(); + } +} + + diff --git a/lib/screens/prescription/add_prescription/search_preescription_widget.dart b/lib/screens/prescription/add_prescription/search_preescription_widget.dart new file mode 100644 index 00000000..167c3fb7 --- /dev/null +++ b/lib/screens/prescription/add_prescription/search_preescription_widget.dart @@ -0,0 +1,153 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; +import '../../../config/config.dart'; +import '../../../core/model/search_drug/get_medication_response_model.dart'; +import '../../../core/viewModel/medicine_view_model.dart'; +import '../../../core/viewModel/prescription_view_model.dart'; +import '../../../util/helpers.dart'; +import '../../../util/translations_delegate_base.dart'; +import '../../../widgets/medicine/medicine_item_widget.dart'; +import '../../../widgets/shared/buttons/app_buttons_widget.dart'; +import '../../../widgets/shared/loader/gif_loader_dialog_utils.dart'; +import '../../../widgets/shared/network_base_view.dart'; +import '../../../widgets/shared/text_fields/app_text_form_field.dart'; +import '../../base/base_view.dart'; + +final myController = TextEditingController(); +class SearchPrescriptionWidget extends StatelessWidget { + final double spaceBetweenTextFields; + final MedicineViewModel medicineViewModel; + final PrescriptionViewModel prescriptionViewModel; + + + + + const SearchPrescriptionWidget({Key key, this.spaceBetweenTextFields, this.medicineViewModel, + this.prescriptionViewModel}) : super(key: key); + + @override + Widget build(BuildContext context) { + bool visibilityPrescriptionForm = false; + bool visibilitySearch = true; + GetMedicationResponseModel _selectedMedication; + + return BaseView( + onModelReady: (model) async {}, + builder: ( + BuildContext context, + MedicineViewModel model, + Widget child,) => + NetworkBaseView( + baseViewModel: model, + child: Visibility( + visible: visibilityPrescriptionForm, + child: Column( + children: [ + FractionallySizedBox( + widthFactor: 0.9, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(10), + child: AppTextFormField( + onTap: () { + visibilityPrescriptionForm = false; + visibilitySearch = true; + }, + borderColor: Colors.white, + hintText: TranslationBase.of(context).searchMedicineNameHere, + controller: myController, + onSaved: (value) {}, + onFieldSubmitted: (value) { + searchMedicine(context, model); + }, + inputFormatter: ONLY_LETTERS, + ), + ), + ), + SizedBox( + height: 15.0, + ), + Visibility( + visible: visibilitySearch, + child: Container( + child: Column( + children: [ + FractionallySizedBox( + widthFactor: 0.8, + child: Container( + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context).search, + onPressed: () async { + await searchMedicine( + context, + model, + ); + }, + ), + ], + ), + ), + ), + if (myController.text != '') + Container( + height: MediaQuery.of(context).size.height * 0.5, + child: ListView.builder( + padding: const EdgeInsets.only(top: 20), + scrollDirection: Axis.vertical, + itemCount: model.allMedicationList == null + ? 0 + : model.allMedicationList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + child: MedicineItemWidget( + label: + model.allMedicationList[index].description), + onTap: () { + model.getItem( + itemID: model.allMedicationList[index].itemId); + visibilityPrescriptionForm = true; + visibilitySearch = false; + + _selectedMedication = + model.allMedicationList[index]; + // uom = _selectedMedication.uom; + }, + ); + }, + ), + ), + ], + ), + ), + ), + SizedBox( + height: spaceBetweenTextFields, + ), + ], + ), + ), + + ), + + );} + + searchMedicine(context, MedicineViewModel model) async { + FocusScope.of(context).unfocus(); + if (myController.text.length < 3) { + Helpers.showErrorToast(TranslationBase.of(context).moreThan3Letter); + return; + } + GifLoaderDialogUtils.showMyDialog(context); + await model.getMedicationList(drug: myController.text,isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + } + +} + + diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index 90ca0e55..7ef3e6e2 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -167,11 +167,11 @@ class _BaseAddProcedureTabPageState extends State ), if (widget.procedureType == ProcedureType.PRESCRIPTION) - PrescriptionFormWidget( + AddPrescriptionForm( widget.prescriptionModel, widget.patient, - widget.prescriptionModel - .prescriptionList) + widget.prescriptionModel.prescriptionList, + ) else AddProcedurePage( model: this.model, From c1956aee9bcd0c56406be960811d7a397a3d106b Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Tue, 1 Feb 2022 10:05:02 +0200 Subject: [PATCH 07/25] Refactor add_prescription_form --- .../add_prescription_form.dart | 91 +- .../prescription_form_widget.dart | 840 ++++++++---------- .../search_preescription_widget.dart | 203 ++--- 3 files changed, 494 insertions(+), 640 deletions(-) diff --git a/lib/screens/prescription/add_prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription/add_prescription_form.dart index 3201a6ed..a5889a5a 100644 --- a/lib/screens/prescription/add_prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription/add_prescription_form.dart @@ -1,54 +1,24 @@ import 'package:autocomplete_textfield/autocomplete_textfield.dart'; -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; -import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; -import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/locator.dart'; -import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/prescription/add_prescription/drugtodrug.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/prescription_form_widget.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/search_preescription_widget.dart'; -import 'package:doctor_app_flutter/screens/prescription/prescription_text_filed.dart'; -import 'package:doctor_app_flutter/util/date-utils.dart'; -import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/medicine/medicine_item_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; -import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:permission_handler/permission_handler.dart'; -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; -import 'add_drug_widget.dart'; - class AddPrescriptionForm extends StatefulWidget { final PrescriptionViewModel prescriptionViewModel; final PatiantInformtion patient; final List prescriptionList; - - AddPrescriptionForm(this.prescriptionViewModel, this.patient, this.prescriptionList, ); + AddPrescriptionForm( + this.prescriptionViewModel, this.patient, this.prescriptionList); @override _AddPrescriptionFormState createState() => _AddPrescriptionFormState(); @@ -61,9 +31,10 @@ class _AddPrescriptionFormState extends State { String durationError; String unitError; String strengthError; - int selectedType; + bool visibilitySearch = true; + TextEditingController strengthController = TextEditingController(); TextEditingController unitController = TextEditingController(); TextEditingController indicationController = TextEditingController(); @@ -107,21 +78,21 @@ class _AddPrescriptionFormState extends State { onModelReady: (model) async { // // await getPatientAssessment(getAssessmentReqModel); // model.onInitiateAllPrescription(groupProcedures: widget.groupProcedures, patient: widget.patient); - await model.getAssessmentList(patientInfo: widget.patient,isLocalBusy: true); - - + await model.getAssessmentList( + patientInfo: widget.patient, isLocalBusy: true); }, builder: ( BuildContext context, MedicineViewModel model, - Widget child,) => + Widget child, + ) => NetworkBaseView( - baseViewModel: model, - child: GestureDetector( - onTap: () { + baseViewModel: model, + child: GestureDetector( + onTap: () { FocusScope.of(context).requestFocus(new FocusNode()); - }, - child: DraggableScrollableSheet( + }, + child: DraggableScrollableSheet( initialChildSize: 0.98, maxChildSize: 0.98, minChildSize: 0.9, @@ -151,24 +122,42 @@ class _AddPrescriptionFormState extends State { key: formKey, child: Column( children: [ - SearchPrescriptionWidget( - spaceBetweenTextFields: spaceBetweenTextFields, - medicineViewModel: model, - prescriptionViewModel: widget.prescriptionViewModel, + Visibility( + visible: visibilitySearch, + child: SearchPrescriptionWidget( + spaceBetweenTextFields: + spaceBetweenTextFields, + medicineViewModel: model, + prescriptionViewModel: + widget.prescriptionViewModel, + onItemSelected: + (GetMedicationResponseModel + medication) { + setState(() { + visibilitySearch = !visibilitySearch; + _selectedMedication = medication; + }); + }, + ), ), - - Container( + Visibility( + visible: !visibilitySearch, + child: Container( child: Column( children: [ PrescriptionFormWidget( patient: widget.patient, - prescriptionViewModel: widget.prescriptionViewModel, + prescriptionViewModel: + widget.prescriptionViewModel, medicineViewModel: model, - prescriptionList: widget.prescriptionList, + prescriptionList: + widget.prescriptionList, + selectedMedication: _selectedMedication, ), ], ), ), + ), ], ), ), diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index b75aa52b..9569fa94 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -2,6 +2,7 @@ import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; @@ -9,7 +10,6 @@ import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/locator.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_text_filed.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; @@ -25,19 +25,23 @@ import 'package:flutter/services.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; -import 'add_drug_widget.dart'; - +import 'add_drug_widget.dart'; class PrescriptionFormWidget extends StatefulWidget { final PatiantInformtion patient; final List prescriptionList; final PrescriptionViewModel prescriptionViewModel; final MedicineViewModel medicineViewModel; + final GetMedicationResponseModel selectedMedication; - - const PrescriptionFormWidget({Key key, this.patient, this.prescriptionList, - this.prescriptionViewModel, this.medicineViewModel,}); + const PrescriptionFormWidget( + {Key key, + this.patient, + this.prescriptionList, + this.prescriptionViewModel, + this.medicineViewModel, + this.selectedMedication}); @override _PrescriptionFormWidgetState createState() => _PrescriptionFormWidgetState(); @@ -64,11 +68,10 @@ class _PrescriptionFormWidgetState extends State { final myController = TextEditingController(); DateTime selectedDate; int strengthChar; - GetMedicationResponseModel _selectedMedication; PrescriptionViewModel prescriptionViewModel; GlobalKey key = - new GlobalKey>(); + new GlobalKey>(); TextEditingController drugIdController = TextEditingController(); TextEditingController doseController = TextEditingController(); @@ -89,7 +92,6 @@ class _PrescriptionFormWidgetState extends State { dynamic box; dynamic x; - setSelectedType(int val) { setState(() { selectedType = val; @@ -153,445 +155,366 @@ class _PrescriptionFormWidgetState extends State { @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; - return Visibility( - visible: visibilitySearch, - child: Column( - children: [ - AppText( - _selectedMedication?.description ?? - "", - fontWeight: FontWeight.w600, - ), - SizedBox( - height: 15.0, - ), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox(width: 6,), - AppText( - TranslationBase.of(context) - .orderType, - fontWeight: FontWeight.w500, - ), - SizedBox(width: 18,), - Radio( - activeColor: - AppGlobal.appRedColor, - value: 1, - groupValue: selectedType, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text(TranslationBase.of(context) - .regular), - ], - ), + return Column( + children: [ + AppText( + widget.selectedMedication?.description ?? "", + fontWeight: FontWeight.w600, + ), + SizedBox( + height: 15.0, + ), + Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + width: 6, + ), + AppText( + TranslationBase.of(context).orderType, + fontWeight: FontWeight.w500, + ), + SizedBox( + width: 18, + ), + Radio( + activeColor: AppGlobal.appRedColor, + value: 1, + groupValue: selectedType, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).regular), + ], ), - Container( - width: double.infinity, - child: Row( - children: [ - Container( - width: MediaQuery.of(context) - .size - .width * - 0.35, - child: AppTextFieldCustom( - height: 38, - validationError: - strengthError, - hintText: 'Strength', - isTextFieldHasSuffix: false, - enabled: true, - controller: - strengthController, - onChanged: (String value) { - setState(() { - strengthChar = - value.length; - }); - if (strengthChar >= 5) { - DrAppToastMsg - .showErrorToast( - TranslationBase.of( - context) - .only5DigitsAllowedForStrength, - ); - } - }, - inputType: TextInputType - .numberWithOptions( - decimal: true, - ), - ), - ), - SizedBox( - width: 5.0, - ), - // Container( - // width: MediaQuery.of(context) - // .size - // .width * - // 0.35, - // child: AppTextFieldCustom( - // height: 38, - // validationError: - // unitError, - // hintText: 'Unit', - // isTextFieldHasSuffix: false, - // enabled: true, - // controller: - // unitController, - // onChanged: (selectedValue) { - // setState(() { - // units = selectedValue; - // units['isDefault'] = true; - // }); - // if (strengthChar >= 5) { - // DrAppToastMsg - // .showErrorToast( - // TranslationBase.of( - // context) - // .only5DigitsAllowedForStrength, - // ); - // } - // }, - // inputType: TextInputType - // .numberWithOptions( - // decimal: true, - // ), - // ), - // ), - PrescriptionTextFiled( - width: MediaQuery.of(context) - .size - .width * - 0.510, - element: widget.medicineViewModel - .itemMedicineListUnit - .length == - 1 - ? widget.medicineViewModel - .itemMedicineListUnit[0] - : units, - elementError: unitError, - keyName: 'description', - keyId: 'parameterCode', - hintText: 'Unit', - elementList: widget.medicineViewModel - .itemMedicineListUnit, - okFunction: (selectedValue) { + ), + Container( + width: double.infinity, + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.35, + child: AppTextFieldCustom( + height: 38, + validationError: strengthError, + hintText: 'Strength', + isTextFieldHasSuffix: false, + enabled: true, + controller: strengthController, + onChanged: (String value) { setState(() { - units = selectedValue; - units['isDefault'] = true; + strengthChar = value.length; }); + if (strengthChar >= 5) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .only5DigitsAllowedForStrength, + ); + } }, - ), - ], - ), - ), - SizedBox( - height: spaceBetweenTextFields), - PrescriptionTextFiled( - elementList: - widget.medicineViewModel.itemMedicineListRoute, - element: widget.medicineViewModel.itemMedicineListRoute - .length == - 1 - ? route = widget.medicineViewModel.itemMedicineListRoute[0] - : route, - elementError: routeError, - keyId: 'parameterCode', - keyName: 'description', - okFunction: (selectedValue) { - setState(() { - route = selectedValue; - route['isDefault'] = true; - }); - }, - hintText: - TranslationBase.of(context) - .route, - ), - SizedBox( - height: spaceBetweenTextFields), - PrescriptionTextFiled( - hintText: TranslationBase.of(context).frequency, - elementError: frequencyError, - // element: frequency, - element: widget.medicineViewModel.itemMedicineListRoute - .length == - 1 - ? frequency = widget.medicineViewModel.itemMedicineListRoute[0] - : frequency, - elementList: widget.medicineViewModel.itemMedicineList, - keyId: 'parameterCode', - keyName: 'description', - okFunction: (selectedValue) { - setState(() { - frequency = selectedValue; - frequency['isDefault'] = true; - if (_selectedMedication != null && duration != null && frequency != null && strengthController.text != null) { - widget.medicineViewModel.getBoxQuantity( - freq: frequency['parameterCode'], - duration: duration['id'], - itemCode: _selectedMedication.itemId, - strength: double.parse(strengthController.text) - ); - - return; - } - }); - }), - SizedBox( - height: spaceBetweenTextFields), - PrescriptionTextFiled( - hintText: - TranslationBase.of(context) - .doseTime, - elementError: doseTimeError, - element: doseTime, - elementList: - widget.medicineViewModel.medicationDoseTimeList, - keyId: 'id', - keyName: 'nameEn', - okFunction: (selectedValue) { - setState(() { - doseTime = selectedValue; - }); - }), - SizedBox( - height: spaceBetweenTextFields), - if (widget.medicineViewModel - .patientAssessmentList.isNotEmpty) - Container( - height: screenSize.height * 0.070, - width: double.infinity, - color: Colors.white, - child: Row( - children: [ - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.29, - child: AppTextFieldCustom( - hintText: - widget.medicineViewModel - .patientAssessmentList[ - 0] - .icdCode10ID - .toString(), - // indication != null - // ? indication[ - // 'name'] - // : null, - - enabled: true, - ), + inputType: TextInputType.numberWithOptions( + decimal: true, ), - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.57, - color: Colors.white, - child: AppTextFieldCustom( - maxLines: 5, - hintText: - widget.medicineViewModel - .patientAssessmentList[ - 0] - .asciiDesc - .toString(), - // indication != null - // ? indication[ - // 'name'] - // : null, - enabled: true, - ), - ), - ], - ), - ), - SizedBox( - height: spaceBetweenTextFields), - Container( - color: Colors.transparent, - child: InkWell( - onTap: () => selectDate( - context, widget.prescriptionViewModel), - child: AppTextFieldCustom( - validationError: - strengthError, - hintText: 'Date', - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon( - Icons.calendar_today, - color: Colors.black,), ), - dropDownText: selectedDate != null - ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" - : null, - enabled: false, - controller: strengthController, ), - - // TextField( - // decoration: - // textFieldSelectorDecoration( + SizedBox( + width: 5.0, + ), + // Container( + // width: MediaQuery.of(context) + // .size + // .width * + // 0.35, + // child: AppTextFieldCustom( + // height: 38, + // validationError: + // unitError, + // hintText: 'Unit', + // isTextFieldHasSuffix: false, + // enabled: true, + // controller: + // unitController, + // onChanged: (selectedValue) { + // setState(() { + // units = selectedValue; + // units['isDefault'] = true; + // }); + // if (strengthChar >= 5) { + // DrAppToastMsg + // .showErrorToast( // 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, + // context) + // .only5DigitsAllowedForStrength, + // ); + // } + // }, + // inputType: TextInputType + // .numberWithOptions( + // decimal: true, + // ), + // ), // ), - ), + PrescriptionTextFiled( + width: MediaQuery.of(context).size.width * 0.510, + element: + widget.medicineViewModel.itemMedicineListUnit.length == 1 + ? widget.medicineViewModel.itemMedicineListUnit[0] + : units, + elementError: unitError, + keyName: 'description', + keyId: 'parameterCode', + hintText: 'Unit', + elementList: widget.medicineViewModel.itemMedicineListUnit, + okFunction: (selectedValue) { + setState(() { + units = selectedValue; + units['isDefault'] = true; + }); + }, + ), + ], ), - SizedBox( - height: spaceBetweenTextFields), - PrescriptionTextFiled( - element: duration, - elementError: durationError, - hintText: - TranslationBase.of(context) - .duration, - elementList: - widget.medicineViewModel.medicationDurationList, - keyName: 'nameEn', - keyId: 'id', + ), + SizedBox(height: spaceBetweenTextFields), + PrescriptionTextFiled( + elementList: widget.medicineViewModel.itemMedicineListRoute, + element: widget.medicineViewModel.itemMedicineListRoute.length == 1 + ? route = widget.medicineViewModel.itemMedicineListRoute[0] + : route, + elementError: routeError, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + route['isDefault'] = true; + }); + }, + hintText: TranslationBase.of(context).route, + ), + SizedBox(height: spaceBetweenTextFields), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).frequency, + elementError: frequencyError, + // element: frequency, + element: widget.medicineViewModel.itemMedicineListRoute.length == 1 + ? frequency = widget.medicineViewModel.itemMedicineListRoute[0] + : frequency, + elementList: widget.medicineViewModel.itemMedicineList, + keyId: 'parameterCode', + keyName: 'description', okFunction: (selectedValue) { setState(() { - duration = selectedValue; - if (_selectedMedication != - null && + frequency = selectedValue; + frequency['isDefault'] = true; + if (widget.selectedMedication != null && duration != null && frequency != null && - strengthController.text != - null) { + strengthController.text != null) { widget.medicineViewModel.getBoxQuantity( - freq: frequency[ - 'parameterCode'], - duration: duration['id'], - itemCode: - _selectedMedication - .itemId, - strength: double.parse( - strengthController - .text), - ); - box = widget.medicineViewModel.boxQuintity; + freq: frequency['parameterCode'], + duration: duration['id'], + itemCode: widget.selectedMedication.itemId, + strength: double.parse(strengthController.text)); return; } }); - }, - ), - SizedBox( - height: spaceBetweenTextFields), + }), + SizedBox(height: spaceBetweenTextFields), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).doseTime, + elementError: doseTimeError, + element: doseTime, + elementList: widget.medicineViewModel.medicationDoseTimeList, + keyId: 'id', + keyName: 'nameEn', + okFunction: (selectedValue) { + setState(() { + doseTime = selectedValue; + }); + }), + SizedBox(height: spaceBetweenTextFields), + if (widget.medicineViewModel.patientAssessmentList.isNotEmpty) Container( + height: screenSize.height * 0.070, + width: double.infinity, color: Colors.white, - child: AppTextFieldCustom( - hintText: "UOM", - isTextFieldHasSuffix: false, - dropDownText: - uom != null ? uom : null, - enabled: false, + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.29, + child: AppTextFieldCustom( + hintText: widget + .medicineViewModel.patientAssessmentList[0].icdCode10ID + .toString(), + // indication != null + // ? indication[ + // 'name'] + // : null, + + enabled: true, + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.57, + color: Colors.white, + child: AppTextFieldCustom( + maxLines: 5, + hintText: widget + .medicineViewModel.patientAssessmentList[0].asciiDesc + .toString(), + // indication != null + // ? indication[ + // 'name'] + // : null, + enabled: true, + ), + ), + ], ), ), - SizedBox( - height: spaceBetweenTextFields), - Container( - color: Colors.white, + SizedBox(height: spaceBetweenTextFields), + Container( + color: Colors.transparent, + child: InkWell( + onTap: () => selectDate(context, widget.prescriptionViewModel), child: AppTextFieldCustom( - hintText: - TranslationBase.of(context) - .boxQuantity, - isTextFieldHasSuffix: false, - dropDownText: box != null - ? widget.medicineViewModel.boxQuintity.toString() + validationError: strengthError, + hintText: 'Date', + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon( + Icons.calendar_today, + color: Colors.black, + ), + ), + dropDownText: selectedDate != null + ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" : null, enabled: false, + controller: strengthController, ), + + // 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, + // )), + // enabled: false, + // ), ), - SizedBox( - height: spaceBetweenTextFields + ), + SizedBox(height: spaceBetweenTextFields), + PrescriptionTextFiled( + element: duration, + elementError: durationError, + hintText: TranslationBase.of(context).duration, + elementList: widget.medicineViewModel.medicationDurationList, + keyName: 'nameEn', + keyId: 'id', + okFunction: (selectedValue) { + setState(() { + duration = selectedValue; + if (widget.selectedMedication != null && + duration != null && + frequency != null && + strengthController.text != null) { + widget.medicineViewModel.getBoxQuantity( + freq: frequency['parameterCode'], + duration: duration['id'], + itemCode: widget.selectedMedication.itemId, + strength: double.parse(strengthController.text), + ); + box = widget.medicineViewModel.boxQuintity; + + return; + } + }); + }, + ), + SizedBox(height: spaceBetweenTextFields), + Container( + color: Colors.white, + child: AppTextFieldCustom( + hintText: "UOM", + isTextFieldHasSuffix: false, + dropDownText: uom != null ? uom : null, + enabled: false, ), - Container( - decoration: BoxDecoration( - 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, - //keyboardType: TextInputType.number, - ), - Positioned( - top: 0, - right: 15, - child: IconButton( - icon: Icon( - DoctorApp.speechtotext, - color: Colors.black, - size: 35, - ), - onPressed: () { - initSpeechState().then( - (value) => - {onVoiceText()}); - }, - ), - ), - ], - ), + ), + SizedBox(height: spaceBetweenTextFields), + Container( + color: Colors.white, + child: AppTextFieldCustom( + hintText: TranslationBase.of(context).boxQuantity, + isTextFieldHasSuffix: false, + dropDownText: box != null + ? widget.medicineViewModel.boxQuintity.toString() + : null, + enabled: false, ), - SizedBox( - height: spaceBetweenTextFields), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - color: Color(0xff359846), - title: TranslationBase.of( - context) - .addMedication, - fontWeight: FontWeight.w600, - onPressed: () async { - addMedicationButton( widget.medicineViewModel); + ), + SizedBox(height: spaceBetweenTextFields), + Container( + decoration: BoxDecoration( + 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, + //keyboardType: TextInputType.number, + ), + Positioned( + top: 0, + right: 15, + child: IconButton( + icon: Icon( + DoctorApp.speechtotext, + color: Colors.black, + size: 35, + ), + onPressed: () { + initSpeechState().then((value) => {onVoiceText()}); }, ), - ], - ), + ), + ], + ), + ), + SizedBox(height: spaceBetweenTextFields), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + color: Color(0xff359846), + title: TranslationBase.of(context).addMedication, + fontWeight: FontWeight.w600, + onPressed: () async { + addMedicationButton(widget.medicineViewModel); + }, + ), + ], ), - ], - ), + ), + ], ); } @@ -613,7 +536,8 @@ class _PrescriptionFormWidgetState extends State { } } - openDrugToDrug(MedicineViewModel model, PrescriptionViewModel modelPrescription) { + openDrugToDrug( + MedicineViewModel model, PrescriptionViewModel modelPrescription) { showModalBottomSheet( context: context, builder: (context) { @@ -626,107 +550,65 @@ class _PrescriptionFormWidgetState extends State { }); } - addMedicationButton(MedicineViewModel model) async { - await locator< - AnalyticsService>() - .logEvent( - eventCategory: - "Add Prescription Form", - eventAction: - "Add Prescription", + await locator().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 (widget.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, widget.prescriptionViewModel); + openDrugToDrug(model, widget.prescriptionViewModel); } } 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; } @@ -735,5 +617,3 @@ class _PrescriptionFormWidgetState extends State { formKey.currentState.save(); } } - - diff --git a/lib/screens/prescription/add_prescription/search_preescription_widget.dart b/lib/screens/prescription/add_prescription/search_preescription_widget.dart index 167c3fb7..4e6cd449 100644 --- a/lib/screens/prescription/add_prescription/search_preescription_widget.dart +++ b/lib/screens/prescription/add_prescription/search_preescription_widget.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; + import '../../../config/config.dart'; import '../../../core/model/search_drug/get_medication_response_model.dart'; import '../../../core/viewModel/medicine_view_model.dart'; @@ -15,127 +16,114 @@ import '../../../widgets/shared/text_fields/app_text_form_field.dart'; import '../../base/base_view.dart'; final myController = TextEditingController(); + class SearchPrescriptionWidget extends StatelessWidget { final double spaceBetweenTextFields; final MedicineViewModel medicineViewModel; final PrescriptionViewModel prescriptionViewModel; + final Function(GetMedicationResponseModel) onItemSelected; - - - - const SearchPrescriptionWidget({Key key, this.spaceBetweenTextFields, this.medicineViewModel, - this.prescriptionViewModel}) : super(key: key); + const SearchPrescriptionWidget( + {Key key, + this.spaceBetweenTextFields, + this.medicineViewModel, + this.prescriptionViewModel, + this.onItemSelected}) + : super(key: key); @override Widget build(BuildContext context) { - bool visibilityPrescriptionForm = false; - bool visibilitySearch = true; - GetMedicationResponseModel _selectedMedication; - return BaseView( onModelReady: (model) async {}, - builder: ( - BuildContext context, - MedicineViewModel model, - Widget child,) => - NetworkBaseView( - baseViewModel: model, - child: Visibility( - visible: visibilityPrescriptionForm, - child: Column( - children: [ - FractionallySizedBox( - widthFactor: 0.9, - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( - onTap: () { - visibilityPrescriptionForm = false; - visibilitySearch = true; - }, - borderColor: Colors.white, - hintText: TranslationBase.of(context).searchMedicineNameHere, - controller: myController, - onSaved: (value) {}, - onFieldSubmitted: (value) { - searchMedicine(context, model); - }, - inputFormatter: ONLY_LETTERS, - ), - ), - ), - SizedBox( - height: 15.0, + builder: ( + BuildContext context, + MedicineViewModel model, + Widget child, + ) => + NetworkBaseView( + baseViewModel: model, + child: Column( + children: [ + FractionallySizedBox( + widthFactor: 0.9, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(10), + child: AppTextFormField( + borderColor: Colors.white, + hintText: TranslationBase.of(context).searchMedicineNameHere, + controller: myController, + onSaved: (value) {}, + onFieldSubmitted: (value) { + searchMedicine(context, model); + }, + inputFormatter: ONLY_LETTERS, ), - Visibility( - visible: visibilitySearch, - child: Container( - child: Column( - children: [ - FractionallySizedBox( - widthFactor: 0.8, - child: Container( - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of(context).search, - onPressed: () async { - await searchMedicine( - context, - model, - ); - }, - ), - ], - ), - ), - ), - if (myController.text != '') - Container( - height: MediaQuery.of(context).size.height * 0.5, - child: ListView.builder( - padding: const EdgeInsets.only(top: 20), - scrollDirection: Axis.vertical, - itemCount: model.allMedicationList == null - ? 0 - : model.allMedicationList.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - child: MedicineItemWidget( - label: - model.allMedicationList[index].description), - onTap: () { - model.getItem( - itemID: model.allMedicationList[index].itemId); - visibilityPrescriptionForm = true; - visibilitySearch = false; - - _selectedMedication = - model.allMedicationList[index]; - // uom = _selectedMedication.uom; - }, - ); - }, - ), + ), + ), + SizedBox( + height: 15.0, + ), + Container( + child: Column( + children: [ + FractionallySizedBox( + widthFactor: 0.8, + child: Container( + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context).search, + onPressed: () async { + await searchMedicine( + context, + model, + ); + }, ), - ], + ], + ), ), ), - ), - SizedBox( - height: spaceBetweenTextFields, - ), - ], + if (myController.text != '') + Container( + height: MediaQuery.of(context).size.height * 0.5, + child: ListView.builder( + padding: const EdgeInsets.only(top: 20), + scrollDirection: Axis.vertical, + itemCount: model.allMedicationList == null + ? 0 + : model.allMedicationList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + child: MedicineItemWidget( + label: + model.allMedicationList[index].description), + onTap: () { + model.getItem( + itemID: + model.allMedicationList[index].itemId); + onItemSelected(model.allMedicationList[index]); + // uom = _selectedMedication.uom; + }, + ); + }, + ), + ), + ], + ), ), - ), - + SizedBox( + height: spaceBetweenTextFields, + ), + ], ), - - );} + ), + ); + } searchMedicine(context, MedicineViewModel model) async { FocusScope.of(context).unfocus(); @@ -144,10 +132,7 @@ class SearchPrescriptionWidget extends StatelessWidget { return; } GifLoaderDialogUtils.showMyDialog(context); - await model.getMedicationList(drug: myController.text,isLocalBusy: true); + await model.getMedicationList(drug: myController.text, isLocalBusy: true); GifLoaderDialogUtils.hideDialog(context); } - } - - From 5b8211eec4f68cad996d5fb4e43b4191fd803b4f Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Tue, 1 Feb 2022 14:29:12 +0200 Subject: [PATCH 08/25] Refactor add_prescription_form --- .../procedure/procedure_service.dart | 3 +- lib/core/viewModel/medicine_view_model.dart | 44 +++++++++---------- lib/core/viewModel/procedure_View_model.dart | 18 ++++---- .../add_prescription_form.dart | 15 +++---- .../search_preescription_widget.dart | 9 ++-- .../procedures/add-favourite-procedure.dart | 10 ++--- .../base_add_procedure_tab_page.dart | 38 +++++----------- 7 files changed, 63 insertions(+), 74 deletions(-) diff --git a/lib/core/service/patient_medical_file/procedure/procedure_service.dart b/lib/core/service/patient_medical_file/procedure/procedure_service.dart index be674540..c207d459 100644 --- a/lib/core/service/patient_medical_file/procedure/procedure_service.dart +++ b/lib/core/service/patient_medical_file/procedure/procedure_service.dart @@ -67,12 +67,13 @@ class ProcedureService extends BaseService { ); Future getProcedureTemplate( - {int doctorId, int projectId, int clinicId, String categoryID}) async { + {int doctorId, int projectId, int clinicId, String categoryID, bool isLocalBusy}) async { _procedureTempleteRequestModel = ProcedureTempleteRequestModel( // tokenID: "@dm!n", patientID: 0, searchType: 1, ); + hasError = false; await baseAppClient.post(GET_TEMPLETE_LIST /*GET_PROCEDURE_TEMPLETE*/, diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 2ec86367..2b645a29 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -68,16 +68,30 @@ class MedicineViewModel extends BaseViewModel { - Future getItem({int itemID}) async { - setState(ViewState.Busy); + Future getItem({int itemID, bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } await _prescriptionService.getItem(itemID: itemID); if (_prescriptionService.hasError) { error = _prescriptionService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } + // async { + // setState(ViewState.BusyLocal); + // await _prescriptionService.getItem(itemID: itemID); + // if (_prescriptionService.hasError) { + // error = _prescriptionService.error; + // setState(ViewState.ErrorLocal); + // } else + // setState(ViewState.Idle); + // } + setTemplateListDependOnId() { procedureTemplate.forEach((element) { List templateListData = templateList @@ -180,10 +194,7 @@ class MedicineViewModel extends BaseViewModel { - Future getAssessmentList ({ - PatiantInformtion patientInfo, - bool isLocalBusy = false - }) async { + Future getAssessmentList ({PatiantInformtion patientInfo, bool isLocalBusy = false}) async { if (isLocalBusy) { setState(ViewState.BusyLocal); } else { @@ -196,13 +207,13 @@ class MedicineViewModel extends BaseViewModel { doctorID: '', appointmentNo: patientInfo.appointmentNo); if (medicationStrengthList.length == 0) { - await getMedicationStrength(); + await getMedicationStrength(isLocalBusy: true); } if (medicationDurationList.length == 0) { - await getMedicationDuration(); + await getMedicationDuration(isLocalBusy: true); } if (medicationDoseTimeList.length == 0) { - await getMedicationDoseTime(); + await getMedicationDoseTime(isLocalBusy: true); } await getPatientAssessment(getAssessmentReqModel, isLocalBusy: true); if (_prescriptionService.hasError) { @@ -217,18 +228,7 @@ class MedicineViewModel extends BaseViewModel { } } - Future getProcedureTemplate({String categoryID}) async { - hasError = false; - setState(ViewState.Busy); - await _procedureService.getProcedureTemplate(categoryID: categoryID); - if (_procedureService.hasError) { - error = _procedureService.error; - setState(ViewState.ErrorLocal); - } else { - setTemplateListDependOnId(); - setState(ViewState.Idle); - } - } + Future getPrescription({int mrn}) async { //hasError = false; diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index 1d12328e..2bcfad33 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -6,8 +6,7 @@ import 'package:doctor_app_flutter/core/model/labs/patient_lab_orders.dart'; import 'package:doctor_app_flutter/core/model/labs/patient_lab_special_result.dart'; import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart'; import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; -import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart' - as cpe; +import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart' as cpe; import 'package:doctor_app_flutter/core/model/procedure/get_ordered_procedure_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; @@ -25,6 +24,7 @@ import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; +import '../../widgets/shared/loader/gif_loader_dialog_utils.dart'; class ProcedureViewModel extends BaseViewModel { //TODO Hussam clean it @@ -117,17 +117,19 @@ class ProcedureViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getProcedureTemplate({String categoryID}) async { - hasError = false; - setState(ViewState.Busy); - await _procedureService.getProcedureTemplate(categoryID: categoryID); + Future getProcedureTemplate({String categoryID, bool isLocalBusy = false, BuildContext context}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + await _procedureService.getProcedureTemplate(categoryID: categoryID, isLocalBusy: false); if (_procedureService.hasError) { error = _procedureService.error; setState(ViewState.ErrorLocal); - } else { + } else setTemplateListDependOnId(); setState(ViewState.Idle); - } } setTemplateListDependOnId() { diff --git a/lib/screens/prescription/add_prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription/add_prescription_form.dart index a5889a5a..ada41bd7 100644 --- a/lib/screens/prescription/add_prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription/add_prescription_form.dart @@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/prescription_form_widget.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/search_preescription_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; @@ -75,12 +76,6 @@ class _AddPrescriptionFormState extends State { @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) async { - // // await getPatientAssessment(getAssessmentReqModel); - // model.onInitiateAllPrescription(groupProcedures: widget.groupProcedures, patient: widget.patient); - await model.getAssessmentList( - patientInfo: widget.patient, isLocalBusy: true); - }, builder: ( BuildContext context, MedicineViewModel model, @@ -132,12 +127,16 @@ class _AddPrescriptionFormState extends State { widget.prescriptionViewModel, onItemSelected: (GetMedicationResponseModel - medication) { + medication) async { setState(() { visibilitySearch = !visibilitySearch; _selectedMedication = medication; }); - }, + GifLoaderDialogUtils.showMyDialog(context); + await model.getAssessmentList(patientInfo: widget.patient, isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + }, + ), ), Visibility( diff --git a/lib/screens/prescription/add_prescription/search_preescription_widget.dart b/lib/screens/prescription/add_prescription/search_preescription_widget.dart index 4e6cd449..7bd0508d 100644 --- a/lib/screens/prescription/add_prescription/search_preescription_widget.dart +++ b/lib/screens/prescription/add_prescription/search_preescription_widget.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import 'package:html_editor_enhanced/utils/utils.dart'; import '../../../config/config.dart'; import '../../../core/model/search_drug/get_medication_response_model.dart'; @@ -102,10 +103,10 @@ class SearchPrescriptionWidget extends StatelessWidget { child: MedicineItemWidget( label: model.allMedicationList[index].description), - onTap: () { - model.getItem( - itemID: - model.allMedicationList[index].itemId); + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + await model.getItem(itemID: model.allMedicationList[index].itemId, isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); onItemSelected(model.allMedicationList[index]); // uom = _selectedMedication.uom; }, diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index 9a355dea..ff84dcf0 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -12,22 +12,22 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../config/config.dart'; +import '../../widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'ProcedureType.dart'; class AddFavouriteProcedure extends StatefulWidget { - final ProcedureViewModel model; + final ProcedureViewModel previousProcedureViewModel; final PrescriptionViewModel prescriptionModel; final PatiantInformtion patient; final ProcedureType procedureType; AddFavouriteProcedure({ Key key, - this.model, + this.previousProcedureViewModel, this.prescriptionModel, this.patient, @required this.procedureType, @@ -48,8 +48,8 @@ class _AddFavouriteProcedureState extends State { @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => model.getProcedureTemplate( - categoryID: widget.procedureType.getCategoryId()), + onModelReady: (model) async { + }, builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( isShowAppBar: false, diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index 7ef3e6e2..b4fc9573 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/add_prescription_form.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -68,12 +69,18 @@ class _BaseAddProcedureTabPageState extends State final screenSize = MediaQuery.of(context).size; return BaseView( + onModelReady: (model) async { + await model.getProcedureTemplate(categoryID: widget.procedureType.getCategoryId()); + + }, builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( - isShowAppBar: false, - body: NetworkBaseView( - baseViewModel: model, - child: DraggableScrollableSheet( + baseViewModel: model, + isShowAppBar: true, + appBar: BottomSheetTitle(title: procedureType.getToolbarLabel(context),), + body: NetworkBaseView( + baseViewModel: model, + child: DraggableScrollableSheet( minChildSize: 0.90, initialChildSize: 0.95, maxChildSize: 1.0, @@ -86,27 +93,6 @@ class _BaseAddProcedureTabPageState extends State child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText( - procedureType.getToolbarLabel(context), - fontWeight: FontWeight.w700, - fontSize: 20, - ), - InkWell( - child: Icon( - Icons.close, - size: 24.0, - ), - onTap: () { - Navigator.pop(context); - }, - ) - ]), - SizedBox( - height: MediaQuery.of(context).size.height * 0.04, - ), Expanded( child: Scaffold( extendBodyBehindAppBar: true, @@ -159,7 +145,7 @@ class _BaseAddProcedureTabPageState extends State controller: _tabController, children: [ AddFavouriteProcedure( - model: this.model, + previousProcedureViewModel: model, prescriptionModel: widget.prescriptionModel, patient: patient, From d5e3a79f859f0310e2ffb62274405ab5f10119b9 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Wed, 2 Feb 2022 08:59:35 +0200 Subject: [PATCH 09/25] Fix add medication button --- .../add_prescription/add_drug_widget.dart | 61 +- .../add_prescription_form.dart | 81 +-- .../prescription_form_widget.dart | 679 +++++++++--------- 3 files changed, 411 insertions(+), 410 deletions(-) diff --git a/lib/screens/prescription/add_prescription/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug_widget.dart index 19968858..f3d9bedd 100644 --- a/lib/screens/prescription/add_prescription/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug_widget.dart @@ -8,7 +8,6 @@ import '../../../core/model/patient/patiant_info_model.dart'; import '../../../core/model/search_drug/get_medication_response_model.dart'; import '../../../core/viewModel/prescription_view_model.dart'; import '../../../widgets/shared/buttons/app_buttons_widget.dart'; -import 'add_prescription_form.dart'; import 'drugtodrug.dart'; class AddDrugWidget extends StatefulWidget { @@ -16,37 +15,30 @@ class AddDrugWidget extends StatefulWidget { final List prescriptionList; final MedicineViewModel medicineModel; final PrescriptionViewModel modelPrescription; + final dynamic units; + final dynamic route; + final dynamic frequency; + final dynamic duration; + final dynamic doseTime; + final dynamic uom; + final dynamic x; + final GetMedicationResponseModel selectedMedication; + final String strength; + final String indication; + final String instruction; + final DateTime selectedDate; - - - - const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel, this.modelPrescription}) : super(key: key); + const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel, + this.modelPrescription, this.units, this.route, this.frequency, this.duration, this.doseTime, + this.uom, this.x, this.selectedMedication, this.strength, this.indication, this.instruction, this.selectedDate}) : super(key: key); @override _AddDrugWidgetState createState() => _AddDrugWidgetState(); } class _AddDrugWidgetState extends State { - - TextEditingController strengthController = TextEditingController(); - dynamic route; - dynamic frequency; - dynamic duration; - dynamic doseTime; - dynamic indication; - dynamic units; - dynamic uom; - dynamic box; - dynamic x; - @override Widget build(BuildContext context) { - GetMedicationResponseModel _selectedMedication; - TextEditingController indicationController = TextEditingController(); - TextEditingController instructionController = TextEditingController(); - DateTime selectedDate; - - return Container( height: SizeConfig.realScreenHeight * .8, width: SizeConfig.realScreenWidth, @@ -66,7 +58,6 @@ class _AddDrugWidgetState extends State { title: TranslationBase.of(context).addMedication, onPressed: () { Navigator.pop(context); - widget.medicineModel.postPrescription( icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty ? widget.medicineModel.patientAssessmentList[0].icdCode10ID @@ -75,28 +66,28 @@ class _AddDrugWidgetState extends State { : widget.medicineModel.patientAssessmentList[0].icdCode10ID .toString() : "test", - dose: strengthController.text, + dose: widget.strength, doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1 ? widget.medicineModel.itemMedicineListUnit[0]['parameterCode'] .toString() - : units['parameterCode'].toString(), + : widget.units['parameterCode'].toString(), patient: widget.patient, - doseTimeIn: doseTime['id'].toString(), + doseTimeIn: widget.doseTime['id'].toString(), model: widget.modelPrescription, - duration: duration['id'].toString(), + duration: widget.duration['id'].toString(), frequency: widget.medicineModel.itemMedicineList.length == 1 ? widget.medicineModel.itemMedicineList[0]['parameterCode'] .toString() - : frequency['parameterCode'].toString(), + : widget.frequency['parameterCode'].toString(), route: widget.medicineModel.itemMedicineListRoute.length == 1 ? widget.medicineModel.itemMedicineListRoute[0]['parameterCode'] .toString() - : route['parameterCode'].toString(), - drugId: _selectedMedication.itemId.toString(), - strength: strengthController.text, - indication: indicationController.text, - instruction: instructionController.text, - doseTime: selectedDate, + : widget.route['parameterCode'].toString(), + drugId: widget.selectedMedication.itemId.toString(), + strength: widget.strength, + indication: widget.indication, + instruction: widget.instruction, + doseTime: widget.selectedDate, ); }, )) diff --git a/lib/screens/prescription/add_prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription/add_prescription_form.dart index ada41bd7..ba283b1a 100644 --- a/lib/screens/prescription/add_prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription/add_prescription_form.dart @@ -113,52 +113,49 @@ class _AddPrescriptionFormState extends State { height: spaceBetweenTextFields, ), Container( - child: Form( - key: formKey, - child: Column( - children: [ - Visibility( - visible: visibilitySearch, - child: SearchPrescriptionWidget( - spaceBetweenTextFields: - spaceBetweenTextFields, - medicineViewModel: model, - prescriptionViewModel: - widget.prescriptionViewModel, - onItemSelected: - (GetMedicationResponseModel - medication) async { - setState(() { - visibilitySearch = !visibilitySearch; - _selectedMedication = medication; - }); - GifLoaderDialogUtils.showMyDialog(context); - await model.getAssessmentList(patientInfo: widget.patient, isLocalBusy: true); - GifLoaderDialogUtils.hideDialog(context); - }, + child: Column( + children: [ + Visibility( + visible: visibilitySearch, + child: SearchPrescriptionWidget( + spaceBetweenTextFields: + spaceBetweenTextFields, + medicineViewModel: model, + prescriptionViewModel: + widget.prescriptionViewModel, + onItemSelected: + (GetMedicationResponseModel + medication) async { + setState(() { + visibilitySearch = !visibilitySearch; + _selectedMedication = medication; + }); + GifLoaderDialogUtils.showMyDialog(context); + await model.getAssessmentList(patientInfo: widget.patient, isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + }, - ), ), - Visibility( - visible: !visibilitySearch, - child: Container( - child: Column( - children: [ - PrescriptionFormWidget( - patient: widget.patient, - prescriptionViewModel: - widget.prescriptionViewModel, - medicineViewModel: model, - prescriptionList: - widget.prescriptionList, - selectedMedication: _selectedMedication, - ), - ], - ), + ), + Visibility( + visible: !visibilitySearch, + child: Container( + child: Column( + children: [ + PrescriptionFormWidget( + patient: widget.patient, + prescriptionViewModel: + widget.prescriptionViewModel, + medicineViewModel: model, + prescriptionList: + widget.prescriptionList, + selectedMedication: _selectedMedication, + ), + ], ), ), - ], - ), + ), + ], ), ), ], diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index 9569fa94..30f97e85 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -86,7 +86,6 @@ class _PrescriptionFormWidgetState extends State { dynamic frequency; dynamic duration; dynamic doseTime; - dynamic indication; dynamic units; dynamic uom; dynamic box; @@ -155,366 +154,368 @@ class _PrescriptionFormWidgetState extends State { @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; - return Column( - children: [ - AppText( - widget.selectedMedication?.description ?? "", - fontWeight: FontWeight.w600, - ), - SizedBox( - height: 15.0, - ), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox( - width: 6, - ), - AppText( - TranslationBase.of(context).orderType, - fontWeight: FontWeight.w500, - ), - SizedBox( - width: 18, - ), - Radio( - activeColor: AppGlobal.appRedColor, - value: 1, - groupValue: selectedType, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text(TranslationBase.of(context).regular), - ], + return Form( + key: formKey, + child: Column( + children: [ + AppText( + widget.selectedMedication?.description ?? "", + fontWeight: FontWeight.w600, + ), + SizedBox( + height: 15.0, + ), + Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + width: 6, + ), + AppText( + TranslationBase.of(context).orderType, + fontWeight: FontWeight.w500, + ), + SizedBox( + width: 18, + ), + Radio( + activeColor: AppGlobal.appRedColor, + value: 1, + groupValue: selectedType, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).regular), + ], + ), ), - ), - Container( - width: double.infinity, - child: Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.35, - child: AppTextFieldCustom( - height: 38, - validationError: strengthError, - hintText: 'Strength', - isTextFieldHasSuffix: false, - enabled: true, - controller: strengthController, - onChanged: (String value) { + Container( + width: double.infinity, + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.35, + child: AppTextFieldCustom( + height: 38, + validationError: strengthError, + hintText: 'Strength', + isTextFieldHasSuffix: false, + enabled: true, + controller: strengthController, + onChanged: (String value) { + setState(() { + strengthChar = value.length; + }); + if (strengthChar >= 5) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .only5DigitsAllowedForStrength, + ); + } + }, + inputType: TextInputType.numberWithOptions( + decimal: true, + ), + ), + ), + SizedBox( + width: 5.0, + ), + // Container( + // width: MediaQuery.of(context) + // .size + // .width * + // 0.35, + // child: AppTextFieldCustom( + // height: 38, + // validationError: + // unitError, + // hintText: 'Unit', + // isTextFieldHasSuffix: false, + // enabled: true, + // controller: + // unitController, + // onChanged: (selectedValue) { + // setState(() { + // units = selectedValue; + // units['isDefault'] = true; + // }); + // if (strengthChar >= 5) { + // DrAppToastMsg + // .showErrorToast( + // TranslationBase.of( + // context) + // .only5DigitsAllowedForStrength, + // ); + // } + // }, + // inputType: TextInputType + // .numberWithOptions( + // decimal: true, + // ), + // ), + // ), + PrescriptionTextFiled( + width: MediaQuery.of(context).size.width * 0.510, + element: + widget.medicineViewModel.itemMedicineListUnit.length == 1 + ? widget.medicineViewModel.itemMedicineListUnit[0] + : units, + elementError: unitError, + keyName: 'description', + keyId: 'parameterCode', + hintText: 'Unit', + elementList: widget.medicineViewModel.itemMedicineListUnit, + okFunction: (selectedValue) { setState(() { - strengthChar = value.length; + units = selectedValue; + units['isDefault'] = true; }); - if (strengthChar >= 5) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .only5DigitsAllowedForStrength, - ); - } }, - inputType: TextInputType.numberWithOptions( - decimal: true, - ), ), + ], + ), + ), + SizedBox(height: spaceBetweenTextFields), + PrescriptionTextFiled( + elementList: widget.medicineViewModel.itemMedicineListRoute, + element: widget.medicineViewModel.itemMedicineListRoute.length == 1 + ? route = widget.medicineViewModel.itemMedicineListRoute[0] + : route, + elementError: routeError, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + route['isDefault'] = true; + }); + }, + hintText: TranslationBase.of(context).route, + ), + SizedBox(height: spaceBetweenTextFields), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).frequency, + elementError: frequencyError, + // element: frequency, + element: widget.medicineViewModel.itemMedicineListRoute.length == 1 + ? frequency = widget.medicineViewModel.itemMedicineListRoute[0] + : frequency, + elementList: widget.medicineViewModel.itemMedicineList, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + frequency = selectedValue; + frequency['isDefault'] = true; + if (widget.selectedMedication != null && + duration != null && + frequency != null && + strengthController.text != null) { + widget.medicineViewModel.getBoxQuantity( + freq: frequency['parameterCode'], + duration: duration['id'], + itemCode: widget.selectedMedication.itemId, + strength: double.parse(strengthController.text)); + + return; + } + }); + }), + SizedBox(height: spaceBetweenTextFields), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).doseTime, + elementError: doseTimeError, + element: doseTime, + elementList: widget.medicineViewModel.medicationDoseTimeList, + keyId: 'id', + keyName: 'nameEn', + okFunction: (selectedValue) { + setState(() { + doseTime = selectedValue; + }); + }), + SizedBox(height: spaceBetweenTextFields), + if (widget.medicineViewModel.patientAssessmentList.isNotEmpty) + Container( + height: screenSize.height * 0.070, + width: double.infinity, + color: Colors.white, + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.29, + child: AppTextFieldCustom( + hintText: widget + .medicineViewModel.patientAssessmentList[0].icdCode10ID + .toString(), + // indication != null + // ? indication[ + // 'name'] + // : null, + + enabled: true, + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.57, + color: Colors.white, + child: AppTextFieldCustom( + maxLines: 5, + hintText: widget + .medicineViewModel.patientAssessmentList[0].asciiDesc + .toString(), + // indication != null + // ? indication[ + // 'name'] + // : null, + enabled: true, + ), + ), + ], ), - SizedBox( - width: 5.0, + ), + SizedBox(height: spaceBetweenTextFields), + Container( + color: Colors.transparent, + child: InkWell( + onTap: () => selectDate(context, widget.prescriptionViewModel), + child: AppTextFieldCustom( + validationError: strengthError, + hintText: 'Date', + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon( + Icons.calendar_today, + color: Colors.black, + ), + ), + dropDownText: selectedDate != null + ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + : null, + enabled: false, + controller: strengthController, ), - // Container( - // width: MediaQuery.of(context) - // .size - // .width * - // 0.35, - // child: AppTextFieldCustom( - // height: 38, - // validationError: - // unitError, - // hintText: 'Unit', - // isTextFieldHasSuffix: false, - // enabled: true, - // controller: - // unitController, - // onChanged: (selectedValue) { - // setState(() { - // units = selectedValue; - // units['isDefault'] = true; - // }); - // if (strengthChar >= 5) { - // DrAppToastMsg - // .showErrorToast( + + // TextField( + // decoration: + // textFieldSelectorDecoration( // TranslationBase.of( - // context) - // .only5DigitsAllowedForStrength, - // ); - // } - // }, - // inputType: TextInputType - // .numberWithOptions( - // decimal: true, - // ), - // ), + // context) + // .date, + // selectedDate != null + // ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + // : null, + // true, + // suffixIcon: Icon( + // Icons.calendar_today, + // color: Colors.black, + // )), + // enabled: false, // ), - PrescriptionTextFiled( - width: MediaQuery.of(context).size.width * 0.510, - element: - widget.medicineViewModel.itemMedicineListUnit.length == 1 - ? widget.medicineViewModel.itemMedicineListUnit[0] - : units, - elementError: unitError, - keyName: 'description', - keyId: 'parameterCode', - hintText: 'Unit', - elementList: widget.medicineViewModel.itemMedicineListUnit, - okFunction: (selectedValue) { - setState(() { - units = selectedValue; - units['isDefault'] = true; - }); - }, - ), - ], + ), ), - ), - SizedBox(height: spaceBetweenTextFields), - PrescriptionTextFiled( - elementList: widget.medicineViewModel.itemMedicineListRoute, - element: widget.medicineViewModel.itemMedicineListRoute.length == 1 - ? route = widget.medicineViewModel.itemMedicineListRoute[0] - : route, - elementError: routeError, - keyId: 'parameterCode', - keyName: 'description', - okFunction: (selectedValue) { - setState(() { - route = selectedValue; - route['isDefault'] = true; - }); - }, - hintText: TranslationBase.of(context).route, - ), - SizedBox(height: spaceBetweenTextFields), - PrescriptionTextFiled( - hintText: TranslationBase.of(context).frequency, - elementError: frequencyError, - // element: frequency, - element: widget.medicineViewModel.itemMedicineListRoute.length == 1 - ? frequency = widget.medicineViewModel.itemMedicineListRoute[0] - : frequency, - elementList: widget.medicineViewModel.itemMedicineList, - keyId: 'parameterCode', - keyName: 'description', + SizedBox(height: spaceBetweenTextFields), + PrescriptionTextFiled( + element: duration, + elementError: durationError, + hintText: TranslationBase.of(context).duration, + elementList: widget.medicineViewModel.medicationDurationList, + keyName: 'nameEn', + keyId: 'id', okFunction: (selectedValue) { setState(() { - frequency = selectedValue; - frequency['isDefault'] = true; + duration = selectedValue; if (widget.selectedMedication != null && duration != null && frequency != null && strengthController.text != null) { - widget.medicineViewModel.getBoxQuantity( - freq: frequency['parameterCode'], - duration: duration['id'], - itemCode: widget.selectedMedication.itemId, - strength: double.parse(strengthController.text)); - + // widget.medicineViewModel.getBoxQuantity( + // freq: frequency['parameterCode'], + // duration: duration['id'], + // itemCode: widget.selectedMedication.itemId, + // strength: double.parse(strengthController.text), + // ); + box = widget.medicineViewModel.boxQuintity; return; } }); - }), - SizedBox(height: spaceBetweenTextFields), - PrescriptionTextFiled( - hintText: TranslationBase.of(context).doseTime, - elementError: doseTimeError, - element: doseTime, - elementList: widget.medicineViewModel.medicationDoseTimeList, - keyId: 'id', - keyName: 'nameEn', - okFunction: (selectedValue) { - setState(() { - doseTime = selectedValue; - }); - }), - SizedBox(height: spaceBetweenTextFields), - if (widget.medicineViewModel.patientAssessmentList.isNotEmpty) + }, + ), + SizedBox(height: spaceBetweenTextFields), Container( - height: screenSize.height * 0.070, - width: double.infinity, color: Colors.white, - child: Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.29, - child: AppTextFieldCustom( - hintText: widget - .medicineViewModel.patientAssessmentList[0].icdCode10ID - .toString(), - // indication != null - // ? indication[ - // 'name'] - // : null, - - enabled: true, - ), - ), - Container( - width: MediaQuery.of(context).size.width * 0.57, - color: Colors.white, - child: AppTextFieldCustom( - maxLines: 5, - hintText: widget - .medicineViewModel.patientAssessmentList[0].asciiDesc - .toString(), - // indication != null - // ? indication[ - // 'name'] - // : null, - enabled: true, - ), - ), - ], + child: AppTextFieldCustom( + hintText: "UOM", + isTextFieldHasSuffix: false, + dropDownText: uom != null ? uom : null, + enabled: false, ), ), - SizedBox(height: spaceBetweenTextFields), - Container( - color: Colors.transparent, - child: InkWell( - onTap: () => selectDate(context, widget.prescriptionViewModel), + SizedBox(height: spaceBetweenTextFields), + Container( + color: Colors.white, child: AppTextFieldCustom( - validationError: strengthError, - hintText: 'Date', - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon( - Icons.calendar_today, - color: Colors.black, - ), - ), - dropDownText: selectedDate != null - ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + hintText: TranslationBase.of(context).boxQuantity, + isTextFieldHasSuffix: false, + dropDownText: box != null + ? widget.medicineViewModel.boxQuintity.toString() : null, enabled: false, - controller: strengthController, ), - - // 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, - // )), - // enabled: false, - // ), ), - ), - SizedBox(height: spaceBetweenTextFields), - PrescriptionTextFiled( - element: duration, - elementError: durationError, - hintText: TranslationBase.of(context).duration, - elementList: widget.medicineViewModel.medicationDurationList, - keyName: 'nameEn', - keyId: 'id', - okFunction: (selectedValue) { - setState(() { - duration = selectedValue; - if (widget.selectedMedication != null && - duration != null && - frequency != null && - strengthController.text != null) { - widget.medicineViewModel.getBoxQuantity( - freq: frequency['parameterCode'], - duration: duration['id'], - itemCode: widget.selectedMedication.itemId, - strength: double.parse(strengthController.text), - ); - box = widget.medicineViewModel.boxQuintity; - - return; - } - }); - }, - ), - SizedBox(height: spaceBetweenTextFields), - Container( - color: Colors.white, - child: AppTextFieldCustom( - hintText: "UOM", - isTextFieldHasSuffix: false, - dropDownText: uom != null ? uom : null, - enabled: false, - ), - ), - SizedBox(height: spaceBetweenTextFields), - Container( - color: Colors.white, - child: AppTextFieldCustom( - hintText: TranslationBase.of(context).boxQuantity, - isTextFieldHasSuffix: false, - dropDownText: box != null - ? widget.medicineViewModel.boxQuintity.toString() - : null, - enabled: false, - ), - ), - SizedBox(height: spaceBetweenTextFields), - Container( - decoration: BoxDecoration( - 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, - //keyboardType: TextInputType.number, - ), - Positioned( - top: 0, - right: 15, - child: IconButton( - icon: Icon( - DoctorApp.speechtotext, - color: Colors.black, - size: 35, + SizedBox(height: spaceBetweenTextFields), + Container( + decoration: BoxDecoration( + 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, + //keyboardType: TextInputType.number, + ), + Positioned( + top: 0, + right: 15, + child: IconButton( + icon: Icon( + DoctorApp.speechtotext, + color: Colors.black, + size: 35, + ), + onPressed: () { + initSpeechState().then((value) => {onVoiceText()}); + }, ), - onPressed: () { - initSpeechState().then((value) => {onVoiceText()}); - }, ), - ), - ], + ], + ), ), - ), - SizedBox(height: spaceBetweenTextFields), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - color: Color(0xff359846), - title: TranslationBase.of(context).addMedication, - fontWeight: FontWeight.w600, - onPressed: () async { - addMedicationButton(widget.medicineViewModel); - }, - ), - ], + SizedBox(height: spaceBetweenTextFields), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + color: Color(0xff359846), + title: TranslationBase.of(context).addMedication, + fontWeight: FontWeight.w600, + onPressed: () async { + addMedicationButton(widget.medicineViewModel); + }, + ), + ], + ), ), - ), - ], + ], + ), ); } @@ -537,15 +538,27 @@ class _PrescriptionFormWidgetState extends State { } openDrugToDrug( - MedicineViewModel model, PrescriptionViewModel modelPrescription) { + MedicineViewModel medicineViewModel, PrescriptionViewModel modelPrescription) { showModalBottomSheet( context: context, builder: (context) { return AddDrugWidget( patient: widget.patient, - medicineModel: model, - modelPrescription: modelPrescription, + medicineModel: widget.medicineViewModel, + modelPrescription: widget.prescriptionViewModel, prescriptionList: widget.prescriptionList, + route: route, + doseTime: doseTime, + duration: duration, + frequency: frequency, + units: units, + uom: uom, + x: x, + selectedMedication: widget.selectedMedication, + strength: strengthController.text, + indication: indicationController.text, + instruction: instructionController.text, + selectedDate: selectedDate, ); }); } @@ -578,7 +591,7 @@ class _PrescriptionFormWidgetState extends State { if (formKey.currentState.validate()) { Navigator.pop(context); - openDrugToDrug(model, widget.prescriptionViewModel); + openDrugToDrug(model, prescriptionViewModel); } } else { setState(() { From ce978db2ddd81646902af8ddb6f3147976a25ead Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Wed, 2 Feb 2022 11:39:48 +0200 Subject: [PATCH 10/25] Fix add medication button --- lib/core/viewModel/medicine_view_model.dart | 13 ------- .../prescription/prescriptions_page.dart | 36 ++++++++++++------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 2b645a29..1c5da88d 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -229,19 +229,6 @@ class MedicineViewModel extends BaseViewModel { } - - Future getPrescription({int mrn}) async { - //hasError = false; - //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); - await _prescriptionService.getPrescription(mrn: mrn); - if (_prescriptionService.hasError) { - error = _prescriptionService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); - } - Future getMedicineItem(String itemName) async { setState(ViewState.Busy); await _medicineService.getMedicineItem(itemName); diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index b02d1861..1486efba 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; @@ -117,19 +118,28 @@ class PrescriptionsPage extends StatelessWidget { ), ), ), - child: DoctorCard( - doctorName: - model.prescriptionsList[index].doctorName, - profileUrl: model - .prescriptionsList[index].doctorImageURL, - branch: model.prescriptionsList[index].name, - clinic: model.prescriptionsList[index] - .clinicDescription, - isPrescriptions: true, - appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( - model.prescriptionsList[index] - .appointmentDate, + child: Container( + child: Column( + children: [ + AppText( + model.prescriptionsList[index].despensedStatus, + ), + DoctorCard( + doctorName: + model.prescriptionsList[index].doctorName, + profileUrl: model + .prescriptionsList[index].doctorImageURL, + branch: model.prescriptionsList[index].name, + clinic: model.prescriptionsList[index] + .clinicDescription, + isPrescriptions: true, + appointmentDate: + AppDateUtils.getDateTimeFromServerFormat( + model.prescriptionsList[index] + .appointmentDate, + ), + ), + ], ), ))), if (model.prescriptionsList.isEmpty && From e10c07f6a46603f8ee8c5775012f04a18db69933 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Thu, 3 Feb 2022 09:02:14 +0200 Subject: [PATCH 11/25] fix loader in prescriptions_page --- lib/core/viewModel/patient_view_model.dart | 29 ++++++++-- .../prescription/prescriptions_page.dart | 54 ++++++++++--------- 2 files changed, 55 insertions(+), 28 deletions(-) diff --git a/lib/core/viewModel/patient_view_model.dart b/lib/core/viewModel/patient_view_model.dart index 9457ed99..0336a3cd 100644 --- a/lib/core/viewModel/patient_view_model.dart +++ b/lib/core/viewModel/patient_view_model.dart @@ -18,6 +18,8 @@ import 'package:doctor_app_flutter/core/model/patient/prescription/prescription_ import 'package:doctor_app_flutter/core/model/patient/prescription/prescription_res_model.dart'; import 'package:doctor_app_flutter/core/model/patient/radiology/radiology_res_model.dart'; import 'package:doctor_app_flutter/core/model/patient/vital_sign/vital_sign_res_model.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; +import 'package:flutter/cupertino.dart'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -101,16 +103,37 @@ class PatientViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getOutPatientPrescriptions(patient) async { - setState(ViewState.Busy); + Future getOutPatientPrescriptions(patient, {bool isLocalBusy = false, BuildContext context, PatiantInformtion patientInformation}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + GifLoaderDialogUtils.showMyDialog(context); await _patientService.getOutPatientPrescriptions(patient); + GifLoaderDialogUtils.hideDialog(context); if (_patientService.hasError) { error = _patientService.error; - setState(ViewState.Error); + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } } else setState(ViewState.Idle); } + + // async { + // setState(ViewState.Busy); + // await _patientService.getOutPatientPrescriptions(patient); + // if (_patientService.hasError) { + // error = _patientService.error; + // setState(ViewState.Error); + // } else + // setState(ViewState.Idle); + // } + Future getInPatientPrescriptions(patient) async { setState(ViewState.Busy); await _patientService.getInPatientPrescriptions(patient); diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 1486efba..58bad8bc 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -26,6 +27,7 @@ class PrescriptionsPage extends StatelessWidget { @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatientViewModel patientViewModel; PatiantInformtion patient = routeArgs['patient']; String patientType = routeArgs['patientType']; String arrivalType = routeArgs['arrivalType']; @@ -33,9 +35,16 @@ class PrescriptionsPage extends StatelessWidget { bool isFromLiveCare = routeArgs['isFromLiveCare']; bool isSelectInpatient = routeArgs['isSelectInpatient']; return BaseView( - onModelReady: (model) => patient.admissionNo == null - ? model.getPrescriptions(patient, patientType: patientType) - : model.getMedicationForInPatient(patient), + onModelReady: (model) async { + await model.getOutPatientPrescriptions( + patient.admissionNo == null + ? model.getPrescriptions(patient, patientType: patientType) + : model.getMedicationForInPatient(patient), + isLocalBusy: false, + context: context, + patientInformation: patient + ); + }, builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, @@ -118,29 +127,24 @@ class PrescriptionsPage extends StatelessWidget { ), ), ), - child: Container( - child: Column( - children: [ - AppText( - model.prescriptionsList[index].despensedStatus, - ), - DoctorCard( - doctorName: - model.prescriptionsList[index].doctorName, - profileUrl: model - .prescriptionsList[index].doctorImageURL, - branch: model.prescriptionsList[index].name, - clinic: model.prescriptionsList[index] - .clinicDescription, - isPrescriptions: true, - appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( - model.prescriptionsList[index] - .appointmentDate, - ), + child: Column( + children: [ + DoctorCard( + doctorName: + model.prescriptionsList[index].doctorName, + profileUrl: model + .prescriptionsList[index].doctorImageURL, + branch: model.prescriptionsList[index].name, + clinic: model.prescriptionsList[index] + .clinicDescription, + isPrescriptions: true, + appointmentDate: + AppDateUtils.getDateTimeFromServerFormat( + model.prescriptionsList[index] + .appointmentDate, ), - ], - ), + ), + ], ))), if (model.prescriptionsList.isEmpty && patient.patientStatusType != 43) From 5f3f509b8c438ba1f2ac2e890539a928d8cd33aa Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Thu, 3 Feb 2022 17:17:52 +0200 Subject: [PATCH 12/25] fix the DOCTYPE html error in getPrescription service --- .../Prescriptions/prescription_req_model.dart | 6 ++-- .../prescription/prescription_res_model.dart | 4 --- lib/core/viewModel/patient_view_model.dart | 31 ------------------- .../viewModel/prescription_view_model.dart | 25 +++++++++++++++ .../prescription/prescriptions_page.dart | 2 +- 5 files changed, 28 insertions(+), 40 deletions(-) diff --git a/lib/core/model/Prescriptions/prescription_req_model.dart b/lib/core/model/Prescriptions/prescription_req_model.dart index a45878d8..4fc173aa 100644 --- a/lib/core/model/Prescriptions/prescription_req_model.dart +++ b/lib/core/model/Prescriptions/prescription_req_model.dart @@ -2,16 +2,15 @@ class PrescriptionReqModel { String vidaAuthTokenID; dynamic patientMRN; dynamic appNo; - dynamic admissionNo; PrescriptionReqModel( - {this.vidaAuthTokenID, this.patientMRN, this.appNo, this.admissionNo}); + {this.vidaAuthTokenID, this.patientMRN, this.appNo}); PrescriptionReqModel.fromJson(Map json) { vidaAuthTokenID = json['VidaAuthTokenID']; patientMRN = json['PatientMRN']; appNo = json['AppointmentNo']; - admissionNo = json['AdmissionNo']; + } Map toJson() { @@ -19,7 +18,6 @@ class PrescriptionReqModel { data['VidaAuthTokenID'] = this.vidaAuthTokenID; data['PatientMRN'] = this.patientMRN; data['AppointmentNo'] = this.appNo; - data['AdmissionNo'] = this.admissionNo; return data; } diff --git a/lib/core/model/patient/prescription/prescription_res_model.dart b/lib/core/model/patient/prescription/prescription_res_model.dart index 9c7e296d..eed34296 100644 --- a/lib/core/model/patient/prescription/prescription_res_model.dart +++ b/lib/core/model/patient/prescription/prescription_res_model.dart @@ -16,7 +16,6 @@ class PrescriptionResModel { String name; int episodeID; int actualDoctorRate; - int admission; int clinicID; String companyName; String despensedStatus; @@ -51,7 +50,6 @@ class PrescriptionResModel { this.name, this.episodeID, this.actualDoctorRate, - this.admission, this.clinicID, this.companyName, this.despensedStatus, @@ -86,7 +84,6 @@ class PrescriptionResModel { name = json['Name']; episodeID = json['EpisodeID']; actualDoctorRate = json['ActualDoctorRate']; - admission = json['Admission']; clinicID = json['ClinicID']; companyName = json['CompanyName']; despensedStatus = json['Despensed_Status']; @@ -123,7 +120,6 @@ class PrescriptionResModel { data['Name'] = this.name; data['EpisodeID'] = this.episodeID; data['ActualDoctorRate'] = this.actualDoctorRate; - data['Admission'] = this.admission; data['ClinicID'] = this.clinicID; data['CompanyName'] = this.companyName; data['Despensed_Status'] = this.despensedStatus; diff --git a/lib/core/viewModel/patient_view_model.dart b/lib/core/viewModel/patient_view_model.dart index 0336a3cd..b36b5e5b 100644 --- a/lib/core/viewModel/patient_view_model.dart +++ b/lib/core/viewModel/patient_view_model.dart @@ -103,37 +103,6 @@ class PatientViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getOutPatientPrescriptions(patient, {bool isLocalBusy = false, BuildContext context, PatiantInformtion patientInformation}) async { - if (isLocalBusy) { - setState(ViewState.BusyLocal); - } else { - setState(ViewState.Busy); - } - GifLoaderDialogUtils.showMyDialog(context); - await _patientService.getOutPatientPrescriptions(patient); - GifLoaderDialogUtils.hideDialog(context); - if (_patientService.hasError) { - error = _patientService.error; - if (isLocalBusy) { - setState(ViewState.ErrorLocal); - } else { - setState(ViewState.Error); - } - } else - setState(ViewState.Idle); - } - - - // async { - // setState(ViewState.Busy); - // await _patientService.getOutPatientPrescriptions(patient); - // if (_patientService.hasError) { - // error = _patientService.error; - // setState(ViewState.Error); - // } else - // setState(ViewState.Idle); - // } - Future getInPatientPrescriptions(patient) async { setState(ViewState.Busy); await _patientService.getInPatientPrescriptions(patient); diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 480e8bad..0fc34e1e 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -20,9 +20,14 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/patient/vital_sign/patient-vital-sign-data.dart'; import 'package:flutter/cupertino.dart'; +import '../../widgets/shared/loader/gif_loader_dialog_utils.dart'; +import '../service/patient/patient_service.dart'; + class PrescriptionViewModel extends BaseViewModel { FilterType filterType = FilterType.Clinic; bool hasError = false; + PatientService _patientService = locator(); + PrescriptionService _prescriptionService = locator(); List get allMedicationList => @@ -65,6 +70,26 @@ class PrescriptionViewModel extends BaseViewModel { List get inPatientPrescription => _prescriptionsService.prescriptionInPatientList; + Future getOutPatientPrescriptions(patient, {bool isLocalBusy = false, BuildContext context, PatiantInformtion patientInformation}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + await _patientService.getOutPatientPrescriptions(patient); + if (_patientService.hasError) { + error = _patientService.error; + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } + } else + setState(ViewState.Idle); + } + + + getPrescriptionsInPatient(PatiantInformtion patient) async { setState(ViewState.Busy); error = ""; diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 58bad8bc..40bebf17 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -40,7 +40,7 @@ class PrescriptionsPage extends StatelessWidget { patient.admissionNo == null ? model.getPrescriptions(patient, patientType: patientType) : model.getMedicationForInPatient(patient), - isLocalBusy: false, + isLocalBusy: true, context: context, patientInformation: patient ); From 0147481c2795a82b178953f04fdd53d1dec23ed8 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Sun, 6 Feb 2022 16:52:08 +0200 Subject: [PATCH 13/25] Fix the drug to drug page --- .../prescription/prescription_service.dart | 50 ------- lib/core/viewModel/medicine_view_model.dart | 27 ++-- .../viewModel/prescription_view_model.dart | 2 +- .../add_prescription/add_drug_widget.dart | 132 +++++++++++------- .../add_prescription/drugtodrug.dart | 39 +++--- .../prescription_form_widget.dart | 28 +++- 6 files changed, 143 insertions(+), 135 deletions(-) diff --git a/lib/core/service/patient_medical_file/prescription/prescription_service.dart b/lib/core/service/patient_medical_file/prescription/prescription_service.dart index 93048656..1d310c6c 100644 --- a/lib/core/service/patient_medical_file/prescription/prescription_service.dart +++ b/lib/core/service/patient_medical_file/prescription/prescription_service.dart @@ -167,56 +167,6 @@ class PrescriptionService extends LookupService { List allergy, PatiantInformtion patient, List prescription) async { - // Map request = { - // "Prescription": { - // "objPatientInfo": {"Gender": "Male", "Age": "21/06/1967"}, - // "objVitalSign": {"Height": "180", "Weight": "37"}, - // "objPrescriptionItems": [ - // { - // "DrugId": "83-20-00-30-20-03-03", - // "DrugName": "WARFARIN 1 MG TAB 28'S (N)", - // "Dose": "1", - // "DoseType": "04", - // "Unit": "actuation(s)", - // "FrequencyType": "1/3/Day", - // "Duration": "3/Day", - // "IsScreen": "true" - // }, - // { - // "DrugId": "64-20-00-10-00-03-15", - // "DrugName": "PANADOL 500 MG TAB 24'S(DIS)", - // "Dose": "1", - // "DoseType": "04", - // "Unit": "MG", - // "FrequencyType": "3/1/Day", - // "Duration": "4/Day", - // "RouteID": "24", - // "IsScreen": "true" - // } - // ], - // "objAllergies": { - // "Allergy": { - // "objProperties": {"Id": "26", "Name": "phenoxymethylpenicillin"} - // } - // }, - // "objDiagnosis": { - // "Diagnosis": { - // "objProperties": {"Id": "A01.1", "Name": "Paratyphoid fever A"} - // } - // }, - // "IsDoctor": "false", - // "IsPharmacist": "false" - // }, - // "IPAdress": "10.10.10.10", - // "Channel": 9, - // "LanguageID": 2, - // "VersionID": 5.3, - // "SessionID": "BlUSkYymTt", - // "IsLoginForDoctorApp": true, - // "PatientOutSA": 0, - // "TokenID": "@dm!n", - // "OutSA": true - // }; Map request = { "Prescription": { "objPatientInfo": { diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 1c5da88d..7cf96a3e 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -9,6 +9,7 @@ import 'package:doctor_app_flutter/core/service/patient_medical_file/procedure/p import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_container.dart'; import 'package:flutter/cupertino.dart'; import '../../locator.dart'; import '../../util/dr_app_toast_msg.dart'; @@ -158,7 +159,14 @@ class MedicineViewModel extends BaseViewModel { String doseUnit, String icdCode, PatiantInformtion patient, - String patientType}) async { + String patientType, + bool isLocalBusy = false, + BuildContext context, PrescriptionRequestModel prescriptionRequestModel}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); List prescriptionList = List(); @@ -182,13 +190,16 @@ class MedicineViewModel extends BaseViewModel { duration: duration.isEmpty ? 1 : int.parse(duration), doseStartDate: doseTime.toIso8601String())); postProcedureReqModel.prescriptionRequestModel = prescriptionList; - await model.postPrescription(postProcedureReqModel, patient.patientMRN); - - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } else if (model.state == ViewState.Idle) { - model.getPrescriptions(patient); - DrAppToastMsg.showSuccesToast('Medication has been added'); + await _prescriptionService.postPrescription(postProcedureReqModel); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } + } else { + setState(ViewState.Idle); } } diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 0fc34e1e..d79c9f95 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -118,7 +118,7 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPrescription({int mrn}) async { + Future getPrescription({int mrn, BuildContext context}) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.BusyLocal); diff --git a/lib/screens/prescription/add_prescription/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug_widget.dart index f3d9bedd..67970691 100644 --- a/lib/screens/prescription/add_prescription/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug_widget.dart @@ -1,13 +1,20 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.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/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../../core/enum/viewstate.dart'; import '../../../core/model/Prescriptions/prescription_model.dart'; import '../../../core/model/patient/patiant_info_model.dart'; import '../../../core/model/search_drug/get_medication_response_model.dart'; import '../../../core/viewModel/prescription_view_model.dart'; +import '../../../util/dr_app_toast_msg.dart'; +import '../../../util/helpers.dart'; import '../../../widgets/shared/buttons/app_buttons_widget.dart'; +import '../../patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; import 'drugtodrug.dart'; class AddDrugWidget extends StatefulWidget { @@ -39,60 +46,77 @@ class AddDrugWidget extends StatefulWidget { class _AddDrugWidgetState extends State { @override Widget build(BuildContext context) { - return Container( - height: SizeConfig.realScreenHeight * .8, - width: SizeConfig.realScreenWidth, - child: SingleChildScrollView( - child: Column( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - DrugToDrug( - widget.patient, - widget.medicineModel.getPrescriptionForDrug( - widget.prescriptionList, widget.medicineModel - ), - widget.medicineModel.patientAssessmentList), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), - child: AppButton( - title: TranslationBase.of(context).addMedication, - onPressed: () { - Navigator.pop(context); - widget.medicineModel.postPrescription( - icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty - ? widget.medicineModel.patientAssessmentList[0].icdCode10ID - .isEmpty - ? "test" - : widget.medicineModel.patientAssessmentList[0].icdCode10ID - .toString() - : "test", - dose: widget.strength, - doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1 - ? widget.medicineModel.itemMedicineListUnit[0]['parameterCode'] - .toString() - : widget.units['parameterCode'].toString(), - patient: widget.patient, - doseTimeIn: widget.doseTime['id'].toString(), - model: widget.modelPrescription, - duration: widget.duration['id'].toString(), - frequency: widget.medicineModel.itemMedicineList.length == 1 - ? widget.medicineModel.itemMedicineList[0]['parameterCode'] - .toString() - : widget.frequency['parameterCode'].toString(), - route: widget.medicineModel.itemMedicineListRoute.length == 1 - ? widget.medicineModel.itemMedicineListRoute[0]['parameterCode'] - .toString() - : widget.route['parameterCode'].toString(), - drugId: widget.selectedMedication.itemId.toString(), - strength: widget.strength, - indication: widget.indication, - instruction: widget.instruction, - doseTime: widget.selectedDate, - ); - }, - )) - ], - )), + return AppScaffold( + baseViewModel: widget.medicineModel, + appBar: BottomSheetTitle(title: "Add Medication",), + body: Container( + height: SizeConfig.realScreenHeight * .8, + width: SizeConfig.realScreenWidth, + child: SingleChildScrollView( + child: Column( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + DrugToDrug( + widget.patient, + widget.medicineModel.getPrescriptionForDrug( + widget.prescriptionList, widget.medicineModel + ), + widget.medicineModel.patientAssessmentList), + ], + )), + ), + bottomSheet: widget.medicineModel.state == ViewState.BusyLocal || widget.medicineModel.state == ViewState.Busy + ? Container( + height: 0, + ) + : BottomSheetDialogButton( + label: TranslationBase.of(context).addMedication, + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + await widget.medicineModel.postPrescription( + isLocalBusy: true, + icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty + ? widget.medicineModel.patientAssessmentList[0].icdCode10ID + .isEmpty + ? "test" + : widget.medicineModel.patientAssessmentList[0].icdCode10ID + .toString() + : "test", + dose: widget.strength, + doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1 + ? widget.medicineModel.itemMedicineListUnit[0]['parameterCode'] + .toString() + : widget.units['parameterCode'].toString(), + patient: widget.patient, + doseTimeIn: widget.doseTime['id'].toString(), + model: widget.modelPrescription, + duration: widget.duration['id'].toString(), + frequency: widget.medicineModel.itemMedicineList.length == 1 + ? widget.medicineModel.itemMedicineList[0]['parameterCode'] + .toString() + : widget.frequency['parameterCode'].toString(), + route: widget.medicineModel.itemMedicineListRoute.length == 1 + ? widget.medicineModel.itemMedicineListRoute[0]['parameterCode'] + .toString() + : widget.route['parameterCode'].toString(), + drugId: widget.selectedMedication.itemId.toString(), + strength: widget.strength, + indication: widget.indication, + instruction: widget.instruction, + doseTime: widget.selectedDate, + ); + if (widget.medicineModel.state == ViewState.ErrorLocal) { + GifLoaderDialogUtils.hideDialog(context); + Helpers.showErrorToast(widget.medicineModel.error); + } else if (widget.modelPrescription.state == ViewState.Idle) { + widget.modelPrescription.getPrescriptions(widget.patient); + GifLoaderDialogUtils.hideDialog(context); + DrAppToastMsg.showSuccesToast('Medication has been added'); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + } + }, + ), ); } } diff --git a/lib/screens/prescription/add_prescription/drugtodrug.dart b/lib/screens/prescription/add_prescription/drugtodrug.dart index 70075a6a..b008fda0 100644 --- a/lib/screens/prescription/add_prescription/drugtodrug.dart +++ b/lib/screens/prescription/add_prescription/drugtodrug.dart @@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_container.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; @@ -38,8 +39,8 @@ class _DrugToDrug extends State { ]; - VitalSignsViewModel model = new VitalSignsViewModel(); - SOAPViewModel model2 = new SOAPViewModel(); + VitalSignsViewModel vitalSignsViewModel = new VitalSignsViewModel(); + SOAPViewModel soapViewModel = new SOAPViewModel(); @override void initState() { @@ -52,18 +53,18 @@ class _DrugToDrug extends State { Widget build(BuildContext context) { return isLoaded == true ? BaseView( - onModelReady: (model3) => model3.getDrugToDrug( - model.patientVitalSigns, + onModelReady: (prescriptionViewModel) => prescriptionViewModel.getDrugToDrug( + vitalSignsViewModel.patientVitalSigns, widget.listAssessment, - model2.patientAllergiesList, + soapViewModel.patientAllergiesList, widget.patient, widget.prescription), - builder: (BuildContext context, PrescriptionViewModel model3, + builder: (BuildContext context, PrescriptionViewModel prescriptionViewModel, Widget child) => NetworkBaseView( - baseViewModel: model3, + baseViewModel: prescriptionViewModel, child: Container( - height: SizeConfig.realScreenHeight * .4, + height: SizeConfig.realScreenHeight * .9, child: new ListView.builder( itemCount: expandableList.length, itemBuilder: (context, i) { @@ -73,7 +74,7 @@ class _DrugToDrug extends State { ' ' + '(' + getDrugInfo(expandableList[i]['level'], - model3) + prescriptionViewModel) .length .toString() + ')', @@ -81,7 +82,7 @@ class _DrugToDrug extends State { fontWeight: FontWeight.bold, ), children: getDrugInfo( - expandableList[i]['level'], model3) + expandableList[i]['level'], prescriptionViewModel) .map((item) { return Container( padding: EdgeInsets.all(10), @@ -93,10 +94,8 @@ class _DrugToDrug extends State { })))) : Container( height: SizeConfig.realScreenHeight * .45, - child: Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation(Colors.black), - ))); + child: GifLoaderContainer() + ); } getTypeID() async { @@ -119,17 +118,17 @@ class _DrugToDrug extends State { editedBy: ''); /// TODO Elham* rename model to meaning full not just modle with number - await model.getPatientVitalSign(widget.patient); - await model2.getPatientAllergy(generalGetReqForSOAP); - await model2.getMasterLookup(MasterKeysService.DiagnosisType); - if (model.state == ViewState.Idle && model2.state == ViewState.Idle) { + await vitalSignsViewModel.getPatientVitalSign(widget.patient); + await soapViewModel.getPatientAllergy(generalGetReqForSOAP); + await soapViewModel.getMasterLookup(MasterKeysService.DiagnosisType); + if (vitalSignsViewModel.state == ViewState.Idle && soapViewModel.state == ViewState.Idle) { setState(() { isLoaded = true; }); } } - List getDrugInfo(level, model3) { - return model3.drugToDrug.where((i) => i['Severity'] == level).toList(); + List getDrugInfo(level, prescriptionViewModel) { + return prescriptionViewModel.drugToDrug.where((i) => i['Severity'] == level).toList(); } } diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index 30f97e85..1e68c388 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -26,6 +26,7 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; +import '../../../widgets/transitions/slide_up_page.dart'; import 'add_drug_widget.dart'; class PrescriptionFormWidget extends StatefulWidget { @@ -590,8 +591,31 @@ class _PrescriptionFormWidgetState extends State { } if (formKey.currentState.validate()) { - Navigator.pop(context); - openDrugToDrug(model, prescriptionViewModel); + Navigator.push( + context, + SlideUpPageRoute( + widget: AddDrugWidget( + patient: widget.patient, + medicineModel: widget.medicineViewModel, + modelPrescription: widget.prescriptionViewModel, + prescriptionList: widget.prescriptionList, + route: route, + doseTime: doseTime, + duration: duration, + frequency: frequency, + units: units, + uom: uom, + x: x, + selectedMedication: widget.selectedMedication, + strength: strengthController.text, + indication: indicationController.text, + instruction: instructionController.text, + selectedDate: selectedDate, + ), + ), + ); + // Navigator.pop(context); + // openDrugToDrug(model, prescriptionViewModel); } } else { setState(() { From 8cb5171bc98d392e8748642fb07e959ec9ba83a2 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Tue, 8 Feb 2022 15:56:06 +0200 Subject: [PATCH 14/25] Refactor add_prescription_form --- lib/core/service/patient/patient_service.dart | 2 +- .../viewModel/prescription_view_model.dart | 9 +- .../prescription_form_widget.dart | 194 ++++++++---------- .../prescription/prescriptions_page.dart | 13 +- .../procedures/add-favourite-procedure.dart | 10 +- .../base_add_procedure_tab_page.dart | 34 ++- 6 files changed, 121 insertions(+), 141 deletions(-) diff --git a/lib/core/service/patient/patient_service.dart b/lib/core/service/patient/patient_service.dart index 437e5186..5ec06b0f 100644 --- a/lib/core/service/patient/patient_service.dart +++ b/lib/core/service/patient/patient_service.dart @@ -209,7 +209,7 @@ class PatientService extends BaseService { super.error = error; }, body: patient, - ); + ); return patient; } Future getOutPatientPrescriptions(patient) async { diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index d79c9f95..787b4f78 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -294,13 +294,14 @@ class PrescriptionViewModel extends BaseViewModel { } } - getPrescriptions(PatiantInformtion patient, {String patientType}) async { - setState(ViewState.BusyLocal); + getPrescriptions(PatiantInformtion patient, {String patientType, bool isLocalBusy = true}) async { + if(isLocalBusy) + setState(ViewState.BusyLocal); else setState(ViewState.Busy); await _prescriptionsService.getPrescriptions(patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; - if (patientType == "7") - setState(ViewState.ErrorLocal); + if (isLocalBusy) + setState(ViewState.Error); else setState(ViewState.ErrorLocal); } else { diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index 1e68c388..e83c9348 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -192,92 +192,92 @@ class _PrescriptionFormWidgetState extends State { ], ), ), - Container( - width: double.infinity, - child: Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.35, - child: AppTextFieldCustom( - height: 38, - validationError: strengthError, - hintText: 'Strength', - isTextFieldHasSuffix: false, - enabled: true, - controller: strengthController, - onChanged: (String value) { - setState(() { - strengthChar = value.length; - }); - if (strengthChar >= 5) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .only5DigitsAllowedForStrength, - ); - } - }, - inputType: TextInputType.numberWithOptions( - decimal: true, - ), - ), - ), - SizedBox( - width: 5.0, - ), - // Container( - // width: MediaQuery.of(context) - // .size - // .width * - // 0.35, - // child: AppTextFieldCustom( - // height: 38, - // validationError: - // unitError, - // hintText: 'Unit', - // isTextFieldHasSuffix: false, - // enabled: true, - // controller: - // unitController, - // onChanged: (selectedValue) { - // setState(() { - // units = selectedValue; - // units['isDefault'] = true; - // }); - // if (strengthChar >= 5) { - // DrAppToastMsg - // .showErrorToast( - // TranslationBase.of( - // context) - // .only5DigitsAllowedForStrength, - // ); - // } - // }, - // inputType: TextInputType - // .numberWithOptions( - // decimal: true, - // ), - // ), - // ), - PrescriptionTextFiled( - width: MediaQuery.of(context).size.width * 0.510, - element: - widget.medicineViewModel.itemMedicineListUnit.length == 1 - ? widget.medicineViewModel.itemMedicineListUnit[0] - : units, - elementError: unitError, - keyName: 'description', - keyId: 'parameterCode', - hintText: 'Unit', - elementList: widget.medicineViewModel.itemMedicineListUnit, - okFunction: (selectedValue) { + Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.35, + child: AppTextFieldCustom( + validationError: strengthError, + hintText: 'Strength', + isTextFieldHasSuffix: false, + enabled: true, + controller: strengthController, + onChanged: (String value) { setState(() { - units = selectedValue; - units['isDefault'] = true; + strengthChar = value.length; }); + if (strengthChar >= 5) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .only5DigitsAllowedForStrength, + ); + } }, + inputType: TextInputType.numberWithOptions( + decimal: true, + ), ), - ], - ), + + + + + ), + SizedBox( + width: 5.0, + ), + // Container( + // width: MediaQuery.of(context) + // .size + // .width * + // 0.35, + // child: AppTextFieldCustom( + // height: 38, + // validationError: + // unitError, + // hintText: 'Unit', + // isTextFieldHasSuffix: false, + // enabled: true, + // controller: + // unitController, + // onChanged: (selectedValue) { + // setState(() { + // units = selectedValue; + // units['isDefault'] = true; + // }); + // if (strengthChar >= 5) { + // DrAppToastMsg + // .showErrorToast( + // TranslationBase.of( + // context) + // .only5DigitsAllowedForStrength, + // ); + // } + // }, + // inputType: TextInputType + // .numberWithOptions( + // decimal: true, + // ), + // ), + // ), + PrescriptionTextFiled( + width: MediaQuery.of(context).size.width * 0.510, + element: + widget.medicineViewModel.itemMedicineListUnit.length == 1 + ? widget.medicineViewModel.itemMedicineListUnit[0] + : units, + elementError: unitError, + keyName: 'description', + keyId: 'parameterCode', + hintText: 'Unit', + elementList: widget.medicineViewModel.itemMedicineListUnit, + okFunction: (selectedValue) { + setState(() { + units = selectedValue; + units['isDefault'] = true; + }); + }, + ), + ], ), SizedBox(height: spaceBetweenTextFields), PrescriptionTextFiled( @@ -378,8 +378,7 @@ class _PrescriptionFormWidgetState extends State { ], ), ), - SizedBox(height: spaceBetweenTextFields), - Container( + SizedBox(height: spaceBetweenTextFields), Container( color: Colors.transparent, child: InkWell( onTap: () => selectDate(context, widget.prescriptionViewModel), @@ -397,7 +396,6 @@ class _PrescriptionFormWidgetState extends State { ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" : null, enabled: false, - controller: strengthController, ), // TextField( @@ -538,32 +536,6 @@ class _PrescriptionFormWidgetState extends State { } } - openDrugToDrug( - MedicineViewModel medicineViewModel, PrescriptionViewModel modelPrescription) { - showModalBottomSheet( - context: context, - builder: (context) { - return AddDrugWidget( - patient: widget.patient, - medicineModel: widget.medicineViewModel, - modelPrescription: widget.prescriptionViewModel, - prescriptionList: widget.prescriptionList, - route: route, - doseTime: doseTime, - duration: duration, - frequency: frequency, - units: units, - uom: uom, - x: x, - selectedMedication: widget.selectedMedication, - strength: strengthController.text, - indication: indicationController.text, - instruction: instructionController.text, - selectedDate: selectedDate, - ); - }); - } - addMedicationButton(MedicineViewModel model) async { await locator().logEvent( eventCategory: "Add Prescription Form", diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 40bebf17..8ae6148e 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -27,23 +27,16 @@ class PrescriptionsPage extends StatelessWidget { @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; - PatientViewModel patientViewModel; PatiantInformtion patient = routeArgs['patient']; String patientType = routeArgs['patientType']; String arrivalType = routeArgs['arrivalType']; bool isInpatient = routeArgs['isInpatient']; bool isFromLiveCare = routeArgs['isFromLiveCare']; - bool isSelectInpatient = routeArgs['isSelectInpatient']; return BaseView( onModelReady: (model) async { - await model.getOutPatientPrescriptions( - patient.admissionNo == null - ? model.getPrescriptions(patient, patientType: patientType) - : model.getMedicationForInPatient(patient), - isLocalBusy: true, - context: context, - patientInformation: patient - ); + patient.admissionNo == null + ? model.getPrescriptions(patient, patientType: patientType, isLocalBusy: false) + : model.getMedicationForInPatient(patient); }, builder: (_, model, w) => AppScaffold( baseViewModel: model, diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index ff84dcf0..e24af0b3 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -48,9 +48,7 @@ class _AddFavouriteProcedureState extends State { @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) async { - }, - builder: (BuildContext context, ProcedureViewModel model, Widget child) => + builder: (BuildContext context, ProcedureViewModel model_, Widget child) => AppScaffold( isShowAppBar: false, baseViewModel: model, @@ -59,12 +57,12 @@ class _AddFavouriteProcedureState extends State { Container( height: MediaQuery.of(context).size.height * 0.070, ), - (model.templateList.length != 0) + (widget.previousProcedureViewModel.templateList.length != 0) ? Expanded( child: EntityListCheckboxSearchFavProceduresWidget( isProcedure: !(widget.procedureType == ProcedureType.PRESCRIPTION), - model: model, + model: widget.previousProcedureViewModel, removeFavProcedure: (item) { setState(() { entityList.remove(item); @@ -102,7 +100,7 @@ class _AddFavouriteProcedureState extends State { title: widget.procedureType.getAddButtonTitle(context) ?? TranslationBase.of(context).addSelectedProcedures, color: AppGlobal.appGreenColor, - disabled: model.templateList.length == 0 ? true : false, + disabled: widget.previousProcedureViewModel.templateList.length == 0 ? true : false, fontWeight: FontWeight.w700, onPressed: () { if (widget.procedureType == ProcedureType.PRESCRIPTION) { diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index b4fc9573..a3ea04f2 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -10,7 +10,10 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../core/viewModel/project_view_model.dart'; +import '../../util/tab_helper.dart'; import 'ProcedureType.dart'; import 'add-favourite-procedure.dart'; import 'add-procedure-page.dart'; @@ -71,7 +74,6 @@ class _BaseAddProcedureTabPageState extends State return BaseView( onModelReady: (model) async { await model.getProcedureTemplate(categoryID: widget.procedureType.getCategoryId()); - }, builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( @@ -124,13 +126,16 @@ class _BaseAddProcedureTabPageState extends State tabWidget( screenSize, _activeTab == 0, + procedureType .getFavouriteTabName(context), + isFirst: true,context: context ), tabWidget( screenSize, _activeTab == 1, procedureType.getAllLabelName(context), + isLast: true,context: context ), ], ), @@ -181,16 +186,27 @@ class _BaseAddProcedureTabPageState extends State ); } - Widget tabWidget(Size screenSize, bool isActive, String title, - {int counter = -1}) { + Widget tabWidget( + Size screenSize, + bool isActive, + String title, { + int counter = -1, + bool isFirst = false, + bool isMiddle = false, + bool isLast = false, + context, + }) { + ProjectViewModel projectViewModel = Provider.of(context); + return Center( child: Container( - height: screenSize.height * 0.070, - decoration: TextFieldsUtils.containerBorderDecoration( - isActive ? Color(0xFFD02127) : Color(0xFFEAEAEA), - isActive ? Color(0xFFD02127) : Color(0xFFEAEAEA), - borderRadius: 4, - borderWidth: 0), + height: TabHelper.getTabHeight(context), + decoration: TabHelper.getBoxTabsBoxDecoration( + isActive: isActive, + isFirst: isFirst, + isMiddle: isMiddle, + isLast: isLast, + projectViewModel: projectViewModel), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ From c76900a868592e5fd464a006317ab0916a04e144 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Tue, 8 Feb 2022 16:21:36 +0200 Subject: [PATCH 15/25] Refactor add_prescription_form --- .../procedures/add-favourite-procedure.dart | 187 ++++++++--------- .../base_add_procedure_tab_page.dart | 191 +++++++----------- .../procedures/entity_list_fav_procedure.dart | 106 +++++----- 3 files changed, 207 insertions(+), 277 deletions(-) diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index e24af0b3..4df2726e 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -17,6 +17,7 @@ import 'package:flutter/material.dart'; import '../../config/config.dart'; import '../../widgets/shared/loader/gif_loader_dialog_utils.dart'; +import '../patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; import 'ProcedureType.dart'; class AddFavouriteProcedure extends StatefulWidget { @@ -48,110 +49,96 @@ class _AddFavouriteProcedureState extends State { @override Widget build(BuildContext context) { return BaseView( - builder: (BuildContext context, ProcedureViewModel model_, Widget child) => + builder: (BuildContext context, ProcedureViewModel model_, + Widget child) => AppScaffold( - isShowAppBar: false, - baseViewModel: model, - body: Column( - children: [ - Container( - height: MediaQuery.of(context).size.height * 0.070, - ), - (widget.previousProcedureViewModel.templateList.length != 0) - ? Expanded( - child: EntityListCheckboxSearchFavProceduresWidget( - isProcedure: - !(widget.procedureType == ProcedureType.PRESCRIPTION), - model: widget.previousProcedureViewModel, - removeFavProcedure: (item) { - setState(() { - entityList.remove(item); - }); - }, - addFavProcedure: (history) { - setState(() { - entityList.add(history); - }); - }, - isEntityFavListSelected: (master) => - isEntityListSelected(master), - groupProcedures: groupProcedures, - selectProcedures: (selectedProcedure) { - setState(() { - groupProcedures = selectedProcedure; - }); - }, - ), - ) - : Container( - child: Padding( - padding: EdgeInsets.symmetric(vertical: 50.0), - child: AppText('You Don\'t have favorite prescription'), - ), - ), - ], - ), - bottomSheet: Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: widget.procedureType.getAddButtonTitle(context) ?? - TranslationBase.of(context).addSelectedProcedures, - color: AppGlobal.appGreenColor, - disabled: widget.previousProcedureViewModel.templateList.length == 0 ? true : false, - fontWeight: FontWeight.w700, - onPressed: () { - if (widget.procedureType == ProcedureType.PRESCRIPTION) { - if (groupProcedures == null) { - DrAppToastMsg.showErrorToast( - 'Please Select item ', - ); - return; - } + isShowAppBar: false, + baseViewModel: model, + body: Column( + children: [ + (widget.previousProcedureViewModel.templateList.length != 0) + ? Expanded( + child: EntityListCheckboxSearchFavProceduresWidget( + isProcedure: !(widget.procedureType == + ProcedureType.PRESCRIPTION), + model: widget.previousProcedureViewModel, + removeFavProcedure: (item) { + setState(() { + entityList.remove(item); + }); + }, + addFavProcedure: (history) { + setState(() { + entityList.add(history); + }); + }, + isEntityFavListSelected: (master) => + isEntityListSelected(master), + groupProcedures: groupProcedures, + selectProcedures: (selectedProcedure) { + setState(() { + groupProcedures = selectedProcedure; + }); + }, + ), + ) + : Container( + child: Padding( + padding: EdgeInsets.symmetric(vertical: 50.0), + child: AppText( + 'You Don\'t have favorite prescription'), + ), + ), + ], + ), + bottomSheet: BottomSheetDialogButton( + label: widget.procedureType.getAddButtonTitle(context) ?? + TranslationBase.of(context).addSelectedProcedures, + onTap: () async { + if (widget.procedureType == ProcedureType.PRESCRIPTION) { + if (groupProcedures == null) { + DrAppToastMsg.showErrorToast( + 'Please Select item ', + ); + return; + } - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => PrescriptionCheckOutScreen( - patient: widget.patient, - model: widget.prescriptionModel, - groupProcedures: groupProcedures, - ), - settings: RouteSettings( - name: 'PrescriptionCheckOutScreen')), - ); - } else { - if (entityList.isEmpty == true) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .fillTheMandatoryProcedureDetails, + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PrescriptionCheckOutScreen( + patient: widget.patient, + model: widget.prescriptionModel, + groupProcedures: groupProcedures, + ), + settings: RouteSettings( + name: 'PrescriptionCheckOutScreen')), + ); + } else { + if (entityList.isEmpty == true) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .fillTheMandatoryProcedureDetails, + ); + return; + } + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ProcedureCheckOutScreen( + items: entityList, + model: model, + patient: widget.patient, + addButtonTitle: widget.procedureType + .getAddButtonTitle(context), + toolbarTitle: widget.procedureType + .getToolbarLabel(context), + ), + settings: + RouteSettings(name: 'ProcedureCheckOutScreen')), ); - return; } - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ProcedureCheckOutScreen( - items: entityList, - model: model, - patient: widget.patient, - addButtonTitle: widget.procedureType - .getAddButtonTitle(context), - toolbarTitle: widget.procedureType - .getToolbarLabel(context), - ), - settings: - RouteSettings(name: 'ProcedureCheckOutScreen')), - ); - } - }, - ), - ], - ), - ), - ), + })), ); } diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index a3ea04f2..271baff9 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -82,105 +82,74 @@ class _BaseAddProcedureTabPageState extends State appBar: BottomSheetTitle(title: procedureType.getToolbarLabel(context),), body: NetworkBaseView( baseViewModel: model, - child: DraggableScrollableSheet( - minChildSize: 0.90, - initialChildSize: 0.95, - maxChildSize: 1.0, - builder: - (BuildContext context, ScrollController scrollController) { - return Container( - height: MediaQuery.of(context).size.height * 1.25, - child: Padding( - padding: EdgeInsets.all(12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Scaffold( - extendBodyBehindAppBar: true, - appBar: PreferredSize( - preferredSize: Size.fromHeight( - MediaQuery.of(context).size.height * 0.070), - child: Container( - height: - MediaQuery.of(context).size.height * 0.070, - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Theme.of(context).dividerColor, - width: 0.5), //width: 0.7 - ), - color: Colors.white), - child: Center( - child: TabBar( - isScrollable: false, - controller: _tabController, - indicatorColor: Colors.transparent, - indicatorWeight: 1.0, - indicatorSize: TabBarIndicatorSize.tab, - labelColor: Theme.of(context).primaryColor, - labelPadding: EdgeInsets.only( - top: 0, left: 0, right: 0, bottom: 0), - unselectedLabelColor: Colors.grey[800], - tabs: [ - tabWidget( - screenSize, - _activeTab == 0, - - procedureType - .getFavouriteTabName(context), - isFirst: true,context: context - ), - tabWidget( - screenSize, - _activeTab == 1, - procedureType.getAllLabelName(context), - isLast: true,context: context - ), - ], - ), - ), - ), - ), - body: Column( - children: [ - Expanded( - child: TabBarView( - physics: BouncingScrollPhysics(), - controller: _tabController, - children: [ - AddFavouriteProcedure( - previousProcedureViewModel: model, - prescriptionModel: - widget.prescriptionModel, - patient: patient, - procedureType: procedureType, - ), - if (widget.procedureType == - ProcedureType.PRESCRIPTION) - AddPrescriptionForm( - widget.prescriptionModel, - widget.patient, - widget.prescriptionModel.prescriptionList, - ) - else - AddProcedurePage( - model: this.model, - patient: patient, - procedureType: procedureType, - ), - ], - ), - ), - ], - ), + child: Expanded( + child: Scaffold( + extendBodyBehindAppBar: true, + appBar: PreferredSize( + preferredSize: Size.fromHeight( + MediaQuery.of(context).size.height * 0.070), + child: TabBar( + isScrollable: false, + controller: _tabController, + indicatorColor: Colors.transparent, + indicatorWeight: 1.0, + indicatorSize: TabBarIndicatorSize.tab, + labelColor: Theme.of(context).primaryColor, + labelPadding: EdgeInsets.only( + top: 0, left: 0, right: 0, bottom: 0), + unselectedLabelColor: Colors.grey[800], + tabs: [ + tabWidget( + screenSize, + _activeTab == 0, + + procedureType + .getFavouriteTabName(context), + isFirst: true,context: context + ), + tabWidget( + screenSize, + _activeTab == 1, + procedureType.getAllLabelName(context), + isLast: true,context: context + ), + ], + ), + ), + body: Column( + children: [ + Expanded( + child: TabBarView( + physics: BouncingScrollPhysics(), + controller: _tabController, + children: [ + AddFavouriteProcedure( + previousProcedureViewModel: model, + prescriptionModel: + widget.prescriptionModel, + patient: patient, + procedureType: procedureType, ), - ), - ], + if (widget.procedureType == + ProcedureType.PRESCRIPTION) + AddPrescriptionForm( + widget.prescriptionModel, + widget.patient, + widget.prescriptionModel.prescriptionList, + ) + else + AddProcedurePage( + model: this.model, + patient: patient, + procedureType: procedureType, + ), + ], + ), ), - ), - ); - }), + ], + ), + ), + ) ), ), ); @@ -210,32 +179,10 @@ class _BaseAddProcedureTabPageState extends State child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - AppText( - title, - fontSize: SizeConfig.textMultiplier * 1.5, - color: isActive ? Colors.white : Color(0xFF2B353E), - fontWeight: FontWeight.w700, - ), + + TabHelper.getTabText(title: title, isActive: isActive), if (counter != -1) - Container( - margin: EdgeInsets.all(4), - width: 15, - height: 15, - decoration: BoxDecoration( - color: isActive ? Colors.white : Color(0xFFD02127), - shape: BoxShape.circle, - ), - child: Center( - child: FittedBox( - child: AppText( - "$counter", - fontSize: SizeConfig.textMultiplier * 1.5, - color: !isActive ? Colors.white : Color(0xFFD02127), - fontWeight: FontWeight.w700, - ), - ), - ), - ), + TabHelper.getTabCounter(isActive: isActive, counter: counter) ], ), ), diff --git a/lib/screens/procedures/entity_list_fav_procedure.dart b/lib/screens/procedures/entity_list_fav_procedure.dart index 3fc6ca32..a9fa5ddf 100644 --- a/lib/screens/procedures/entity_list_fav_procedure.dart +++ b/lib/screens/procedures/entity_list_fav_procedure.dart @@ -78,63 +78,59 @@ class _EntityListCheckboxSearchFavProceduresWidgetState @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: widget.model, - child: Container( - height: MediaQuery.of(context).size.height * 0.60, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: Colors.white), - child: ListView( - children: [ - TextFields( - hintText: 'Search Favourite templates', - suffixIcon: EvaIcons.search, - suffixIconColor: Color(0xff2B353E), - onChanged: (value) { - filterSearchResults(value); - }, - hasBorder: false, - ), - SizedBox( - height: 15, - ), - widget.model.templateList.length != 0 - ? Column( - children: - widget.model.templateList.map((historyInfo) { - return ExpansionProcedure( - procedureTempleteModel: historyInfo, - model: widget.model, - removeFavProcedure: widget.removeFavProcedure, - addFavProcedure: widget.addFavProcedure, - selectProcedures: widget.selectProcedures, - isEntityListSelected: - widget.isEntityListSelected, - isEntityFavListSelected: - widget.isEntityFavListSelected, - isProcedure: widget.isProcedure, - groupProcedures: widget.groupProcedures); - }).toList(), - ) - : Center( - child: Container( - child: AppText("Sorry , No Match", - color: AppGlobal.appRedColor), - ), - ) - ], + return SingleChildScrollView( + child: NetworkBaseView( + baseViewModel: widget.model, + child: Container( + height: MediaQuery.of(context).size.height * 0.90, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: Colors.white), + child: ListView( + children: [ + TextFields( + hintText: 'Search Favourite templates', + suffixIcon: EvaIcons.search, + suffixIconColor: Color(0xff2B353E), + onChanged: (value) { + filterSearchResults(value); + }, + hasBorder: false, ), - )), + SizedBox( + height: 15, + ), + widget.model.templateList.length != 0 + ? Column( + children: + widget.model.templateList.map((historyInfo) { + return ExpansionProcedure( + procedureTempleteModel: historyInfo, + model: widget.model, + removeFavProcedure: widget.removeFavProcedure, + addFavProcedure: widget.addFavProcedure, + selectProcedures: widget.selectProcedures, + isEntityListSelected: + widget.isEntityListSelected, + isEntityFavListSelected: + widget.isEntityFavListSelected, + isProcedure: widget.isProcedure, + groupProcedures: widget.groupProcedures); + }).toList(), + ) + : Center( + child: Container( + child: AppText("Sorry , No Match", + color: AppGlobal.appRedColor), + ), + ) + ], ), - ), - ], + )), + ), ), ); } From f266f54be0167f328edb9e2fdc148dbe213f150d Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Wed, 9 Feb 2022 12:49:16 +0200 Subject: [PATCH 16/25] Fix the prescriptions pages --- .../add_prescription/add_drug_widget.dart | 3 +- ...iption_form.dart => add_prescription.dart} | 8 +-- .../{drugtodrug.dart => drug_to_drug.dart} | 0 .../prescription_items_in_patient.dart} | 0 .../prescription_items_out_patient.dart} | 0 .../prescription/prescriptions_page.dart | 10 ++-- .../procedures/ExpansionProcedure.dart | 19 ++++--- .../base_add_procedure_tab_page.dart | 8 +-- .../procedures/entity_list_fav_procedure.dart | 32 +++++++++--- lib/widgets/shared/doctor_card.dart | 52 ++++++------------- 10 files changed, 67 insertions(+), 65 deletions(-) rename lib/screens/prescription/add_prescription/{add_prescription_form.dart => add_prescription.dart} (96%) rename lib/screens/prescription/add_prescription/{drugtodrug.dart => drug_to_drug.dart} (100%) rename lib/screens/prescription/{prescription_item_in_patient_page.dart => prescriptions_items/prescription_items_in_patient.dart} (100%) rename lib/screens/prescription/{prescription_items_page.dart => prescriptions_items/prescription_items_out_patient.dart} (100%) diff --git a/lib/screens/prescription/add_prescription/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug_widget.dart index 67970691..00a5a841 100644 --- a/lib/screens/prescription/add_prescription/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug_widget.dart @@ -13,9 +13,8 @@ import '../../../core/model/search_drug/get_medication_response_model.dart'; import '../../../core/viewModel/prescription_view_model.dart'; import '../../../util/dr_app_toast_msg.dart'; import '../../../util/helpers.dart'; -import '../../../widgets/shared/buttons/app_buttons_widget.dart'; import '../../patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; -import 'drugtodrug.dart'; +import 'drug_to_drug.dart'; class AddDrugWidget extends StatefulWidget { final PatiantInformtion patient; diff --git a/lib/screens/prescription/add_prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription/add_prescription.dart similarity index 96% rename from lib/screens/prescription/add_prescription/add_prescription_form.dart rename to lib/screens/prescription/add_prescription/add_prescription.dart index ba283b1a..ab32b9f5 100644 --- a/lib/screens/prescription/add_prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription/add_prescription.dart @@ -13,19 +13,19 @@ import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; -class AddPrescriptionForm extends StatefulWidget { +class AddPrescription extends StatefulWidget { final PrescriptionViewModel prescriptionViewModel; final PatiantInformtion patient; final List prescriptionList; - AddPrescriptionForm( + AddPrescription( this.prescriptionViewModel, this.patient, this.prescriptionList); @override - _AddPrescriptionFormState createState() => _AddPrescriptionFormState(); + _AddPrescriptionState createState() => _AddPrescriptionState(); } -class _AddPrescriptionFormState extends State { +class _AddPrescriptionState extends State { String routeError; String frequencyError; String doseTimeError; diff --git a/lib/screens/prescription/add_prescription/drugtodrug.dart b/lib/screens/prescription/add_prescription/drug_to_drug.dart similarity index 100% rename from lib/screens/prescription/add_prescription/drugtodrug.dart rename to lib/screens/prescription/add_prescription/drug_to_drug.dart diff --git a/lib/screens/prescription/prescription_item_in_patient_page.dart b/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart similarity index 100% rename from lib/screens/prescription/prescription_item_in_patient_page.dart rename to lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart diff --git a/lib/screens/prescription/prescription_items_page.dart b/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart similarity index 100% rename from lib/screens/prescription/prescription_items_page.dart rename to lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 8ae6148e..72d45d46 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -2,8 +2,8 @@ import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/prescription/prescription_item_in_patient_page.dart'; -import 'package:doctor_app_flutter/screens/prescription/prescription_items_page.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_in_patient.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_out_patient.dart'; import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart'; import 'package:doctor_app_flutter/screens/procedures/base_add_procedure_tab_page.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; @@ -21,6 +21,7 @@ import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../util/helpers.dart'; import '../../widgets/shared/errors/error_message.dart'; class PrescriptionsPage extends StatelessWidget { @@ -112,8 +113,7 @@ class PrescriptionsPage extends StatelessWidget { context, FadePage( page: PrescriptionItemsPage( - prescriptions: - model.prescriptionsList[index], + prescriptions: model.prescriptionsList[index], patient: patient, patientType: patientType, arrivalType: arrivalType, @@ -124,7 +124,7 @@ class PrescriptionsPage extends StatelessWidget { children: [ DoctorCard( doctorName: - model.prescriptionsList[index].doctorName, + Helpers.convertToTitleCase(model.prescriptionsList[index].doctorName), profileUrl: model .prescriptionsList[index].doctorImageURL, branch: model.prescriptionsList[index].name, diff --git a/lib/screens/procedures/ExpansionProcedure.dart b/lib/screens/procedures/ExpansionProcedure.dart index 228ca33e..b0593b06 100644 --- a/lib/screens/procedures/ExpansionProcedure.dart +++ b/lib/screens/procedures/ExpansionProcedure.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_templateModel.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; @@ -59,14 +60,16 @@ class _ExpansionProcedureState extends State { Radius.circular(5.0), )), child: Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Row( - children: [ + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Icon( Icons.folder, size: 20, - color: Color(0xff575757), + color: AppGlobal.appTextColor, ), Expanded( child: Padding( @@ -78,10 +81,12 @@ class _ExpansionProcedureState extends State { widget.procedureTempleteModel.templateName : "Prescription for " + widget.procedureTempleteModel.templateName, + letterSpacing: -0.72, fontSize: 16.0, - variant: "bodyText", - bold: true, - color: Color(0xff575757)), + color: AppGlobal.appTextColor, + fontWeight: FontWeight.w600, + ), + ), ), ], @@ -93,8 +98,8 @@ class _ExpansionProcedureState extends State { _isShowMore ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, - color: Colors.grey[800], - size: 22, + color: AppGlobal.appTextColor, + size: 28, ), ) ], diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index 271baff9..b8d1605d 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -1,17 +1,13 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; -import 'package:doctor_app_flutter/screens/prescription/add_prescription/add_prescription_form.dart'; +import 'package:doctor_app_flutter/screens/prescription/add_prescription/add_prescription.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/network_base_view.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; - import '../../core/viewModel/project_view_model.dart'; import '../../util/tab_helper.dart'; import 'ProcedureType.dart'; @@ -132,7 +128,7 @@ class _BaseAddProcedureTabPageState extends State ), if (widget.procedureType == ProcedureType.PRESCRIPTION) - AddPrescriptionForm( + AddPrescription( widget.prescriptionModel, widget.patient, widget.prescriptionModel.prescriptionList, diff --git a/lib/screens/procedures/entity_list_fav_procedure.dart b/lib/screens/procedures/entity_list_fav_procedure.dart index a9fa5ddf..4c8308f4 100644 --- a/lib/screens/procedures/entity_list_fav_procedure.dart +++ b/lib/screens/procedures/entity_list_fav_procedure.dart @@ -7,8 +7,10 @@ import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import '../../config/config.dart'; +import '../../widgets/shared/text_fields/app_text_field_custom_serach.dart'; import 'ExpansionProcedure.dart'; class EntityListCheckboxSearchFavProceduresWidget extends StatefulWidget { @@ -75,6 +77,8 @@ class _EntityListCheckboxSearchFavProceduresWidgetState } TextEditingController remarksController = TextEditingController(); + TextEditingController patientFileInfoController = TextEditingController(); + @override Widget build(BuildContext context) { @@ -91,14 +95,30 @@ class _EntityListCheckboxSearchFavProceduresWidgetState color: Colors.white), child: ListView( children: [ - TextFields( - hintText: 'Search Favourite templates', - suffixIcon: EvaIcons.search, - suffixIconColor: Color(0xff2B353E), - onChanged: (value) { + // TextFields( + // hintText: 'Search Favourite templates', + // suffixIcon: EvaIcons.search, + // suffixIconColor: Color(0xff2B353E), + // onChanged: (value) { + // filterSearchResults(value); + // }, + // hasBorder: false, + // ), + + AppTextFieldCustomSearch( + searchController: patientFileInfoController, + onChangeFun: (value) { filterSearchResults(value); }, - hasBorder: false, + marginTop: 5, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_LETTERS)) + ], + inputType: TextInputType.text, + hintText: 'Search Favourite templates', + // validationError: TranslationBase.of(context).emptyMessage + // : null, ), SizedBox( height: 15, diff --git a/lib/widgets/shared/doctor_card.dart b/lib/widgets/shared/doctor_card.dart index cc54330c..d4f34326 100644 --- a/lib/widgets/shared/doctor_card.dart +++ b/lib/widgets/shared/doctor_card.dart @@ -3,11 +3,14 @@ import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../config/size_config.dart'; + class DoctorCard extends StatelessWidget { final String doctorName; final String branch; @@ -140,43 +143,22 @@ class DoctorCard extends StatelessWidget { ], ), if (clinic != null) - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).clinic + - ": ", - color: Colors.grey[500], - fontSize: 14, - ), - Expanded( - child: AppText( - clinic, - fontSize: 14, - ), - ) - ], + CustomRow( + label: TranslationBase.of(context).clinic + + ": ", + value: clinic, + valueSize: 13, + labelSize: 13, ), if (branch != null) - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).branch + - ": ", - fontSize: 14, - color: Colors.grey[500], - ), - Expanded( - child: AppText( - branch, - fontSize: 14, - ), - ) - ], - ) + CustomRow( + label: TranslationBase.of(context).branch + + ": ", + value: branch, + valueSize: 13, + labelSize: 13, + ), + ]), ), ), From 34f658a1664fce7d552cdd3a8fb8886f1d86d285 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Wed, 9 Feb 2022 16:37:45 +0200 Subject: [PATCH 17/25] Add Translation to prescription pages --- lib/config/localized_values.dart | 6 + .../viewModel/prescription_view_model.dart | 4 +- .../add_prescription/add_drug_widget.dart | 5 +- .../add_prescription/drug_to_drug.dart | 1 - .../prescription_form_widget.dart | 88 +---- .../search_preescription_widget.dart | 2 - .../prescription_checkout_screen.dart | 30 +- .../preacription_items_widget.dart | 157 +++++++++ .../prescription_items_in_patient.dart | 9 - .../prescription_items_out_patient.dart | 327 +----------------- .../prescription/prescriptions_page.dart | 4 - .../procedures/add-favourite-procedure.dart | 8 +- .../procedures/entity_list_fav_procedure.dart | 19 +- lib/util/translations_delegate_base.dart | 199 +++++------ .../app_text_field_custom_serach.dart | 5 +- 15 files changed, 281 insertions(+), 583 deletions(-) create mode 100644 lib/screens/prescription/prescriptions_items/preacription_items_widget.dart diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 253ffc67..bb8b1b1c 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1129,4 +1129,10 @@ const Map> localizedValues = { "VTE_Type": {"en": "VTE Type", "ar": "VTE Type"}, "pharmacology": {"en": "Pharmacology", "ar": "علم العقاقير"}, "reasonsThrombo": {"en": "Reasons Thrombo", "ar": "أسباب ثرومبو"}, + "youDoNotHaveFavoritePrescription": {"en": "you Don't Have Favorite Prescription", "ar": "ليس لديك وصفة طبية مفضلة"}, + "pleaseSelectItem": {"en": "please Select Item", "ar": "الرجاء اختيار عنصر"}, + "searchFavoriteTemplate": {"en": "search Favorites Template", "ar": "البحث في قالب المفضلة"}, + "sorryNoMatch": {"en": "Sorry No Match", "ar": "عذرا لا يوجد تطابق"}, + "thousandIsTheMAXForTheStrength": {"en": "1000 Is The MAX For The Strength", "ar": "ألف هو القيمة الأعلى"}, + "strengthCanNotBeZero": {"en": "Strength Can't Be Zero", "ar": "القوة لا يمكن أن تكون صفر "}, }; diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 787b4f78..640b6037 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -313,11 +313,11 @@ class PrescriptionViewModel extends BaseViewModel { } getMedicationForInPatient(PatiantInformtion patient) async { - setState(ViewState.BusyLocal); + setState(ViewState.Busy); await _prescriptionsService.getMedicationForInPatient(patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; - setState(ViewState.ErrorLocal); + setState(ViewState.Error); } else { setState(ViewState.Idle); } diff --git a/lib/screens/prescription/add_prescription/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug_widget.dart index 00a5a841..ae7b688e 100644 --- a/lib/screens/prescription/add_prescription/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug_widget.dart @@ -47,7 +47,8 @@ class _AddDrugWidgetState extends State { Widget build(BuildContext context) { return AppScaffold( baseViewModel: widget.medicineModel, - appBar: BottomSheetTitle(title: "Add Medication",), + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addMedication), body: Container( height: SizeConfig.realScreenHeight * .8, width: SizeConfig.realScreenWidth, @@ -110,7 +111,7 @@ class _AddDrugWidgetState extends State { } else if (widget.modelPrescription.state == ViewState.Idle) { widget.modelPrescription.getPrescriptions(widget.patient); GifLoaderDialogUtils.hideDialog(context); - DrAppToastMsg.showSuccesToast('Medication has been added'); + DrAppToastMsg.showSuccesToast(TranslationBase.of(context).medicationHasBeenAdded); Navigator.of(context).pop(); Navigator.of(context).pop(); } diff --git a/lib/screens/prescription/add_prescription/drug_to_drug.dart b/lib/screens/prescription/add_prescription/drug_to_drug.dart index b008fda0..350021b5 100644 --- a/lib/screens/prescription/add_prescription/drug_to_drug.dart +++ b/lib/screens/prescription/add_prescription/drug_to_drug.dart @@ -116,7 +116,6 @@ class _DrugToDrug extends State { widget.patient.appointmentNo, doctorID: '', editedBy: ''); - /// TODO Elham* rename model to meaning full not just modle with number await vitalSignsViewModel.getPatientVitalSign(widget.patient); await soapViewModel.getPatientAllergy(generalGetReqForSOAP); diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index e83c9348..6bdf447a 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -25,7 +25,6 @@ import 'package:flutter/services.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; - import '../../../widgets/transitions/slide_up_page.dart'; import 'add_drug_widget.dart'; @@ -198,7 +197,7 @@ class _PrescriptionFormWidgetState extends State { width: MediaQuery.of(context).size.width * 0.35, child: AppTextFieldCustom( validationError: strengthError, - hintText: 'Strength', + hintText: TranslationBase.of(context).strength, isTextFieldHasSuffix: false, enabled: true, controller: strengthController, @@ -217,48 +216,10 @@ class _PrescriptionFormWidgetState extends State { decimal: true, ), ), - - - - ), SizedBox( width: 5.0, ), - // Container( - // width: MediaQuery.of(context) - // .size - // .width * - // 0.35, - // child: AppTextFieldCustom( - // height: 38, - // validationError: - // unitError, - // hintText: 'Unit', - // isTextFieldHasSuffix: false, - // enabled: true, - // controller: - // unitController, - // onChanged: (selectedValue) { - // setState(() { - // units = selectedValue; - // units['isDefault'] = true; - // }); - // if (strengthChar >= 5) { - // DrAppToastMsg - // .showErrorToast( - // TranslationBase.of( - // context) - // .only5DigitsAllowedForStrength, - // ); - // } - // }, - // inputType: TextInputType - // .numberWithOptions( - // decimal: true, - // ), - // ), - // ), PrescriptionTextFiled( width: MediaQuery.of(context).size.width * 0.510, element: @@ -266,9 +227,9 @@ class _PrescriptionFormWidgetState extends State { ? widget.medicineViewModel.itemMedicineListUnit[0] : units, elementError: unitError, - keyName: 'description', + keyName: TranslationBase.of(context).description, keyId: 'parameterCode', - hintText: 'Unit', + hintText: TranslationBase.of(context).unit, elementList: widget.medicineViewModel.itemMedicineListUnit, okFunction: (selectedValue) { setState(() { @@ -287,7 +248,7 @@ class _PrescriptionFormWidgetState extends State { : route, elementError: routeError, keyId: 'parameterCode', - keyName: 'description', + keyName: TranslationBase.of(context).description, okFunction: (selectedValue) { setState(() { route = selectedValue; @@ -306,7 +267,7 @@ class _PrescriptionFormWidgetState extends State { : frequency, elementList: widget.medicineViewModel.itemMedicineList, keyId: 'parameterCode', - keyName: 'description', + keyName: TranslationBase.of(context).description, okFunction: (selectedValue) { setState(() { frequency = selectedValue; @@ -352,11 +313,6 @@ class _PrescriptionFormWidgetState extends State { hintText: widget .medicineViewModel.patientAssessmentList[0].icdCode10ID .toString(), - // indication != null - // ? indication[ - // 'name'] - // : null, - enabled: true, ), ), @@ -368,10 +324,6 @@ class _PrescriptionFormWidgetState extends State { hintText: widget .medicineViewModel.patientAssessmentList[0].asciiDesc .toString(), - // indication != null - // ? indication[ - // 'name'] - // : null, enabled: true, ), ), @@ -384,7 +336,7 @@ class _PrescriptionFormWidgetState extends State { onTap: () => selectDate(context, widget.prescriptionViewModel), child: AppTextFieldCustom( validationError: strengthError, - hintText: 'Date', + hintText: TranslationBase.of(context).date, isTextFieldHasSuffix: true, suffixIcon: IconButton( icon: Icon( @@ -397,23 +349,6 @@ class _PrescriptionFormWidgetState extends State { : null, enabled: false, ), - - // 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, - // )), - // enabled: false, - // ), ), ), SizedBox(height: spaceBetweenTextFields), @@ -431,12 +366,6 @@ class _PrescriptionFormWidgetState extends State { duration != null && frequency != null && strengthController.text != null) { - // widget.medicineViewModel.getBoxQuantity( - // freq: frequency['parameterCode'], - // duration: duration['id'], - // itemCode: widget.selectedMedication.itemId, - // strength: double.parse(strengthController.text), - // ); box = widget.medicineViewModel.boxQuintity; return; } @@ -477,7 +406,6 @@ class _PrescriptionFormWidgetState extends State { minLines: 4, hintText: TranslationBase.of(context).instruction, controller: instructionController, - //keyboardType: TextInputType.number, ), Positioned( top: 0, @@ -554,11 +482,11 @@ class _PrescriptionFormWidgetState extends State { } if (double.parse(strengthController.text) > 1000.0) { - DrAppToastMsg.showErrorToast("1000 is the MAX for the strength"); + DrAppToastMsg.showErrorToast(TranslationBase.of(context).thousandIsTheMAXForTheStrength); return; } if (double.parse(strengthController.text) < 0.0) { - DrAppToastMsg.showErrorToast("strength can't be zero"); + DrAppToastMsg.showErrorToast(TranslationBase.of(context).strengthCanNotBeZero); return; } diff --git a/lib/screens/prescription/add_prescription/search_preescription_widget.dart b/lib/screens/prescription/add_prescription/search_preescription_widget.dart index 7bd0508d..2d84c110 100644 --- a/lib/screens/prescription/add_prescription/search_preescription_widget.dart +++ b/lib/screens/prescription/add_prescription/search_preescription_widget.dart @@ -1,8 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -import 'package:html_editor_enhanced/utils/utils.dart'; - import '../../../config/config.dart'; import '../../../core/model/search_drug/get_medication_response_model.dart'; import '../../../core/viewModel/medicine_view_model.dart'; diff --git a/lib/screens/prescription/prescription_checkout_screen.dart b/lib/screens/prescription/prescription_checkout_screen.dart index dfeea9f6..8f2d8b9d 100644 --- a/lib/screens/prescription/prescription_checkout_screen.dart +++ b/lib/screens/prescription/prescription_checkout_screen.dart @@ -97,7 +97,7 @@ class _PrescriptionCheckOutScreenState Helpers.showErrorToast(model.error); } else if (model.state == ViewState.Idle) { model.getPrescriptions(patient); - DrAppToastMsg.showSuccesToast('Medication has been added'); + DrAppToastMsg.showSuccesToast(TranslationBase.of(context).medicationHasBeenAdded); } } @@ -362,7 +362,7 @@ class _PrescriptionCheckOutScreenState child: AppTextFieldCustom( height: 40, validationError: strengthError, - hintText: 'Strength', + hintText: TranslationBase.of(context).strength, isTextFieldHasSuffix: false, enabled: true, controller: strengthController, @@ -395,7 +395,7 @@ class _PrescriptionCheckOutScreenState 0.560, element: units, elementError: unitError, - keyName: 'description', + keyName: TranslationBase.of(context).description, keyId: 'parameterCode', hintText: 'Select', elementList: @@ -417,7 +417,7 @@ class _PrescriptionCheckOutScreenState element: route, elementError: routeError, keyId: 'parameterCode', - keyName: 'description', + keyName: TranslationBase.of(context).description, okFunction: (selectedValue) { setState(() { route = selectedValue; @@ -435,7 +435,7 @@ class _PrescriptionCheckOutScreenState element: frequency, elementList: model.itemMedicineList, keyId: 'parameterCode', - keyName: 'description', + keyName: TranslationBase.of(context).description, okFunction: (selectedValue) { setState(() { frequency = selectedValue; @@ -651,19 +651,12 @@ class _PrescriptionCheckOutScreenState selectedDate != null && 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"); + TranslationBase.of(context).thousandIsTheMAXForTheStrength,); return; } if (double.parse( @@ -671,14 +664,12 @@ class _PrescriptionCheckOutScreenState .text) < 0.0) { DrAppToastMsg.showErrorToast( - "strength can't be zero"); + TranslationBase.of(context).strengthCanNotBeZero,); return; } - if (formKey.currentState .validate()) { Navigator.pop(context); - // openDrugToDrug(model); { postPrescription( icdCode: model @@ -696,13 +687,6 @@ class _PrescriptionCheckOutScreenState .icdCode10ID .toString() : "test", - // icdCode: model - // .patientAssessmentList - // .map((value) => value - // .icdCode10ID - // .trim()) - // .toList() - // .join(' '), dose: strengthController .text, doseUnit: model diff --git a/lib/screens/prescription/prescriptions_items/preacription_items_widget.dart b/lib/screens/prescription/prescriptions_items/preacription_items_widget.dart new file mode 100644 index 00000000..ce8a530a --- /dev/null +++ b/lib/screens/prescription/prescriptions_items/preacription_items_widget.dart @@ -0,0 +1,157 @@ +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import '../../../core/viewModel/prescriptions_view_model.dart'; +import '../../../widgets/shared/dialogs/ShowImageDialog.dart'; + + +class PrescriptionItemsWidget extends StatelessWidget { + final String itemDescription; + final String route; + final String frequency; + final int dailyDoses; + final String imageSRCUrl; + final String remarks; + final int days; + final PrescriptionsViewModel prescriptionsViewModel; + + + + PrescriptionItemsWidget( + {this.itemDescription, + this.route, + this.frequency, + this.dailyDoses, + this.imageSRCUrl, + this.remarks, + this.days, + this.prescriptionsViewModel}); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ...List.generate( + // TODO Elham* List.generate to list.builder + prescriptionsViewModel.prescriptionReportEnhList.length, + (index) => Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + ), + margin: EdgeInsets.all(12), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 18, right: 18), + child: AppText( + prescriptionsViewModel.prescriptionReportEnhList[index].itemDescription, + bold: true, + ), + ), + SizedBox( + height: 12, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + width: 18, + ), + Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + width: 0.5, color: Colors.grey)), + height: 55, + width: 55, + child: InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => ShowImageDialog( + imageUrl: prescriptionsViewModel.prescriptionReportEnhList[index].imageSRCUrl, + )); + }, + child: Stack( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.network( + prescriptionsViewModel.prescriptionReportEnhList[index].imageSRCUrl, + fit: BoxFit.cover, + ), + ), + Positioned( + top: 10, + right: 10, + child: Icon( + EvaIcons.search, + color: Colors.grey, + size: 35, + )) + ], + ), + ), + ), + SizedBox( + width: 10, + ), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + CustomRow( + label: TranslationBase.of(context).route + ' : ', + value: " " + prescriptionsViewModel.prescriptionReportEnhList[index].route ?? '', + labelSize: 13, + valueSize: 13, + ), + CustomRow( + label: TranslationBase.of(context).frequency + ' : ', + value: " " + prescriptionsViewModel.prescriptionReportEnhList[index].frequency ?? '', + labelSize: 13, + valueSize: 13, + ), + CustomRow( + label: TranslationBase.of(context).dailyDoses + ' : ', + value: " " + prescriptionsViewModel.prescriptionReportEnhList[index].doseDailyQuantity.toString() ?? '', + labelSize: 13, + valueSize: 13, + ), + CustomRow( + label: TranslationBase.of(context).duration + ' : ', + value: " " + prescriptionsViewModel.prescriptionReportList[index].days.toString() ?? '', + labelSize: 13, + valueSize: 13, + ), + SizedBox( + height: 12, + ), + CustomRow( + label: '', + value: prescriptionsViewModel.prescriptionReportList[index].remarks ?? '', + valueSize: 14, + ), + ], + ), + ) + ], + ) + ], + ), + ), + ), + ), + ], + ); + } +} diff --git a/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart b/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart index 5c54289d..787f6853 100644 --- a/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart +++ b/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart @@ -203,15 +203,6 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { ''), ], ), - // Row( - // children: [ - // AppText( - // TranslationBase.of(context).num, - // color: Colors.grey, - // ), - // AppText(" " + prescriptions.dose.toString() ?? ''), - // ], - // ), SizedBox( height: 12, ), diff --git a/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart b/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart index bf1632fd..fa8cebc2 100644 --- a/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart +++ b/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; import 'package:doctor_app_flutter/core/viewModel/prescriptions_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/preacription_items_widget.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; @@ -15,14 +16,12 @@ import 'package:flutter/material.dart'; class PrescriptionItemsPage extends StatelessWidget { final Prescriptions prescriptions; final PatiantInformtion patient; - final String patientType; final String arrivalType; PrescriptionItemsPage( {Key key, this.prescriptions, this.patient, - this.patientType, this.arrivalType}); @override @@ -49,323 +48,19 @@ class PrescriptionItemsPage extends StatelessWidget { child: Container( child: Column( children: [ - if (!prescriptions.isInOutPatient) ...List.generate( - // TODO Elham* List.generate to list.builder model.prescriptionReportList.length, - (index) => Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white, - ), - margin: EdgeInsets.all(12), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: - EdgeInsets.only(left: 18, right: 18), - child: AppText( - model.prescriptionReportList[index] - .itemDescription.isNotEmpty - ? model - .prescriptionReportList[index] - .itemDescription - : model - .prescriptionReportList[index] - .itemDescriptionN, - bold: true, - )), - SizedBox( - height: 12, - ), - Row( - children: [ - SizedBox( - width: 18, - ), - Container( - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all( - width: 0.5, - color: Colors.grey)), - height: 55, - width: 55, - child: InkWell( - onTap: () { - showDialog( - context: context, - builder: (ctx) => - ShowImageDialog( - imageUrl: model - .prescriptionReportEnhList[ - index] - .imageSRCUrl, - )); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Image.network( - model - .prescriptionReportList[index] - .imageSRCUrl, - fit: BoxFit.cover, - ), - ), - ), - ), - SizedBox( - width: 10, - ), - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - AppText( - TranslationBase.of(context) - .route, - color: Colors.grey, - ), - Expanded( - child: AppText(" " + - model - .prescriptionReportList[ - index] - .routeN)), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of(context) - .frequency, - color: Colors.grey, - ), - AppText(" " + - model - .prescriptionReportList[ - index] - .frequencyN ?? - ''), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of(context) - .dailyDoses, - color: Colors.grey, - ), - AppText(" " + - model - .prescriptionReportList[ - index] - .doseDailyQuantity ?? - ''), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of(context) - .duration, - color: Colors.grey, - ), - AppText(" " + - model - .prescriptionReportList[ - index] - .days - .toString() ?? - ''), - ], - ), - SizedBox( - height: 12, - ), - AppText(model - .prescriptionReportList[ - index] - .remarks ?? - ''), - ], - ), - ) - ], - ) - ], - ), - ), - )) - else - ...List.generate( - // TODO Elham* List.generate to list.builder - model.prescriptionReportEnhList.length, - (index) => Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white, - ), - margin: EdgeInsets.all(12), - // TODO Elham* use custom card - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 18, right: 18), - child: AppText( - model.prescriptionReportEnhList[index] - .itemDescription, - bold: true, - ), - ), - SizedBox( - height: 12, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - width: 18, - ), - Container( - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all( - width: 0.5, color: Colors.grey)), - height: 55, - width: 55, - child: InkWell( - onTap: () { - showDialog( - context: context, - builder: (ctx) => ShowImageDialog( - imageUrl: model - .prescriptionReportEnhList[ - index] - .imageSRCUrl, - )); - }, - child: Stack( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Image.network( - model - .prescriptionReportEnhList[ - index] - .imageSRCUrl, - fit: BoxFit.cover, - ), - ), - Positioned( - top: 10, - right: 10, - child: Icon( - EvaIcons.search, - color: Colors.grey, - size: 35, - )) - ], - ), - ), - ), - SizedBox( - width: 10, - ), - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - AppText( - TranslationBase.of(context).route, - color: Colors.grey, - ), - Expanded( - child: AppText(" " + - model - .prescriptionReportEnhList[ - index] - .route ?? - '')), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of(context) - .frequency, - color: Colors.grey, - ), - AppText(" " + - model - .prescriptionReportEnhList[ - index] - .frequency ?? - ''), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of(context) - .dailyDoses, - color: Colors.grey, - ), - AppText(" " + - model - .prescriptionReportEnhList[ - index] - .doseDailyQuantity - .toString() ?? - ''), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of(context) - .duration, - color: Colors.grey, - ), - AppText(" " + - model - .prescriptionReportList[ - index] - .days - .toString() ?? - ''), - ], - ), - SizedBox( - height: 12, - ), - AppText(model - .prescriptionReportEnhList[index] - .remarks ?? - ''), - ], - ), - ) - ], - ) - ], - ), + (index) => PrescriptionItemsWidget( + frequency: model.prescriptionReportEnhList[index].frequency, + itemDescription: model.prescriptionReportEnhList[index].itemDescription, + days: model.prescriptionReportEnhList[index].days, + route: model.prescriptionReportEnhList[index].route, + dailyDoses: model.prescriptionReportEnhList[index].doseDailyQuantity, + imageSRCUrl: model.prescriptionReportEnhList[index].imageSRCUrl, + remarks: model.prescriptionReportEnhList[index].remarks, + prescriptionsViewModel: model, ), - ), - ), + ) ], ), ), diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 72d45d46..30311af2 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -1,4 +1,3 @@ -import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -12,7 +11,6 @@ import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; @@ -20,7 +18,6 @@ import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - import '../../util/helpers.dart'; import '../../widgets/shared/errors/error_message.dart'; @@ -115,7 +112,6 @@ class PrescriptionsPage extends StatelessWidget { page: PrescriptionItemsPage( prescriptions: model.prescriptionsList[index], patient: patient, - patientType: patientType, arrivalType: arrivalType, ), ), diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index 4df2726e..84d92d4f 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -11,12 +11,8 @@ import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - -import '../../config/config.dart'; -import '../../widgets/shared/loader/gif_loader_dialog_utils.dart'; import '../patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; import 'ProcedureType.dart'; @@ -86,7 +82,7 @@ class _AddFavouriteProcedureState extends State { child: Padding( padding: EdgeInsets.symmetric(vertical: 50.0), child: AppText( - 'You Don\'t have favorite prescription'), + TranslationBase.of(context).youDoNotHaveFavoritePrescription,), ), ), ], @@ -98,7 +94,7 @@ class _AddFavouriteProcedureState extends State { if (widget.procedureType == ProcedureType.PRESCRIPTION) { if (groupProcedures == null) { DrAppToastMsg.showErrorToast( - 'Please Select item ', + TranslationBase.of(context).pleaseSelectItem, ); return; } diff --git a/lib/screens/procedures/entity_list_fav_procedure.dart b/lib/screens/procedures/entity_list_fav_procedure.dart index 4c8308f4..1aa73c25 100644 --- a/lib/screens/procedures/entity_list_fav_procedure.dart +++ b/lib/screens/procedures/entity_list_fav_procedure.dart @@ -1,14 +1,12 @@ import 'package:doctor_app_flutter/core/model/procedure/procedure_templateModel.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; - import '../../config/config.dart'; import '../../widgets/shared/text_fields/app_text_field_custom_serach.dart'; import 'ExpansionProcedure.dart'; @@ -95,16 +93,6 @@ class _EntityListCheckboxSearchFavProceduresWidgetState color: Colors.white), child: ListView( children: [ - // TextFields( - // hintText: 'Search Favourite templates', - // suffixIcon: EvaIcons.search, - // suffixIconColor: Color(0xff2B353E), - // onChanged: (value) { - // filterSearchResults(value); - // }, - // hasBorder: false, - // ), - AppTextFieldCustomSearch( searchController: patientFileInfoController, onChangeFun: (value) { @@ -116,7 +104,7 @@ class _EntityListCheckboxSearchFavProceduresWidgetState RegExp(ONLY_LETTERS)) ], inputType: TextInputType.text, - hintText: 'Search Favourite templates', + hintText: TranslationBase.of(context).searchFavoriteTemplate, // validationError: TranslationBase.of(context).emptyMessage // : null, ), @@ -143,7 +131,8 @@ class _EntityListCheckboxSearchFavProceduresWidgetState ) : Center( child: Container( - child: AppText("Sorry , No Match", + child: AppText( + TranslationBase.of(context).sorryNoMatch, color: AppGlobal.appRedColor), ), ) diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index d58139b3..f2382a88 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -13,13 +13,11 @@ class TranslationBase { return Localizations.of(context, TranslationBase); } - String get dashboardScreenToolbarTitle => - localizedValues['dashboardScreenToolbarTitle'][locale.languageCode]; + String get dashboardScreenToolbarTitle => localizedValues['dashboardScreenToolbarTitle'][locale.languageCode]; String get settings => localizedValues['settings'][locale.languageCode]; - String get areYouSureYouWantTo => - localizedValues['areYouSureYouWantTo'][locale.languageCode]; + String get areYouSureYouWantTo => localizedValues['areYouSureYouWantTo'][locale.languageCode]; String get language => localizedValues['language'][locale.languageCode]; @@ -37,48 +35,37 @@ class TranslationBase { String get mobileNo => localizedValues['mobileNo'][locale.languageCode]; - String get replySuccessfully => - localizedValues['replySuccessfully'][locale.languageCode]; + String get replySuccessfully => localizedValues['replySuccessfully'][locale.languageCode]; - String get messagesScreenToolbarTitle => - localizedValues['messagesScreenToolbarTitle'][locale.languageCode]; + String get messagesScreenToolbarTitle => localizedValues['messagesScreenToolbarTitle'][locale.languageCode]; String get mySchedule => localizedValues['mySchedule'][locale.languageCode]; - String get errorNoSchedule => - localizedValues['errorNoSchedule'][locale.languageCode]; + String get errorNoSchedule => localizedValues['errorNoSchedule'][locale.languageCode]; String get verify => localizedValues['verify'][locale.languageCode]; - String get referralDoctor => - localizedValues['referralDoctor'][locale.languageCode]; + String get referralDoctor => localizedValues['referralDoctor'][locale.languageCode]; - String get referringClinic => - localizedValues['referringClinic'][locale.languageCode]; + String get referringClinic => localizedValues['referringClinic'][locale.languageCode]; String get frequency => localizedValues['frequency'][locale.languageCode]; String get priority => localizedValues['priority'][locale.languageCode]; - String get maxResponseTime => - localizedValues['maxResponseTime'][locale.languageCode]; + String get maxResponseTime => localizedValues['maxResponseTime'][locale.languageCode]; - String get clinicDetailsandRemarks => - localizedValues['clinicDetailsandRemarks'][locale.languageCode]; + String get clinicDetailsandRemarks => localizedValues['clinicDetailsandRemarks'][locale.languageCode]; - String get answerSuggestions => - localizedValues['answerSuggestions'][locale.languageCode]; + String get answerSuggestions => localizedValues['answerSuggestions'][locale.languageCode]; String get outPatients => localizedValues['outPatients'][locale.languageCode]; - String get searchPatient => - localizedValues['searchPatient'][locale.languageCode]; + String get searchPatient => localizedValues['searchPatient'][locale.languageCode]; - String get searchPatientDashBoard => - localizedValues['searchPatientDashBoard'][locale.languageCode]; + String get searchPatientDashBoard => localizedValues['searchPatientDashBoard'][locale.languageCode]; - String get searchPatientName => - localizedValues['searchPatient-name'][locale.languageCode]; + String get searchPatientName => localizedValues['searchPatient-name'][locale.languageCode]; String get searchAbout => localizedValues['searchAbout'][locale.languageCode]; @@ -88,11 +75,9 @@ class TranslationBase { String get labResult => localizedValues['labResult'][locale.languageCode]; - String get todayStatistics => - localizedValues['todayStatistics'][locale.languageCode]; + String get todayStatistics => localizedValues['todayStatistics'][locale.languageCode]; - String get familyMedicine => - localizedValues['familyMedicine'][locale.languageCode]; + String get familyMedicine => localizedValues['familyMedicine'][locale.languageCode]; String get arrived => localizedValues['arrived'][locale.languageCode]; @@ -112,36 +97,27 @@ class TranslationBase { String get myInPatient => localizedValues['myInPatient'][locale.languageCode]; - String get myInPatientTitle => - localizedValues['myInPatientTitle'][locale.languageCode]; + String get myInPatientTitle => localizedValues['myInPatientTitle'][locale.languageCode]; - String get inPatientLabel => - localizedValues['inPatientLabel'][locale.languageCode]; + String get inPatientLabel => localizedValues['inPatientLabel'][locale.languageCode]; - String get inPatientAll => - localizedValues['inPatientAll'][locale.languageCode]; + String get inPatientAll => localizedValues['inPatientAll'][locale.languageCode]; String get operations => localizedValues['operations'][locale.languageCode]; - String get patientServices => - localizedValues['patientServices'][locale.languageCode]; + String get patientServices => localizedValues['patientServices'][locale.languageCode]; - String get searchMedicine => - localizedValues['searchMedicine'][locale.languageCode]; + String get searchMedicine => localizedValues['searchMedicine'][locale.languageCode]; - String get searchMedicineDashboard => - localizedValues['searchMedicineDashboard'][locale.languageCode]; + String get searchMedicineDashboard => localizedValues['searchMedicineDashboard'][locale.languageCode]; - String get myReferralPatient => - localizedValues['myReferralPatient'][locale.languageCode]; + String get myReferralPatient => localizedValues['myReferralPatient'][locale.languageCode]; - String get referPatient => - localizedValues['referPatient'][locale.languageCode]; + String get referPatient => localizedValues['referPatient'][locale.languageCode]; String get myReferral => localizedValues['myReferral'][locale.languageCode]; - String get myReferredPatient => - localizedValues['myReferredPatient'][locale.languageCode]; + String get myReferredPatient => localizedValues['myReferredPatient'][locale.languageCode]; String get referredPatient => localizedValues['referredPatient'][locale.languageCode]; @@ -150,18 +126,15 @@ class TranslationBase { String get firstName => localizedValues['firstName'][locale.languageCode]; - String get firstNameInAr => - localizedValues['firstNameInAr'][locale.languageCode]; + String get firstNameInAr => localizedValues['firstNameInAr'][locale.languageCode]; String get middleName => localizedValues['middleName'][locale.languageCode]; - String get middleNameInAr => - localizedValues['middleNameInAr'][locale.languageCode]; + String get middleNameInAr => localizedValues['middleNameInAr'][locale.languageCode]; String get lastName => localizedValues['lastName'][locale.languageCode]; - String get lastNameInAr => - localizedValues['lastNameInAr'][locale.languageCode]; + String get lastNameInAr => localizedValues['lastNameInAr'][locale.languageCode]; String get phoneNumber => localizedValues['phoneNumber'][locale.languageCode]; @@ -171,23 +144,19 @@ class TranslationBase { String get search => localizedValues['search'][locale.languageCode]; - String get onlyArrivedPatient => - localizedValues['onlyArrivedPatient'][locale.languageCode]; + String get onlyArrivedPatient => localizedValues['onlyArrivedPatient'][locale.languageCode]; - String get searchMedicineNameHere => - localizedValues['searchMedicineNameHere'][locale.languageCode]; + String get searchMedicineNameHere => localizedValues['searchMedicineNameHere'][locale.languageCode]; String get youCanFind => localizedValues['youCanFind'][locale.languageCode]; - String get medicineSearchResult => - localizedValues['medicineSearchResult'][locale.languageCode]; + String get medicineSearchResult => localizedValues['medicineSearchResult'][locale.languageCode]; String get qr => localizedValues['qr'][locale.languageCode]; String get reader => localizedValues['reader'][locale.languageCode]; - String get startScanning => - localizedValues['startScanning'][locale.languageCode]; + String get startScanning => localizedValues['startScanning'][locale.languageCode]; String get scanQrCode => localizedValues['scanQrCode'][locale.languageCode]; @@ -199,21 +168,17 @@ class TranslationBase { String get clinic => localizedValues['clinic'][locale.languageCode]; - String get clinicSelect => - localizedValues['clinicSelect'][locale.languageCode]; + String get clinicSelect => localizedValues['clinicSelect'][locale.languageCode]; - String get doctorSelect => - localizedValues['doctorSelect'][locale.languageCode]; + String get doctorSelect => localizedValues['doctorSelect'][locale.languageCode]; String get hospital => localizedValues['hospital'][locale.languageCode]; String get speciality => localizedValues['speciality'][locale.languageCode]; - String get errorMessage => - localizedValues['errorMessage'][locale.languageCode]; + String get errorMessage => localizedValues['errorMessage'][locale.languageCode]; - String get patientProfile => - localizedValues['patientProfile'][locale.languageCode]; + String get patientProfile => localizedValues['patientProfile'][locale.languageCode]; String get vitalSign => localizedValues['vitalSign'][locale.languageCode]; @@ -229,18 +194,15 @@ class TranslationBase { String get medicines => localizedValues['medicines'][locale.languageCode]; - String get prescription => - localizedValues['prescription'][locale.languageCode]; + String get prescription => localizedValues['prescription'][locale.languageCode]; - String get insuranceApprovals => - localizedValues['insuranceApprovals'][locale.languageCode]; + String get insuranceApprovals => localizedValues['insuranceApprovals'][locale.languageCode]; String get insurance => localizedValues['insurance'][locale.languageCode]; String get approvals => localizedValues['approvals'][locale.languageCode]; - String get bodyMeasurements => - localizedValues['bodyMeasurements'][locale.languageCode]; + String get bodyMeasurements => localizedValues['bodyMeasurements'][locale.languageCode]; String get temperature => localizedValues['temperature'][locale.languageCode]; @@ -248,34 +210,27 @@ class TranslationBase { String get respiration => localizedValues['respiration'][locale.languageCode]; - String get bloodPressure => - localizedValues['bloodPressure'][locale.languageCode]; + String get bloodPressure => localizedValues['bloodPressure'][locale.languageCode]; String get oxygenation => localizedValues['oxygenation'][locale.languageCode]; String get painScale => localizedValues['painScale'][locale.languageCode]; - String get errorNoVitalSign => - localizedValues['errorNoVitalSign'][locale.languageCode]; + String get errorNoVitalSign => localizedValues['errorNoVitalSign'][locale.languageCode]; String get labOrders => localizedValues['labOrders'][locale.languageCode]; - String get errorNoLabOrders => - localizedValues['errorNoLabOrders'][locale.languageCode]; + String get errorNoLabOrders => localizedValues['errorNoLabOrders'][locale.languageCode]; - String get answerThePatient => - localizedValues['answerThePatient'][locale.languageCode]; + String get answerThePatient => localizedValues['answerThePatient'][locale.languageCode]; - String get pleaseEnterAnswer => - localizedValues['pleaseEnterAnswer'][locale.languageCode]; + String get pleaseEnterAnswer => localizedValues['pleaseEnterAnswer'][locale.languageCode]; String get replay => localizedValues['replay'][locale.languageCode]; - String get progressNote => - localizedValues['progressNote'][locale.languageCode]; + String get progressNote => localizedValues['progressNote'][locale.languageCode]; - String get operationReports => - localizedValues['operationReports'][locale.languageCode]; + String get operationReports => localizedValues['operationReports'][locale.languageCode]; String get reports => localizedValues['reports'][locale.languageCode]; @@ -287,15 +242,13 @@ class TranslationBase { String get searchNote => localizedValues['searchNote'][locale.languageCode]; - String get errorNoProgressNote => - localizedValues['errorNoProgressNote'][locale.languageCode]; + String get errorNoProgressNote => localizedValues['errorNoProgressNote'][locale.languageCode]; String get invoiceNo => localizedValues['invoiceNo:'][locale.languageCode]; String get orderNo => localizedValues['orderNo'][locale.languageCode]; - String get generalResult => - localizedValues['generalResult'][locale.languageCode]; + String get generalResult => localizedValues['generalResult'][locale.languageCode]; String get description => localizedValues['description'][locale.languageCode]; @@ -305,30 +258,23 @@ class TranslationBase { String get enterId => localizedValues['enterId'][locale.languageCode]; - String get pleaseEnterYourID => - localizedValues['pleaseEnterYourID'][locale.languageCode]; + String get pleaseEnterYourID => localizedValues['pleaseEnterYourID'][locale.languageCode]; - String get enterPassword => - localizedValues['enterPassword'][locale.languageCode]; + String get enterPassword => localizedValues['enterPassword'][locale.languageCode]; - String get pleaseEnterPassword => - localizedValues['pleaseEnterPassword'][locale.languageCode]; + String get pleaseEnterPassword => localizedValues['pleaseEnterPassword'][locale.languageCode]; - String get selectYourProject => - localizedValues['selectYourProject'][locale.languageCode]; + String get selectYourProject => localizedValues['selectYourProject'][locale.languageCode]; - String get pleaseEnterYourProject => - localizedValues['pleaseEnterYourProject'][locale.languageCode]; + String get pleaseEnterYourProject => localizedValues['pleaseEnterYourProject'][locale.languageCode]; String get login => localizedValues['login'][locale.languageCode]; - String get drSulaimanAlHabib => - localizedValues['drSulaimanAlHabib'][locale.languageCode]; + String get drSulaimanAlHabib => localizedValues['drSulaimanAlHabib'][locale.languageCode]; String get welcomeTo => localizedValues['welcomeTo'][locale.languageCode]; - String get welcomeBackTo => - localizedValues['welcomeBackTo'][locale.languageCode]; + String get welcomeBackTo => localizedValues['welcomeBackTo'][locale.languageCode]; String get home => localizedValues['home'][locale.languageCode]; @@ -344,23 +290,19 @@ class TranslationBase { String get whatsAppBy => localizedValues['whatsAppBy'][locale.languageCode]; - String get pleaseChoose => - localizedValues['pleaseChoose'][locale.languageCode]; + String get pleaseChoose => localizedValues['pleaseChoose'][locale.languageCode]; String get choose => localizedValues['choose'][locale.languageCode]; - String get verification => - localizedValues['verification'][locale.languageCode]; + String get verification => localizedValues['verification'][locale.languageCode]; String get firstStep => localizedValues['firstStep'][locale.languageCode]; - String get yourAccount => - localizedValues['yourAccount!'][locale.languageCode]; + String get yourAccount => localizedValues['yourAccount!'][locale.languageCode]; String get verify1 => localizedValues['verify1'][locale.languageCode]; - String get youWillReceiveA => - localizedValues['youWillReceiveA'][locale.languageCode]; + String get youWillReceiveA => localizedValues['youWillReceiveA'][locale.languageCode]; String get loginCode => localizedValues['loginCode'][locale.languageCode]; @@ -1742,19 +1684,32 @@ class TranslationBase { String get chart => localizedValues['chart'][locale.languageCode]; - String get investigation => - localizedValues['investigation'][locale.languageCode]; + String get investigation => localizedValues['investigation'][locale.languageCode]; - String get conditionOnDischarge => - localizedValues['conditionOnDischarge'][locale.languageCode]; + String get conditionOnDischarge => localizedValues['conditionOnDischarge'][locale.languageCode]; - String get planedProcedure => - localizedValues['planedProcedure'][locale.languageCode]; + String get planedProcedure => localizedValues['planedProcedure'][locale.languageCode]; String get moreDetails => localizedValues['moreDetails'][locale.languageCode]; + String get VTE_Type => localizedValues['VTE_Type'][locale.languageCode]; + String get pharmacology => localizedValues['pharmacology'][locale.languageCode]; + String get reasonsThrombo => localizedValues['reasonsThrombo'][locale.languageCode]; + + String get youDoNotHaveFavoritePrescription => localizedValues['youDoNotHaveFavoritePrescription'][locale.languageCode]; + + String get pleaseSelectItem => localizedValues['pleaseSelectItem'][locale.languageCode]; + + String get searchFavoriteTemplate => localizedValues['searchFavoriteTemplate'][locale.languageCode]; + + String get sorryNoMatch => localizedValues['sorryNoMatch'][locale.languageCode]; + + String get thousandIsTheMAXForTheStrength => localizedValues['thousandIsTheMAXForTheStrength'][locale.languageCode]; + + String get strengthCanNotBeZero => localizedValues['strengthCanNotBeZero'][locale.languageCode]; + } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart b/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart index 355a0dc8..823b79aa 100644 --- a/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart +++ b/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart @@ -18,7 +18,7 @@ class AppTextFieldCustomSearch extends StatelessWidget { this.inputFormatters, this.searchController, this.onFieldSubmitted, - this.hintText, + this.hintText, this.height, }); final TextEditingController searchController; @@ -34,6 +34,8 @@ class AppTextFieldCustomSearch extends StatelessWidget { final TextInputType inputType; final List inputFormatters; + final double height; + @override Widget build(BuildContext context) { @@ -43,6 +45,7 @@ class AppTextFieldCustomSearch extends StatelessWidget { child: Stack( children: [ AppTextFieldCustom( + height: height??0, hintText: hintText ?? TranslationBase.of(context).searchPatientName, isTextFieldHasSuffix: true, From cdc0d2f4a9c6d6c11856d3193020a68d1a0a04de Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Thu, 10 Feb 2022 14:00:00 +0200 Subject: [PATCH 18/25] Finish prescription refactoring --- .../{ => add_drug}/add_drug_widget.dart | 16 +- .../{ => add_drug}/drug_to_drug.dart | 0 .../prescription_form_widget.dart | 11 +- .../prescription_items_in_patient.dart | 183 +++++++--------- .../prescription/prescriptions_page.dart | 59 ++---- .../user-guid/in_patient_doctor_card.dart | 196 ------------------ 6 files changed, 96 insertions(+), 369 deletions(-) rename lib/screens/prescription/add_prescription/{ => add_drug}/add_drug_widget.dart (88%) rename lib/screens/prescription/add_prescription/{ => add_drug}/drug_to_drug.dart (100%) delete mode 100644 lib/widgets/shared/user-guid/in_patient_doctor_card.dart diff --git a/lib/screens/prescription/add_prescription/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart similarity index 88% rename from lib/screens/prescription/add_prescription/add_drug_widget.dart rename to lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart index ae7b688e..7c99c603 100644 --- a/lib/screens/prescription/add_prescription/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart @@ -1,19 +1,19 @@ import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../core/enum/viewstate.dart'; -import '../../../core/model/Prescriptions/prescription_model.dart'; -import '../../../core/model/patient/patiant_info_model.dart'; -import '../../../core/model/search_drug/get_medication_response_model.dart'; -import '../../../core/viewModel/prescription_view_model.dart'; -import '../../../util/dr_app_toast_msg.dart'; -import '../../../util/helpers.dart'; -import '../../patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; import 'drug_to_drug.dart'; class AddDrugWidget extends StatefulWidget { diff --git a/lib/screens/prescription/add_prescription/drug_to_drug.dart b/lib/screens/prescription/add_prescription/add_drug/drug_to_drug.dart similarity index 100% rename from lib/screens/prescription/add_prescription/drug_to_drug.dart rename to lib/screens/prescription/add_prescription/add_drug/drug_to_drug.dart diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index 6bdf447a..d5f146c5 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -26,7 +26,7 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; import '../../../widgets/transitions/slide_up_page.dart'; -import 'add_drug_widget.dart'; +import 'add_drug/add_drug_widget.dart'; class PrescriptionFormWidget extends StatefulWidget { final PatiantInformtion patient; @@ -122,13 +122,6 @@ class _PrescriptionFormWidgetState extends State { recognizedWord = status == 'listening' ? 'Listening...' : 'Sorry....'; } - // void requestPermissions() async { - // void requestPermissions() async { - // Map statuses = await [ - // Permission.microphone, - // ].request(); - // } - void resultListener(result) { recognizedWord = result.recognizedWords; event.setValue({"searchText": recognizedWord}); @@ -514,8 +507,6 @@ class _PrescriptionFormWidgetState extends State { ), ), ); - // Navigator.pop(context); - // openDrugToDrug(model, prescriptionViewModel); } } else { setState(() { diff --git a/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart b/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart index 787f6853..843377c5 100644 --- a/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart +++ b/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart @@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -84,129 +85,89 @@ class PrescriptionItemsInPatientPage extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - AppText( - TranslationBase.of(context).direction, - color: Colors.grey, - ), - Expanded( - child: AppText(" " + - prescriptions - .directionDescription - .toString() ?? - '')), - ], + CustomRow( + label: TranslationBase.of(context).direction + ' :', + value: " " + prescriptions.directionDescription.toString() ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), - Row( - children: [ - AppText( - TranslationBase.of(context).route, - color: Colors.grey, - ), - AppText(" " + - prescriptions.routeDescription - .toString() ?? - ''), - ], + CustomRow( + label: TranslationBase.of(context).route + ' :', + value: " " + prescriptions.routeDescription ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), - Row( - children: [ - AppText( - TranslationBase.of(context).refill, - color: Colors.grey, - ), - Expanded( - child: AppText(" " + - prescriptions - .refillDescription - .toString() ?? - '')), - ], + CustomRow( + label: TranslationBase.of(context).refill + ' :', + value: " " + prescriptions.refillDescription ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), - Row( - children: [ - AppText( - TranslationBase.of(context).startDate, - color: Colors.grey, - ), - Expanded( - child: AppText( - '${AppDateUtils.getDayMonthYearDateFormatted(startOn, isArabic: projectViewModel.isArabic)}', - color: Colors.black, - fontWeight: FontWeight.w600, - fontSize: 14, - ), - ), - ], + CustomRow( + label: TranslationBase.of(context).startDate + ' :', + value: " " + AppDateUtils.getDayMonthYearDateFormatted(startOn, isArabic: projectViewModel.isArabic) ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), - Row( - children: [ - AppText( - TranslationBase.of(context).stopDate, - color: Colors.grey, - ), - Expanded( - child: AppText( - '${AppDateUtils.getDayMonthYearDateFormatted(stopOn, isArabic: projectViewModel.isArabic)}', - color: Colors.black, - fontWeight: FontWeight.w600, - fontSize: 14, - ), - ), - ], + CustomRow( + label: TranslationBase.of(context).stopDate + ' :', + value: " " + AppDateUtils.getDayMonthYearDateFormatted(stopOn, isArabic: projectViewModel.isArabic) ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), - Row( - children: [ - AppText( - 'UOM', - color: Colors.grey, - ), - AppText(" " + - prescriptions.uomDescription - .toString() ?? - ''), - ], + CustomRow( + label: 'UOM' + ' :', + value: " " + prescriptions.uomDescription.toString() ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), - Row( - children: [ - AppText( - TranslationBase.of(context).dailyDoses, - color: Colors.grey, - ), - AppText( - " " + prescriptions.dose.toString() ?? - ''), - ], + CustomRow( + label: TranslationBase.of(context).dailyDoses, + value: " " + prescriptions.dose.toString() ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), - Row( - children: [ - AppText( - TranslationBase.of(context).status, - color: Colors.grey, - ), - AppText(" " + - prescriptions.statusDescription - .toString() ?? - ''), - ], + CustomRow( + label: TranslationBase.of(context).status, + value: " " + prescriptions.statusDescription.toString() ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), - Row( - children: [ - AppText( - TranslationBase.of(context).processed, - color: Colors.grey, - ), - AppText(" " + - prescriptions.doctorName - .toString() ?? - ''), - ], + CustomRow( + label: TranslationBase.of(context).processed, + value: " " + prescriptions.doctorName.toString() ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, ), SizedBox( height: 12, ), - AppText(prescriptions.comments ?? ''), + CustomRow( + label: '', + value: prescriptions.comments ?? '', + isCopyable: false, + isExpanded: false, + valueSize: 13, + labelSize: 13, + ), ], ), ) diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 30311af2..a7877568 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -13,7 +13,6 @@ import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-prof import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; -import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/cupertino.dart'; @@ -121,17 +120,11 @@ class PrescriptionsPage extends StatelessWidget { DoctorCard( doctorName: Helpers.convertToTitleCase(model.prescriptionsList[index].doctorName), - profileUrl: model - .prescriptionsList[index].doctorImageURL, + profileUrl: model.prescriptionsList[index].doctorImageURL, branch: model.prescriptionsList[index].name, - clinic: model.prescriptionsList[index] - .clinicDescription, + clinic: model.prescriptionsList[index].clinicDescription, isPrescriptions: true, - appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( - model.prescriptionsList[index] - .appointmentDate, - ), + appointmentDate: AppDateUtils.getDateTimeFromServerFormat(model.prescriptionsList[index].appointmentDate,), ), ], ))), @@ -160,53 +153,31 @@ class PrescriptionsPage extends StatelessWidget { itemBuilder: (context, index) { //model.medicationForInPatient.length, return InkWell( + child: DoctorCard( + doctorName: Helpers.convertToTitleCase(model.medicationForInPatient[index].pHRItemDescription,), + profileUrl: model.prescriptionsList[index].doctorImageURL, + branch: model.prescriptionsList[index].name, + clinic: model.prescriptionsList[index].clinicDescription, + isPrescriptions: true, + appointmentDate: AppDateUtils.getDateTimeFromServerFormat(model.medicationForInPatient[index].prescriptionDatetime,), + ), onTap: () => Navigator.push( context, FadePage( page: PrescriptionItemsInPatientPage( prescriptionIndex: index, - prescriptions: - model.medicationForInPatient[ - index], + prescriptions: model.medicationForInPatient[index], patient: patient, patientType: patientType, arrivalType: arrivalType, - startOn: AppDateUtils - .getDateTimeFromServerFormat( - model - .medicationForInPatient[ - index] - .startDatetime, - ), - stopOn: AppDateUtils - .getDateTimeFromServerFormat( - model - .medicationForInPatient[ - index] - .stopDatetime, + startOn: AppDateUtils.getDateTimeFromServerFormat(model.medicationForInPatient[index].startDatetime,), + stopOn: AppDateUtils.getDateTimeFromServerFormat(model.medicationForInPatient[index].stopDatetime, ), ), ), ), - child: InPatientDoctorCard( - doctorName: model - .medicationForInPatient[index] - .pHRItemDescription, - profileUrl: 'sss', - branch: 'hamza', - clinic: 'basheer', - isPrescriptions: true, - appointmentDate: AppDateUtils - .getDateTimeFromServerFormat( - model.medicationForInPatient[index] - .prescriptionDatetime, - ), - createdBy: model - .medicationForInPatient[index] - .doctorName - .toString(), - )); + ); }), if (model.medicationForInPatient.length == 0) Center( diff --git a/lib/widgets/shared/user-guid/in_patient_doctor_card.dart b/lib/widgets/shared/user-guid/in_patient_doctor_card.dart deleted file mode 100644 index 9197a4a1..00000000 --- a/lib/widgets/shared/user-guid/in_patient_doctor_card.dart +++ /dev/null @@ -1,196 +0,0 @@ -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; -import 'package:doctor_app_flutter/util/date-utils.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class InPatientDoctorCard extends StatelessWidget { - final String doctorName; - final String branch; - final DateTime appointmentDate; - final String profileUrl; - final String invoiceNO; - final String orderNo; - final Function onTap; - final bool isPrescriptions; - final String clinic; - final createdBy; - - InPatientDoctorCard( - {this.doctorName, - this.branch, - this.profileUrl, - this.invoiceNO, - this.onTap, - this.appointmentDate, - this.orderNo, - this.isPrescriptions = false, - this.clinic, - this.createdBy}); - - @override - Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - return Container( - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - border: Border.all( - width: 0.5, - color: Colors.white, - ), - borderRadius: BorderRadius.all( - Radius.circular(15.0), - ), - color: Colors.white), - child: Padding( - padding: const EdgeInsets.all(15.0), - child: InkWell( - onTap: onTap, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded( - child: AppText( - doctorName, - bold: true, - )), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - AppText( - '${AppDateUtils.getDayMonthYearDateFormatted(appointmentDate, isArabic: projectViewModel.isArabic)}', - color: Colors.black, - fontWeight: FontWeight.w600, - fontSize: 14, - ), - if (!isPrescriptions) - AppText( - '${AppDateUtils.getHour(appointmentDate)}', - fontWeight: FontWeight.w600, - color: Colors.grey[700], - fontSize: 14, - ), - ], - ), - ), - ], - ), - Row( - children: [ - AppText( - 'CreatedBy ', - //bold: true, - ), - Expanded( - child: AppText( - createdBy, - bold: true, - ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - // Container( - // child: LargeAvatar( - // name: doctorName, - // url: profileUrl, - // ), - // width: 55, - // height: 55, - // ), - Expanded( - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: Container( - margin: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // if (orderNo != null && !isPrescriptions) - // Row( - // children: [ - // AppText( - // TranslationBase.of(context).orderNo + - // ": ", - // color: Colors.grey[500], - // fontSize: 14, - // ), - // AppText( - // orderNo ?? '', - // fontSize: 14, - // ) - // ], - // ), - // if (invoiceNO != null && !isPrescriptions) - // Row( - // children: [ - // AppText( - // TranslationBase.of(context) - // .invoiceNo + - // ": ", - // fontSize: 14, - // color: Colors.grey[500], - // ), - // AppText( - // invoiceNO, - // fontSize: 14, - // ) - // ], - // ), - // if (clinic != null) - // Row( - // children: [ - // AppText( - // TranslationBase.of(context).clinic + - // ": ", - // color: Colors.grey[500], - // fontSize: 14, - // ), - // AppText( - // clinic, - // fontSize: 14, - // ) - // ], - // ), - // if (branch != null) - // Row( - // children: [ - // AppText( - // TranslationBase.of(context).branch + - // ": ", - // fontSize: 14, - // color: Colors.grey[500], - // ), - // AppText( - // branch, - // fontSize: 14, - // ) - // ], - // ) - ]), - ), - ), - Icon( - EvaIcons.eye, - ) - ], - ), - ), - ], - ), - ], - ), - ), - ), - ); - } -} From 85a6f4965fe5816dd718743033daa45f62c0f9d9 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Thu, 10 Feb 2022 17:38:00 +0200 Subject: [PATCH 19/25] Fix some issues in prescription pages --- .../Prescriptions/prescription_req_model.dart | 1 - lib/core/service/patient/patient_service.dart | 2 +- lib/core/viewModel/medicine_view_model.dart | 24 +- .../viewModel/prescription_view_model.dart | 15 +- .../medicine/medicine_search_screen.dart | 36 - .../profile/UCAF/page-stepper-widget.dart | 8 - .../add_drug/add_drug_widget.dart | 1 - .../prescription_form_widget.dart | 8 +- .../update_prescription_form.dart | 991 ------------------ .../prescription_checkout_screen.dart | 7 +- .../prescription/prescription_text_filed.dart | 2 +- .../prescription_items_out_patient.dart | 11 +- .../prescription/prescriptions_page.dart | 248 +++-- 13 files changed, 171 insertions(+), 1183 deletions(-) delete mode 100644 lib/screens/prescription/add_prescription/update_prescription_form.dart diff --git a/lib/core/model/Prescriptions/prescription_req_model.dart b/lib/core/model/Prescriptions/prescription_req_model.dart index 4fc173aa..e9b05950 100644 --- a/lib/core/model/Prescriptions/prescription_req_model.dart +++ b/lib/core/model/Prescriptions/prescription_req_model.dart @@ -18,7 +18,6 @@ class PrescriptionReqModel { data['VidaAuthTokenID'] = this.vidaAuthTokenID; data['PatientMRN'] = this.patientMRN; data['AppointmentNo'] = this.appNo; - return data; } } diff --git a/lib/core/service/patient/patient_service.dart b/lib/core/service/patient/patient_service.dart index 5ec06b0f..437e5186 100644 --- a/lib/core/service/patient/patient_service.dart +++ b/lib/core/service/patient/patient_service.dart @@ -209,7 +209,7 @@ class PatientService extends BaseService { super.error = error; }, body: patient, - ); return patient; + ); } Future getOutPatientPrescriptions(patient) async { diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 7cf96a3e..6caf98a6 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -66,9 +66,6 @@ class MedicineViewModel extends BaseViewModel { _prescriptionService.itemMedicineListUnit; - - - Future getItem({int itemID, bool isLocalBusy = false}) async { if (isLocalBusy) { setState(ViewState.BusyLocal); @@ -83,15 +80,6 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } - // async { - // setState(ViewState.BusyLocal); - // await _prescriptionService.getItem(itemID: itemID); - // if (_prescriptionService.hasError) { - // error = _prescriptionService.error; - // setState(ViewState.ErrorLocal); - // } else - // setState(ViewState.Idle); - // } setTemplateListDependOnId() { procedureTemplate.forEach((element) { @@ -200,6 +188,8 @@ class MedicineViewModel extends BaseViewModel { } } else { setState(ViewState.Idle); + // TODO Elham* to investigate why we are calling that + setTemplateListDependOnId(); } } @@ -319,10 +309,7 @@ class MedicineViewModel extends BaseViewModel { if (medicationDoseTimeList.length == 0) { await getMedicationDoseTime(); } - // await model.getPatientAssessment(getAssessmentReqModel); - // GifLoaderDialogUtils.showMyDialog(context); await getPatientAssessment(getAssessmentReqModel); - // GifLoaderDialogUtils.hideDialog(context); } Future getMedicationStrength({bool isLocalBusy = false}) async { @@ -335,8 +322,11 @@ class MedicineViewModel extends BaseViewModel { .getMasterLookup(MasterKeysService.MedicationStrength); if (_prescriptionService.hasError) { error = _prescriptionService.error; - setState(ViewState.ErrorLocal); - } else + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + }} else setState(ViewState.Idle); } diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 640b6037..578ea6c8 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -41,7 +41,6 @@ class PrescriptionViewModel extends BaseViewModel { List get drugsList => _prescriptionService.doctorsList; - //List get allMedicationList => _prescriptionService.allMedicationList; List get drugToDrug => _prescriptionService.drugToDrugList; List get itemMedicineList => _prescriptionService.itemMedicineList; @@ -70,7 +69,7 @@ class PrescriptionViewModel extends BaseViewModel { List get inPatientPrescription => _prescriptionsService.prescriptionInPatientList; - Future getOutPatientPrescriptions(patient, {bool isLocalBusy = false, BuildContext context, PatiantInformtion patientInformation}) async { + Future getOutPatientPrescriptions(patient, {bool isLocalBusy = false, PatiantInformtion patientInformation}) async { if (isLocalBusy) { setState(ViewState.BusyLocal); } else { @@ -108,7 +107,6 @@ class PrescriptionViewModel extends BaseViewModel { Future getItem({int itemID}) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); setState(ViewState.BusyLocal); await _prescriptionService.getItem(itemID: itemID); if (_prescriptionService.hasError) { @@ -120,7 +118,6 @@ class PrescriptionViewModel extends BaseViewModel { Future getPrescription({int mrn, BuildContext context}) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); setState(ViewState.BusyLocal); await _prescriptionService.getPrescription(mrn: mrn); if (_prescriptionService.hasError) { @@ -133,7 +130,6 @@ class PrescriptionViewModel extends BaseViewModel { Future postPrescription( PostPrescriptionReqModel postProcedureReqModel, int mrn) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); setState(ViewState.BusyLocal); await _prescriptionService.postPrescription(postProcedureReqModel); if (_prescriptionService.hasError) { @@ -158,7 +154,6 @@ class PrescriptionViewModel extends BaseViewModel { Future updatePrescription( PostPrescriptionReqModel updatePrescriptionReqModel, int mrn) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); setState(ViewState.BusyLocal); await _prescriptionService.updatePrescription(updatePrescriptionReqModel); if (_prescriptionService.hasError) { @@ -172,7 +167,6 @@ class PrescriptionViewModel extends BaseViewModel { Future getDrugs({String drugName}) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); setState(ViewState.BusyLocal); await _prescriptionService.getDrugs(drugName: drugName); if (_prescriptionService.hasError) { @@ -296,14 +290,15 @@ class PrescriptionViewModel extends BaseViewModel { getPrescriptions(PatiantInformtion patient, {String patientType, bool isLocalBusy = true}) async { if(isLocalBusy) - setState(ViewState.BusyLocal); else setState(ViewState.Busy); + setState(ViewState.BusyLocal); + else setState(ViewState.Busy); await _prescriptionsService.getPrescriptions(patient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; if (isLocalBusy) - setState(ViewState.Error); - else setState(ViewState.ErrorLocal); + else + setState(ViewState.Error); } else { _filterList(); await _getPrescriptionsOrders(); diff --git a/lib/screens/medicine/medicine_search_screen.dart b/lib/screens/medicine/medicine_search_screen.dart index aef2ff05..3656c585 100644 --- a/lib/screens/medicine/medicine_search_screen.dart +++ b/lib/screens/medicine/medicine_search_screen.dart @@ -1,13 +1,10 @@ import 'dart:math'; - import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/medicine/pharmacies_list_screen.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; @@ -21,7 +18,6 @@ import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_field_custom_serach.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_recognition_result.dart'; import 'package:speech_to_text/speech_to_text.dart'; @@ -45,15 +41,11 @@ class _MedicineSearchState extends State { Helpers helpers = new Helpers(); bool _hasSpeech = false; String _currentLocaleId = ""; - bool _isInit = true; final SpeechToText speech = SpeechToText(); String lastStatus = ''; - GetMedicationResponseModel _selectedMedication; GlobalKey key = new GlobalKey>(); - // String lastWords; - List _localeNames = []; String lastError; double level = 0.0; double minSoundLevel = 50000; @@ -65,24 +57,13 @@ class _MedicineSearchState extends State { super.didChangeDependencies(); } - void requestPermissions() async { - Map statuses = await [ - Permission.microphone, - ].request(); - } Future initSpeechState() async { bool hasSpeech = await speech.initialize( onError: errorListener, onStatus: statusListener); - // if (hasSpeech) { - // _localeNames = await speech.locales(); - - // var systemLocale = await speech.systemLocale(); _currentLocaleId = TranslationBase.of(context).locale.languageCode == 'en' ? 'en-GB' : 'ar-SA'; // systemLocale.localeId; - // } - if (!mounted) return; setState(() { @@ -101,7 +82,6 @@ class _MedicineSearchState extends State { appBar: BottomSheetTitle( title: TranslationBase.of(context).searchMedicine, ), - //appBarTitle: TranslationBase.of(context).searchMedicine + "6", body: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -153,7 +133,6 @@ class _MedicineSearchState extends State { child: ListView.builder( padding: const EdgeInsets.only(top: 20), scrollDirection: Axis.vertical, - // shrinkWrap: true, itemCount: model.pharmacyItemsList == null ? 0 : model.pharmacyItemsList.length, @@ -208,9 +187,7 @@ class _MedicineSearchState extends State { fontWeight: FontWeight.w700, title: TranslationBase.of(context).search, onPressed: () async { - // onSubmitSearch(); await searchMedicine(context, model); - }, color: AppGlobal.appRedColor, ), @@ -232,7 +209,6 @@ class _MedicineSearchState extends State { FocusScope.of(context).unfocus(); if (myController.text.isNullOrEmpty()) { Helpers.showErrorToast(TranslationBase.of(context).typeMedicineName); - //"Type Medicine Name") return; } if (myController.text.length < 3) { @@ -247,7 +223,6 @@ class _MedicineSearchState extends State { } startVoiceSearch() { - // lastWords = ""; lastError = ""; speech.listen( onResult: resultListener, @@ -263,18 +238,15 @@ class _MedicineSearchState extends State { void resultListener(SpeechRecognitionResult result) { setState(() { - // lastWords = "${result.recognizedWords} - ${result.finalResult}"; recognizedWord = result.recognizedWords; lastStatus = ''; myController.text = recognizedWord; Future.delayed(const Duration(seconds: 2), () { - // searchMedicine(context); }); }); } void errorListener(SpeechRecognitionError error) { - // print("Received error status: $error, listening: ${speech.isListening}"); setState(() { lastError = "${error.errorMsg} - ${error.permanent}"; }); @@ -282,23 +254,15 @@ class _MedicineSearchState extends State { void statusListener(String status) { // print( - // "Received listener status: $status, listening: ${speech.isListening}"); setState(() { lastStatus = status; }); } - // _switchLang(selectedVal) { - // setState(() { - // _currentLocaleId = selectedVal; - // }); - // print(selectedVal); - // } void soundLevelListener(double level) { minSoundLevel = min(minSoundLevel, level); maxSoundLevel = max(maxSoundLevel, level); - // print("sound level $level: $minSoundLevel - $maxSoundLevel "); setState(() { this.level = level; }); diff --git a/lib/screens/patients/profile/UCAF/page-stepper-widget.dart b/lib/screens/patients/profile/UCAF/page-stepper-widget.dart index d43dafb2..4ab7f0f6 100644 --- a/lib/screens/patients/profile/UCAF/page-stepper-widget.dart +++ b/lib/screens/patients/profile/UCAF/page-stepper-widget.dart @@ -5,14 +5,6 @@ import 'package:flutter/material.dart'; import '../../../../config/config.dart'; -/// * -/// By Mousa Zaid Mousa Abuzaid -/// At 13/4/2021 - -/* - All hex value from 100% to 0% alpha: used in line 122 - https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4 - */ class PageStepperWidget extends StatelessWidget { final int stepsCount; diff --git a/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart index 7c99c603..056b2129 100644 --- a/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart @@ -54,7 +54,6 @@ class _AddDrugWidgetState extends State { width: SizeConfig.realScreenWidth, child: SingleChildScrollView( child: Column( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ DrugToDrug( widget.patient, diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index d5f146c5..e9a21030 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -220,7 +220,7 @@ class _PrescriptionFormWidgetState extends State { ? widget.medicineViewModel.itemMedicineListUnit[0] : units, elementError: unitError, - keyName: TranslationBase.of(context).description, + keyName: 'description', keyId: 'parameterCode', hintText: TranslationBase.of(context).unit, elementList: widget.medicineViewModel.itemMedicineListUnit, @@ -241,7 +241,7 @@ class _PrescriptionFormWidgetState extends State { : route, elementError: routeError, keyId: 'parameterCode', - keyName: TranslationBase.of(context).description, + keyName: 'description', okFunction: (selectedValue) { setState(() { route = selectedValue; @@ -260,7 +260,7 @@ class _PrescriptionFormWidgetState extends State { : frequency, elementList: widget.medicineViewModel.itemMedicineList, keyId: 'parameterCode', - keyName: TranslationBase.of(context).description, + keyName: 'description', okFunction: (selectedValue) { setState(() { frequency = selectedValue; @@ -507,6 +507,8 @@ class _PrescriptionFormWidgetState extends State { ), ), ); + // Navigator.pop(context); + // openDrugToDrug(model, prescriptionViewModel); } } else { setState(() { diff --git a/lib/screens/prescription/add_prescription/update_prescription_form.dart b/lib/screens/prescription/add_prescription/update_prescription_form.dart deleted file mode 100644 index 2f542e86..00000000 --- a/lib/screens/prescription/add_prescription/update_prescription_form.dart +++ /dev/null @@ -1,991 +0,0 @@ -import 'package:autocomplete_textfield/autocomplete_textfield.dart'; -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/post_prescrition_req_model.dart'; -import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/util/date-utils.dart'; -import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; -import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:hexcolor/hexcolor.dart'; - -class UpdatePrescriptionForm extends StatefulWidget { - final String drugName; - final String doseStreangth; - final int drugId; - final String remarks; - final PatiantInformtion patient; - final String duration; - final String route; - final String dose; - final String doseUnit; - final String enteredRemarks; - final String startDate; - final String frequency; - final String drugNameGeneric; - final String uom; - final int box; - - final PrescriptionViewModel model; - - UpdatePrescriptionForm( - {this.drugName, - this.doseStreangth, - this.drugId, - this.remarks, - this.patient, - this.duration, - this.route, - this.dose, - this.startDate, - this.doseUnit, - this.enteredRemarks, - this.frequency, - this.model, - this.drugNameGeneric, - this.uom, - this.box}); - - @override - _UpdatePrescriptionFormState createState() => _UpdatePrescriptionFormState(); -} - -class _UpdatePrescriptionFormState extends State { - TextEditingController strengthController = TextEditingController(); - TextEditingController remarksController = TextEditingController(); - int testNum = 0; - int strengthChar; - PatiantInformtion patient; - /// TODO Elham* add type - dynamic route; - dynamic doseTime; - dynamic frequencyUpdate; - dynamic updatedDuration; - dynamic units; - GetMedicationResponseModel newSelectedMedication; - GlobalKey key = - new GlobalKey>(); - List indicationList; - dynamic indication; - DateTime selectedDate; - - @override - void initState() { - super.initState(); - strengthController.text = widget.doseStreangth; - remarksController.text = widget.remarks; - indicationList = List(); - /// TODO Elham* create model and try to have them form service and add translation - - dynamic indication1 = {"id": 545, "name": "Gingival Hyperplasia"}; - dynamic indication2 = {"id": 546, "name": "Mild Drowsiness"}; - dynamic indication3 = {"id": 547, "name": "Hypertrichosis"}; - dynamic indication4 = {"id": 548, "name": "Mild Dizziness"}; - dynamic indication5 = {"id": 549, "name": "Enlargement of Facial Features"}; - dynamic indication6 = { - "id": 550, - "name": "Phenytoin Hypersensitivity Syndrome" - }; - dynamic indication7 = {"id": 551, "name": "Asterixis"}; - dynamic indication8 = {"id": 552, "name": "Bullous Dermatitis"}; - dynamic indication9 = {"id": 554, "name": "Purpuric Dermatitis"}; - dynamic indication10 = {"id": 555, "name": "Systemic Lupus Erythematosus"}; - - indicationList.add(indication1); - indicationList.add(indication2); - indicationList.add(indication3); - indicationList.add(indication4); - indicationList.add(indication5); - indicationList.add(indication6); - indicationList.add(indication7); - indicationList.add(indication8); - indicationList.add(indication9); - indicationList.add(indication10); - } - /// TODO Elham* Add Translation - - @override - Widget build(BuildContext context) { - final screenSize = MediaQuery.of(context).size; - return StatefulBuilder(builder: - (BuildContext context, StateSetter setState /*You can rename this!*/) { - return BaseView( - onModelReady: (model) async { - /// TODO Elham* Move this to view model and remove unused data - - await model.getMedicationList(); - await model.getMedicationStrength(); - await model.getMedicationDuration(); - await model.getMedicationRoute(); - await model.getMedicationFrequency(); - await model.getMedicationDoseTime(); - await model.getItem(itemID: widget.drugId); - //await model.getMedicationIndications(); - route = model.getLookupByIdFilter( - model.itemMedicineListRoute, widget.route); - doseTime = - model.getLookupById(model.medicationDoseTimeList, widget.dose); - updatedDuration = model.getLookupById( - model.medicationDurationList, widget.duration); - units = model.getLookupByIdFilter( - model.itemMedicineListUnit, widget.doseUnit); - frequencyUpdate = model.getLookupById( - model.medicationFrequencyList, widget.frequency); - }, - builder: - (BuildContext context, MedicineViewModel model, Widget child) => - NetworkBaseView( - baseViewModel: model, - child: GestureDetector( - onTap: () { - FocusScope.of(context).requestFocus(new FocusNode()); - }, - child: DraggableScrollableSheet( - initialChildSize: 0.98, - maxChildSize: 0.99, - minChildSize: 0.6, - builder: - (BuildContext context, ScrollController scrollController) { - return SingleChildScrollView( - child: Container( - height: MediaQuery.of(context).size.height * 1.5, - child: Form( - child: Padding( - padding: EdgeInsets.symmetric( - horizontal: 20.0, vertical: 12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - widget.drugName.toUpperCase(), - fontWeight: FontWeight.w900, - ), - SizedBox( - height: 10.0, - ), - Column( - children: [ - Container( - height: - MediaQuery.of(context).size.height * - 0.060, - width: double.infinity, - child: Row( - children: [ - Container( - width: MediaQuery.of(context) - .size - .width * - 0.4900, - height: MediaQuery.of(context) - .size - .height * - 0.55, - child: TextFields( - inputFormatters: [ - LengthLimitingTextInputFormatter( - 5), - // WhitelistingTextInputFormatter - // .digitsOnly - ], - - hintText: widget.doseStreangth, - fontSize: 15.0, - controller: strengthController, - keyboardType: TextInputType - .numberWithOptions( - decimal: true, - ), - onChanged: (String value) { - setState(() { - strengthChar = value.length; - }); - if (strengthChar >= 5) { - DrAppToastMsg.showErrorToast( - "Only 5 Digits allowed for strength"); - } - }, - ), - ), - SizedBox( - width: 10.0, - ), - Container( - width: MediaQuery.of(context) - .size - .width * - 0.3700, - child: InkWell( - onTap: - model.itemMedicineListUnit != - null - ? () { - Helpers.hideKeyboard( - context); - ListSelectDialog - dialog = - ListSelectDialog( - list: model - .itemMedicineListUnit, - attributeName: - 'description', - attributeValueId: - 'parameterCode', - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - units = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: - (BuildContext - context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - 'UNIT Type', - units != null - ? units[ - 'description'] - : null, - true), - enabled: false, - ), - ), - ), - ], - ), - ), - SizedBox( - height: 12, - ), - Container( - height: - MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.itemMedicineListRoute != - null - ? () { - Helpers.hideKeyboard(context); - ListSelectDialog dialog = - ListSelectDialog( - list: model - .itemMedicineListRoute, - attributeName: 'description', - attributeValueId: - 'parameterCode', - okText: TranslationBase.of( - context) - .ok, - okFunction: (selectedValue) { - setState(() { - route = selectedValue; - }); - if (route == null) { - route = route['id']; - } - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - 'Route', - route != null - ? route['description'] - : null, - true), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: - MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.medicationDoseTimeList != - null - ? () { - Helpers.hideKeyboard(context); - ListSelectDialog dialog = - ListSelectDialog( - list: model - .medicationDoseTimeList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: TranslationBase.of( - context) - .ok, - okFunction: (selectedValue) { - setState(() { - doseTime = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - TranslationBase.of(context) - .doseTime, - doseTime != null - ? doseTime['nameEn'] - : null, - true), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: - MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.medicationFrequencyList != - null - ? () { - Helpers.hideKeyboard(context); - ListSelectDialog dialog = - ListSelectDialog( - list: model - .medicationFrequencyList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: TranslationBase.of( - context) - .ok, - okFunction: (selectedValue) { - setState(() { - frequencyUpdate = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - TranslationBase.of(context) - .frequency, - frequencyUpdate != null - ? frequencyUpdate[ - 'nameEn'] - : null, - true), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: - MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.medicationDurationList != - null - ? () { - Helpers.hideKeyboard(context); - ListSelectDialog dialog = - ListSelectDialog( - list: model - .medicationDurationList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: TranslationBase.of( - context) - .ok, - okFunction: (selectedValue) { - setState(() { - updatedDuration = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - TranslationBase.of(context) - .duration, - updatedDuration != null - ? updatedDuration[ - 'nameEn'] - .toString() - : null, - true), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: model.patientAssessmentList - .isNotEmpty - ? screenSize.height * 0.070 - : 0.0, - width: model.patientAssessmentList - .isNotEmpty - ? double.infinity - : 0.0, - child: model.patientAssessmentList - .isNotEmpty - ? Row( - children: [ - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.29, - child: InkWell( - onTap: - indicationList != null - ? () { - Helpers.hideKeyboard( - context); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - model.patientAssessmentList - .isNotEmpty - ? model - .patientAssessmentList[ - 0] - .icdCode10ID - .toString() - : '', - indication != null - ? indication[ - 'name'] - : null, - true), - enabled: true, - readOnly: true, - ), - ), - ), - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.61, - child: InkWell( - onTap: - indicationList != null - ? () { - Helpers.hideKeyboard( - context); - } - : null, - child: TextField( - maxLines: 3, - decoration: textFieldSelectorDecoration( - model.patientAssessmentList - .isNotEmpty - ? model - .patientAssessmentList[ - 0] - .asciiDesc - .toString() - : '', - indication != null - ? indication[ - 'name'] - : null, - true), - enabled: true, - readOnly: true, - ), - ), - ), - ], - ) - : null), - SizedBox( - height: 12.0, - ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: () => - selectDate(context, widget.model), - child: TextField( - decoration: Helpers - .textFieldSelectorDecoration( - AppDateUtils.getDateFormatted( - DateTime.parse( - widget.startDate)), - selectedDate != null - ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" - : null, - true, - suffixIcon: Icon( - Icons.calendar_today, - color: Colors.black, - )), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.allMedicationList != null - ? () { - Helpers.hideKeyboard(context); - ListSelectDialog dialog = - ListSelectDialog( - list: model.allMedicationList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: TranslationBase.of( - context) - .ok, - okFunction: (selectedValue) { - setState(() { - // duration = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - "UOM", - widget.uom != null - ? widget.uom - : null, - true), - // enabled: false, - readOnly: true, - ), - ), - ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.allMedicationList != null - ? () { - Helpers.hideKeyboard(context); - ListSelectDialog dialog = - ListSelectDialog( - list: model.allMedicationList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: TranslationBase.of( - context) - .ok, - okFunction: (selectedValue) { - setState(() { - // duration = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - 'Box Quantity', - widget.box != null - ? "Box Quantity: " + - widget.box.toString() - : null, - true), - // enabled: false, - readOnly: true, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - child: TextFields( - controller: remarksController, - maxLines: 7, - minLines: 4, - ), - ), - SizedBox( - height: 10.0, - ), - SizedBox( - height: - MediaQuery.of(context).size.height * - 0.08, - ), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: 'update prescription' - .toUpperCase(), - onPressed: () { - - /// TODO Elham* Move this to function - - 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"); - return; - } - if (strengthController - .text.length > - 4) { - DrAppToastMsg.showErrorToast( - "strength can't be more then 4 digits "); - return; - } - // if(units==null&& updatedDuration==null&&frequencyUpdate==null&&) - updatePrescription( - newStartDate: selectedDate, - newDoseStreangth: - strengthController - .text.isNotEmpty - ? strengthController - .text - : widget - .doseStreangth, - newUnit: units != null - ? units['parameterCode'] - .toString() - : widget.doseUnit, - doseUnit: widget.doseUnit, - doseStreangth: - widget.doseStreangth, - duration: widget.duration, - startDate: widget.startDate, - doseId: widget.dose, - frequencyId: widget.frequency, - routeId: widget.route, - patient: widget.patient, - model: widget.model, - newDuration: - updatedDuration != null - ? updatedDuration['id'] - .toString() - : widget.duration, - drugId: widget.drugId, - remarks: remarksController - .text, - route: route != null - ? route['parameterCode'] - .toString() - : widget.route, - frequency: - frequencyUpdate != null - ? frequencyUpdate[ - 'id'] - .toString() - : widget.frequency, - dose: doseTime != null - ? doseTime['id'] - .toString() - : widget.dose, - enteredRemarks: - widget.enteredRemarks); - Navigator.pop(context); - }, - ), - ], - ), - ), - ], - ), - ], - ), - ), - )), - ); - }), - ), - ), - ); - }); - } - - selectDate(BuildContext context, PrescriptionViewModel model) async { - Helpers.hideKeyboard(context); - DateTime selectedDate; - selectedDate = DateTime.now(); - final DateTime picked = await showDatePicker( - context: context, - initialDate: selectedDate, - firstDate: DateTime.now(), - lastDate: DateTime(2040), - initialEntryMode: DatePickerEntryMode.calendar, - ); - if (picked != null && picked != selectedDate) { - setState(() { - this.selectedDate = picked; - }); - } - } - // /// TODO Elham* Use it from the textfeild utils - InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown, - {Icon suffixIcon}) { - return InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown - ? suffixIcon != null - ? suffixIcon - : Icon( - Icons.arrow_drop_down, - color: Colors.black, - ) - : null, - hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.shade600, - ), - ); - } - - /// TODO Elham* Move this to view model and pass all data as model - updatePrescription( - {PrescriptionViewModel model, - int drugId, - String newDrugId, - String frequencyId, - String remarks, - String dose, - String doseId, - String frequency, - String route, - String routeId, - String startDate, - DateTime newStartDate, - String doseUnit, - String doseStreangth, - String newDoseStreangth, - String duration, - String newDuration, - String newUnit, - String enteredRemarks, - PatiantInformtion patient}) async { - //PrescriptionViewModel model = PrescriptionViewModel(); - PostPrescriptionReqModel updatePrescriptionReqModel = - new PostPrescriptionReqModel(); - List sss = List(); - - updatePrescriptionReqModel.appointmentNo = patient.appointmentNo; - updatePrescriptionReqModel.clinicID = patient.clinicId; - updatePrescriptionReqModel.episodeID = patient.episodeNo; - updatePrescriptionReqModel.patientMRN = patient.patientMRN; - - sss.add(PrescriptionRequestModel( - covered: true, - dose: newDoseStreangth.isNotEmpty - ? double.parse(newDoseStreangth) - : double.parse(doseStreangth), - //frequency.isNotEmpty ? int.parse(dose) : 1, - itemId: drugId, - doseUnitId: - newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit), - route: route.isNotEmpty ? int.parse(route) : int.parse(routeId), - frequency: frequency.isNotEmpty - ? int.parse(frequency) - : int.parse(frequencyId), - remarks: remarks.isEmpty ? enteredRemarks : remarks, - approvalRequired: true, - icdcode10Id: "test2", - doseTime: dose.isNotEmpty ? int.parse(dose) : int.parse(doseId), - duration: newDuration.isNotEmpty - ? int.parse(newDuration) - : int.parse(duration), - doseStartDate: - newStartDate != null ? newStartDate.toIso8601String() : startDate)); - updatePrescriptionReqModel.prescriptionRequestModel = sss; - //postProcedureReqModel.procedures = controlsProcedure; - - await model.updatePrescription( - updatePrescriptionReqModel, patient.patientMRN); - - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } else if (model.state == ViewState.Idle) { - DrAppToastMsg.showSuccesToast('Medication has been updated'); - } - } -} - -void updatePrescriptionForm( - {context, - String drugName, - String drugNameGeneric, - int drugId, - String remarks, - PrescriptionViewModel model, - PatiantInformtion patient, - String rouat, - String frequency, - String dose, - String duration, - String doseStreangth, - String doseUnit, - String enteredRemarks, - String uom, - int box, - String startDate}) { - - /// TODO Elham* remove unused code. - - TextEditingController remarksController = TextEditingController(); - TextEditingController doseController = TextEditingController(); - TextEditingController frequencyController = TextEditingController(); - TextEditingController routeController = TextEditingController(); - showModalBottomSheet( - context: context, - isScrollControlled: true, - builder: (BuildContext context) { - return UpdatePrescriptionForm( - box: box, - uom: uom, - drugName: drugName, - patient: patient, - doseStreangth: doseStreangth, - remarks: remarks, - drugId: drugId, - enteredRemarks: enteredRemarks, - duration: duration, - dose: dose, - doseUnit: doseUnit, - frequency: frequency, - route: rouat, - startDate: startDate, - model: model, - drugNameGeneric: drugNameGeneric, - ); - }); -} diff --git a/lib/screens/prescription/prescription_checkout_screen.dart b/lib/screens/prescription/prescription_checkout_screen.dart index 8f2d8b9d..20f502a3 100644 --- a/lib/screens/prescription/prescription_checkout_screen.dart +++ b/lib/screens/prescription/prescription_checkout_screen.dart @@ -221,6 +221,7 @@ class _PrescriptionCheckOutScreenState final screenSize = MediaQuery.of(context).size; return BaseView( onModelReady: (model) async { + // TODO Elham* move this logic to the model model.getItem( itemID: int.parse( widget.groupProcedures.aliasN.replaceAll("item code ;", ""))); @@ -395,7 +396,7 @@ class _PrescriptionCheckOutScreenState 0.560, element: units, elementError: unitError, - keyName: TranslationBase.of(context).description, + keyName: 'description', keyId: 'parameterCode', hintText: 'Select', elementList: @@ -417,7 +418,7 @@ class _PrescriptionCheckOutScreenState element: route, elementError: routeError, keyId: 'parameterCode', - keyName: TranslationBase.of(context).description, + keyName: 'description', okFunction: (selectedValue) { setState(() { route = selectedValue; @@ -435,7 +436,7 @@ class _PrescriptionCheckOutScreenState element: frequency, elementList: model.itemMedicineList, keyId: 'parameterCode', - keyName: TranslationBase.of(context).description, + keyName: 'description', okFunction: (selectedValue) { setState(() { frequency = selectedValue; diff --git a/lib/screens/prescription/prescription_text_filed.dart b/lib/screens/prescription/prescription_text_filed.dart index 95b70182..8f2676bc 100644 --- a/lib/screens/prescription/prescription_text_filed.dart +++ b/lib/screens/prescription/prescription_text_filed.dart @@ -44,7 +44,7 @@ class _PrescriptionTextFiledState extends State { list: widget.elementList, attributeName: '${widget.keyName}', attributeValueId: widget.elementList.length == 1 - ? widget.elementList[0]['${widget.keyId}'].toString() + ? widget.elementList[0]['${widget.keyId}'] : '${widget.keyId}', okText: TranslationBase.of(context).ok, okFunction: (selectedValue) => diff --git a/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart b/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart index fa8cebc2..085d4fc3 100644 --- a/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart +++ b/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart @@ -48,9 +48,12 @@ class PrescriptionItemsPage extends StatelessWidget { child: Container( child: Column( children: [ - ...List.generate( - model.prescriptionReportList.length, - (index) => PrescriptionItemsWidget( + ListView.builder( + scrollDirection: Axis.vertical, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: model.prescriptionReportEnhList.length, + itemBuilder: (context, index) => PrescriptionItemsWidget( frequency: model.prescriptionReportEnhList[index].frequency, itemDescription: model.prescriptionReportEnhList[index].itemDescription, days: model.prescriptionReportEnhList[index].days, @@ -60,7 +63,7 @@ class PrescriptionItemsPage extends StatelessWidget { remarks: model.prescriptionReportEnhList[index].remarks, prescriptionsViewModel: model, ), - ) + ), ], ), ), diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index a7877568..cd41db0d 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -32,7 +32,8 @@ class PrescriptionsPage extends StatelessWidget { return BaseView( onModelReady: (model) async { patient.admissionNo == null - ? model.getPrescriptions(patient, patientType: patientType, isLocalBusy: false) + ? model.getPrescriptions(patient, + patientType: patientType, isLocalBusy: false) : model.getMedicationForInPatient(patient); }, builder: (_, model, w) => AppScaffold( @@ -46,96 +47,113 @@ class PrescriptionsPage extends StatelessWidget { body: patient.admissionNo == null ? FractionallySizedBox( widthFactor: 1.0, - child: ListView( - physics: BouncingScrollPhysics(), - children: [ - SizedBox( - height: 12, - ), - if (model.prescriptionsList.isNotEmpty && - patient.patientStatusType != 43) - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ServiceTitle( - title: TranslationBase.of(context).orders, - subTitle: - TranslationBase.of(context).prescriptions, - ), - ], - ), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 12, ), - if (patient.patientStatusType != null && - patient.patientStatusType == 43) - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ServiceTitle( - title: TranslationBase.of(context).orders, - subTitle: - TranslationBase.of(context).prescriptions, - ), - ], + if (model.prescriptionsList.isNotEmpty && + patient.patientStatusType != 43) + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ServiceTitle( + title: TranslationBase.of(context).orders, + subTitle: TranslationBase.of(context) + .prescriptions, + ), + ], + ), ), - ), - if ((patient.patientStatusType != null && - patient.patientStatusType == 43) || - (isFromLiveCare && patient.appointmentNo != null)) - AddNewOrder( - onTap: () { - Navigator.push( - context, - SlideUpPageRoute( - widget: BaseAddProcedureTabPage( - patient: patient, - prescriptionModel: model, - procedureType: ProcedureType.PRESCRIPTION, - ), - settingRoute: 'AddProcedureTabPage'), - ); - }, - label: TranslationBase.of(context) - .applyForNewPrescriptionsOrder, - ), - ...List.generate - ( - model.prescriptionsList.length, - (index) => InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: PrescriptionItemsPage( - prescriptions: model.prescriptionsList[index], - patient: patient, - arrivalType: arrivalType, - ), + if (patient.patientStatusType != null && + patient.patientStatusType == 43) + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ServiceTitle( + title: TranslationBase.of(context).orders, + subTitle: TranslationBase.of(context) + .prescriptions, + ), + ], + ), + ), + if ((patient.patientStatusType != null && + patient.patientStatusType == 43) || + (isFromLiveCare && patient.appointmentNo != null)) + AddNewOrder( + onTap: () { + Navigator.push( + context, + SlideUpPageRoute( + widget: BaseAddProcedureTabPage( + patient: patient, + prescriptionModel: model, + procedureType: + ProcedureType.PRESCRIPTION, ), - ), - child: Column( - children: [ - DoctorCard( - doctorName: - Helpers.convertToTitleCase(model.prescriptionsList[index].doctorName), - profileUrl: model.prescriptionsList[index].doctorImageURL, - branch: model.prescriptionsList[index].name, - clinic: model.prescriptionsList[index].clinicDescription, - isPrescriptions: true, - appointmentDate: AppDateUtils.getDateTimeFromServerFormat(model.prescriptionsList[index].appointmentDate,), - ), - ], - ))), - if (model.prescriptionsList.isEmpty && - patient.patientStatusType != 43) - Center( - child: ErrorMessage( - error: TranslationBase.of(context) - .noPrescriptionsFound, - )) - ], + settingRoute: 'AddProcedureTabPage'), + ); + }, + label: TranslationBase.of(context) + .applyForNewPrescriptionsOrder, + ), + ListView.builder( + physics: BouncingScrollPhysics(), + itemCount: model.prescriptionsList.length, + shrinkWrap: true, + itemBuilder: (BuildContext ctxt, int index) { + return InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionItemsPage( + prescriptions: model + .prescriptionsList[index], + patient: patient, + arrivalType: arrivalType, + ), + ), + ), + child: Column( + children: [ + DoctorCard( + doctorName: + Helpers.convertToTitleCase(model + .prescriptionsList[index] + .doctorName), + profileUrl: model + .prescriptionsList[index] + .doctorImageURL, + branch: model + .prescriptionsList[index].name, + clinic: model.prescriptionsList[index] + .clinicDescription, + isPrescriptions: true, + appointmentDate: AppDateUtils + .getDateTimeFromServerFormat( + model.prescriptionsList[index] + .appointmentDate, + ), + ), + ], + )); + }), + if (model.prescriptionsList.isEmpty && + patient.patientStatusType != 43) + Center( + child: ErrorMessage( + error: TranslationBase.of(context) + .noPrescriptionsFound, + )) + ], + ), ), ) : NetworkBaseView( @@ -154,29 +172,45 @@ class PrescriptionsPage extends StatelessWidget { //model.medicationForInPatient.length, return InkWell( child: DoctorCard( - doctorName: Helpers.convertToTitleCase(model.medicationForInPatient[index].pHRItemDescription,), - profileUrl: model.prescriptionsList[index].doctorImageURL, + doctorName: Helpers.convertToTitleCase( + model.medicationForInPatient[index] + .pHRItemDescription, + ), + profileUrl: model.prescriptionsList[index] + .doctorImageURL, branch: model.prescriptionsList[index].name, - clinic: model.prescriptionsList[index].clinicDescription, + clinic: model.prescriptionsList[index] + .clinicDescription, isPrescriptions: true, - appointmentDate: AppDateUtils.getDateTimeFromServerFormat(model.medicationForInPatient[index].prescriptionDatetime,), + appointmentDate: AppDateUtils + .getDateTimeFromServerFormat( + model.medicationForInPatient[index] + .prescriptionDatetime, + ), ), - onTap: () => Navigator.push( - context, - FadePage( - page: - PrescriptionItemsInPatientPage( - prescriptionIndex: index, - prescriptions: model.medicationForInPatient[index], - patient: patient, - patientType: patientType, - arrivalType: arrivalType, - startOn: AppDateUtils.getDateTimeFromServerFormat(model.medicationForInPatient[index].startDatetime,), - stopOn: AppDateUtils.getDateTimeFromServerFormat(model.medicationForInPatient[index].stopDatetime, - ), - ), - ), + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionItemsInPatientPage( + prescriptionIndex: index, + prescriptions: + model.medicationForInPatient[index], + patient: patient, + patientType: patientType, + arrivalType: arrivalType, + startOn: AppDateUtils + .getDateTimeFromServerFormat( + model.medicationForInPatient[index] + .startDatetime, + ), + stopOn: AppDateUtils + .getDateTimeFromServerFormat( + model.medicationForInPatient[index] + .stopDatetime, ), + ), + ), + ), ); }), if (model.medicationForInPatient.length == 0) From 1f770793fdcc2f89a2c4f877daad4c9b0d484ee7 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 13 Feb 2022 15:18:03 +0200 Subject: [PATCH 20/25] fix issue --- ios/Runner.xcodeproj/project.pbxproj | 4 +- .../prescription/prescriptions_page.dart | 56 ++--- .../user-guid/in_patient_doctor_card.dart | 196 ++++++++++++++++++ 3 files changed, 219 insertions(+), 37 deletions(-) create mode 100644 lib/widgets/shared/user-guid/in_patient_doctor_card.dart diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 41e65f70..3c58fe30 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -310,7 +310,7 @@ "${BUILT_PRODUCTS_DIR}/speech_to_text/speech_to_text.framework", "${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework", "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", - "${BUILT_PRODUCTS_DIR}/video_player/video_player.framework", + "${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework", "${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework", "${BUILT_PRODUCTS_DIR}/webview_flutter_wkwebview/webview_flutter_wkwebview.framework", ); @@ -352,7 +352,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/speech_to_text.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter_wkwebview.framework", ); diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index cd41db0d..cbb2b24a 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -13,6 +13,7 @@ import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-prof import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/cupertino.dart'; @@ -20,6 +21,7 @@ import 'package:flutter/material.dart'; import '../../util/helpers.dart'; import '../../widgets/shared/errors/error_message.dart'; +///TODO Elham* the design should be fixed By roaa class PrescriptionsPage extends StatelessWidget { @override Widget build(BuildContext context) { @@ -54,23 +56,6 @@ class PrescriptionsPage extends StatelessWidget { SizedBox( height: 12, ), - if (model.prescriptionsList.isNotEmpty && - patient.patientStatusType != 43) - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ServiceTitle( - title: TranslationBase.of(context).orders, - subTitle: TranslationBase.of(context) - .prescriptions, - ), - ], - ), - ), - if (patient.patientStatusType != null && - patient.patientStatusType == 43) Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -163,7 +148,13 @@ class PrescriptionsPage extends StatelessWidget { child: ListView( physics: BouncingScrollPhysics(), children: [ - ListView.builder( + + model.medicationForInPatient.length == 0? + Center( + child: ErrorMessage( + error: TranslationBase.of(context) + .noPrescriptionsFound, + )): ListView.builder( scrollDirection: Axis.vertical, physics: NeverScrollableScrollPhysics(), shrinkWrap: true, @@ -171,22 +162,23 @@ class PrescriptionsPage extends StatelessWidget { itemBuilder: (context, index) { //model.medicationForInPatient.length, return InkWell( - child: DoctorCard( - doctorName: Helpers.convertToTitleCase( - model.medicationForInPatient[index] - .pHRItemDescription, - ), - profileUrl: model.prescriptionsList[index] - .doctorImageURL, - branch: model.prescriptionsList[index].name, - clinic: model.prescriptionsList[index] - .clinicDescription, + child: InPatientDoctorCard( + doctorName: Helpers.convertToTitleCase(model + .medicationForInPatient[index] + .pHRItemDescription), + profileUrl: 'sss', + branch: 'hamza', + clinic: 'basheer', isPrescriptions: true, appointmentDate: AppDateUtils .getDateTimeFromServerFormat( model.medicationForInPatient[index] .prescriptionDatetime, ), + createdBy: Helpers.convertToTitleCase(model + .medicationForInPatient[index] + .doctorName + .toString()), ), onTap: () => Navigator.push( context, @@ -194,7 +186,7 @@ class PrescriptionsPage extends StatelessWidget { page: PrescriptionItemsInPatientPage( prescriptionIndex: index, prescriptions: - model.medicationForInPatient[index], + model.medicationForInPatient[index], patient: patient, patientType: patientType, arrivalType: arrivalType, @@ -213,12 +205,6 @@ class PrescriptionsPage extends StatelessWidget { ), ); }), - if (model.medicationForInPatient.length == 0) - Center( - child: ErrorMessage( - error: TranslationBase.of(context) - .noPrescriptionsFound, - )) ], ), ), diff --git a/lib/widgets/shared/user-guid/in_patient_doctor_card.dart b/lib/widgets/shared/user-guid/in_patient_doctor_card.dart new file mode 100644 index 00000000..9197a4a1 --- /dev/null +++ b/lib/widgets/shared/user-guid/in_patient_doctor_card.dart @@ -0,0 +1,196 @@ +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class InPatientDoctorCard extends StatelessWidget { + final String doctorName; + final String branch; + final DateTime appointmentDate; + final String profileUrl; + final String invoiceNO; + final String orderNo; + final Function onTap; + final bool isPrescriptions; + final String clinic; + final createdBy; + + InPatientDoctorCard( + {this.doctorName, + this.branch, + this.profileUrl, + this.invoiceNO, + this.onTap, + this.appointmentDate, + this.orderNo, + this.isPrescriptions = false, + this.clinic, + this.createdBy}); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Container( + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + border: Border.all( + width: 0.5, + color: Colors.white, + ), + borderRadius: BorderRadius.all( + Radius.circular(15.0), + ), + color: Colors.white), + child: Padding( + padding: const EdgeInsets.all(15.0), + child: InkWell( + onTap: onTap, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: AppText( + doctorName, + bold: true, + )), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + AppText( + '${AppDateUtils.getDayMonthYearDateFormatted(appointmentDate, isArabic: projectViewModel.isArabic)}', + color: Colors.black, + fontWeight: FontWeight.w600, + fontSize: 14, + ), + if (!isPrescriptions) + AppText( + '${AppDateUtils.getHour(appointmentDate)}', + fontWeight: FontWeight.w600, + color: Colors.grey[700], + fontSize: 14, + ), + ], + ), + ), + ], + ), + Row( + children: [ + AppText( + 'CreatedBy ', + //bold: true, + ), + Expanded( + child: AppText( + createdBy, + bold: true, + ), + ), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + // Container( + // child: LargeAvatar( + // name: doctorName, + // url: profileUrl, + // ), + // width: 55, + // height: 55, + // ), + Expanded( + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: Container( + margin: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // if (orderNo != null && !isPrescriptions) + // Row( + // children: [ + // AppText( + // TranslationBase.of(context).orderNo + + // ": ", + // color: Colors.grey[500], + // fontSize: 14, + // ), + // AppText( + // orderNo ?? '', + // fontSize: 14, + // ) + // ], + // ), + // if (invoiceNO != null && !isPrescriptions) + // Row( + // children: [ + // AppText( + // TranslationBase.of(context) + // .invoiceNo + + // ": ", + // fontSize: 14, + // color: Colors.grey[500], + // ), + // AppText( + // invoiceNO, + // fontSize: 14, + // ) + // ], + // ), + // if (clinic != null) + // Row( + // children: [ + // AppText( + // TranslationBase.of(context).clinic + + // ": ", + // color: Colors.grey[500], + // fontSize: 14, + // ), + // AppText( + // clinic, + // fontSize: 14, + // ) + // ], + // ), + // if (branch != null) + // Row( + // children: [ + // AppText( + // TranslationBase.of(context).branch + + // ": ", + // fontSize: 14, + // color: Colors.grey[500], + // ), + // AppText( + // branch, + // fontSize: 14, + // ) + // ], + // ) + ]), + ), + ), + Icon( + EvaIcons.eye, + ) + ], + ), + ), + ], + ), + ], + ), + ), + ), + ); + } +} From 9461d3d4a119150f771d5f2c308dbbf3133e6e0a Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 14 Feb 2022 11:56:50 +0200 Subject: [PATCH 21/25] add new prescription --- lib/config/config.dart | 4 +- .../Prescriptions/prescription_req_model.dart | 5 +- .../medical_report/medical_file_service.dart | 5 +- .../prescription/prescription_service.dart | 198 ++- .../prescription/prescriptions_service.dart | 238 --- .../procedure/procedure_service.dart | 14 - lib/core/viewModel/medicine_view_model.dart | 2 +- .../prescription_view_model.dart | 202 +-- .../viewModel/prescriptions_view_model.dart | 163 -- lib/locator.dart | 6 +- lib/routes.dart | 3 + .../profile_gird_for_InPatient.dart | 7 + .../profile_gird_for_other.dart | 6 + .../profile_gird_for_search.dart | 6 + .../add_drug/add_drug_widget.dart | 2 +- .../add_drug/drug_to_drug.dart | 2 +- .../add_prescription/add_prescription.dart | 2 +- .../prescription_form_widget.dart | 2 +- .../search_preescription_widget.dart | 2 +- .../prescription/new_prescriptions_page.dart | 213 +++ .../prescription_checkout_screen.dart | 2 +- .../preacription_items_widget.dart | 26 +- .../prescription_items_in_patient.dart | 2 +- .../prescription_items_out_patient.dart | 6 +- .../prescription/prescriptions_page.dart | 2 +- .../procedures/add-favourite-procedure.dart | 2 +- .../base_add_procedure_tab_page.dart | 2 +- ...rofile_medical_info_widget_in_patient.dart | 9 + pubspec.lock | 1424 +++++++++++++++++ 29 files changed, 1938 insertions(+), 619 deletions(-) delete mode 100644 lib/core/service/patient_medical_file/prescription/prescriptions_service.dart rename lib/core/viewModel/{ => prescription}/prescription_view_model.dart (55%) delete mode 100644 lib/core/viewModel/prescriptions_view_model.dart create mode 100644 lib/screens/prescription/new_prescriptions_page.dart create mode 100644 pubspec.lock diff --git a/lib/config/config.dart b/lib/config/config.dart index 11c6dfbc..4d7f3828 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; +// const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = diff --git a/lib/core/model/Prescriptions/prescription_req_model.dart b/lib/core/model/Prescriptions/prescription_req_model.dart index e9b05950..ec69ca33 100644 --- a/lib/core/model/Prescriptions/prescription_req_model.dart +++ b/lib/core/model/Prescriptions/prescription_req_model.dart @@ -1,13 +1,11 @@ class PrescriptionReqModel { - String vidaAuthTokenID; dynamic patientMRN; dynamic appNo; PrescriptionReqModel( - {this.vidaAuthTokenID, this.patientMRN, this.appNo}); + { this.patientMRN, this.appNo}); PrescriptionReqModel.fromJson(Map json) { - vidaAuthTokenID = json['VidaAuthTokenID']; patientMRN = json['PatientMRN']; appNo = json['AppointmentNo']; @@ -15,7 +13,6 @@ class PrescriptionReqModel { Map toJson() { final Map data = new Map(); - data['VidaAuthTokenID'] = this.vidaAuthTokenID; data['PatientMRN'] = this.patientMRN; data['AppointmentNo'] = this.appNo; return data; diff --git a/lib/core/service/patient_medical_file/medical_report/medical_file_service.dart b/lib/core/service/patient_medical_file/medical_report/medical_file_service.dart index 8a85fa4f..19eda72e 100644 --- a/lib/core/service/patient_medical_file/medical_report/medical_file_service.dart +++ b/lib/core/service/patient_medical_file/medical_report/medical_file_service.dart @@ -9,10 +9,7 @@ class MedicalFileService extends BaseService { List get medicalFileList => _medicalFileList; MedicalFileRequestModel _fileRequestModel = MedicalFileRequestModel( - //patientMRN: 1231755, - vidaAuthTokenID: - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiNDM1MGNjZTYtYzc3MS00YjBiLThiNDItMGZhY2IzYzgxMjQ4IiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1OTYwNTQiLCJDbGluaWNJZCI6IjEiLCJyb2xlIjpbIkRPQ1RPUlMiLCJIRUFEIERPQ1RPUlMiLCJBRE1JTklTVFJBVE9SUyIsIlJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiRVIgUkVDRVBUSU9OSVNUIiwiUEhBUk1BQ1kgQUNDT1VOVCBTVEFGRiIsIlBIQVJNQUNZIE5VUlNFIiwiSU5QQVRJRU5UIFBIQVJNQUNJU1QiLCJBRE1JU1NJT04gU1RBRkYiLCJBUFBST1ZBTCBTVEFGRiIsIkNPTlNFTlQgIiwiTUVESUNBTCBSRVBPUlQgLSBTSUNLIExFQVZFIE1BTkFHRVIiXSwibmJmIjoxNjA5MjI1MjMwLCJleHAiOjE2MTAwODkyMzAsImlhdCI6MTYwOTIyNTIzMH0.rs7lTBQ1ON4PbR11PBkOyjf818DdeMKuqz2IrCJMYQU", - ); + ); Future getMedicalFile({int mrn}) async { _fileRequestModel = MedicalFileRequestModel(patientMRN: mrn); diff --git a/lib/core/service/patient_medical_file/prescription/prescription_service.dart b/lib/core/service/patient_medical_file/prescription/prescription_service.dart index 1d310c6c..d2ad393e 100644 --- a/lib/core/service/patient_medical_file/prescription/prescription_service.dart +++ b/lib/core/service/patient_medical_file/prescription/prescription_service.dart @@ -1,7 +1,18 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_request_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/post_prescrition_req_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_in_patient.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report_enh.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_req_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescriptions_order.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/request_get_list_pharmacy_for_prescriptions.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/request_prescription_report.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/request_prescription_report_enh.dart'; import 'package:doctor_app_flutter/core/model/calculate_box_request_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/item_by_medicine_request_model.dart'; @@ -14,6 +25,7 @@ import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/patient/vital_sign/patient-vital-sign-data.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:flutter/cupertino.dart'; class PrescriptionService extends LookupService { List _prescriptionList = List(); @@ -37,7 +49,6 @@ class PrescriptionService extends LookupService { ItemByMedicineRequestModel _itemByMedicineRequestModel = ItemByMedicineRequestModel(); SearchDrugRequestModel _drugRequestModel = SearchDrugRequestModel( - //search: ["Acetaminophen"], search: ["Amoxicillin"], ); @@ -81,9 +92,10 @@ class PrescriptionService extends LookupService { }, body: getAssessmentReqModel.toJson()); } - Future getPrescription({int mrn}) async { + Future getPrescriptionListNew({int mrn, int appNo }) async { _prescriptionReqModel = PrescriptionReqModel( patientMRN: mrn, + appNo:appNo ); hasError = false; _prescriptionList.clear(); @@ -236,4 +248,186 @@ class PrescriptionService extends LookupService { }); return lstAssessmentsObj; } + + + + List prescriptionsList = List(); + List medicationForInPatient = List(); + List prescriptionsOrderList = List(); + List prescriptionInPatientList = List(); + + GetMedicationForInPatientRequestModel _getMedicationForInPatientRequestModel = + GetMedicationForInPatientRequestModel(); + + Future getPrescriptions(PatiantInformtion patient) async { + hasError = false; + Map body = Map(); + body['isDentalAllowedBackend'] = false; + await baseAppClient.postPatient(PRESCRIPTIONS, patient: patient, + onSuccess: (dynamic response, int statusCode) { + prescriptionsList.clear(); + response['PatientPrescriptionList'].forEach((prescriptions) { + prescriptionsList.add(Prescriptions.fromJson(prescriptions)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + + RequestPrescriptionReport _requestPrescriptionReport = + RequestPrescriptionReport( + appointmentNo: 0, isDentalAllowedBackend: false); + List prescriptionReportList = List(); + + Future getPrescriptionReport( + {Prescriptions prescriptions, + @required PatiantInformtion patient}) async { + hasError = false; + _requestPrescriptionReport.dischargeNo = prescriptions.dischargeNo; + _requestPrescriptionReport.projectID = prescriptions.projectID; + _requestPrescriptionReport.clinicID = prescriptions.clinicID; + _requestPrescriptionReport.setupID = prescriptions.setupID; + _requestPrescriptionReport.episodeID = prescriptions.episodeID; + _requestPrescriptionReport.appointmentNo = prescriptions.appointmentNo; + + await baseAppClient.postPatient( + prescriptions.isInOutPatient + ? GET_PRESCRIPTION_REPORT_ENH + : GET_PRESCRIPTION_REPORT_NEW, + patient: patient, onSuccess: (dynamic response, int statusCode) { + prescriptionReportList.clear(); + prescriptionReportEnhList.clear(); + if (prescriptions.isInOutPatient) { + response['ListPRM'].forEach((prescriptions) { + prescriptionReportList + .add(PrescriptionReport.fromJson(prescriptions)); + prescriptionReportEnhList + .add(PrescriptionReportEnh.fromJson(prescriptions)); + }); + } else { + response['INP_GetPrescriptionReport_List'].forEach((prescriptions) { + prescriptionReportList + .add(PrescriptionReport.fromJson(prescriptions)); + }); + } + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _requestPrescriptionReport.toJson()); + } + + RequestGetListPharmacyForPrescriptions + requestGetListPharmacyForPrescriptions = + RequestGetListPharmacyForPrescriptions( + latitude: 0, + longitude: 0, + isDentalAllowedBackend: false, + ); + List pharmacyPrescriptionsList = List(); + + + RequestPrescriptionReportEnh _requestPrescriptionReportEnh = + RequestPrescriptionReportEnh( + isDentalAllowedBackend: false, + ); + + List prescriptionReportEnhList = List(); + + Future getPrescriptionReportEnh( + {PrescriptionsOrder prescriptionsOrder, + @required PatiantInformtion patient}) async { + ///This logic copy from the old app from class [order-history.component.ts] in line 45 + bool isInPatient = false; + prescriptionsList.forEach((element) { + if (prescriptionsOrder.appointmentNo == "0") { + if (element.dischargeNo == int.parse(prescriptionsOrder.dischargeID)) { + _requestPrescriptionReportEnh.appointmentNo = element.appointmentNo; + _requestPrescriptionReportEnh.clinicID = element.clinicID; + _requestPrescriptionReportEnh.projectID = element.projectID; + _requestPrescriptionReportEnh.episodeID = element.episodeID; + _requestPrescriptionReportEnh.setupID = element.setupID; + _requestPrescriptionReportEnh.dischargeNo = element.dischargeNo; + isInPatient = element.isInOutPatient; + } + } else { + if (int.parse(prescriptionsOrder.appointmentNo) == + element.appointmentNo) { + _requestPrescriptionReportEnh.appointmentNo = element.appointmentNo; + _requestPrescriptionReportEnh.clinicID = element.clinicID; + _requestPrescriptionReportEnh.projectID = element.projectID; + _requestPrescriptionReportEnh.episodeID = element.episodeID; + _requestPrescriptionReportEnh.setupID = element.setupID; + _requestPrescriptionReportEnh.dischargeNo = element.dischargeNo; + isInPatient = element.isInOutPatient; + + ///call inpGetPrescriptionReport + } + } + }); + + hasError = false; + + await baseAppClient.postPatient( + isInPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT_NEW, + patient: patient, onSuccess: (dynamic response, int statusCode) { + prescriptionReportEnhList.clear(); + + if (isInPatient) { + response['ListPRM'].forEach((prescriptions) { + prescriptionReportEnhList + .add(PrescriptionReportEnh.fromJson(prescriptions)); + }); + } else { + response['INP_GetPrescriptionReport_List'].forEach((prescriptions) { + PrescriptionReportEnh reportEnh = + PrescriptionReportEnh.fromJson(prescriptions); + reportEnh.itemDescription = prescriptions['ItemDescriptionN']; + prescriptionReportEnhList.add(reportEnh); + }); + } + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _requestPrescriptionReportEnh.toJson()); + } + + Future getPrescriptionsOrders() async { + Map body = Map(); + body['isDentalAllowedBackend'] = false; + await baseAppClient.post(GET_PRESCRIPTIONS_ALL_ORDERS, + onSuccess: (dynamic response, int statusCode) { + prescriptionsOrderList.clear(); + response['PatientER_GetPatientAllPresOrdersList'] + .forEach((prescriptionsOrder) { + prescriptionsOrderList + .add(PrescriptionsOrder.fromJson(prescriptionsOrder)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + + Future getMedicationForInPatient(PatiantInformtion patient) async { + hasError = false; + _getMedicationForInPatientRequestModel = + GetMedicationForInPatientRequestModel( + isDentalAllowedBackend: false, + admissionNo: int.parse(patient.admissionNo), + tokenID: "@dm!n", + projectID: patient.projectId, + ); + await baseAppClient.postPatient(GET_MEDICATION_FOR_IN_PATIENT, + patient: patient, onSuccess: (dynamic response, int statusCode) { + medicationForInPatient.clear(); + response['List_GetMedicationForInpatient'].forEach((prescriptions) { + medicationForInPatient + .add(GetMedicationForInPatientModel.fromJson(prescriptions)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _getMedicationForInPatientRequestModel.toJson()); + } } diff --git a/lib/core/service/patient_medical_file/prescription/prescriptions_service.dart b/lib/core/service/patient_medical_file/prescription/prescriptions_service.dart deleted file mode 100644 index a6a3eb41..00000000 --- a/lib/core/service/patient_medical_file/prescription/prescriptions_service.dart +++ /dev/null @@ -1,238 +0,0 @@ -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_request_model.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/in_patient_prescription_model.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_in_patient.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report_enh.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/prescriptions_order.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/request_get_list_pharmacy_for_prescriptions.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/request_prescription_report.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/request_prescription_report_enh.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:flutter/cupertino.dart'; - -import '../../base/base_service.dart'; - -class PrescriptionsService extends BaseService { - List prescriptionsList = List(); - List medicationForInPatient = List(); - List prescriptionsOrderList = List(); - List prescriptionInPatientList = List(); - - InPatientPrescriptionRequestModel _inPatientPrescriptionRequestModel = - InPatientPrescriptionRequestModel(); - GetMedicationForInPatientRequestModel _getMedicationForInPatientRequestModel = - GetMedicationForInPatientRequestModel(); - - Future getPrescriptionInPatient({int mrn, String adn}) async { - _inPatientPrescriptionRequestModel = InPatientPrescriptionRequestModel( - patientMRN: mrn, - admissionNo: adn, - ); - hasError = false; - prescriptionInPatientList.clear(); - - await baseAppClient.post(GET_PRESCRIPTION_IN_PATIENT, - onSuccess: (dynamic response, int statusCode) { - prescriptionsList.clear(); - response['List_PrescriptionReportForInPatient'].forEach((prescriptions) { - prescriptionInPatientList - .add(PrescriotionInPatient.fromJson(prescriptions)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: _inPatientPrescriptionRequestModel.toJson()); - } - - Future getPrescriptions(PatiantInformtion patient) async { - hasError = false; - Map body = Map(); - body['isDentalAllowedBackend'] = false; - await baseAppClient.postPatient(PRESCRIPTIONS, patient: patient, - onSuccess: (dynamic response, int statusCode) { - prescriptionsList.clear(); - response['PatientPrescriptionList'].forEach((prescriptions) { - prescriptionsList.add(Prescriptions.fromJson(prescriptions)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); - } - - RequestPrescriptionReport _requestPrescriptionReport = - RequestPrescriptionReport( - appointmentNo: 0, isDentalAllowedBackend: false); - List prescriptionReportList = List(); - - Future getPrescriptionReport( - {Prescriptions prescriptions, - @required PatiantInformtion patient}) async { - hasError = false; - _requestPrescriptionReport.dischargeNo = prescriptions.dischargeNo; - _requestPrescriptionReport.projectID = prescriptions.projectID; - _requestPrescriptionReport.clinicID = prescriptions.clinicID; - _requestPrescriptionReport.setupID = prescriptions.setupID; - _requestPrescriptionReport.episodeID = prescriptions.episodeID; - _requestPrescriptionReport.appointmentNo = prescriptions.appointmentNo; - - await baseAppClient.postPatient( - prescriptions.isInOutPatient - ? GET_PRESCRIPTION_REPORT_ENH - : GET_PRESCRIPTION_REPORT_NEW, - patient: patient, onSuccess: (dynamic response, int statusCode) { - prescriptionReportList.clear(); - prescriptionReportEnhList.clear(); - if (prescriptions.isInOutPatient) { - response['ListPRM'].forEach((prescriptions) { - prescriptionReportList - .add(PrescriptionReport.fromJson(prescriptions)); - prescriptionReportEnhList - .add(PrescriptionReportEnh.fromJson(prescriptions)); - }); - } else { - response['INP_GetPrescriptionReport_List'].forEach((prescriptions) { - prescriptionReportList - .add(PrescriptionReport.fromJson(prescriptions)); - }); - } - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: _requestPrescriptionReport.toJson()); - } - - RequestGetListPharmacyForPrescriptions - requestGetListPharmacyForPrescriptions = - RequestGetListPharmacyForPrescriptions( - latitude: 0, - longitude: 0, - isDentalAllowedBackend: false, - ); - List pharmacyPrescriptionsList = List(); - - Future getListPharmacyForPrescriptions( - {int itemId, @required PatiantInformtion patient}) async { - hasError = false; - requestGetListPharmacyForPrescriptions.itemID = itemId; - await baseAppClient.postPatient(GET_PHARMACY_LIST, patient: patient, - onSuccess: (dynamic response, int statusCode) { - pharmacyPrescriptionsList.clear(); - response['PharmList'].forEach((prescriptions) { - pharmacyPrescriptionsList - .add(PharmacyPrescriptions.fromJson(prescriptions)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: requestGetListPharmacyForPrescriptions.toJson()); - } - - RequestPrescriptionReportEnh _requestPrescriptionReportEnh = - RequestPrescriptionReportEnh( - isDentalAllowedBackend: false, - ); - - List prescriptionReportEnhList = List(); - - Future getPrescriptionReportEnh( - {PrescriptionsOrder prescriptionsOrder, - @required PatiantInformtion patient}) async { - ///This logic copy from the old app from class [order-history.component.ts] in line 45 - bool isInPatient = false; - prescriptionsList.forEach((element) { - if (prescriptionsOrder.appointmentNo == "0") { - if (element.dischargeNo == int.parse(prescriptionsOrder.dischargeID)) { - _requestPrescriptionReportEnh.appointmentNo = element.appointmentNo; - _requestPrescriptionReportEnh.clinicID = element.clinicID; - _requestPrescriptionReportEnh.projectID = element.projectID; - _requestPrescriptionReportEnh.episodeID = element.episodeID; - _requestPrescriptionReportEnh.setupID = element.setupID; - _requestPrescriptionReportEnh.dischargeNo = element.dischargeNo; - isInPatient = element.isInOutPatient; - } - } else { - if (int.parse(prescriptionsOrder.appointmentNo) == - element.appointmentNo) { - _requestPrescriptionReportEnh.appointmentNo = element.appointmentNo; - _requestPrescriptionReportEnh.clinicID = element.clinicID; - _requestPrescriptionReportEnh.projectID = element.projectID; - _requestPrescriptionReportEnh.episodeID = element.episodeID; - _requestPrescriptionReportEnh.setupID = element.setupID; - _requestPrescriptionReportEnh.dischargeNo = element.dischargeNo; - isInPatient = element.isInOutPatient; - - ///call inpGetPrescriptionReport - } - } - }); - - hasError = false; - - await baseAppClient.postPatient( - isInPatient ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT_NEW, - patient: patient, onSuccess: (dynamic response, int statusCode) { - prescriptionReportEnhList.clear(); - - if (isInPatient) { - response['ListPRM'].forEach((prescriptions) { - prescriptionReportEnhList - .add(PrescriptionReportEnh.fromJson(prescriptions)); - }); - } else { - response['INP_GetPrescriptionReport_List'].forEach((prescriptions) { - PrescriptionReportEnh reportEnh = - PrescriptionReportEnh.fromJson(prescriptions); - reportEnh.itemDescription = prescriptions['ItemDescriptionN']; - prescriptionReportEnhList.add(reportEnh); - }); - } - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: _requestPrescriptionReportEnh.toJson()); - } - - Future getPrescriptionsOrders() async { - Map body = Map(); - body['isDentalAllowedBackend'] = false; - await baseAppClient.post(GET_PRESCRIPTIONS_ALL_ORDERS, - onSuccess: (dynamic response, int statusCode) { - prescriptionsOrderList.clear(); - response['PatientER_GetPatientAllPresOrdersList'] - .forEach((prescriptionsOrder) { - prescriptionsOrderList - .add(PrescriptionsOrder.fromJson(prescriptionsOrder)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); - } - - Future getMedicationForInPatient(PatiantInformtion patient) async { - hasError = false; - _getMedicationForInPatientRequestModel = - GetMedicationForInPatientRequestModel( - isDentalAllowedBackend: false, - admissionNo: int.parse(patient.admissionNo), - tokenID: "@dm!n", - projectID: patient.projectId, - ); - await baseAppClient.postPatient(GET_MEDICATION_FOR_IN_PATIENT, - patient: patient, onSuccess: (dynamic response, int statusCode) { - medicationForInPatient.clear(); - response['List_GetMedicationForInpatient'].forEach((prescriptions) { - medicationForInPatient - .add(GetMedicationForInPatientModel.fromJson(prescriptions)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: _getMedicationForInPatientRequestModel.toJson()); - } -} diff --git a/lib/core/service/patient_medical_file/procedure/procedure_service.dart b/lib/core/service/patient_medical_file/procedure/procedure_service.dart index c207d459..8370e968 100644 --- a/lib/core/service/patient_medical_file/procedure/procedure_service.dart +++ b/lib/core/service/patient_medical_file/procedure/procedure_service.dart @@ -43,15 +43,6 @@ class ProcedureService extends BaseService { ProcedureTempleteDetailsRequestModel(); GetProcedureReqModel _getProcedureReqModel = GetProcedureReqModel( - // clinicId: 17, - // pageSize: 10, - // pageIndex: 1, - // //patientMRN: 3120725, - // //categoryId: null, - // vidaAuthTokenID: - // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiZjQ4YTk0OTQtYTczZS00MDI3LWI2MjgtNzc4MjAwMzUyYWEzIiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODUyMTAiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODM2NDU2OCwiZXhwIjoxNjA5MjI4NTY4LCJpYXQiOjE2MDgzNjQ1Njh9.YLbvq5nxPn8o9ZYkcbc5YAX7Jy23Mm0s33oRmE8GHDI", - // - // search: ["lab"], ); GetProcedureReqModel _getProcedureCategoriseReqModel = GetProcedureReqModel( @@ -59,11 +50,6 @@ class ProcedureService extends BaseService { pageSize: 100, pageIndex: 1, patientMRN: 0, - //categoryId: null, - vidaAuthTokenID: - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiZjQ4YTk0OTQtYTczZS00MDI3LWI2MjgtNzc4MjAwMzUyYWEzIiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODUyMTAiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODM2NDU2OCwiZXhwIjoxNjA5MjI4NTY4LCJpYXQiOjE2MDgzNjQ1Njh9.YLbvq5nxPn8o9ZYkcbc5YAX7Jy23Mm0s33oRmE8GHDI", - - //search: ["DENTAL"], ); Future getProcedureTemplate( diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 6caf98a6..25916661 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -8,7 +8,7 @@ import 'package:doctor_app_flutter/core/service/patient_medical_file/prescriptio import 'package:doctor_app_flutter/core/service/patient_medical_file/procedure/procedure_service.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_container.dart'; import 'package:flutter/cupertino.dart'; import '../../locator.dart'; diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription/prescription_view_model.dart similarity index 55% rename from lib/core/viewModel/prescription_view_model.dart rename to lib/core/viewModel/prescription/prescription_view_model.dart index 578ea6c8..5fc44a77 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription/prescription_view_model.dart @@ -4,106 +4,51 @@ import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/post_prescrition_req_model.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_in_patient.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report_enh.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescriptions_order.dart'; -import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; -import 'package:doctor_app_flutter/core/service/patient_medical_file/prescription/prescription_service.dart'; -import 'package:doctor_app_flutter/core/service/patient_medical_file/prescription/prescriptions_service.dart'; -import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; -import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAllergiesResModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/patient/vital_sign/patient-vital-sign-data.dart'; +import 'package:doctor_app_flutter/core/service/patient_medical_file/prescription/prescription_service.dart'; +import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; +import 'package:doctor_app_flutter/locator.dart'; import 'package:flutter/cupertino.dart'; -import '../../widgets/shared/loader/gif_loader_dialog_utils.dart'; -import '../service/patient/patient_service.dart'; - class PrescriptionViewModel extends BaseViewModel { FilterType filterType = FilterType.Clinic; bool hasError = false; - PatientService _patientService = locator(); PrescriptionService _prescriptionService = locator(); - List get allMedicationList => - _prescriptionService.allMedicationList; List get medicationForInPatient => - _prescriptionsService.medicationForInPatient; + _prescriptionService.medicationForInPatient; List get prescriptionList => _prescriptionService.prescriptionList; - List get drugsList => _prescriptionService.doctorsList; - - List get drugToDrug => _prescriptionService.drugToDrugList; - - List get itemMedicineList => _prescriptionService.itemMedicineList; - PrescriptionsService _prescriptionsService = locator(); - - List _prescriptionsOrderListClinic = List(); - List _prescriptionsOrderListHospital = List(); - List get prescriptionReportList => - _prescriptionsService.prescriptionReportList; - - List get prescriptionsList => - _prescriptionsService.prescriptionsList; + _prescriptionService.prescriptionReportList; List get pharmacyPrescriptionsList => - _prescriptionsService.pharmacyPrescriptionsList; + _prescriptionService.pharmacyPrescriptionsList; List get prescriptionReportEnhList => - _prescriptionsService.prescriptionReportEnhList; - - List get prescriptionsOrderList => - filterType == FilterType.Clinic - ? _prescriptionsOrderListClinic - : _prescriptionsOrderListHospital; - - List get inPatientPrescription => - _prescriptionsService.prescriptionInPatientList; + _prescriptionService.prescriptionReportEnhList; - Future getOutPatientPrescriptions(patient, {bool isLocalBusy = false, PatiantInformtion patientInformation}) async { - if (isLocalBusy) { - setState(ViewState.BusyLocal); - } else { - setState(ViewState.Busy); - } - await _patientService.getOutPatientPrescriptions(patient); - if (_patientService.hasError) { - error = _patientService.error; - if (isLocalBusy) { - setState(ViewState.ErrorLocal); - } else { - setState(ViewState.Error); - } - } else - setState(ViewState.Idle); - } + List get drugToDrug => _prescriptionService.drugToDrugList; + + List _prescriptionsOrderListClinic = List(); + List _prescriptionsOrderListHospital = List(); - getPrescriptionsInPatient(PatiantInformtion patient) async { - setState(ViewState.Busy); - error = ""; - await _prescriptionsService.getPrescriptionInPatient( - mrn: patient.patientId, adn: patient.admissionNo); - if (_prescriptionsService.hasError) { - error = "No Prescription Found"; - setState(ViewState.Error); - } else { - _filterList(); - await _getPrescriptionsOrders(); - setState(ViewState.Idle); - } - } + List get prescriptionsList => + _prescriptionService.prescriptionsList; Future getItem({int itemID}) async { hasError = false; @@ -116,10 +61,11 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPrescription({int mrn, BuildContext context}) async { + Future getPrescriptionListNew({int mrn,int appNo, bool isLocalBusy = false}) async { hasError = false; - setState(ViewState.BusyLocal); - await _prescriptionService.getPrescription(mrn: mrn); + if(isLocalBusy) + setState(ViewState.BusyLocal); else setState(ViewState.Busy); + await _prescriptionService.getPrescriptionListNew(mrn: mrn, appNo:appNo ); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.ErrorLocal); @@ -136,45 +82,11 @@ class PrescriptionViewModel extends BaseViewModel { error = _prescriptionService.error; setState(ViewState.ErrorLocal); } else { - await getPrescription(mrn: mrn); + await getPrescriptionListNew(mrn: mrn); setState(ViewState.Idle); } } - Future getMedicationList({String drug}) async { - setState(ViewState.BusyLocal); - await _prescriptionService.getMedicationList(drug: drug); - if (_prescriptionService.hasError) { - error = _prescriptionService.error; - setState(ViewState.Error); - } else - setState(ViewState.Idle); - } - - Future updatePrescription( - PostPrescriptionReqModel updatePrescriptionReqModel, int mrn) async { - hasError = false; - setState(ViewState.BusyLocal); - await _prescriptionService.updatePrescription(updatePrescriptionReqModel); - if (_prescriptionService.hasError) { - error = _prescriptionService.error; - setState(ViewState.ErrorLocal); - } else { - await getPrescription(mrn: mrn); - setState(ViewState.Idle); - } - } - - Future getDrugs({String drugName}) async { - hasError = false; - setState(ViewState.BusyLocal); - await _prescriptionService.getDrugs(drugName: drugName); - if (_prescriptionService.hasError) { - error = _prescriptionService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); - } Future getDrugToDrug( VitalSignData vital, @@ -193,40 +105,9 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } - setFilterType(FilterType filterType) { - this.filterType = filterType; - notifyListeners(); - } - - getPrescriptionReport( - {Prescriptions prescriptions, - @required PatiantInformtion patient}) async { - setState(ViewState.BusyLocal); - await _prescriptionsService.getPrescriptionReport( - prescriptions: prescriptions, patient: patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.ErrorLocal); - } else { - setState(ViewState.Idle); - } - } - - getListPharmacyForPrescriptions( - {int itemId, @required PatiantInformtion patient}) async { - setState(ViewState.BusyLocal); - await _prescriptionsService.getListPharmacyForPrescriptions( - itemId: itemId, patient: patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - } - } void _filterList() { - _prescriptionsService.prescriptionsList.forEach((element) { + _prescriptionService.prescriptionsList.forEach((element) { /// PrescriptionsList list sort clinic List prescriptionsByClinic = _prescriptionsOrderListClinic @@ -264,24 +145,11 @@ class PrescriptionViewModel extends BaseViewModel { }); } - getPrescriptionReportEnh( - {PrescriptionsOrder prescriptionsOrder, - @required PatiantInformtion patient}) async { - setState(ViewState.Busy); - await _prescriptionsService.getPrescriptionReportEnh( - prescriptionsOrder: prescriptionsOrder, patient: patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - } - } _getPrescriptionsOrders() async { - await _prescriptionsService.getPrescriptionsOrders(); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; + await _prescriptionService.getPrescriptionsOrders(); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; setState(ViewState.ErrorLocal); } else { setState(ViewState.Idle); @@ -292,9 +160,9 @@ class PrescriptionViewModel extends BaseViewModel { if(isLocalBusy) setState(ViewState.BusyLocal); else setState(ViewState.Busy); - await _prescriptionsService.getPrescriptions(patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; + await _prescriptionService.getPrescriptions(patient); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; if (isLocalBusy) setState(ViewState.ErrorLocal); else @@ -309,12 +177,26 @@ class PrescriptionViewModel extends BaseViewModel { getMedicationForInPatient(PatiantInformtion patient) async { setState(ViewState.Busy); - await _prescriptionsService.getMedicationForInPatient(patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; + await _prescriptionService.getMedicationForInPatient(patient); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; setState(ViewState.Error); } else { setState(ViewState.Idle); } } + + getPrescriptionReport( + {Prescriptions prescriptions, + @required PatiantInformtion patient}) async { + setState(ViewState.Busy); + await _prescriptionService.getPrescriptionReport( + prescriptions: prescriptions, patient: patient); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } } diff --git a/lib/core/viewModel/prescriptions_view_model.dart b/lib/core/viewModel/prescriptions_view_model.dart deleted file mode 100644 index 31780a86..00000000 --- a/lib/core/viewModel/prescriptions_view_model.dart +++ /dev/null @@ -1,163 +0,0 @@ -import 'package:doctor_app_flutter/core/enum/filter_type.dart'; -import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report_enh.dart'; -import 'package:doctor_app_flutter/core/model/Prescriptions/prescriptions_order.dart'; -import 'package:doctor_app_flutter/core/service/patient_medical_file/prescription/prescriptions_service.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:flutter/material.dart'; - -import '../../locator.dart'; -import 'base_view_model.dart'; - -class PrescriptionsViewModel extends BaseViewModel { - FilterType filterType = FilterType.Clinic; - PrescriptionsService _prescriptionsService = locator(); - - List _prescriptionsOrderListClinic = List(); - List _prescriptionsOrderListHospital = List(); - - List get prescriptionReportList => - _prescriptionsService.prescriptionReportList; - - List get prescriptionsList => - _prescriptionsService.prescriptionsList; - - List get pharmacyPrescriptionsList => - _prescriptionsService.pharmacyPrescriptionsList; - - List get prescriptionReportEnhList => - _prescriptionsService.prescriptionReportEnhList; - - List get prescriptionsOrderList => - filterType == FilterType.Clinic - ? _prescriptionsOrderListClinic - : _prescriptionsOrderListHospital; - - List get medicationForInPatient => - _prescriptionsService.medicationForInPatient; - - List _medicationForInPatient = List(); - - getPrescriptions(PatiantInformtion patient) async { - setState(ViewState.Busy); - await _prescriptionsService.getPrescriptions(patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.Error); - } else { - _filterList(); - await _getPrescriptionsOrders(); - - setState(ViewState.Idle); - } - } - - _getPrescriptionsOrders() async { - await _prescriptionsService.getPrescriptionsOrders(); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.ErrorLocal); - } else { - setState(ViewState.Idle); - } - } - - void _filterList() { - _prescriptionsService.prescriptionsList.forEach((element) { - /// PrescriptionsList list sort clinic - List prescriptionsByClinic = - _prescriptionsOrderListClinic - .where((elementClinic) => - elementClinic.filterName == element.clinicDescription) - .toList(); - - if (prescriptionsByClinic.length != 0) { - _prescriptionsOrderListClinic[ - _prescriptionsOrderListClinic.indexOf(prescriptionsByClinic[0])] - .prescriptionsList - .add(element); - } else { - _prescriptionsOrderListClinic.add(PrescriptionsList( - filterName: element.clinicDescription, prescriptions: element)); - } - - /// PrescriptionsList list sort via hospital - List prescriptionsByHospital = - _prescriptionsOrderListHospital - .where( - (elementClinic) => elementClinic.filterName == element.name, - ) - .toList(); - - if (prescriptionsByHospital.length != 0) { - _prescriptionsOrderListHospital[_prescriptionsOrderListHospital - .indexOf(prescriptionsByHospital[0])] - .prescriptionsList - .add(element); - } else { - _prescriptionsOrderListHospital.add(PrescriptionsList( - filterName: element.name, prescriptions: element)); - } - }); - } - - setFilterType(FilterType filterType) { - this.filterType = filterType; - notifyListeners(); - } - - getPrescriptionReport( - {Prescriptions prescriptions, - @required PatiantInformtion patient}) async { - setState(ViewState.Busy); - await _prescriptionsService.getPrescriptionReport( - prescriptions: prescriptions, patient: patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.ErrorLocal); - } else { - setState(ViewState.Idle); - } - } - - getListPharmacyForPrescriptions( - {int itemId, @required PatiantInformtion patient}) async { - setState(ViewState.Busy); - await _prescriptionsService.getListPharmacyForPrescriptions( - itemId: itemId, patient: patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - } - } - - getPrescriptionReportEnh( - {PrescriptionsOrder prescriptionsOrder, - @required PatiantInformtion patient}) async { - setState(ViewState.Busy); - await _prescriptionsService.getPrescriptionReportEnh( - prescriptionsOrder: prescriptionsOrder, patient: patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - } - } - - getMedicationForInPatient(PatiantInformtion patient) async { - await _prescriptionsService.getMedicationForInPatient(patient); - if (_prescriptionsService.hasError) { - error = _prescriptionsService.error; - setState(ViewState.ErrorLocal); - } else { - setState(ViewState.Idle); - } - } -} diff --git a/lib/locator.dart b/lib/locator.dart index fc42e632..0bdfe8e9 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -7,7 +7,7 @@ import 'package:doctor_app_flutter/core/viewModel/hospitals_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/medical_file_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/pednding_orders_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/core/viewModel/profile/discharge_summary_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/profile/operation_report_view_model.dart'; @@ -42,7 +42,6 @@ import 'core/service/patient_medical_file/medical_report/PatientMedicalReportSer import 'core/service/patient_medical_file/medical_report/medical_file_service.dart'; import 'core/service/patient_medical_file/prescription/medicine_service.dart'; import 'core/service/patient_medical_file/prescription/prescription_service.dart'; -import 'core/service/patient_medical_file/prescription/prescriptions_service.dart'; import 'core/service/patient_medical_file/procedure/procedure_service.dart'; import 'core/service/patient_medical_file/radiology/radiology_service.dart'; import 'core/service/patient_medical_file/sick_leave/sickleave_service.dart'; @@ -65,7 +64,6 @@ import 'core/viewModel/patient-admission-request-viewmodel.dart'; import 'core/viewModel/patient-referral-viewmodel.dart'; import 'core/viewModel/patient-ucaf-viewmodel.dart'; import 'core/viewModel/patient-vital-sign-viewmodel.dart'; -import 'core/viewModel/prescriptions_view_model.dart'; import 'core/viewModel/profile/intervention_medication_view_model.dart'; import 'core/viewModel/profile/vte_assessment_view_model.dart'; import 'core/viewModel/radiology_view_model.dart'; @@ -97,7 +95,6 @@ void setupLocator() { locator.registerLazySingleton(() => LabsService()); locator.registerLazySingleton(() => InsuranceCardService()); locator.registerLazySingleton(() => RadiologyService()); - locator.registerLazySingleton(() => PrescriptionsService()); locator.registerLazySingleton(() => ReferralService()); locator.registerLazySingleton(() => MyReferralInPatientService()); locator.registerLazySingleton(() => DischargedPatientService()); @@ -138,7 +135,6 @@ void setupLocator() { locator.registerFactory(() => LabsViewModel()); locator.registerFactory(() => InsuranceViewModel()); locator.registerFactory(() => RadiologyViewModel()); - locator.registerFactory(() => PrescriptionsViewModel()); locator.registerFactory(() => DischargedPatientViewModel()); locator.registerFactory(() => PatientSearchViewModel()); locator.registerFactory(() => HospitalViewModel()); diff --git a/lib/routes.dart b/lib/routes.dart index 23f1dcbc..c50504a7 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -24,6 +24,7 @@ import 'package:doctor_app_flutter/screens/patients/profile/radiology/radiology_ import 'package:doctor_app_flutter/screens/patients/profile/referral/refer-patient-screen-in-patient.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/update_soap_index.dart'; import 'package:doctor_app_flutter/screens/patients/profile/vte_assessment/vte_assessment_screen.dart'; +import 'package:doctor_app_flutter/screens/prescription/new_prescriptions_page.dart'; import 'package:doctor_app_flutter/screens/prescription/prescriptions_page.dart'; import 'package:doctor_app_flutter/screens/procedures/procedure_screen.dart'; @@ -71,6 +72,7 @@ const String PATIENT_UCAF_DETAIL = 'patients/ucaf/detail'; const String PATIENT_ECG = 'patients/ecg'; const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; const String ORDER_PRESCRIPTION_NEW = 'prescription/prescription_new'; +const String ORDER_PRESCRIPTION_NEW_By_Elham = 'prescription/prescription_new_elham'; const String ORDER_PROCEDURE = 'procedure/procedure'; const String ADD_SICKLEAVE = 'add-sickleave'; const String RADIOLOGY_PATIENT = 'radiology-patient'; @@ -124,6 +126,7 @@ var routes = { IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), ADD_SICKLEAVE: (_) => PatientSickLeaveScreen(), ORDER_PRESCRIPTION_NEW: (_) => PrescriptionsPage(), + ORDER_PRESCRIPTION_NEW_By_Elham: (_) => NewPrescriptionsPage(), ORDER_PROCEDURE: (_) => ProcedureScreen(), MY_REFERRAL_DETAIL: (_) => MyReferralDetailScreen(), PATIENT_UCAF_REQUEST: (_) => UCAFPagerScreen(), diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart index ac4f224a..4382bca7 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart @@ -64,6 +64,13 @@ class ProfileGridForInPatient extends StatelessWidget { ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), + PatientProfileCardModel( + TranslationBase.of(context).patient, + TranslationBase.of(context).prescription +"Elham", + ORDER_PRESCRIPTION_NEW_By_Elham, + 'assets/images/svgs/profile_screen/order prescription.svg', + isInPatient: isInpatient), + PatientProfileCardModel( TranslationBase.of(context).progress, TranslationBase.of(context).note, diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart index baa4c5a2..cfe0cb8a 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart @@ -62,6 +62,12 @@ class ProfileGridForOther extends StatelessWidget { ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), + PatientProfileCardModel( + TranslationBase.of(context).patient, + TranslationBase.of(context).prescription +"Elham", + ORDER_PRESCRIPTION_NEW_By_Elham, + 'assets/images/svgs/profile_screen/order prescription.svg', + isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).health, TranslationBase.of(context).summary, diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart index 21157b94..3f9ae85c 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart @@ -59,6 +59,12 @@ class ProfileGridForSearch extends StatelessWidget { ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), + PatientProfileCardModel( + TranslationBase.of(context).patient, + TranslationBase.of(context).prescription +"Elham", + ORDER_PRESCRIPTION_NEW_By_Elham, + 'assets/images/svgs/profile_screen/order prescription.svg', + isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).health, TranslationBase.of(context).summary, diff --git a/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart index 056b2129..8ce52a43 100644 --- a/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart @@ -4,7 +4,7 @@ import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.d import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; diff --git a/lib/screens/prescription/add_prescription/add_drug/drug_to_drug.dart b/lib/screens/prescription/add_prescription/add_drug/drug_to_drug.dart index 350021b5..2ce61af0 100644 --- a/lib/screens/prescription/add_prescription/add_drug/drug_to_drug.dart +++ b/lib/screens/prescription/add_prescription/add_drug/drug_to_drug.dart @@ -4,7 +4,7 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-vital-sign-viewmodel.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; diff --git a/lib/screens/prescription/add_prescription/add_prescription.dart b/lib/screens/prescription/add_prescription/add_prescription.dart index ab32b9f5..074a01fe 100644 --- a/lib/screens/prescription/add_prescription/add_prescription.dart +++ b/lib/screens/prescription/add_prescription/add_prescription.dart @@ -4,7 +4,7 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/prescription_form_widget.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/search_preescription_widget.dart'; diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index e9a21030..39c9d171 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -7,7 +7,7 @@ import 'package:doctor_app_flutter/core/model/search_drug/get_medication_respons import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_text_filed.dart'; diff --git a/lib/screens/prescription/add_prescription/search_preescription_widget.dart b/lib/screens/prescription/add_prescription/search_preescription_widget.dart index 2d84c110..8adeddd4 100644 --- a/lib/screens/prescription/add_prescription/search_preescription_widget.dart +++ b/lib/screens/prescription/add_prescription/search_preescription_widget.dart @@ -4,7 +4,7 @@ import 'package:hexcolor/hexcolor.dart'; import '../../../config/config.dart'; import '../../../core/model/search_drug/get_medication_response_model.dart'; import '../../../core/viewModel/medicine_view_model.dart'; -import '../../../core/viewModel/prescription_view_model.dart'; +import '../../../core/viewModel/prescription/prescription_view_model.dart'; import '../../../util/helpers.dart'; import '../../../util/translations_delegate_base.dart'; import '../../../widgets/medicine/medicine_item_widget.dart'; diff --git a/lib/screens/prescription/new_prescriptions_page.dart b/lib/screens/prescription/new_prescriptions_page.dart new file mode 100644 index 00000000..d672ad7c --- /dev/null +++ b/lib/screens/prescription/new_prescriptions_page.dart @@ -0,0 +1,213 @@ +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_in_patient.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_out_patient.dart'; +import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart'; +import 'package:doctor_app_flutter/screens/procedures/base_add_procedure_tab_page.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; +import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; +import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import '../../util/helpers.dart'; +import '../../widgets/shared/errors/error_message.dart'; + +class NewPrescriptionsPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatiantInformtion patient = routeArgs['patient']; + String patientType = routeArgs['patientType']; + String arrivalType = routeArgs['arrivalType']; + bool isInpatient = routeArgs['isInpatient']; + bool isFromLiveCare = routeArgs['isFromLiveCare']; + return BaseView( + onModelReady: (model) async { + model.getPrescriptionListNew( + mrn: patient.patientMRN, appNo: patient.appointmentNo); + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + backgroundColor: Colors.grey[100], + appBar: PatientProfileAppBar( + patient, + isInpatient: isInpatient, + ), + body: patient.admissionNo == null + ? FractionallySizedBox( + widthFactor: 1.0, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 12, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ServiceTitle( + title: TranslationBase.of(context).orders, + subTitle: + TranslationBase.of(context).prescriptions, + ), + ], + ), + ), + if ((patient.patientStatusType != null && + patient.patientStatusType == 43) || + (isFromLiveCare && patient.appointmentNo != null)) + AddNewOrder( + onTap: () { + Navigator.push( + context, + SlideUpPageRoute( + widget: BaseAddProcedureTabPage( + patient: patient, + prescriptionModel: model, + procedureType: + ProcedureType.PRESCRIPTION, + ), + settingRoute: 'AddProcedureTabPage'), + ); + }, + label: TranslationBase.of(context) + .applyForNewPrescriptionsOrder, + ), + ListView.builder( + physics: BouncingScrollPhysics(), + itemCount: model.prescriptionsList.length, + shrinkWrap: true, + itemBuilder: (BuildContext ctxt, int index) { + return InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionItemsPage( + prescriptions: model + .prescriptionsList[index], + patient: patient, + arrivalType: arrivalType, + ), + ), + ), + child: Column( + children: [ + DoctorCard( + doctorName: + Helpers.convertToTitleCase(model + .prescriptionsList[index] + .doctorName), + profileUrl: model + .prescriptionsList[index] + .doctorImageURL, + branch: model + .prescriptionsList[index].name, + clinic: model.prescriptionsList[index] + .clinicDescription, + isPrescriptions: true, + appointmentDate: AppDateUtils + .getDateTimeFromServerFormat( + model.prescriptionsList[index] + .appointmentDate, + ), + ), + ], + )); + }), + if (model.prescriptionsList.isEmpty && + patient.patientStatusType != 43) + Center( + child: ErrorMessage( + error: TranslationBase.of(context) + .noPrescriptionsFound, + )) + ], + ), + ), + ) + : NetworkBaseView( + baseViewModel: model, + child: FractionallySizedBox( + widthFactor: 1.0, + child: ListView( + physics: BouncingScrollPhysics(), + children: [ + model.medicationForInPatient.length == 0 + ? Center( + child: ErrorMessage( + error: TranslationBase.of(context) + .noPrescriptionsFound, + )) + : ListView.builder( + scrollDirection: Axis.vertical, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: + model.medicationForInPatient.length, + itemBuilder: (context, index) { + //model.medicationForInPatient.length, + return InkWell( + child: InPatientDoctorCard( + doctorName: Helpers.convertToTitleCase( + model.medicationForInPatient[index] + .pHRItemDescription), + profileUrl: 'sss', + branch: 'hamza', + clinic: 'basheer', + isPrescriptions: true, + appointmentDate: AppDateUtils + .getDateTimeFromServerFormat( + model.medicationForInPatient[index] + .prescriptionDatetime, + ), + createdBy: Helpers.convertToTitleCase( + model.medicationForInPatient[index] + .doctorName + .toString()), + ), + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionItemsInPatientPage( + prescriptionIndex: index, + prescriptions: model + .medicationForInPatient[index], + patient: patient, + patientType: patientType, + arrivalType: arrivalType, + startOn: AppDateUtils + .getDateTimeFromServerFormat( + model + .medicationForInPatient[index] + .startDatetime, + ), + stopOn: AppDateUtils + .getDateTimeFromServerFormat( + model + .medicationForInPatient[index] + .stopDatetime, + ), + ), + ), + ), + ); + }), + ], + ), + ), + ))); + } +} diff --git a/lib/screens/prescription/prescription_checkout_screen.dart b/lib/screens/prescription/prescription_checkout_screen.dart index 20f502a3..3930cffd 100644 --- a/lib/screens/prescription/prescription_checkout_screen.dart +++ b/lib/screens/prescription/prescription_checkout_screen.dart @@ -8,7 +8,7 @@ import 'package:doctor_app_flutter/core/model/procedure/procedure_template_detai import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; diff --git a/lib/screens/prescription/prescriptions_items/preacription_items_widget.dart b/lib/screens/prescription/prescriptions_items/preacription_items_widget.dart index ce8a530a..7883848c 100644 --- a/lib/screens/prescription/prescriptions_items/preacription_items_widget.dart +++ b/lib/screens/prescription/prescriptions_items/preacription_items_widget.dart @@ -1,10 +1,10 @@ +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../core/viewModel/prescriptions_view_model.dart'; import '../../../widgets/shared/dialogs/ShowImageDialog.dart'; @@ -16,7 +16,7 @@ class PrescriptionItemsWidget extends StatelessWidget { final String imageSRCUrl; final String remarks; final int days; - final PrescriptionsViewModel prescriptionsViewModel; + final PrescriptionViewModel prescriptionViewModel; @@ -27,8 +27,8 @@ class PrescriptionItemsWidget extends StatelessWidget { this.dailyDoses, this.imageSRCUrl, this.remarks, - this.days, - this.prescriptionsViewModel}); + this.days, this.prescriptionViewModel, + }); @override Widget build(BuildContext context) { @@ -36,7 +36,7 @@ class PrescriptionItemsWidget extends StatelessWidget { children: [ ...List.generate( // TODO Elham* List.generate to list.builder - prescriptionsViewModel.prescriptionReportEnhList.length, + prescriptionViewModel.prescriptionReportEnhList.length, (index) => Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), @@ -51,7 +51,7 @@ class PrescriptionItemsWidget extends StatelessWidget { Container( margin: EdgeInsets.only(left: 18, right: 18), child: AppText( - prescriptionsViewModel.prescriptionReportEnhList[index].itemDescription, + prescriptionViewModel.prescriptionReportEnhList[index].itemDescription, bold: true, ), ), @@ -77,7 +77,7 @@ class PrescriptionItemsWidget extends StatelessWidget { showDialog( context: context, builder: (ctx) => ShowImageDialog( - imageUrl: prescriptionsViewModel.prescriptionReportEnhList[index].imageSRCUrl, + imageUrl: prescriptionViewModel.prescriptionReportEnhList[index].imageSRCUrl, )); }, child: Stack( @@ -85,7 +85,7 @@ class PrescriptionItemsWidget extends StatelessWidget { Padding( padding: const EdgeInsets.all(8.0), child: Image.network( - prescriptionsViewModel.prescriptionReportEnhList[index].imageSRCUrl, + prescriptionViewModel.prescriptionReportEnhList[index].imageSRCUrl, fit: BoxFit.cover, ), ), @@ -111,25 +111,25 @@ class PrescriptionItemsWidget extends StatelessWidget { children: [ CustomRow( label: TranslationBase.of(context).route + ' : ', - value: " " + prescriptionsViewModel.prescriptionReportEnhList[index].route ?? '', + value: " " + prescriptionViewModel.prescriptionReportEnhList[index].route ?? '', labelSize: 13, valueSize: 13, ), CustomRow( label: TranslationBase.of(context).frequency + ' : ', - value: " " + prescriptionsViewModel.prescriptionReportEnhList[index].frequency ?? '', + value: " " + prescriptionViewModel.prescriptionReportEnhList[index].frequency ?? '', labelSize: 13, valueSize: 13, ), CustomRow( label: TranslationBase.of(context).dailyDoses + ' : ', - value: " " + prescriptionsViewModel.prescriptionReportEnhList[index].doseDailyQuantity.toString() ?? '', + value: " " + prescriptionViewModel.prescriptionReportEnhList[index].doseDailyQuantity.toString() ?? '', labelSize: 13, valueSize: 13, ), CustomRow( label: TranslationBase.of(context).duration + ' : ', - value: " " + prescriptionsViewModel.prescriptionReportList[index].days.toString() ?? '', + value: " " + prescriptionViewModel.prescriptionReportList[index].days.toString() ?? '', labelSize: 13, valueSize: 13, ), @@ -138,7 +138,7 @@ class PrescriptionItemsWidget extends StatelessWidget { ), CustomRow( label: '', - value: prescriptionsViewModel.prescriptionReportList[index].remarks ?? '', + value: prescriptionViewModel.prescriptionReportList[index].remarks ?? '', valueSize: 14, ), ], diff --git a/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart b/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart index 843377c5..cc21e1e3 100644 --- a/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart +++ b/lib/screens/prescription/prescriptions_items/prescription_items_in_patient.dart @@ -1,5 +1,5 @@ import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; diff --git a/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart b/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart index 085d4fc3..e49fb5e2 100644 --- a/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart +++ b/lib/screens/prescription/prescriptions_items/prescription_items_out_patient.dart @@ -1,6 +1,6 @@ import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescriptions_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/preacription_items_widget.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; @@ -26,7 +26,7 @@ class PrescriptionItemsPage extends StatelessWidget { @override Widget build(BuildContext context) { - return BaseView( + return BaseView( onModelReady: (model) => model.getPrescriptionReport( prescriptions: prescriptions, patient: patient), builder: (_, model, widget) => AppScaffold( @@ -61,7 +61,7 @@ class PrescriptionItemsPage extends StatelessWidget { dailyDoses: model.prescriptionReportEnhList[index].doseDailyQuantity, imageSRCUrl: model.prescriptionReportEnhList[index].imageSRCUrl, remarks: model.prescriptionReportEnhList[index].remarks, - prescriptionsViewModel: model, + prescriptionViewModel: model, ), ), ], diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index cbb2b24a..43083f60 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -1,4 +1,4 @@ -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_in_patient.dart'; diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index 84d92d4f..c062d69b 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -1,6 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index b8d1605d..9cbea46c 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -1,4 +1,4 @@ -import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; diff --git a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart index 6a7b7296..21618fd7 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart @@ -79,6 +79,15 @@ class ProfileMedicalInfoWidgetInPatient extends StatelessWidget { nameLine1: TranslationBase.of(context).patient, nameLine2: TranslationBase.of(context).prescription, icon: 'assets/images/svgs/profile_screen/order prescription.svg'), + PatientProfileButton( + key: key, + patient: patient, + patientType: patientType, + arrivalType: arrivalType, + route: ORDER_PRESCRIPTION_NEW_By_Elham, + nameLine1: TranslationBase.of(context).patient, + nameLine2: TranslationBase.of(context).prescription +"Elham", + icon: 'assets/images/svgs/profile_screen/order prescription.svg'), PatientProfileButton( key: key, patient: patient, diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 00000000..424d9a09 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,1424 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "22.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.2" + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.0" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + autocomplete_textfield: + dependency: "direct main" + description: + name: autocomplete_textfield + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.3" + badges: + dependency: "direct main" + description: + name: badges + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + barcode_scan2: + dependency: "direct main" + description: + name: barcode_scan2 + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.0" + bazel_worker: + dependency: transitive + description: + name: bazel_worker + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.3" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.6" + build_daemon: + dependency: transitive + description: + name: build_daemon + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.10" + build_modules: + dependency: transitive + description: + name: build_modules + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.5" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.4" + build_runner: + dependency: "direct dev" + description: + name: build_runner + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.5" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.10" + build_web_compilers: + dependency: "direct dev" + description: + name: build_web_compilers + url: "https://pub.dartlang.org" + source: hosted + version: "2.16.5" + built_collection: + dependency: transitive + description: + name: built_collection + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + url: "https://pub.dartlang.org" + source: hosted + version: "8.1.4" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.0" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + charts_common: + dependency: transitive + description: + name: charts_common + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.0" + charts_flutter: + dependency: "direct main" + description: + name: charts_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + chewie: + dependency: transitive + description: + name: chewie + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + chewie_audio: + dependency: transitive + description: + name: chewie_audio + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + code_builder: + dependency: transitive + description: + name: code_builder + url: "https://pub.dartlang.org" + source: hosted + version: "3.7.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + connectivity: + dependency: "direct main" + description: + name: connectivity + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.6" + connectivity_for_web: + dependency: transitive + description: + name: connectivity_for_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0+1" + connectivity_macos: + dependency: transitive + description: + name: connectivity_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1+2" + connectivity_platform_interface: + dependency: transitive + description: + name: connectivity_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + csslib: + dependency: transitive + description: + name: csslib + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.1" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.14" + date_time_picker: + dependency: "direct main" + description: + name: date_time_picker + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + device_info: + dependency: "direct main" + description: + name: device_info + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + device_info_platform_interface: + dependency: transitive + description: + name: device_info_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + dropdown_search: + dependency: "direct main" + description: + name: dropdown_search + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + equatable: + dependency: transitive + description: + name: equatable + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + eva_icons_flutter: + dependency: "direct main" + description: + name: eva_icons_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + expandable: + dependency: "direct main" + description: + name: expandable + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.1" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" + file_picker: + dependency: "direct main" + description: + name: file_picker + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.4" + firebase: + dependency: transitive + description: + name: firebase + url: "https://pub.dartlang.org" + source: hosted + version: "9.0.2" + firebase_analytics: + dependency: "direct main" + description: + name: firebase_analytics + url: "https://pub.dartlang.org" + source: hosted + version: "8.3.4" + firebase_analytics_platform_interface: + dependency: transitive + description: + name: firebase_analytics_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + firebase_analytics_web: + dependency: transitive + description: + name: firebase_analytics_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0+1" + firebase_core: + dependency: transitive + description: + name: firebase_core + url: "https://pub.dartlang.org" + source: hosted + version: "1.12.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.4" + firebase_messaging: + dependency: "direct main" + description: + name: firebase_messaging + url: "https://pub.dartlang.org" + source: hosted + version: "10.0.9" + firebase_messaging_platform_interface: + dependency: transitive + description: + name: firebase_messaging_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.6" + firebase_messaging_web: + dependency: transitive + description: + name: firebase_messaging_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.7" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + fl_chart: + dependency: "direct main" + description: + name: fl_chart + url: "https://pub.dartlang.org" + source: hosted + version: "0.36.4" + flutter: + dependency: "direct main" + 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.6.0" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + url: "https://pub.dartlang.org" + source: hosted + version: "3.3.0" + flutter_colorpicker: + dependency: "direct main" + description: + name: flutter_colorpicker + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" + flutter_datetime_picker: + dependency: "direct main" + description: + name: flutter_datetime_picker + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.1" + flutter_device_type: + dependency: "direct main" + description: + name: flutter_device_type + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" + flutter_gifimage: + dependency: "direct main" + description: + name: flutter_gifimage + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + flutter_html: + dependency: "direct main" + description: + name: flutter_html + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" + flutter_inappwebview: + dependency: transitive + description: + name: flutter_inappwebview + url: "https://pub.dartlang.org" + source: hosted + version: "5.3.2" + flutter_keyboard_visibility: + dependency: transitive + description: + name: flutter_keyboard_visibility + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.1" + flutter_keyboard_visibility_platform_interface: + dependency: transitive + description: + name: flutter_keyboard_visibility_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility_web: + dependency: transitive + description: + name: flutter_keyboard_visibility_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + flutter_layout_grid: + dependency: transitive + description: + name: flutter_layout_grid + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_math_fork: + dependency: transitive + description: + name: flutter_math_fork + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" + flutter_page_indicator: + dependency: transitive + description: + name: flutter_page_indicator + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.3" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + flutter_staggered_grid_view: + dependency: "direct main" + description: + name: flutter_staggered_grid_view + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.1" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + url: "https://pub.dartlang.org" + source: hosted + version: "0.23.0+1" + flutter_swiper: + dependency: "direct main" + description: + name: flutter_swiper + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.6" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + url: "https://pub.dartlang.org" + source: hosted + version: "8.0.8" + font_awesome_flutter: + dependency: "direct main" + description: + name: font_awesome_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "9.2.0" + get_it: + dependency: "direct main" + description: + name: get_it + url: "https://pub.dartlang.org" + source: hosted + version: "7.2.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + graphs: + dependency: transitive + description: + name: graphs + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" + hexcolor: + dependency: "direct main" + description: + name: hexcolor + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.6" + hijri: + dependency: transitive + description: + name: hijri + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + hijri_picker: + dependency: "direct main" + description: + name: hijri_picker + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + html: + dependency: "direct main" + description: + name: html + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.0" + html_editor_enhanced: + dependency: "direct main" + description: + name: html_editor_enhanced + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0+1-dev.1" + http: + dependency: "direct main" + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.4" + http_interceptor: + dependency: "direct main" + description: + name: http_interceptor + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.1" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + infinite_listview: + dependency: transitive + description: + name: infinite_listview + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + intl: + dependency: "direct main" + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" + json_annotation: + dependency: transitive + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" + local_auth: + dependency: "direct main" + description: + name: local_auth + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.10" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + maps_launcher: + dependency: "direct main" + description: + name: maps_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + nested: + dependency: transitive + description: + name: nested + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + numberpicker: + dependency: transitive + description: + name: numberpicker + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + numerus: + dependency: transitive + description: + name: numerus + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + octo_image: + dependency: transitive + description: + name: octo_image + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + path_drawing: + dependency: transitive + description: + name: path_drawing + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.1+1" + path_parsing: + dependency: transitive + description: + name: path_parsing + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.7" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" + percent_indicator: + dependency: "direct main" + description: + name: percent_indicator + url: "https://pub.dartlang.org" + source: hosted + version: "3.4.0" + permission_handler: + dependency: "direct main" + description: + name: permission_handler + url: "https://pub.dartlang.org" + source: hosted + version: "8.3.0" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "3.7.0" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "4.4.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + pointer_interceptor: + dependency: transitive + description: + name: pointer_interceptor + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.1" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.0" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" + protobuf: + dependency: transitive + description: + name: protobuf + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + provider: + dependency: "direct main" + description: + name: provider + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.2" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.8" + quiver: + dependency: "direct main" + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1+1" + rxdart: + dependency: transitive + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.27.3" + scratch_space: + dependency: transitive + description: + name: scratch_space + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+3" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.13" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.10" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.4+1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.10" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + speech_to_text: + dependency: "direct main" + description: + path: speech_to_text + relative: true + source: path + version: "0.0.0" + sqflite: + dependency: transitive + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + sticky_headers: + dependency: "direct main" + description: + name: sticky_headers + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.3" + timing: + dependency: transitive + description: + name: timing + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.1+3" + transformer_page_view: + dependency: transitive + description: + name: transformer_page_view + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.6" + tuple: + dependency: transitive + description: + name: tuple + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.20" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.15" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.15" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.6" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + uuid: + dependency: transitive + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.5" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + video_player: + dependency: transitive + description: + name: video_player + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.18" + video_player_android: + dependency: transitive + description: + name: video_player_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.17" + video_player_avfoundation: + dependency: transitive + description: + name: video_player_avfoundation + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.18" + video_player_platform_interface: + dependency: transitive + description: + name: video_player_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.2" + video_player_web: + dependency: transitive + description: + name: video_player_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.7" + visibility_detector: + dependency: transitive + description: + name: visibility_detector + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.2" + wakelock: + dependency: transitive + description: + name: wakelock + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.6" + wakelock_macos: + dependency: transitive + description: + name: wakelock_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" + wakelock_platform_interface: + dependency: transitive + description: + name: wakelock_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" + wakelock_web: + dependency: transitive + description: + name: wakelock_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" + wakelock_windows: + dependency: transitive + description: + name: wakelock_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + webview_flutter: + dependency: transitive + description: + name: webview_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + url: "https://pub.dartlang.org" + source: hosted + version: "2.7.1" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.11" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+1" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "5.3.1" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" +sdks: + dart: ">=2.15.0 <3.0.0" + flutter: ">=2.8.0" From 954402fe52c372b5dbef1a41a2ac15bc6de89c31 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 16 Feb 2022 12:27:13 +0200 Subject: [PATCH 22/25] show the list of prescription --- lib/config/config.dart | 4 +- lib/config/localized_values.dart | 1 + .../prescription_entity_model.dart | 145 ++++++++ .../Prescriptions/prescription_model.dart | 154 +-------- .../prescription/prescription_service.dart | 12 + .../prescription/prescription_view_model.dart | 3 + lib/screens/live_care/end_call_screen.dart | 2 +- .../profile/UCAF/UCAF-detail-screen.dart | 3 +- ...l.dart => patient_profile_card_model.dart} | 0 .../profile_gird_for_InPatient.dart | 6 +- .../profile_gird_for_other.dart | 6 +- .../profile_gird_for_search.dart | 6 +- .../prescription/new_prescriptions_page.dart | 321 ++++++++---------- lib/util/translations_delegate_base.dart | 1 + ...rofile_medical_info_widget_in_patient.dart | 4 +- 15 files changed, 327 insertions(+), 341 deletions(-) create mode 100644 lib/core/model/Prescriptions/prescription_entity_model.dart rename lib/screens/patients/profile/profile_screen/{PatientProfileCardModel.dart => patient_profile_card_model.dart} (100%) diff --git a/lib/config/config.dart b/lib/config/config.dart index 4d7f3828..11c6dfbc 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index bb8b1b1c..6dcf5968 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1135,4 +1135,5 @@ const Map> localizedValues = { "sorryNoMatch": {"en": "Sorry No Match", "ar": "عذرا لا يوجد تطابق"}, "thousandIsTheMAXForTheStrength": {"en": "1000 Is The MAX For The Strength", "ar": "ألف هو القيمة الأعلى"}, "strengthCanNotBeZero": {"en": "Strength Can't Be Zero", "ar": "القوة لا يمكن أن تكون صفر "}, + "old": {"en": "Old", "ar":"القديمه"}, }; diff --git a/lib/core/model/Prescriptions/prescription_entity_model.dart b/lib/core/model/Prescriptions/prescription_entity_model.dart new file mode 100644 index 00000000..166cd599 --- /dev/null +++ b/lib/core/model/Prescriptions/prescription_entity_model.dart @@ -0,0 +1,145 @@ +class PrescriptionEntityModel { + dynamic appointmentNo; + dynamic clinicName; + dynamic createdBy; + dynamic createdOn; + dynamic doctorName; + dynamic doseDailyQuantity; + dynamic doseDailyUnitID; + dynamic doseDetail; + dynamic doseDurationDays; + dynamic doseTimingID; + dynamic episodeID; + dynamic frequencyID; + dynamic icdCode10ID; + dynamic indication; + dynamic isDispensed; + dynamic isMedicineCovered; + dynamic isSIG; + dynamic medicationName; + dynamic medicationPrice; + dynamic medicineCode; + dynamic orderTypeDescription; + dynamic qty; + dynamic quantity; + dynamic remarks; + dynamic routeID; + dynamic startDate; + dynamic status; + dynamic stopDate; + dynamic uom; + dynamic pharmacistRemarks; + dynamic pharmacyInervention; + dynamic refill; + dynamic mediSpanGPICode; + + PrescriptionEntityModel( + {this.appointmentNo, + this.clinicName, + this.createdBy, + this.createdOn, + this.doctorName, + this.doseDailyQuantity, + this.doseDailyUnitID, + this.doseDetail, + this.doseDurationDays, + this.doseTimingID, + this.episodeID, + this.frequencyID, + this.icdCode10ID, + this.indication, + this.isDispensed, + this.isMedicineCovered, + this.isSIG, + this.medicationName, + this.medicationPrice, + this.medicineCode, + this.orderTypeDescription, + this.qty, + this.quantity, + this.remarks, + this.routeID, + this.startDate, + this.status, + this.stopDate, + this.uom, + this.pharmacistRemarks, + this.mediSpanGPICode, + this.pharmacyInervention, + this.refill}); + + PrescriptionEntityModel.fromJson(Map json) { + appointmentNo = json['appointmentNo']; + clinicName = json['clinicName']; + createdBy = json['createdBy']; + createdOn = json['createdOn']; + doctorName = json['doctorName']; + doseDailyQuantity = json['doseDailyQuantity']; + doseDailyUnitID = json['doseDailyUnitID']; + doseDetail = json['doseDetail']; + doseDurationDays = json['doseDurationDays']; + doseTimingID = json['doseTimingID']; + episodeID = json['episodeID']; + frequencyID = json['frequencyID']; + icdCode10ID = json['icdCode10ID']; + indication = json['indication']; + isDispensed = json['isDispensed']; + isMedicineCovered = json['isMedicineCovered']; + isSIG = json['isSIG']; + medicationName = json['medicationName']; + medicationPrice = json['medicationPrice']; + medicineCode = json['medicineCode']; + orderTypeDescription = json['orderTypeDescription']; + qty = json['qty']; + quantity = json['quantity']; + remarks = json['remarks']; + routeID = json['routeID']; + startDate = json['startDate']; + status = json['status']; + stopDate = json['stopDate']; + uom = json['uom']; + pharmacistRemarks = json['pharmacistRemarks']; + mediSpanGPICode = json['mediSpanGPICode']; + refill = json['refill']; + pharmacyInervention = json['interventionID']; + } + + Map toJson() { + final Map data = new Map(); + data['appointmentNo'] = this.appointmentNo; + data['clinicName'] = this.clinicName; + data['createdBy'] = this.createdBy; + data['createdOn'] = this.createdOn; + data['doctorName'] = this.doctorName; + data['doseDailyQuantity'] = this.doseDailyQuantity; + data['doseDailyUnitID'] = this.doseDailyUnitID; + data['doseDetail'] = this.doseDetail; + data['doseDurationDays'] = this.doseDurationDays; + data['doseTimingID'] = this.doseTimingID; + data['episodeID'] = this.episodeID; + data['frequencyID'] = this.frequencyID; + data['icdCode10ID'] = this.icdCode10ID; + data['indication'] = this.indication; + data['isDispensed'] = this.isDispensed; + data['isMedicineCovered'] = this.isMedicineCovered; + data['isSIG'] = this.isSIG; + data['medicationName'] = this.medicationName; + data['medicationPrice'] = this.medicationPrice; + data['medicineCode'] = this.medicineCode; + data['orderTypeDescription'] = this.orderTypeDescription; + data['qty'] = this.qty; + data['quantity'] = this.quantity; + data['remarks'] = this.remarks; + data['routeID'] = this.routeID; + data['startDate'] = this.startDate; + data['status'] = this.status; + data['stopDate'] = this.stopDate; + data['uom'] = this.uom; + data['pharmacistRemarks'] = this.pharmacistRemarks; + data['mediSpanGPICode'] = this.mediSpanGPICode; + data['refill'] = this.refill; + data['interventionID'] = this.pharmacyInervention; + + return data; + } +} \ No newline at end of file diff --git a/lib/core/model/Prescriptions/prescription_model.dart b/lib/core/model/Prescriptions/prescription_model.dart index 52c3edec..a286908f 100644 --- a/lib/core/model/Prescriptions/prescription_model.dart +++ b/lib/core/model/Prescriptions/prescription_model.dart @@ -1,5 +1,7 @@ +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_entity_model.dart'; + class PrescriptionModel { - List entityList; + List entityList; dynamic rowcount; dynamic statusMessage; @@ -7,9 +9,9 @@ class PrescriptionModel { PrescriptionModel.fromJson(Map json) { if (json['entityList'] != null) { - entityList = new List(); + entityList = new List(); json['entityList'].forEach((v) { - entityList.add(new EntityList.fromJson(v)); + entityList.add(new PrescriptionEntityModel.fromJson(v)); }); } rowcount = json['rowcount']; @@ -26,149 +28,3 @@ class PrescriptionModel { return data; } } - -class EntityList { - dynamic appointmentNo; - dynamic clinicName; - dynamic createdBy; - dynamic createdOn; - dynamic doctorName; - dynamic doseDailyQuantity; - dynamic doseDailyUnitID; - dynamic doseDetail; - dynamic doseDurationDays; - dynamic doseTimingID; - dynamic episodeID; - dynamic frequencyID; - dynamic icdCode10ID; - dynamic indication; - dynamic isDispensed; - dynamic isMedicineCovered; - dynamic isSIG; - dynamic medicationName; - dynamic medicationPrice; - dynamic medicineCode; - dynamic orderTypeDescription; - dynamic qty; - dynamic quantity; - dynamic remarks; - dynamic routeID; - dynamic startDate; - dynamic status; - dynamic stopDate; - dynamic uom; - dynamic pharmacistRemarks; - dynamic pharmacyInervention; - dynamic refill; - dynamic mediSpanGPICode; - - EntityList( - {this.appointmentNo, - this.clinicName, - this.createdBy, - this.createdOn, - this.doctorName, - this.doseDailyQuantity, - this.doseDailyUnitID, - this.doseDetail, - this.doseDurationDays, - this.doseTimingID, - this.episodeID, - this.frequencyID, - this.icdCode10ID, - this.indication, - this.isDispensed, - this.isMedicineCovered, - this.isSIG, - this.medicationName, - this.medicationPrice, - this.medicineCode, - this.orderTypeDescription, - this.qty, - this.quantity, - this.remarks, - this.routeID, - this.startDate, - this.status, - this.stopDate, - this.uom, - this.pharmacistRemarks, - this.mediSpanGPICode, - this.pharmacyInervention, - this.refill}); - - EntityList.fromJson(Map json) { - appointmentNo = json['appointmentNo']; - clinicName = json['clinicName']; - createdBy = json['createdBy']; - createdOn = json['createdOn']; - doctorName = json['doctorName']; - doseDailyQuantity = json['doseDailyQuantity']; - doseDailyUnitID = json['doseDailyUnitID']; - doseDetail = json['doseDetail']; - doseDurationDays = json['doseDurationDays']; - doseTimingID = json['doseTimingID']; - episodeID = json['episodeID']; - frequencyID = json['frequencyID']; - icdCode10ID = json['icdCode10ID']; - indication = json['indication']; - isDispensed = json['isDispensed']; - isMedicineCovered = json['isMedicineCovered']; - isSIG = json['isSIG']; - medicationName = json['medicationName']; - medicationPrice = json['medicationPrice']; - medicineCode = json['medicineCode']; - orderTypeDescription = json['orderTypeDescription']; - qty = json['qty']; - quantity = json['quantity']; - remarks = json['remarks']; - routeID = json['routeID']; - startDate = json['startDate']; - status = json['status']; - stopDate = json['stopDate']; - uom = json['uom']; - pharmacistRemarks = json['pharmacistRemarks']; - mediSpanGPICode = json['mediSpanGPICode']; - refill = json['refill']; - pharmacyInervention = json['interventionID']; - } - - Map toJson() { - final Map data = new Map(); - data['appointmentNo'] = this.appointmentNo; - data['clinicName'] = this.clinicName; - data['createdBy'] = this.createdBy; - data['createdOn'] = this.createdOn; - data['doctorName'] = this.doctorName; - data['doseDailyQuantity'] = this.doseDailyQuantity; - data['doseDailyUnitID'] = this.doseDailyUnitID; - data['doseDetail'] = this.doseDetail; - data['doseDurationDays'] = this.doseDurationDays; - data['doseTimingID'] = this.doseTimingID; - data['episodeID'] = this.episodeID; - data['frequencyID'] = this.frequencyID; - data['icdCode10ID'] = this.icdCode10ID; - data['indication'] = this.indication; - data['isDispensed'] = this.isDispensed; - data['isMedicineCovered'] = this.isMedicineCovered; - data['isSIG'] = this.isSIG; - data['medicationName'] = this.medicationName; - data['medicationPrice'] = this.medicationPrice; - data['medicineCode'] = this.medicineCode; - data['orderTypeDescription'] = this.orderTypeDescription; - data['qty'] = this.qty; - data['quantity'] = this.quantity; - data['remarks'] = this.remarks; - data['routeID'] = this.routeID; - data['startDate'] = this.startDate; - data['status'] = this.status; - data['stopDate'] = this.stopDate; - data['uom'] = this.uom; - data['pharmacistRemarks'] = this.pharmacistRemarks; - data['mediSpanGPICode'] = this.mediSpanGPICode; - data['refill'] = this.refill; - data['interventionID'] = this.pharmacyInervention; - - return data; - } -} diff --git a/lib/core/service/patient_medical_file/prescription/prescription_service.dart b/lib/core/service/patient_medical_file/prescription/prescription_service.dart index d2ad393e..99d24fb4 100644 --- a/lib/core/service/patient_medical_file/prescription/prescription_service.dart +++ b/lib/core/service/patient_medical_file/prescription/prescription_service.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_i import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_request_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/post_prescrition_req_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_entity_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_in_patient.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.dart'; @@ -31,6 +32,11 @@ class PrescriptionService extends LookupService { List _prescriptionList = List(); List get prescriptionList => _prescriptionList; + + List _prescriptionListNew = List(); + + List get prescriptionListNew => _prescriptionListNew; + List _drugsList = List(); List get drugsList => _drugsList; @@ -99,10 +105,16 @@ class PrescriptionService extends LookupService { ); hasError = false; _prescriptionList.clear(); + _prescriptionListNew.clear(); await baseAppClient.post(GET_PRESCRIPTION_LIST, onSuccess: (dynamic response, int statusCode) { _prescriptionList .add(PrescriptionModel.fromJson(response['PrescriptionList'])); + if(response['PrescriptionList']!=null){ + response['PrescriptionList']["entityList"].forEach((prescriptions) { + _prescriptionListNew.add(PrescriptionEntityModel.fromJson(prescriptions)); + }); + } }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/core/viewModel/prescription/prescription_view_model.dart b/lib/core/viewModel/prescription/prescription_view_model.dart index 5fc44a77..3c2b38a6 100644 --- a/lib/core/viewModel/prescription/prescription_view_model.dart +++ b/lib/core/viewModel/prescription/prescription_view_model.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/core/model/Prescriptions/Prescriptions.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/get_medication_for_inpatient_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/perscription_pharmacy.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/post_prescrition_req_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_entity_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_report_enh.dart'; @@ -29,6 +30,8 @@ class PrescriptionViewModel extends BaseViewModel { List get prescriptionList => _prescriptionService.prescriptionList; + List get prescriptionListNew => + _prescriptionService.prescriptionListNew; List get prescriptionReportList => _prescriptionService.prescriptionReportList; diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index 6cd610c7..a68eff56 100644 --- a/lib/screens/live_care/end_call_screen.dart +++ b/lib/screens/live_care/end_call_screen.dart @@ -7,7 +7,7 @@ import 'package:doctor_app_flutter/core/model/livecare/session_status_model.dart import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/live_care/live-care_transfer_to_admin.dart'; -import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/PatientProfileCardModel.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/patient_profile_card_model.dart'; import 'package:doctor_app_flutter/util/VideoChannel.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; diff --git a/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart b/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart index 658b99e4..c7b51da3 100644 --- a/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart +++ b/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_entity_model.dart'; import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-ucaf-viewmodel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart'; @@ -339,7 +340,7 @@ class DiagnosisWidget extends StatelessWidget { class MedicationWidget extends StatelessWidget { final UcafViewModel model; - final EntityList prescription; + final PrescriptionEntityModel prescription; MedicationWidget(this.model, this.prescription); diff --git a/lib/screens/patients/profile/profile_screen/PatientProfileCardModel.dart b/lib/screens/patients/profile/profile_screen/patient_profile_card_model.dart similarity index 100% rename from lib/screens/patients/profile/profile_screen/PatientProfileCardModel.dart rename to lib/screens/patients/profile/profile_screen/patient_profile_card_model.dart diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart index 4382bca7..ed9e2c1d 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart @@ -1,5 +1,5 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/PatientProfileCardModel.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/patient_profile_card_model.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/PatientProfileButton.dart'; import 'package:flutter/material.dart'; @@ -60,13 +60,13 @@ class ProfileGridForInPatient extends StatelessWidget { isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, - TranslationBase.of(context).prescription, + TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, - TranslationBase.of(context).prescription +"Elham", + TranslationBase.of(context).prescription, ORDER_PRESCRIPTION_NEW_By_Elham, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart index cfe0cb8a..0ff600a6 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart @@ -1,5 +1,5 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/PatientProfileCardModel.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/patient_profile_card_model.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/PatientProfileButton.dart'; import 'package:flutter/material.dart'; @@ -58,13 +58,13 @@ class ProfileGridForOther extends StatelessWidget { isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).orders, - TranslationBase.of(context).prescription, + TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, - TranslationBase.of(context).prescription +"Elham", + TranslationBase.of(context).prescription, ORDER_PRESCRIPTION_NEW_By_Elham, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart index 3f9ae85c..21f5823e 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart @@ -1,5 +1,5 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/PatientProfileCardModel.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/patient_profile_card_model.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/PatientProfileButton.dart'; import 'package:flutter/material.dart'; @@ -55,13 +55,13 @@ class ProfileGridForSearch extends StatelessWidget { isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).orders, - TranslationBase.of(context).prescription, + TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, - TranslationBase.of(context).prescription +"Elham", + TranslationBase.of(context).prescription, ORDER_PRESCRIPTION_NEW_By_Elham, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), diff --git a/lib/screens/prescription/new_prescriptions_page.dart b/lib/screens/prescription/new_prescriptions_page.dart index d672ad7c..71653de9 100644 --- a/lib/screens/prescription/new_prescriptions_page.dart +++ b/lib/screens/prescription/new_prescriptions_page.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -11,8 +12,10 @@ import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; @@ -26,188 +29,152 @@ class NewPrescriptionsPage extends StatelessWidget { Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; - String patientType = routeArgs['patientType']; - String arrivalType = routeArgs['arrivalType']; bool isInpatient = routeArgs['isInpatient']; bool isFromLiveCare = routeArgs['isFromLiveCare']; return BaseView( - onModelReady: (model) async { - model.getPrescriptionListNew( - mrn: patient.patientMRN, appNo: patient.appointmentNo); - }, - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: true, - backgroundColor: Colors.grey[100], - appBar: PatientProfileAppBar( - patient, - isInpatient: isInpatient, - ), - body: patient.admissionNo == null - ? FractionallySizedBox( - widthFactor: 1.0, - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 12, - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ServiceTitle( - title: TranslationBase.of(context).orders, - subTitle: - TranslationBase.of(context).prescriptions, - ), - ], - ), - ), - if ((patient.patientStatusType != null && - patient.patientStatusType == 43) || - (isFromLiveCare && patient.appointmentNo != null)) - AddNewOrder( - onTap: () { - Navigator.push( - context, - SlideUpPageRoute( - widget: BaseAddProcedureTabPage( - patient: patient, - prescriptionModel: model, - procedureType: - ProcedureType.PRESCRIPTION, - ), - settingRoute: 'AddProcedureTabPage'), - ); - }, - label: TranslationBase.of(context) - .applyForNewPrescriptionsOrder, - ), - ListView.builder( - physics: BouncingScrollPhysics(), - itemCount: model.prescriptionsList.length, - shrinkWrap: true, - itemBuilder: (BuildContext ctxt, int index) { - return InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: PrescriptionItemsPage( - prescriptions: model - .prescriptionsList[index], - patient: patient, - arrivalType: arrivalType, - ), - ), - ), - child: Column( - children: [ - DoctorCard( - doctorName: - Helpers.convertToTitleCase(model - .prescriptionsList[index] - .doctorName), - profileUrl: model - .prescriptionsList[index] - .doctorImageURL, - branch: model - .prescriptionsList[index].name, - clinic: model.prescriptionsList[index] - .clinicDescription, - isPrescriptions: true, - appointmentDate: AppDateUtils - .getDateTimeFromServerFormat( - model.prescriptionsList[index] - .appointmentDate, - ), - ), - ], - )); - }), - if (model.prescriptionsList.isEmpty && - patient.patientStatusType != 43) - Center( - child: ErrorMessage( - error: TranslationBase.of(context) - .noPrescriptionsFound, - )) - ], - ), + onModelReady: (model) async { + model.getPrescriptionListNew( + mrn: patient.patientMRN, appNo: patient.appointmentNo); + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + backgroundColor: Colors.grey[100], + appBar: PatientProfileAppBar( + patient, + isInpatient: isInpatient, + ), + body: FractionallySizedBox( + widthFactor: 1.0, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 12, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ServiceTitle( + title: TranslationBase.of(context).orders, + subTitle: TranslationBase.of(context).prescriptions, + ), + ], + ), + ), + if ((patient.patientStatusType != null && + patient.patientStatusType == 43) || + (isFromLiveCare && patient.appointmentNo != null)) + AddNewOrder( + onTap: () { + Navigator.push( + context, + SlideUpPageRoute( + widget: BaseAddProcedureTabPage( + patient: patient, + prescriptionModel: model, + procedureType: ProcedureType.PRESCRIPTION, + ), + settingRoute: 'AddProcedureTabPage'), + ); + }, + label: TranslationBase.of(context) + .applyForNewPrescriptionsOrder, ), - ) - : NetworkBaseView( - baseViewModel: model, + Center( child: FractionallySizedBox( - widthFactor: 1.0, - child: ListView( - physics: BouncingScrollPhysics(), - children: [ - model.medicationForInPatient.length == 0 - ? Center( - child: ErrorMessage( - error: TranslationBase.of(context) - .noPrescriptionsFound, - )) - : ListView.builder( - scrollDirection: Axis.vertical, - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemCount: - model.medicationForInPatient.length, - itemBuilder: (context, index) { - //model.medicationForInPatient.length, - return InkWell( - child: InPatientDoctorCard( - doctorName: Helpers.convertToTitleCase( - model.medicationForInPatient[index] - .pHRItemDescription), - profileUrl: 'sss', - branch: 'hamza', - clinic: 'basheer', - isPrescriptions: true, - appointmentDate: AppDateUtils - .getDateTimeFromServerFormat( - model.medicationForInPatient[index] - .prescriptionDatetime, - ), - createdBy: Helpers.convertToTitleCase( - model.medicationForInPatient[index] - .doctorName - .toString()), - ), - onTap: () => Navigator.push( - context, - FadePage( - page: PrescriptionItemsInPatientPage( - prescriptionIndex: index, - prescriptions: model - .medicationForInPatient[index], - patient: patient, - patientType: patientType, - arrivalType: arrivalType, - startOn: AppDateUtils - .getDateTimeFromServerFormat( - model - .medicationForInPatient[index] - .startDatetime, - ), - stopOn: AppDateUtils - .getDateTimeFromServerFormat( - model - .medicationForInPatient[index] - .stopDatetime, - ), - ), - ), - ), - ); - }), - ], - ), + widthFactor: 0.92, + child: ListView.builder( + physics: BouncingScrollPhysics(), + itemCount: model.prescriptionListNew.length, + shrinkWrap: true, + itemBuilder: (BuildContext ctxt, int index) { + return InkWell( + child: CardWithBgWidget( + bgColor: Colors.transparent, + widget: Column( + children: [ + CustomRow( + label: "", + value: Helpers.convertToTitleCase(model + .prescriptionListNew[index] + .medicationName), + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.5, + ), + SizedBox( + height: 10, + ), + CustomRow( + label: "Doctor Name :", + value: model + .prescriptionListNew[index].doctorName, + ), + CustomRow( + label: "Order Type Description :", + value: model.prescriptionListNew[index] + .orderTypeDescription, + ), + CustomRow( + label: "status :", + value: + model.prescriptionListNew[index].status, + ), + CustomRow( + label: "indication :", + value: model + .prescriptionListNew[index].indication, + ), + CustomRow( + label: "doseDetail :", + value: model + .prescriptionListNew[index].doseDetail, + ), + CustomRow( + label: "quantity :", + value: model + .prescriptionListNew[index].quantity + .toString(), + ),CustomRow( + label: "start Date :", + value: model + .prescriptionListNew[index].startDate + .toString(), + ),CustomRow( + label: "stop Date :", + value: model + .prescriptionListNew[index].stopDate + .toString(), + ), + if(model + .prescriptionListNew[index].remarks != null&& model + .prescriptionListNew[index].remarks!= "") + CustomRow( + label: "Remark :", + value: model + .prescriptionListNew[index].remarks + .toString(), + ), + ], + ), + )); + }), ), - ))); + ), + if (model.prescriptionListNew.isEmpty && + patient.patientStatusType != 43) + Center( + child: ErrorMessage( + error: TranslationBase.of(context).noPrescriptionsFound, + )) + ], + ), + ), + )), + ); } } diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index f2382a88..43ae8e56 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1709,6 +1709,7 @@ class TranslationBase { String get thousandIsTheMAXForTheStrength => localizedValues['thousandIsTheMAXForTheStrength'][locale.languageCode]; String get strengthCanNotBeZero => localizedValues['strengthCanNotBeZero'][locale.languageCode]; + String get old => localizedValues['old'][locale.languageCode]; } diff --git a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart index 21618fd7..48a96bf0 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart @@ -77,7 +77,7 @@ class ProfileMedicalInfoWidgetInPatient extends StatelessWidget { arrivalType: arrivalType, route: ORDER_PRESCRIPTION_NEW, nameLine1: TranslationBase.of(context).patient, - nameLine2: TranslationBase.of(context).prescription, + nameLine2:TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', icon: 'assets/images/svgs/profile_screen/order prescription.svg'), PatientProfileButton( key: key, @@ -86,7 +86,7 @@ class ProfileMedicalInfoWidgetInPatient extends StatelessWidget { arrivalType: arrivalType, route: ORDER_PRESCRIPTION_NEW_By_Elham, nameLine1: TranslationBase.of(context).patient, - nameLine2: TranslationBase.of(context).prescription +"Elham", + nameLine2: TranslationBase.of(context).prescription, icon: 'assets/images/svgs/profile_screen/order prescription.svg'), PatientProfileButton( key: key, From ba62056c4dd837eae2b6b9ae42cf826ee2f49d0e Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 16 Feb 2022 13:17:04 +0200 Subject: [PATCH 23/25] finish add Prescription --- lib/config/localized_values.dart | 2 +- lib/routes.dart | 8 +- .../profile_gird_for_InPatient.dart | 4 +- .../profile_gird_for_other.dart | 4 +- .../profile_gird_for_search.dart | 4 +- .../add_drug/add_drug_widget.dart | 153 ++++++++++-------- .../prescription_form_widget.dart | 2 - ..._page.dart => old_prescriptions_page.dart} | 26 +-- .../procedures/add-favourite-procedure.dart | 68 ++++---- .../profile/profile_medical_info_widget.dart | 2 +- ...rofile_medical_info_widget_in_patient.dart | 4 +- .../profile_medical_info_widget_search.dart | 2 +- 12 files changed, 139 insertions(+), 140 deletions(-) rename lib/screens/prescription/{prescriptions_page.dart => old_prescriptions_page.dart} (89%) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 6dcf5968..cac9883a 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1129,7 +1129,7 @@ const Map> localizedValues = { "VTE_Type": {"en": "VTE Type", "ar": "VTE Type"}, "pharmacology": {"en": "Pharmacology", "ar": "علم العقاقير"}, "reasonsThrombo": {"en": "Reasons Thrombo", "ar": "أسباب ثرومبو"}, - "youDoNotHaveFavoritePrescription": {"en": "you Don't Have Favorite Prescription", "ar": "ليس لديك وصفة طبية مفضلة"}, + "youDoNotHaveFavoritePrescription": {"en": "You Don't Have Favorite Prescription", "ar": "ليس لديك وصفة طبية مفضلة"}, "pleaseSelectItem": {"en": "please Select Item", "ar": "الرجاء اختيار عنصر"}, "searchFavoriteTemplate": {"en": "search Favorites Template", "ar": "البحث في قالب المفضلة"}, "sorryNoMatch": {"en": "Sorry No Match", "ar": "عذرا لا يوجد تطابق"}, diff --git a/lib/routes.dart b/lib/routes.dart index c50504a7..917b1c6c 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -25,7 +25,7 @@ import 'package:doctor_app_flutter/screens/patients/profile/referral/refer-patie import 'package:doctor_app_flutter/screens/patients/profile/soap_update/update_soap_index.dart'; import 'package:doctor_app_flutter/screens/patients/profile/vte_assessment/vte_assessment_screen.dart'; import 'package:doctor_app_flutter/screens/prescription/new_prescriptions_page.dart'; -import 'package:doctor_app_flutter/screens/prescription/prescriptions_page.dart'; +import 'package:doctor_app_flutter/screens/prescription/old_prescriptions_page.dart'; import 'package:doctor_app_flutter/screens/procedures/procedure_screen.dart'; import './screens/auth/login_screen.dart'; @@ -71,8 +71,8 @@ const String PATIENT_UCAF_REQUEST = 'patients/ucaf'; const String PATIENT_UCAF_DETAIL = 'patients/ucaf/detail'; const String PATIENT_ECG = 'patients/ecg'; const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; +const String ORDER_PRESCRIPTION_OLD = 'prescription/prescription_old'; const String ORDER_PRESCRIPTION_NEW = 'prescription/prescription_new'; -const String ORDER_PRESCRIPTION_NEW_By_Elham = 'prescription/prescription_new_elham'; const String ORDER_PROCEDURE = 'procedure/procedure'; const String ADD_SICKLEAVE = 'add-sickleave'; const String RADIOLOGY_PATIENT = 'radiology-patient'; @@ -125,8 +125,8 @@ var routes = { ), IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), ADD_SICKLEAVE: (_) => PatientSickLeaveScreen(), - ORDER_PRESCRIPTION_NEW: (_) => PrescriptionsPage(), - ORDER_PRESCRIPTION_NEW_By_Elham: (_) => NewPrescriptionsPage(), + ORDER_PRESCRIPTION_OLD: (_) => OldPrescriptionsPage(), + ORDER_PRESCRIPTION_NEW: (_) => NewPrescriptionsPage(), ORDER_PROCEDURE: (_) => ProcedureScreen(), MY_REFERRAL_DETAIL: (_) => MyReferralDetailScreen(), PATIENT_UCAF_REQUEST: (_) => UCAFPagerScreen(), diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart index ed9e2c1d..d4c20025 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart @@ -61,13 +61,13 @@ class ProfileGridForInPatient extends StatelessWidget { PatientProfileCardModel( TranslationBase.of(context).patient, TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', - ORDER_PRESCRIPTION_NEW, + ORDER_PRESCRIPTION_OLD, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, TranslationBase.of(context).prescription, - ORDER_PRESCRIPTION_NEW_By_Elham, + ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart index 0ff600a6..b2f844dd 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart @@ -59,13 +59,13 @@ class ProfileGridForOther extends StatelessWidget { PatientProfileCardModel( TranslationBase.of(context).orders, TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', - ORDER_PRESCRIPTION_NEW, + ORDER_PRESCRIPTION_OLD, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, TranslationBase.of(context).prescription, - ORDER_PRESCRIPTION_NEW_By_Elham, + ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart index 21f5823e..8e54c8ca 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart @@ -56,13 +56,13 @@ class ProfileGridForSearch extends StatelessWidget { PatientProfileCardModel( TranslationBase.of(context).orders, TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', - ORDER_PRESCRIPTION_NEW, + ORDER_PRESCRIPTION_OLD, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, TranslationBase.of(context).prescription, - ORDER_PRESCRIPTION_NEW_By_Elham, + ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( diff --git a/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart index 8ce52a43..854ec4ae 100644 --- a/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart @@ -34,9 +34,25 @@ class AddDrugWidget extends StatefulWidget { final String instruction; final DateTime selectedDate; - const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel, - this.modelPrescription, this.units, this.route, this.frequency, this.duration, this.doseTime, - this.uom, this.x, this.selectedMedication, this.strength, this.indication, this.instruction, this.selectedDate}) : super(key: key); + const AddDrugWidget( + {Key key, + this.patient, + this.prescriptionList, + this.medicineModel, + this.modelPrescription, + this.units, + this.route, + this.frequency, + this.duration, + this.doseTime, + this.uom, + this.x, + this.selectedMedication, + this.strength, + this.indication, + this.instruction, + this.selectedDate}) + : super(key: key); @override _AddDrugWidgetState createState() => _AddDrugWidgetState(); @@ -47,75 +63,84 @@ class _AddDrugWidgetState extends State { Widget build(BuildContext context) { return AppScaffold( baseViewModel: widget.medicineModel, - appBar: BottomSheetTitle( - title: TranslationBase.of(context).addMedication), + appBar: + BottomSheetTitle(title: TranslationBase.of(context).addMedication), body: Container( height: SizeConfig.realScreenHeight * .8, width: SizeConfig.realScreenWidth, child: SingleChildScrollView( child: Column( - children: [ - DrugToDrug( - widget.patient, - widget.medicineModel.getPrescriptionForDrug( - widget.prescriptionList, widget.medicineModel - ), - widget.medicineModel.patientAssessmentList), - ], - )), + children: [ + DrugToDrug( + widget.patient, + widget.medicineModel.getPrescriptionForDrug( + widget.prescriptionList, widget.medicineModel), + widget.medicineModel.patientAssessmentList), + ], + )), ), - bottomSheet: widget.medicineModel.state == ViewState.BusyLocal || widget.medicineModel.state == ViewState.Busy + bottomSheet: widget.medicineModel.state == ViewState.BusyLocal || + widget.medicineModel.state == ViewState.Busy ? Container( - height: 0, - ) + height: 0, + ) : BottomSheetDialogButton( - label: TranslationBase.of(context).addMedication, - onTap: () async { - GifLoaderDialogUtils.showMyDialog(context); - await widget.medicineModel.postPrescription( - isLocalBusy: true, - icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty - ? widget.medicineModel.patientAssessmentList[0].icdCode10ID - .isEmpty - ? "test" - : widget.medicineModel.patientAssessmentList[0].icdCode10ID - .toString() - : "test", - dose: widget.strength, - doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1 - ? widget.medicineModel.itemMedicineListUnit[0]['parameterCode'] - .toString() - : widget.units['parameterCode'].toString(), - patient: widget.patient, - doseTimeIn: widget.doseTime['id'].toString(), - model: widget.modelPrescription, - duration: widget.duration['id'].toString(), - frequency: widget.medicineModel.itemMedicineList.length == 1 - ? widget.medicineModel.itemMedicineList[0]['parameterCode'] - .toString() - : widget.frequency['parameterCode'].toString(), - route: widget.medicineModel.itemMedicineListRoute.length == 1 - ? widget.medicineModel.itemMedicineListRoute[0]['parameterCode'] - .toString() - : widget.route['parameterCode'].toString(), - drugId: widget.selectedMedication.itemId.toString(), - strength: widget.strength, - indication: widget.indication, - instruction: widget.instruction, - doseTime: widget.selectedDate, - ); - if (widget.medicineModel.state == ViewState.ErrorLocal) { - GifLoaderDialogUtils.hideDialog(context); - Helpers.showErrorToast(widget.medicineModel.error); - } else if (widget.modelPrescription.state == ViewState.Idle) { - widget.modelPrescription.getPrescriptions(widget.patient); - GifLoaderDialogUtils.hideDialog(context); - DrAppToastMsg.showSuccesToast(TranslationBase.of(context).medicationHasBeenAdded); - Navigator.of(context).pop(); - Navigator.of(context).pop(); - } - }, - ), + label: TranslationBase.of(context).addMedication, + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + await widget.medicineModel.postPrescription( + isLocalBusy: true, + icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty + ? widget.medicineModel.patientAssessmentList[0] + .icdCode10ID.isEmpty + ? "test" + : widget.medicineModel.patientAssessmentList[0] + .icdCode10ID + .toString() + : "test", + dose: widget.strength, + doseUnit: + widget.medicineModel.itemMedicineListUnit.length == 1 + ? widget.medicineModel + .itemMedicineListUnit[0]['parameterCode'] + .toString() + : widget.units['parameterCode'].toString(), + patient: widget.patient, + doseTimeIn: widget.doseTime['id'].toString(), + model: widget.modelPrescription, + duration: widget.duration['id'].toString(), + frequency: widget.medicineModel.itemMedicineList.length == 1 + ? widget + .medicineModel.itemMedicineList[0]['parameterCode'] + .toString() + : widget.frequency['parameterCode'].toString(), + route: widget.medicineModel.itemMedicineListRoute.length == 1 + ? widget.medicineModel + .itemMedicineListRoute[0]['parameterCode'] + .toString() + : widget.route['parameterCode'].toString(), + drugId: widget.selectedMedication.itemId.toString(), + strength: widget.strength, + indication: widget.indication, + instruction: widget.instruction, + doseTime: widget.selectedDate, + ); + if (widget.medicineModel.state == ViewState.ErrorLocal) { + GifLoaderDialogUtils.hideDialog(context); + Helpers.showErrorToast(widget.medicineModel.error); + } else if (widget.modelPrescription.state == ViewState.Idle) { + await widget.modelPrescription.getPrescriptionListNew( + appNo: widget.patient.appointmentNo, + mrn: widget.patient.patientMRN, + isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context).medicationHasBeenAdded); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + } + }, + ), ); } } diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index 39c9d171..13ec5a15 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -68,8 +68,6 @@ class _PrescriptionFormWidgetState extends State { final myController = TextEditingController(); DateTime selectedDate; int strengthChar; - PrescriptionViewModel prescriptionViewModel; - GlobalKey key = new GlobalKey>(); diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/old_prescriptions_page.dart similarity index 89% rename from lib/screens/prescription/prescriptions_page.dart rename to lib/screens/prescription/old_prescriptions_page.dart index 43083f60..c969397d 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/old_prescriptions_page.dart @@ -21,8 +21,7 @@ import 'package:flutter/material.dart'; import '../../util/helpers.dart'; import '../../widgets/shared/errors/error_message.dart'; -///TODO Elham* the design should be fixed By roaa -class PrescriptionsPage extends StatelessWidget { +class OldPrescriptionsPage extends StatelessWidget { @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; @@ -64,31 +63,12 @@ class PrescriptionsPage extends StatelessWidget { ServiceTitle( title: TranslationBase.of(context).orders, subTitle: TranslationBase.of(context) - .prescriptions, + .prescriptions + "(${TranslationBase.of(context) + .old }) ", ), ], ), ), - if ((patient.patientStatusType != null && - patient.patientStatusType == 43) || - (isFromLiveCare && patient.appointmentNo != null)) - AddNewOrder( - onTap: () { - Navigator.push( - context, - SlideUpPageRoute( - widget: BaseAddProcedureTabPage( - patient: patient, - prescriptionModel: model, - procedureType: - ProcedureType.PRESCRIPTION, - ), - settingRoute: 'AddProcedureTabPage'), - ); - }, - label: TranslationBase.of(context) - .applyForNewPrescriptionsOrder, - ), ListView.builder( physics: BouncingScrollPhysics(), itemCount: model.prescriptionsList.length, diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index c062d69b..85261de2 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; @@ -50,43 +51,38 @@ class _AddFavouriteProcedureState extends State { AppScaffold( isShowAppBar: false, baseViewModel: model, - body: Column( - children: [ - (widget.previousProcedureViewModel.templateList.length != 0) - ? Expanded( - child: EntityListCheckboxSearchFavProceduresWidget( - isProcedure: !(widget.procedureType == - ProcedureType.PRESCRIPTION), - model: widget.previousProcedureViewModel, - removeFavProcedure: (item) { - setState(() { - entityList.remove(item); - }); - }, - addFavProcedure: (history) { - setState(() { - entityList.add(history); - }); - }, - isEntityFavListSelected: (master) => - isEntityListSelected(master), - groupProcedures: groupProcedures, - selectProcedures: (selectedProcedure) { - setState(() { - groupProcedures = selectedProcedure; - }); - }, - ), - ) - : Container( - child: Padding( - padding: EdgeInsets.symmetric(vertical: 50.0), - child: AppText( - TranslationBase.of(context).youDoNotHaveFavoritePrescription,), - ), + body: Column(children: [ + (widget.previousProcedureViewModel.templateList.length != 0) + ? Expanded( + child: EntityListCheckboxSearchFavProceduresWidget( + isProcedure: !(widget.procedureType == + ProcedureType.PRESCRIPTION), + model: widget.previousProcedureViewModel, + removeFavProcedure: (item) { + setState(() { + entityList.remove(item); + }); + }, + addFavProcedure: (history) { + setState(() { + entityList.add(history); + }); + }, + isEntityFavListSelected: (master) => + isEntityListSelected(master), + groupProcedures: groupProcedures, + selectProcedures: (selectedProcedure) { + setState(() { + groupProcedures = selectedProcedure; + }); + }, ), - ], - ), + ) + : ErrorMessage( + error: TranslationBase.of(context) + .youDoNotHaveFavoritePrescription, + ), + ]), bottomSheet: BottomSheetDialogButton( label: widget.procedureType.getAddButtonTitle(context) ?? TranslationBase.of(context).addSelectedProcedures, diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 4869ca9d..abf548ed 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -102,7 +102,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: ORDER_PRESCRIPTION_NEW, + route: ORDER_PRESCRIPTION_OLD, nameLine1: TranslationBase.of(context).orders, nameLine2: TranslationBase.of(context).prescription, icon: 'assets/images/svgs/profile_screen/order prescription.svg'), diff --git a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart index 48a96bf0..9de84de2 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart @@ -75,7 +75,7 @@ class ProfileMedicalInfoWidgetInPatient extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: ORDER_PRESCRIPTION_NEW, + route: ORDER_PRESCRIPTION_OLD, nameLine1: TranslationBase.of(context).patient, nameLine2:TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', icon: 'assets/images/svgs/profile_screen/order prescription.svg'), @@ -84,7 +84,7 @@ class ProfileMedicalInfoWidgetInPatient extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: ORDER_PRESCRIPTION_NEW_By_Elham, + route: ORDER_PRESCRIPTION_NEW, nameLine1: TranslationBase.of(context).patient, nameLine2: TranslationBase.of(context).prescription, icon: 'assets/images/svgs/profile_screen/order prescription.svg'), diff --git a/lib/widgets/patients/profile/profile_medical_info_widget_search.dart b/lib/widgets/patients/profile/profile_medical_info_widget_search.dart index 41063bdf..297b9d75 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget_search.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget_search.dart @@ -114,7 +114,7 @@ class ProfileMedicalInfoWidgetSearch extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: ORDER_PRESCRIPTION_NEW, + route: ORDER_PRESCRIPTION_OLD, nameLine1: TranslationBase.of(context).orders, nameLine2: TranslationBase.of(context).prescription, icon: From ada10f595a7b9ea94c6469efd4f1e86d6da58d4b Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 16 Feb 2022 14:51:37 +0200 Subject: [PATCH 24/25] finish add Prescription --- lib/screens/prescription/prescription_text_filed.dart | 2 +- lib/widgets/shared/dialogs/dailog-list-select.dart | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/screens/prescription/prescription_text_filed.dart b/lib/screens/prescription/prescription_text_filed.dart index 8f2676bc..95b70182 100644 --- a/lib/screens/prescription/prescription_text_filed.dart +++ b/lib/screens/prescription/prescription_text_filed.dart @@ -44,7 +44,7 @@ class _PrescriptionTextFiledState extends State { list: widget.elementList, attributeName: '${widget.keyName}', attributeValueId: widget.elementList.length == 1 - ? widget.elementList[0]['${widget.keyId}'] + ? widget.elementList[0]['${widget.keyId}'].toString() : '${widget.keyId}', okText: TranslationBase.of(context).ok, okFunction: (selectedValue) => diff --git a/lib/widgets/shared/dialogs/dailog-list-select.dart b/lib/widgets/shared/dialogs/dailog-list-select.dart index 01849e5b..aa03320d 100644 --- a/lib/widgets/shared/dialogs/dailog-list-select.dart +++ b/lib/widgets/shared/dialogs/dailog-list-select.dart @@ -46,7 +46,6 @@ class _ListSelectDialogState extends State { } showAlertDialog(BuildContext context) { - // set up the buttons Widget cancelButton = FlatButton( child: Text(TranslationBase.of(context).cancel), onPressed: () { @@ -58,9 +57,7 @@ class _ListSelectDialogState extends State { Navigator.of(context).pop(); this.widget.okFunction(widget.selectedValue); }); -// set up the AlertDialog AlertDialog alert = AlertDialog( - // title: Text(widget.title), content: createDialogList(), actions: [ cancelButton, From b1ddd9935c3771a1e976d159105970d1d8bd8112 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 17 Feb 2022 10:11:43 +0200 Subject: [PATCH 25/25] finish add Prescription --- .../prescription/new_prescriptions_page.dart | 2 +- .../prescription/old_prescriptions_page.dart | 89 ++++++++++++++----- 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/lib/screens/prescription/new_prescriptions_page.dart b/lib/screens/prescription/new_prescriptions_page.dart index 71653de9..e5403139 100644 --- a/lib/screens/prescription/new_prescriptions_page.dart +++ b/lib/screens/prescription/new_prescriptions_page.dart @@ -161,7 +161,7 @@ class NewPrescriptionsPage extends StatelessWidget { ), ], ), - )); + ),); }), ), ), diff --git a/lib/screens/prescription/old_prescriptions_page.dart b/lib/screens/prescription/old_prescriptions_page.dart index c969397d..19d12416 100644 --- a/lib/screens/prescription/old_prescriptions_page.dart +++ b/lib/screens/prescription/old_prescriptions_page.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -11,8 +12,10 @@ import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; @@ -121,14 +124,22 @@ class OldPrescriptionsPage extends StatelessWidget { ), ), ) - : NetworkBaseView( - baseViewModel: model, - child: FractionallySizedBox( - widthFactor: 1.0, - child: ListView( - physics: BouncingScrollPhysics(), + : Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - + SizedBox( + height: 12, + ), + ServiceTitle( + title: TranslationBase.of(context).orders, + subTitle: TranslationBase.of(context) + .prescriptions + "(${TranslationBase.of(context) + .old }) ", + ), model.medicationForInPatient.length == 0? Center( child: ErrorMessage( @@ -142,23 +153,52 @@ class OldPrescriptionsPage extends StatelessWidget { itemBuilder: (context, index) { //model.medicationForInPatient.length, return InkWell( - child: InPatientDoctorCard( - doctorName: Helpers.convertToTitleCase(model - .medicationForInPatient[index] - .pHRItemDescription), - profileUrl: 'sss', - branch: 'hamza', - clinic: 'basheer', - isPrescriptions: true, - appointmentDate: AppDateUtils - .getDateTimeFromServerFormat( - model.medicationForInPatient[index] - .prescriptionDatetime, + child: CardWithBgWidget( + bgColor: Colors.transparent, + widget: Column( + children: [ + CustomRow( + label: "", + value: Helpers.convertToTitleCase(model + .medicationForInPatient[index] + .pHRItemDescription), + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.5, + ), + SizedBox( + height: 10, + ), + CustomRow( + label: "Doctor Name :", + value: Helpers.convertToTitleCase(model + .medicationForInPatient[index] + .doctorName + .toString()), + ), + CustomRow( + label: "Status :", + value: Helpers.convertToTitleCase(model + .medicationForInPatient[index] + .statusDescription + .toString()), + ), + CustomRow( + label: "dose :", + value: Helpers.convertToTitleCase(model + .medicationForInPatient[index] + .dose + .toString()), + ), CustomRow( + label: "comments :", + value: Helpers.convertToTitleCase(model + .medicationForInPatient[index] + .comments + .toString()), + ), + + ], ), - createdBy: Helpers.convertToTitleCase(model - .medicationForInPatient[index] - .doctorName - .toString()), ), onTap: () => Navigator.push( context, @@ -188,6 +228,7 @@ class OldPrescriptionsPage extends StatelessWidget { ], ), ), - ))); + ), + ))); } }