From 70573d190a14c3e22202940a9af049f8d78dd894 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 14 Apr 2022 10:18:21 +0300 Subject: [PATCH] first step from procedures --- .../procedure_valadate_request_model.dart | 6 +- .../procedure/procedure_service.dart | 6 +- lib/core/viewModel/procedure_View_model.dart | 28 +- .../profile/lab_result/labs_home_page.dart | 2 +- .../radiology/radiology_home_page.dart | 2 +- .../base_add_procedure_tab_page.dart | 19 +- .../add_favourite_procedure.dart | 3 +- .../procedure_checkout_screen.dart | 286 ++++++++---------- lib/screens/procedures/procedure_screen.dart | 21 +- 9 files changed, 177 insertions(+), 196 deletions(-) diff --git a/lib/core/model/procedure/procedure_valadate_request_model.dart b/lib/core/model/procedure/procedure_valadate_request_model.dart index 0b872b93..93aafbcf 100644 --- a/lib/core/model/procedure/procedure_valadate_request_model.dart +++ b/lib/core/model/procedure/procedure_valadate_request_model.dart @@ -1,18 +1,18 @@ -class ProcedureValadteRequestModel { +class ProcedureValidationRequestModel { String vidaAuthTokenID; int patientMRN; int appointmentNo; int episodeID; List procedure; - ProcedureValadteRequestModel( + ProcedureValidationRequestModel( {this.vidaAuthTokenID, this.patientMRN, this.appointmentNo, this.episodeID, this.procedure}); - ProcedureValadteRequestModel.fromJson(Map json) { + ProcedureValidationRequestModel.fromJson(Map json) { vidaAuthTokenID = json['VidaAuthTokenID']; patientMRN = json['PatientMRN']; appointmentNo = json['AppointmentNo']; 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 8370e968..2c923694 100644 --- a/lib/core/service/patient_medical_file/procedure/procedure_service.dart +++ b/lib/core/service/patient_medical_file/procedure/procedure_service.dart @@ -183,8 +183,8 @@ class ProcedureService extends BaseService { }, body: updateProcedureRequestModel.toJson()); } - Future valadteProcedure( - ProcedureValadteRequestModel procedureValadteRequestModel) async { + Future validationProcedure( + ProcedureValidationRequestModel validationProcedureRequestModel) async { hasError = false; _valadteProcedureList.clear(); await baseAppClient.post(GET_PROCEDURE_VALIDATION, @@ -194,6 +194,6 @@ class ProcedureService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: procedureValadteRequestModel.toJson()); + }, body: validationProcedureRequestModel.toJson()); } } diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index e433f54e..269aeefd 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/filter_type.dart'; import 'package:doctor_app_flutter/core/enum/view_state.dart'; import 'package:doctor_app_flutter/core/model/labs/lab_order_result.dart'; @@ -167,9 +168,9 @@ class ProcedureViewModel extends BaseViewModel { } Future postProcedure( - PostProcedureReqModel postProcedureReqModel, int mrn) async { + PostProcedureReqModel postProcedureReqModel, int mrn, {bool isLocalBusy = false}) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); + if(isLocalBusy) setState(ViewState.BusyLocal); else setState(ViewState.Busy); await _procedureService.postProcedure(postProcedureReqModel); if (_procedureService.hasError) { @@ -181,12 +182,12 @@ class ProcedureViewModel extends BaseViewModel { } } - Future valadteProcedure( - ProcedureValadteRequestModel procedureValadteRequestModel) async { + Future validationProcedure( + ProcedureValidationRequestModel procedureValadteRequestModel) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); - await _procedureService.valadteProcedure(procedureValadteRequestModel); + await _procedureService.validationProcedure(procedureValadteRequestModel); if (_procedureService.hasError) { error = _procedureService.error; setState(ViewState.ErrorLocal); @@ -381,8 +382,8 @@ class ProcedureViewModel extends BaseViewModel { setState(ViewState.Busy); } PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel(); - ProcedureValadteRequestModel procedureValadteRequestModel = - new ProcedureValadteRequestModel(); + ProcedureValidationRequestModel procedureValadteRequestModel = + new ProcedureValidationRequestModel(); procedureValadteRequestModel.patientMRN = patient.patientMRN; procedureValadteRequestModel.episodeID = patient.episodeNo; procedureValadteRequestModel.appointmentNo = patient.appointmentNo; @@ -415,16 +416,20 @@ class ProcedureViewModel extends BaseViewModel { }); postProcedureReqModel.procedures = controlsProcedure; - await valadteProcedure(procedureValadteRequestModel); + await validationProcedure(procedureValadteRequestModel); if (state == ViewState.Idle) { if (valadteProcedureList[0].entityList.length == 0) { - await postProcedure(postProcedureReqModel, patient.patientMRN); + await postProcedure(postProcedureReqModel, patient.patientMRN, isLocalBusy:isLocalBusy); if (state == ViewState.ErrorLocal) { Utils.showErrorToast(error); getProcedure(mrn: patient.patientMRN); } else if (state == ViewState.Idle) { DrAppToastMsg.showSuccesToast('procedure has been added'); + if(Navigator.canPop(AppGlobal.CONTEX)) + Navigator.pop(AppGlobal.CONTEX); + if(Navigator.canPop(AppGlobal.CONTEX)) + Navigator.pop(AppGlobal.CONTEX); } } else { if (state == ViewState.ErrorLocal) { @@ -464,8 +469,7 @@ class ProcedureViewModel extends BaseViewModel { Future addProcedures(ProcedureViewModel model, List items, PatiantInformtion patient, - TextEditingController remarksController, - {bool isLocalBusy = false,}) async { + TextEditingController remarksController,{bool isLocalBusy = false}) async { if (isLocalBusy) { setState(ViewState.BusyLocal); } else { @@ -489,7 +493,7 @@ class ProcedureViewModel extends BaseViewModel { await model.preparePostProcedure( entityList: entityList, patient: patient, - remarks: remarksController.text); + remarks: remarksController.text, isLocalBusy: isLocalBusy); } diff --git a/lib/screens/patients/profile/lab_result/labs_home_page.dart b/lib/screens/patients/profile/lab_result/labs_home_page.dart index b8684aee..4ac476d0 100644 --- a/lib/screens/patients/profile/lab_result/labs_home_page.dart +++ b/lib/screens/patients/profile/lab_result/labs_home_page.dart @@ -84,7 +84,7 @@ class _LabsHomePageState extends State { MaterialPageRoute( builder: (context) => BaseAddProcedureTabPage( patient: patient, - model: model, + previousProcedureViewModel: model, procedureType: ProcedureType.LAB_RESULT, ), settings: RouteSettings(name: 'AddProcedureTabPage'), diff --git a/lib/screens/patients/profile/radiology/radiology_home_page.dart b/lib/screens/patients/profile/radiology/radiology_home_page.dart index c6be1c21..5978dcf7 100644 --- a/lib/screens/patients/profile/radiology/radiology_home_page.dart +++ b/lib/screens/patients/profile/radiology/radiology_home_page.dart @@ -88,7 +88,7 @@ class _RadiologyHomePageState extends State { SlideUpPageRoute( widget: BaseAddProcedureTabPage( patient: patient, - model: model, + previousProcedureViewModel: model, procedureType: ProcedureType.RADIOLOGY, ), settingRoute: 'AddProcedureTabPage'), diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index 7f37a09c..76b98849 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -14,14 +14,14 @@ import 'package:flutter/material.dart'; class BaseAddProcedureTabPage extends StatefulWidget { - final ProcedureViewModel model; + final ProcedureViewModel previousProcedureViewModel; final PrescriptionViewModel prescriptionModel; final PatiantInformtion patient; final ProcedureType procedureType; const BaseAddProcedureTabPage( {Key key, - this.model, + this.previousProcedureViewModel, this.prescriptionModel, this.patient, @required this.procedureType}) @@ -29,16 +29,15 @@ class BaseAddProcedureTabPage extends StatefulWidget { @override _BaseAddProcedureTabPageState createState() => _BaseAddProcedureTabPageState( - patient: patient, model: model, procedureType: procedureType); + patient: patient, procedureType: procedureType); } class _BaseAddProcedureTabPageState extends State with SingleTickerProviderStateMixin { - final ProcedureViewModel model; final PatiantInformtion patient; final ProcedureType procedureType; - _BaseAddProcedureTabPageState({this.patient, this.model, this.procedureType}); + _BaseAddProcedureTabPageState({this.patient, this.procedureType}); TabController _tabController; int _activeTab = 0; @@ -68,7 +67,11 @@ class _BaseAddProcedureTabPageState extends State return BaseView( onModelReady: (model) async { - await model.getProcedureTemplate(categoryID: widget.procedureType.getCategoryId()); + if(widget.previousProcedureViewModel == null) { + await model.getProcedureTemplate( + categoryID: widget.procedureType.getCategoryId()); + } + }, builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( @@ -118,7 +121,7 @@ class _BaseAddProcedureTabPageState extends State controller: _tabController, children: [ AddFavouriteProcedure( - previousProcedureViewModel: model, + previousProcedureViewModel: widget.previousProcedureViewModel??model, prescriptionModel: widget.prescriptionModel, patient: patient, @@ -133,7 +136,7 @@ class _BaseAddProcedureTabPageState extends State ) else AddProcedurePage( - model: this.model, + model: widget.previousProcedureViewModel, patient: patient, procedureType: procedureType, ), diff --git a/lib/screens/procedures/favorite_procedure/add_favourite_procedure.dart b/lib/screens/procedures/favorite_procedure/add_favourite_procedure.dart index ae98fe96..86f1b801 100644 --- a/lib/screens/procedures/favorite_procedure/add_favourite_procedure.dart +++ b/lib/screens/procedures/favorite_procedure/add_favourite_procedure.dart @@ -48,7 +48,6 @@ class _AddFavouriteProcedureState extends State { Widget child) => AppScaffold( isShowAppBar: false, - baseViewModel: model, body: Column(children: [ (widget.previousProcedureViewModel.templateList.length != 0) ? Expanded( @@ -117,7 +116,7 @@ class _AddFavouriteProcedureState extends State { MaterialPageRoute( builder: (context) => ProcedureCheckOutScreen( items: entityList, - model: model, + previousProcedureViewModel: widget.previousProcedureViewModel, patient: widget.patient, addButtonTitle: widget.procedureType .getAddButtonTitle(context), diff --git a/lib/screens/procedures/favorite_procedure/procedure_checkout_screen.dart b/lib/screens/procedures/favorite_procedure/procedure_checkout_screen.dart index fd579208..eb96aeb6 100644 --- a/lib/screens/procedures/favorite_procedure/procedure_checkout_screen.dart +++ b/lib/screens/procedures/favorite_procedure/procedure_checkout_screen.dart @@ -1,9 +1,12 @@ import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/view_state.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/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -15,14 +18,14 @@ import '../../../config/config.dart'; class ProcedureCheckOutScreen extends StatefulWidget { final List items; - final ProcedureViewModel model; + final ProcedureViewModel previousProcedureViewModel; final PatiantInformtion patient; final String addButtonTitle; final String toolbarTitle; ProcedureCheckOutScreen( {this.items, - this.model, + this.previousProcedureViewModel, this.patient, @required this.addButtonTitle, @required this.toolbarTitle}); @@ -43,170 +46,142 @@ class _ProcedureCheckOutScreenState extends State { builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( backgroundColor: Color(0xffF8F8F8).withOpacity(0.9), - isShowAppBar: false, + isShowAppBar: true, + appBar: PatientSearchHeader( + title: widget.toolbarTitle ?? 'Add Procedure', + ), body: SingleChildScrollView( - child: Column( - children: [ - Container( - height: MediaQuery.of(context).size.height * 0.070, - color: Colors.white, - ), - Container( - color: Colors.white, - child: Padding( - padding: EdgeInsets.all(12.0), - child: Row( - //mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Icon( - Icons.arrow_back_ios_sharp, - size: 24.0, - ), - onTap: () { - Navigator.pop(context); - }, - ), - SizedBox( - width: 5.0, - ), - AppText( - widget.toolbarTitle ?? 'Add Procedure', - fontWeight: FontWeight.w700, - fontSize: 20, - ), - ], + child: Center( + child: FractionallySizedBox( + widthFactor: 0.95, + child: Column( + children: [ + SizedBox( + height: 30, ), - ), - ), - SizedBox( - height: 30, - ), - ListView.builder( - scrollDirection: Axis.vertical, - itemCount: widget.items.length, - shrinkWrap: true, - itemBuilder: (BuildContext ctxt, int index) { - final TextEditingController remarksControllerNew = TextEditingController(text: widget.items[index].remarks); + ListView.builder( + scrollDirection: Axis.vertical, + itemCount: widget.items.length, + physics: BouncingScrollPhysics(), - return Container( - margin: EdgeInsets.only(bottom: 15.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10.0))), - child: ExpansionTile( - initiallyExpanded: true, - title: Row( - children: [ - Icon( - Icons.check_box, - color: Color(0xffD02127), - size: 30.5, - ), - SizedBox( - width: 6.0, + shrinkWrap: true, + itemBuilder: (BuildContext ctxt, int index) { + final TextEditingController remarksControllerNew = TextEditingController(text: widget.items[index].remarks); + + return Container( + margin: EdgeInsets.only(bottom: 15.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.all(Radius.circular(10.0))), + child: ExpansionTile( + initiallyExpanded: true, + title: Row( + children: [ + + Expanded( + child: + AppText(Utils.convertToTitleCase(widget.items[index].procedureName), fontWeight: FontWeight.w700,color: AppGlobal.appTextColor, + )), + ], ), - Expanded( - child: - AppText(widget.items[index].procedureName)), - ], - ), - children: [ - Container( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 11), - child: AppText( - TranslationBase.of(context).orderType, - fontWeight: FontWeight.w700, - color: Color(0xff2B353E), - ), - ), - ], - ), - Row( + children: [ + Container( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Radio( - activeColor: Color(0xFFD02127), - value: 0, - groupValue: - widget.items[index].selectedType, - onChanged: (value) { - widget.items[index].selectedType = 0; - setState(() { - widget.items[index].type = - value.toString(); - }); - }, - ), - AppText( - 'routine', - color: Color(0xff575757), - fontWeight: FontWeight.w600, + Row( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 11), + child: AppText( + TranslationBase.of(context).orderType, + fontWeight: FontWeight.w700, + color: Color(0xff2B353E), + ), + ), + ], ), - Radio( - activeColor: Color(0xFFD02127), - groupValue: - widget.items[index].selectedType, - value: 1, - onChanged: (value) { - widget.items[index].selectedType = 1; - setState(() { - widget.items[index].type = - value.toString(); - }); - }, - ), - AppText( - TranslationBase.of(context).urgent, - color: Color(0xff575757), - fontWeight: FontWeight.w600, + Row( + children: [ + Radio( + activeColor: Color(0xFFD02127), + value: 0, + groupValue: + widget.items[index].selectedType, + onChanged: (value) { + widget.items[index].selectedType = 0; + setState(() { + widget.items[index].type = + value.toString(); + }); + }, + ), + AppText( + 'routine', + color: Color(0xff575757), + fontWeight: FontWeight.w600, + ), + Radio( + activeColor: Color(0xFFD02127), + groupValue: + widget.items[index].selectedType, + value: 1, + onChanged: (value) { + widget.items[index].selectedType = 1; + setState(() { + widget.items[index].type = + value.toString(); + }); + }, + ), + AppText( + TranslationBase.of(context).urgent, + color: Color(0xff575757), + fontWeight: FontWeight.w600, + ), + ], ), ], ), - ], + ), ), - ), - ), - SizedBox( - height: 2.0, - ), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 12, vertical: 15.0), - child: TextFields( - hintText: TranslationBase.of(context).remarks, - controller: remarksControllerNew, - onChanged: (value) { - widget.items[index].remarks = value; - }, - minLines: 3, - maxLines: 5, - borderWidth: 0.5, - borderColor: Colors.grey[500], - ), - ), - SizedBox( - height: 19.0, + SizedBox( + height: 2.0, + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 12, vertical: 15.0), + child: TextFields( + hintText: TranslationBase.of(context).remarks, + controller: remarksControllerNew, + onChanged: (value) { + widget.items[index].remarks = value; + }, + minLines: 3, + maxLines: 5, + borderWidth: 0.5, + borderColor: Colors.grey[500], + ), + ), + SizedBox( + height: 19.0, + ), + //DividerWithSpacesAround(), + ], ), - //DividerWithSpacesAround(), - ], - ), - ); - }), + ); + }), - SizedBox( - height: 90, + SizedBox( + height: 90, + ), + ], ), - ], + ), ), ), bottomSheet: Container( @@ -221,10 +196,7 @@ class _ProcedureCheckOutScreenState extends State { fontWeight: FontWeight.w700, onPressed: () async { GifLoaderDialogUtils.showMyDialog(context); - await widget.model.addProcedures(model, widget.items, widget.patient, remarksController, isLocalBusy: true); - - Navigator.pop(context); - Navigator.pop(context); + await widget.previousProcedureViewModel.addProcedures(widget.previousProcedureViewModel, widget.items, widget.patient, remarksController, isLocalBusy: true); GifLoaderDialogUtils.hideDialog(context); }, ), diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index cb9514f4..8e959d91 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -14,6 +14,7 @@ import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-prof import 'package:doctor_app_flutter/widgets/patients/patient_service_title.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/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/material.dart'; import '../../widgets/shared/errors/error_message.dart'; @@ -57,13 +58,8 @@ class ProcedureScreen extends StatelessWidget { SizedBox( height: 12, ), - if (model.procedureList.length == 0 && - patient.patientStatusType != 43) - ServiceTitle( - title: TranslationBase.of(context).orderTestOr, - subTitle: TranslationBase.of(context).procedure, - ), - if (patient.patientStatusType != null && + if ((model.procedureList.length == 0 && + patient.patientStatusType != 43) || patient.patientStatusType != null && patient.patientStatusType == 43) ServiceTitle( title: TranslationBase.of(context).orderTestOr, @@ -73,13 +69,18 @@ class ProcedureScreen extends StatelessWidget { patient.patientStatusType == 43) || (isFromLiveCare && patient.appointmentNo != null)) AddNewOrder( - onTap: () { + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProcedureTemplate( + categoryID: ProcedureType.PROCEDURE.getCategoryId(), isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push( context, SlideUpPageRoute( widget: BaseAddProcedureTabPage( patient: patient, - model: model, + previousProcedureViewModel: model, procedureType: ProcedureType.PROCEDURE, ), settingRoute: 'AddProcedureTabPage'), @@ -93,6 +94,8 @@ class ProcedureScreen extends StatelessWidget { scrollDirection: Axis.vertical, itemCount: model.procedureList[0].rowcount, shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (BuildContext ctxt, int index) { return ProcedureCard( categoryID: model