From c182928a5d902267904c3896196fd8d7f27c4e21 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 19 May 2021 17:17:09 +0300 Subject: [PATCH 1/3] favourite template Procedure service --- lib/client/base_app_client.dart | 12 +- lib/config/config.dart | 17 +- .../procedures/procedure_checkout_screen.dart | 227 ++++++++++++++++++ lib/screens/procedures/procedure_screen.dart | 14 +- 4 files changed, 254 insertions(+), 16 deletions(-) create mode 100644 lib/screens/procedures/procedure_checkout_screen.dart diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 7336db13..fe7db950 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -24,7 +24,7 @@ class BaseAppClient { bool isAllowAny = false}) async { String url = BASE_URL + endPoint; - bool callLog= true; + bool callLog = true; try { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); @@ -48,7 +48,7 @@ class BaseAppClient { if (body['EditedBy'] == '') { body.remove("EditedBy"); } - body['TokenID'] = token ?? ''; + body['TokenID'] = "@dm!n" ?? ''; String lang = await sharedPref.getString(APP_Language); if (lang != null && lang == 'ar') body['LanguageID'] = 1; @@ -74,9 +74,9 @@ class BaseAppClient { //int projectID = await sharedPref.getInt(PROJECT_ID); //if (projectID == 2 || projectID == 3) - // body['PatientOutSA'] = true; + // body['PatientOutSA'] = true; //else - body['PatientOutSA'] = false; + body['PatientOutSA'] = false; body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; print("URL : $url"); @@ -104,7 +104,9 @@ class BaseAppClient { if (body['OTP_SendType'] != null) { onFailure(getError(parsed), statusCode); } else if (!isAllowAny) { - await Provider.of(AppGlobal.CONTEX, listen: false).logout(); + await Provider.of(AppGlobal.CONTEX, + listen: false) + .logout(); Helpers.showErrorToast('Your session expired Please login again'); } if (isAllowAny) { diff --git a/lib/config/config.dart b/lib/config/config.dart index 0e8106bc..8464f720 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -4,8 +4,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; -// const BASE_URL = 'https://hmgwebservices.com/'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; +//const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = @@ -283,11 +283,14 @@ const GET_SICK_LEAVE_PATIENT = "Services/Patients.svc/REST/GetPatientSickLeave"; const GET_MY_OUT_PATIENT = "Services/DoctorApplication.svc/REST/GetMyOutPatient"; - -const PATIENT_MEDICAL_REPORT_GET_LIST = "Services/Patients.svc/REST/DAPP_ListMedicalReport"; -const PATIENT_MEDICAL_REPORT_GET_TEMPLATE = "Services/Patients.svc/REST/DAPP_GetTemplateByID"; -const PATIENT_MEDICAL_REPORT_INSERT = "Services/Patients.svc/REST/DAPP_InsertMedicalReport"; -const PATIENT_MEDICAL_REPORT_VERIFIED = "Services/Patients.svc/REST/DAPP_VerifiedMedicalReport"; +const PATIENT_MEDICAL_REPORT_GET_LIST = + "Services/Patients.svc/REST/DAPP_ListMedicalReport"; +const PATIENT_MEDICAL_REPORT_GET_TEMPLATE = + "Services/Patients.svc/REST/DAPP_GetTemplateByID"; +const PATIENT_MEDICAL_REPORT_INSERT = + "Services/Patients.svc/REST/DAPP_InsertMedicalReport"; +const PATIENT_MEDICAL_REPORT_VERIFIED = + "Services/Patients.svc/REST/DAPP_VerifiedMedicalReport"; const GET_PROCEDURE_TEMPLETE = 'Services/Doctors.svc/REST/DAPP_ProcedureTemplateGet'; diff --git a/lib/screens/procedures/procedure_checkout_screen.dart b/lib/screens/procedures/procedure_checkout_screen.dart new file mode 100644 index 00000000..04bbaa3a --- /dev/null +++ b/lib/screens/procedures/procedure_checkout_screen.dart @@ -0,0 +1,227 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; +import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.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_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/divider_with_spaces_around.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class ProcedureCheckOutScreen extends StatefulWidget { + @override + _ProcedureCheckOutScreenState createState() => + _ProcedureCheckOutScreenState(); +} + +class _ProcedureCheckOutScreenState extends State { + List items = List(); + List remarksList = List(); + List typeList = List(); + int selectedType = 0; + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + + @override + Widget build(BuildContext context) { + return BaseView( + builder: (BuildContext context, ProcedureViewModel model, Widget child) => + AppScaffold( + backgroundColor: Color(0xffF8F8F8).withOpacity(0.9), + isShowAppBar: false, + body: Column( + children: [ + Container( + height: MediaQuery.of(context).size.height * 0.070, + color: Colors.white, + ), + Container( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.all(15.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( + 'Add Procedure', + fontWeight: FontWeight.w700, + fontSize: 20, + ), + ], + ), + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.022, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: ListView.builder( + scrollDirection: Axis.vertical, + physics: AlwaysScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: 1, + itemBuilder: (BuildContext context, int index) { + return Container( + 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, + ), + AppText('Procedure Name'), + ], + ), + 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: [ + Radio( + activeColor: Color(0xFFD02127), + value: 0, + groupValue: selectedType, + onChanged: (value) { + // historyInfo.type = + // setSelectedType(value).toString(); + // + // historyInfo.type = value.toString(); + }, + ), + AppText( + 'routine', + color: Color(0xff575757), + fontWeight: FontWeight.w600, + ), + Radio( + activeColor: Color(0xFFD02127), + groupValue: selectedType, + value: 1, + onChanged: (value) { + // historyInfo.type = + // setSelectedType(value).toString(); + // + // historyInfo.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: remarksController, + onChanged: (value) { + // historyInfo.remarks = value; + }, + minLines: 3, + maxLines: 5, + borderWidth: 0.5, + borderColor: Colors.grey[500], + ), + ), + SizedBox( + height: 19.0, + ), + //DividerWithSpacesAround(), + ], + ), + ); + }), + ), + ], + ), + bottomSheet: Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context).addSelectedProcedures, + color: Color(0xff359846), + fontWeight: FontWeight.w700, + onPressed: () { + //print(entityList.toString()); + onPressed: + // if (entityList.isEmpty == true) { + // DrAppToastMsg.showErrorToast( + // TranslationBase.of(context) + // .fillTheMandatoryProcedureDetails, + // ); + // return; + // } + + Navigator.pop(context); + // postProcedure( + // orderType: selectedType.toString(), + // entityList: entityList, + // patient: patient, + // model: widget.model, + // remarks: remarksController.text); + }, + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index b964392e..8d03f86c 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/procedures/add-procedure-form.dart'; import 'package:doctor_app_flutter/screens/procedures/add_procedure_homeScreen.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_checkout_screen.dart'; import 'package:doctor_app_flutter/screens/procedures/update-procedure.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; @@ -102,13 +103,18 @@ class ProcedureScreen extends StatelessWidget { patient.patientStatusType == 43) InkWell( onTap: () { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => AddProcedureHome( + // patient: patient, + // model: model, + // )), + // ); Navigator.push( context, MaterialPageRoute( - builder: (context) => AddProcedureHome( - patient: patient, - model: model, - )), + builder: (context) => ProcedureCheckOutScreen()), ); }, child: Container( From 40b4a83c6b3ae9890fbb05e073dd3ede9a13d30e Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Wed, 19 May 2021 17:20:14 +0300 Subject: [PATCH 2/3] Fix Expansion Procedure --- ios/Podfile.lock | 2 +- lib/client/base_app_client.dart | 3 +- lib/config/config.dart | 4 +- lib/core/viewModel/procedure_View_model.dart | 2 +- .../procedures/ExpansionProcedure.dart | 189 ++++++++++++++++++ .../procedures/add-favourite-procedure.dart | 45 +---- .../procedures/entity_list_fav_procedure.dart | 121 +---------- pubspec.lock | 6 +- 8 files changed, 215 insertions(+), 157 deletions(-) create mode 100644 lib/screens/procedures/ExpansionProcedure.dart diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1cf7499c..59cdf14c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -328,4 +328,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 649616dc336b3659ac6b2b25159d8e488e042b69 -COCOAPODS: 1.10.0.rc.1 +COCOAPODS: 1.10.1 diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 7336db13..4b362e35 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -48,7 +48,8 @@ class BaseAppClient { if (body['EditedBy'] == '') { body.remove("EditedBy"); } - body['TokenID'] = token ?? ''; + body['TokenID'] = "@dm!n";// token ?? ''; + // body['TokenID'] = token ?? ''; String lang = await sharedPref.getString(APP_Language); if (lang != null && lang == 'ar') body['LanguageID'] = 1; diff --git a/lib/config/config.dart b/lib/config/config.dart index 0e8106bc..8d5459cc 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -4,8 +4,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; -// const BASE_URL = 'https://hmgwebservices.com/'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; +// const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index 4f9a7cf6..3bdd676f 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -115,7 +115,7 @@ class ProcedureViewModel extends BaseViewModel { tempId = templateId; hasError = false; //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _procedureService.getProcedureTemplateDetails(templateId: templateId); if (_procedureService.hasError) { error = _procedureService.error; diff --git a/lib/screens/procedures/ExpansionProcedure.dart b/lib/screens/procedures/ExpansionProcedure.dart new file mode 100644 index 00000000..188f6634 --- /dev/null +++ b/lib/screens/procedures/ExpansionProcedure.dart @@ -0,0 +1,189 @@ +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/model/procedure/procedure_template_details_request_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.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:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class ExpansionProcedure extends StatefulWidget { + final ProcedureTempleteModel procedureTempleteModel; + final ProcedureViewModel model; + final Function(ProcedureTempleteDetailsModel) removeFavProcedure; + final Function(ProcedureTempleteDetailsModel) addFavProcedure; + final Function(ProcedureTempleteDetailsModel) addProceduresRemarks; + + final bool Function(ProcedureTempleteModel) isEntityListSelected; + final bool Function(ProcedureTempleteDetailsModel) isEntityFavListSelected; + + const ExpansionProcedure( + {Key key, + this.procedureTempleteModel, + this.model, + this.removeFavProcedure, + this.addFavProcedure, + this.addProceduresRemarks, + this.isEntityListSelected, + this.isEntityFavListSelected}) + : super(key: key); + + @override + _ExpansionProcedureState createState() => _ExpansionProcedureState(); +} + +class _ExpansionProcedureState extends State { + bool _isShowMore = false; + List _templateDetailsList = List(); + BaseAppClient baseAppClient = BaseAppClient(); + @override + Widget build(BuildContext context) { + return Column( + children: [ + InkWell( + onTap: () async { + if (!_isShowMore && _templateDetailsList.isEmpty) { + GifLoaderDialogUtils.showMyDialog(context); + await getProcedureTemplateDetails(widget.procedureTempleteModel.templateID); + GifLoaderDialogUtils.hideDialog(context); + } + setState(() { + _isShowMore = !_isShowMore; + }); + }, + child: Container( + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(5.0), + )), + child: Row( + children: [ + Expanded( + child: Row( + children: [ + Icon( + Icons.folder, + size: 20, + color: Color(0xff575757), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, vertical: 0), + child: AppText( + "Procedures for " + + widget.procedureTempleteModel.templateName, + fontSize: 16.0, + variant: "bodyText", + bold: true, + color: Color(0xff575757)), + ), + ), + ], + )), + Container( + width: 25, + height: 25, + child: Icon( + _isShowMore + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down, + color: Colors.grey[800], + size: 22, + ), + ) + ], + ), + ), + ), + if (_isShowMore) + AnimatedContainer( + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(5.0), + bottomRight: Radius.circular(5.0), + )), + duration: Duration(milliseconds: 7000), + child: Column( + children: + _templateDetailsList.map((itemProcedure) { + return Container( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 11), + child: Checkbox( + value: widget + .isEntityFavListSelected(itemProcedure), + activeColor: Color(0xffD02127), + onChanged: (bool newValue) { + setState(() { + if (widget.isEntityFavListSelected(itemProcedure)) { + widget.removeFavProcedure(itemProcedure); + } else { + widget.addFavProcedure(itemProcedure); + } + }); + }), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, vertical: 0), + child: AppText(itemProcedure.procedureName, + fontSize: 14.0, + variant: "bodyText", + bold: true, + color: Color(0xff575757)), + ), + ), + ], + ), + ], + ), + ), + ); + }).toList(), + ), + ), + SizedBox( + height: 10, + ), + ], + ); + } + + getProcedureTemplateDetails(templateId)async { + ProcedureTempleteDetailsRequestModel _procedureTempleteDetailsRequestModel = ProcedureTempleteDetailsRequestModel(templateID: templateId, searchType: 1, patientID: 0); + _templateDetailsList.clear(); + await baseAppClient.post(GET_PROCEDURE_TEMPLETE_DETAILS, + onSuccess: (dynamic response, int statusCode) { + response['HIS_ProcedureTemplateDetailsList'].forEach((template) { + setState(() { + _templateDetailsList.add(ProcedureTempleteDetailsModel.fromJson(template)); + }); + }); + }, onFailure: (String error, int statusCode) { + DrAppToastMsg.showErrorToast(error); + + }, body: _procedureTempleteDetailsRequestModel.toJson()); + } + +} diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index 89a382ad..fe95735d 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -20,15 +20,18 @@ class AddFavouriteProcedure extends StatefulWidget { const AddFavouriteProcedure({Key key, this.model, this.patient}) : super(key: key); + @override _AddFavouriteProcedureState createState() => _AddFavouriteProcedureState(); } class _AddFavouriteProcedureState extends State { _AddFavouriteProcedureState({this.patient, this.model}); + ProcedureViewModel model; PatiantInformtion patient; List entityList = List(); + @override Widget build(BuildContext context) { return BaseView( @@ -49,12 +52,7 @@ class _AddFavouriteProcedureState extends State { Expanded( child: NetworkBaseView( baseViewModel: model, - child: - // selectedCategory != null - // ? selectedCategory['categoryId'] == 02 || - // selectedCategory['categoryId'] == 03 - // ? - EntityListCheckboxSearchFavProceduresWidget( + child: EntityListCheckboxSearchFavProceduresWidget( model: widget.model, masterList: widget.model.procedureTemplate, removeFavProcedure: (item) { @@ -73,30 +71,7 @@ class _AddFavouriteProcedureState extends State { }, isEntityFavListSelected: (master) => isEntityListSelected(master), - ) - // : ProcedureListWidget( - // model: widget.model, - // masterList: widget.model - // .categoriesList[0].entityList, - // removeHistory: (item) { - // setState(() { - // entityList.remove(item); - // }); - // }, - // addHistory: (history) { - // setState(() { - // entityList.add(history); - // }); - // }, - // addSelectedHistories: () { - // //TODO build your fun herr - // // widget.addSelectedHistories(); - // }, - // isEntityListSelected: (master) => - // isEntityListSelected(master), - // ) - // : null, - ), + )), ), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), @@ -108,8 +83,6 @@ class _AddFavouriteProcedureState extends State { color: Color(0xff359846), fontWeight: FontWeight.w700, onPressed: () { - //print(entityList.toString()); - onPressed: if (entityList.isEmpty == true) { DrAppToastMsg.showErrorToast( TranslationBase.of(context) @@ -119,12 +92,6 @@ class _AddFavouriteProcedureState extends State { } Navigator.pop(context); - // postProcedure( - // orderType: selectedType.toString(), - // entityList: entityList, - // patient: patient, - // model: widget.model, - // remarks: remarksController.text); }, ), ], @@ -138,7 +105,7 @@ class _AddFavouriteProcedureState extends State { bool isEntityListSelected(ProcedureTempleteDetailsModel masterKey) { Iterable history = entityList - .where((element) => masterKey.templateID == element.templateID); + .where((element) => masterKey.templateID == element.templateID && masterKey.procedureName == element.procedureName); if (history.length > 0) { return true; } diff --git a/lib/screens/procedures/entity_list_fav_procedure.dart b/lib/screens/procedures/entity_list_fav_procedure.dart index 31b2a784..1dac2f24 100644 --- a/lib/screens/procedures/entity_list_fav_procedure.dart +++ b/lib/screens/procedures/entity_list_fav_procedure.dart @@ -11,6 +11,8 @@ import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'ExpansionProcedure.dart'; + class EntityListCheckboxSearchFavProceduresWidget extends StatefulWidget { final ProcedureViewModel model; final Function addSelectedHistories; @@ -70,6 +72,7 @@ class _EntityListCheckboxSearchFavProceduresWidgetState } TextEditingController remarksController = TextEditingController(); + @override Widget build(BuildContext context) { return Container( @@ -102,116 +105,14 @@ class _EntityListCheckboxSearchFavProceduresWidgetState items.length != 0 ? Column( children: items.map((historyInfo) { - return Column( - children: [ - ExpansionTile( - title: InkWell( - onTap: () { - widget.model - .getProcedureTemplateDetails( - templateId: - historyInfo.templateID); - }, - child: Row( - children: [ - Icon( - Icons.folder, - size: 20, - color: Color(0xff575757), - ), - Expanded( - child: Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 10, - vertical: 0), - child: AppText( - "Procedures for " + - historyInfo.templateName, - fontSize: 16.0, - variant: "bodyText", - bold: true, - color: Color(0xff575757)), - ), - ), - ], - ), - ), - children: [ - Column( - children: widget - .model.procedureTemplateDetails - .map((itemProcedure) { - return Container( - child: Padding( - padding: EdgeInsets.symmetric( - horizontal: 12), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 11), - child: Checkbox( - value: widget - .isEntityFavListSelected( - itemProcedure), - activeColor: Color( - 0xffD02127), - onChanged: (bool - newValue) { - setState(() { - if (widget - .isEntityFavListSelected( - itemProcedure)) { - widget.removeFavProcedure( - itemProcedure); - } else { - widget.addFavProcedure( - itemProcedure); - } - }); - }), - ), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: - 10, - vertical: 0), - child: AppText( - itemProcedure - .procedureName, - fontSize: 14.0, - variant: - "bodyText", - bold: true, - color: Color( - 0xff575757)), - ), - ), - ], - ), - ], - ), - ), - ); - }).toList(), - ), - SizedBox( - height: 2.0, - ), - DividerWithSpacesAround(), - ], - ), - ], + return ExpansionProcedure( + procedureTempleteModel: historyInfo, + model: widget.model, + removeFavProcedure: widget.removeFavProcedure, + addFavProcedure: widget.addFavProcedure, + addProceduresRemarks: widget.addProceduresRemarks, + isEntityListSelected: widget.isEntityListSelected, + isEntityFavListSelected: widget.isEntityFavListSelected, ); }).toList(), ) diff --git a/pubspec.lock b/pubspec.lock index 613c2753..4b6a9b7a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -629,7 +629,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.4" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -921,7 +921,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.2" + version: "1.10.0-nullsafety.1" sticky_headers: dependency: "direct main" description: @@ -1119,5 +1119,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <=2.11.0-213.1.beta" + dart: ">=2.10.0 <2.11.0" flutter: ">=1.22.0 <2.0.0" From 67e0cac7428cd36a677295cc6c566e18d30a1f02 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 19 May 2021 17:46:00 +0300 Subject: [PATCH 3/3] add livecare to home --- lib/config/config.dart | 2 + lib/core/service/home/dasboard_service.dart | 21 +- lib/core/viewModel/dashboard_view_model.dart | 29 +- lib/screens/home/home_screen.dart | 267 ++++++++++-------- .../AddVerifyMedicalReport.dart | 187 +----------- .../medical_report/MedicalReportPage.dart | 51 ++-- pubspec.lock | 8 +- 7 files changed, 247 insertions(+), 318 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 0e8106bc..1760caef 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -295,6 +295,8 @@ const GET_PROCEDURE_TEMPLETE = const GET_PROCEDURE_TEMPLETE_DETAILS = "Services/Doctors.svc/REST/DAPP_ProcedureTemplateDetailsGet"; +const DOCTOR_CHECK_HAS_LIVE_CARE = "Services/DoctorApplication.svc/REST/CheckDoctorHasLiveCare"; + var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ diff --git a/lib/core/service/home/dasboard_service.dart b/lib/core/service/home/dasboard_service.dart index 5a66e9eb..685646ee 100644 --- a/lib/core/service/home/dasboard_service.dart +++ b/lib/core/service/home/dasboard_service.dart @@ -6,7 +6,8 @@ class DashboardService extends BaseService { List _dashboardItemsList = []; List get dashboardItemsList => _dashboardItemsList; - // DashboardModel _dashboard = DashboardModel(); + bool hasVirtualClinic; + String sServiceID; Future getDashboard() async { hasError = false; @@ -28,4 +29,22 @@ class DashboardService extends BaseService { }, ); } + + Future checkDoctorHasLiveCare() async { + hasError = false; + await baseAppClient.post( + DOCTOR_CHECK_HAS_LIVE_CARE, + onSuccess: (dynamic response, int statusCode) { + hasVirtualClinic = response['HasVirtualClinic']; + sServiceID = response['SserviceID']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: { + "DoctorID": 9920 + }, + ); + } } diff --git a/lib/core/viewModel/dashboard_view_model.dart b/lib/core/viewModel/dashboard_view_model.dart index a1f83293..bbbef0b6 100644 --- a/lib/core/viewModel/dashboard_view_model.dart +++ b/lib/core/viewModel/dashboard_view_model.dart @@ -12,14 +12,18 @@ import 'authentication_view_model.dart'; import 'base_view_model.dart'; class DashboardViewModel extends BaseViewModel { - final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); DashboardService _dashboardService = locator(); List get dashboardItemsList => _dashboardService.dashboardItemsList; - Future setFirebaseNotification(ProjectViewModel projectsProvider, AuthenticationViewModel authProvider) async{ + bool get hasVirtualClinic => _dashboardService.hasVirtualClinic; + + String get sServiceID => _dashboardService.sServiceID; + + Future setFirebaseNotification(ProjectViewModel projectsProvider, + AuthenticationViewModel authProvider) async { setState(ViewState.Busy); await projectsProvider.getDoctorClinicsList(); @@ -50,12 +54,27 @@ class DashboardViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future changeClinic(int clinicId, AuthenticationViewModel authProvider) async { + Future checkDoctorHasLiveCare() async { + setState(ViewState.Busy); + await _dashboardService.checkDoctorHasLiveCare(); + if (_dashboardService.hasError) { + error = _dashboardService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future changeClinic( + int clinicId, AuthenticationViewModel authProvider) async { setState(ViewState.BusyLocal); await getDoctorProfile(); - ClinicModel clinicModel = ClinicModel(doctorID:doctorProfile.doctorID,clinicID: clinicId, projectID: doctorProfile.projectID,); + ClinicModel clinicModel = ClinicModel( + doctorID: doctorProfile.doctorID, + clinicID: clinicId, + projectID: doctorProfile.projectID, + ); await authProvider.getDoctorProfileBasedOnClinic(clinicModel); - if(authProvider.state == ViewState.ErrorLocal) { + if (authProvider.state == ViewState.ErrorLocal) { error = authProvider.error; } } diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 40277db9..f99dc727 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -33,7 +33,6 @@ import 'package:provider/provider.dart'; import 'package:sticky_headers/sticky_headers/widget.dart'; import '../../widgets/shared/app_texts_widget.dart'; -import 'home_page_card.dart'; class HomeScreen extends StatefulWidget { HomeScreen({Key key, this.title}) : super(key: key); @@ -55,6 +54,7 @@ class _HomeScreenState extends State { int sliderActiveIndex = 0; var clinicId; AuthenticationViewModel authenticationViewModel; + int colorIndex = 0; @override Widget build(BuildContext context) { @@ -68,9 +68,11 @@ class _HomeScreenState extends State { return BaseView( onModelReady: (model) async { - await model.setFirebaseNotification(projectsProvider, authenticationViewModel); + await model.setFirebaseNotification( + projectsProvider, authenticationViewModel); await model.getDashboard(); await model.getDoctorProfile(isGetProfile: true); + await model.checkDoctorHasLiveCare(); }, builder: (_, model, w) => AppScaffold( baseViewModel: model, @@ -289,117 +291,7 @@ class _HomeScreenState extends State { child: ListView( scrollDirection: Axis.horizontal, children: [ - HomePatientCard( - backgroundColor: Color(0xffD02127), - backgroundIconColor: Colors.white12, - cardIcon: DoctorApp.inpatient, - textColor: Colors.white, - text: "Live Care Patients", - onTap: () { - Navigator.push( - context, - FadePage( - page: PatientInPatientScreen(), - ), - ); - }, - ), - HomePatientCard( - backgroundColor: Color(0xffD02127), - backgroundIconColor: Colors.white12, - cardIcon: DoctorApp.inpatient, - textColor: Colors.white, - text: TranslationBase.of(context) - .myInPatient, - onTap: () { - Navigator.push( - context, - FadePage( - page: PatientInPatientScreen(), - ), - ); - }, - ), - HomePatientCard( - backgroundColor: Colors.grey[300], - backgroundIconColor: Colors.white38, - cardIcon: DoctorApp.arrival_patients, - textColor: Colors.black, - text: TranslationBase.of(context) - .myOutPatient_2lines, - onTap: () { - String date = - AppDateUtils.convertDateToFormat( - DateTime( - DateTime.now().year, - DateTime.now().month, - DateTime.now().day), - 'yyyy-MM-dd'); - - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => OutPatientsScreen( - patientSearchRequestModel: - PatientSearchRequestModel( - from: date, - to: date, - doctorID: - authenticationViewModel - .doctorProfile - .doctorID)), - )); - }, - ), - HomePatientCard( - backgroundColor: Color(0xff2B353E), - backgroundIconColor: Colors.white10, - cardIcon: DoctorApp.referral_1, - textColor: Colors.white, - text: TranslationBase.of(context) - .myPatientsReferral, - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - PatientReferralScreen(), - ), - ); - }, - ), - HomePatientCard( - backgroundColor: Color(0xffD02127), - backgroundIconColor: Colors.white10, - cardIcon: DoctorApp.search, - textColor: Colors.white, - text: TranslationBase.of(context) - .searchPatientDashBoard, - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - PatientSearchScreen(), - )); - }, - ), - HomePatientCard( - backgroundColor: Color(0xffC9C9C9), - backgroundIconColor: Colors.black12, - cardIcon: DoctorApp.search_medicines, - textColor: Color(0xff2B353E), - text: TranslationBase.of(context) - .searchMedicineDashboard, - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - MedicineSearchScreen(), - )); - }, - ), + ...homePatientsCardsWidget(model), ])), SizedBox( height: 20, @@ -416,4 +308,153 @@ class _HomeScreenState extends State { ), ); } + + List homePatientsCardsWidget(DashboardViewModel model) { + colorIndex = 0; + + List backgroundColors = List(3); + backgroundColors[0] = Color(0xffD02127); + backgroundColors[1] = Colors.grey[300]; + backgroundColors[2] = Color(0xff2B353E); + List backgroundIconColors = List(3); + backgroundIconColors[0] = Colors.white12; + backgroundIconColors[1] = Colors.white38; + backgroundIconColors[2] = Colors.white10; + List textColors = List(3); + textColors[0] = Colors.white; + textColors[1] = Colors.black; + textColors[2] = Colors.white; + + List patientCards = List(); + + if (model.hasVirtualClinic) { + patientCards.add(HomePatientCard( + backgroundColor: backgroundColors[colorIndex], + backgroundIconColor: backgroundIconColors[colorIndex], + cardIcon: DoctorApp.inpatient, + textColor: textColors[colorIndex], + text: + "${TranslationBase.of(context).liveCare}\n${TranslationBase.of(context).patients}", + onTap: () { + Navigator.push( + context, + FadePage( + page: PatientInPatientScreen(), + ), + ); + }, + )); + changeColorIndex(); + } + + patientCards.add(HomePatientCard( + backgroundColor: backgroundColors[colorIndex], + backgroundIconColor: backgroundIconColors[colorIndex], + cardIcon: DoctorApp.inpatient, + textColor: textColors[colorIndex], + text: TranslationBase.of(context).myInPatient, + onTap: () { + Navigator.push( + context, + FadePage( + page: PatientInPatientScreen(), + ), + ); + }, + )); + changeColorIndex(); + + patientCards.add(HomePatientCard( + backgroundColor: backgroundColors[colorIndex], + backgroundIconColor: backgroundIconColors[colorIndex], + cardIcon: DoctorApp.arrival_patients, + textColor: textColors[colorIndex], + text: TranslationBase.of(context).myOutPatient_2lines, + onTap: () { + String date = AppDateUtils.convertDateToFormat( + DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day), + 'yyyy-MM-dd'); + + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OutPatientsScreen( + patientSearchRequestModel: PatientSearchRequestModel( + from: date, + to: date, + doctorID: + authenticationViewModel.doctorProfile.doctorID)), + )); + }, + )); + changeColorIndex(); + + patientCards.add(HomePatientCard( + backgroundColor: backgroundColors[colorIndex], + backgroundIconColor: backgroundIconColors[colorIndex], + cardIcon: DoctorApp.referral_1, + textColor: textColors[colorIndex], + text: TranslationBase.of(context) + .myPatientsReferral, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PatientReferralScreen(), + ), + ); + }, + )); + changeColorIndex(); + + patientCards.add(HomePatientCard( + backgroundColor: backgroundColors[colorIndex], + backgroundIconColor: backgroundIconColors[colorIndex], + cardIcon: DoctorApp.search, + textColor: textColors[colorIndex], + text: TranslationBase.of(context) + .searchPatientDashBoard, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PatientSearchScreen(), + )); + }, + )); + changeColorIndex(); + + patientCards.add(HomePatientCard( + backgroundColor: backgroundColors[colorIndex], + backgroundIconColor: backgroundIconColors[colorIndex], + cardIcon: DoctorApp.search_medicines, + textColor: textColors[colorIndex], + text: TranslationBase.of(context) + .searchMedicineDashboard, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + MedicineSearchScreen(), + )); + }, + )); + changeColorIndex(); + + return [ + ...List.generate(patientCards.length, (index) => patientCards[index]) + .toList() + ]; + } + + changeColorIndex() { + colorIndex++; + if (colorIndex > 2) { + colorIndex = 0; + } + } } diff --git a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart index 4c51e3d7..a3fa91e9 100644 --- a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart +++ b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart @@ -1,6 +1,4 @@ -import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientMedicalReportViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/patient/MedicalReport/MeidcalReportModel.dart'; @@ -11,14 +9,11 @@ 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/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/speech-text-popup.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/html_rich_editor.dart'; import 'package:flutter/material.dart'; import 'package:html_editor_enhanced/html_editor.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; class AddVerifyMedicalReport extends StatefulWidget { @override @@ -26,42 +21,6 @@ class AddVerifyMedicalReport extends StatefulWidget { } class _AddVerifyMedicalReportState extends State { - stt.SpeechToText speechHistoryFinding = stt.SpeechToText(); - stt.SpeechToText speechLaboratoryData = stt.SpeechToText(); - stt.SpeechToText speechRecommendation = stt.SpeechToText(); - var recognizedWord1; - var recognizedWord2; - var recognizedWord3; - var event = RobotProvider(); - - TextEditingController historyFindingController = TextEditingController(); - TextEditingController laboratoryDataController = TextEditingController(); - TextEditingController recommendationController = TextEditingController(); - String commentsError; - String comments2Error; - String comments3Error; - - @override - void initState() { - requestPermissions(); - event.controller.stream.listen((p) { - if (p['startPopUp'] == 'true') { - if (this.mounted) { - initSpeechState().then((value) { - onVoiceText(); - }); - initSpeechState2().then((value) { - onVoiceText2(); - }); - initSpeechState3().then((value) { - onVoiceText3(); - }); - } - } - }); - super.initState(); - } - @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -94,9 +53,15 @@ class _AddVerifyMedicalReportState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - HtmlRichEditor(initialText: model - .medicalReportTemplate[0] - .templateTextHtml, height: MediaQuery.of(context).size.height * 0.75,), + if (model.medicalReportTemplate.length > 0) + HtmlRichEditor( + initialText: model + .medicalReportTemplate[0] + .templateTextHtml, + height: + MediaQuery.of(context).size.height * + 0.75, + ), ], ), ), @@ -121,13 +86,13 @@ class _AddVerifyMedicalReportState extends State { // disabled: progressNoteController.text.isEmpty, fontWeight: FontWeight.w700, onPressed: () async { - - String txtOfMedicalReport = await HtmlEditor.getText(); + String txtOfMedicalReport = + await HtmlEditor.getText(); if (txtOfMedicalReport.isNotEmpty) { GifLoaderDialogUtils.showMyDialog(context); - model.insertMedicalReport(patient,txtOfMedicalReport - ); + model.insertMedicalReport( + patient, txtOfMedicalReport); GifLoaderDialogUtils.hideDialog(context); if (model.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(model.error); @@ -166,137 +131,11 @@ class _AddVerifyMedicalReportState extends State { )); } - onVoiceText() async { - new SpeechToText(context: context).showAlertDialog(context); - var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; - bool available = await speechHistoryFinding.initialize( - onStatus: statusListener, onError: errorListener); - if (available) { - speechHistoryFinding.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."); - } - } - - onVoiceText2() async { - new SpeechToText(context: context).showAlertDialog(context); - var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; - bool available = await speechLaboratoryData.initialize( - onStatus: statusListener, onError: errorListener); - if (available) { - speechLaboratoryData.listen( - onResult: resultListener2, - listenMode: stt.ListenMode.confirmation, - localeId: lang == 'en' ? 'en-US' : 'ar-SA', - ); - } else { - print("The user has denied the use of speech recognition."); - } - } - - onVoiceText3() async { - new SpeechToText(context: context).showAlertDialog(context); - var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; - bool available = await speechRecommendation.initialize( - onStatus: statusListener, onError: errorListener); - if (available) { - speechRecommendation.listen( - onResult: resultListener3, - 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'}); - //SpeechToText.closeAlertDialog(context); - print(error); - } - - void statusListener(String status) { - recognizedWord1 = status == 'listening' ? 'Lisening...' : 'Sorry....'; - recognizedWord2 = status == 'listening' ? 'Lisening...' : 'Sorry....'; - recognizedWord3 = status == 'listening' ? 'Lisening...' : 'Sorry....'; - } - void requestPermissions() async { Map statuses = await [ Permission.microphone, ].request(); } - - void resultListener(result) { - recognizedWord1 = result.recognizedWords; - event.setValue({"searchText": recognizedWord1}); - - if (result.finalResult == true) { - setState(() { - SpeechToText.closeAlertDialog(context); - speechHistoryFinding.stop(); - historyFindingController.text += recognizedWord1 + '\n'; - }); - } else { - print(result.finalResult); - } - } - - void resultListener2(result) { - recognizedWord2 = result.recognizedWords; - event.setValue({"searchText": recognizedWord2}); - - if (result.finalResult == true) { - setState(() { - SpeechToText.closeAlertDialog(context); - speechLaboratoryData.stop(); - laboratoryDataController.text += recognizedWord2 + '\n'; - }); - } else { - print(result.finalResult); - } - } - - void resultListener3(result) { - recognizedWord3 = result.recognizedWords; - event.setValue({"searchText": recognizedWord3}); - - if (result.finalResult == true) { - setState(() { - SpeechToText.closeAlertDialog(context); - speechRecommendation.stop(); - recommendationController.text += recognizedWord3 + '\n'; - }); - } else { - print(result.finalResult); - } - } - - Future initSpeechState() async { - bool hasSpeech = await speechHistoryFinding.initialize( - onError: errorListener, onStatus: statusListener); - print(hasSpeech); - if (!mounted) return; - } - - Future initSpeechState2() async { - bool hasSpeech = await speechLaboratoryData.initialize( - onError: errorListener, onStatus: statusListener); - print(hasSpeech); - if (!mounted) return; - } - - Future initSpeechState3() async { - bool hasSpeech = await speechRecommendation.initialize( - onError: errorListener, onStatus: statusListener); - print(hasSpeech); - if (!mounted) return; - } } enum MedicalReportStatus { ADD, VERIFY } diff --git a/lib/screens/patients/profile/medical_report/MedicalReportPage.dart b/lib/screens/patients/profile/medical_report/MedicalReportPage.dart index 4dad827c..5e71dbd6 100644 --- a/lib/screens/patients/profile/medical_report/MedicalReportPage.dart +++ b/lib/screens/patients/profile/medical_report/MedicalReportPage.dart @@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/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/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; @@ -32,12 +33,16 @@ class MedicalReportPage extends StatelessWidget { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getMedicalReportList(patient), + onModelReady: (model) async { + await model.getMedicalReportList(patient); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error); + } + }, builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, backgroundColor: Theme.of(context).scaffoldBackgroundColor, - appBar: PatientProfileHeaderNewDesignAppBar( patient, patientType, @@ -80,10 +85,10 @@ class MedicalReportPage extends StatelessWidget { }, label: TranslationBase.of(context).createNewMedicalReport, ), - if (model.state == ViewState.ErrorLocal) - Container( - child: ErrorMessage(error: model.error), - ), + // if (model.state == ViewState.ErrorLocal) + // Container( + // child: ErrorMessage(error: model.error), + // ), if (model.state != ViewState.ErrorLocal) ...List.generate( model.medicalReportList.length, @@ -150,22 +155,26 @@ class MedicalReportPage extends StatelessWidget { onTap: () { if (model.medicalReportList[index].status == 0) { - Navigator.of(context) - .pushNamed(PATIENT_MEDICAL_REPORT_INSERT, arguments: { - 'patient': patient, - 'patientType': patientType, - 'arrivalType': arrivalType, - 'type': MedicalReportStatus.ADD, - 'medicalReport' : model.medicalReportList[index] - }); + Navigator.of(context).pushNamed( + PATIENT_MEDICAL_REPORT_INSERT, + arguments: { + 'patient': patient, + 'patientType': patientType, + 'arrivalType': arrivalType, + 'type': MedicalReportStatus.ADD, + 'medicalReport': + model.medicalReportList[index] + }); } else { - Navigator.of(context) - .pushNamed(PATIENT_MEDICAL_REPORT_DETAIL, arguments: { - 'patient': patient, - 'patientType': patientType, - 'arrivalType': arrivalType, - 'medicalReport' : model.medicalReportList[index] - }); + Navigator.of(context).pushNamed( + PATIENT_MEDICAL_REPORT_DETAIL, + arguments: { + 'patient': patient, + 'patientType': patientType, + 'arrivalType': arrivalType, + 'medicalReport': + model.medicalReportList[index] + }); } }, child: Icon( diff --git a/pubspec.lock b/pubspec.lock index 613c2753..980a4154 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -587,7 +587,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3-nullsafety.1" + version: "0.6.2" json_annotation: dependency: transitive description: @@ -629,7 +629,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.4" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -921,7 +921,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.2" + version: "1.10.0-nullsafety.1" sticky_headers: dependency: "direct main" description: @@ -1119,5 +1119,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <=2.11.0-213.1.beta" + dart: ">=2.10.0 <2.11.0" flutter: ">=1.22.0 <2.0.0"