diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 2b71ab8e..8f53ef69 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/screens/prescription/add_prescription_form.da 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/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/profile_medical_info_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; @@ -248,61 +249,7 @@ class _NewPrescriptionScreenState extends State { child: Container( child: Column( children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Row( - children: [ - AvatarWidget( - Icon( - patient.genderDescription == "Male" - ? DoctorApp.male - : DoctorApp.female_icon, - size: 70, - color: Colors.white, - ), - ), - SizedBox( - width: 20, - ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - patient.firstName + - ' ' + - patient.lastName, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - //if (model.prescriptionList.length > 0) - Row( - children: [ - AppText( - TranslationBase.of(context).age2, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - SizedBox( - width: 5.0, - ), - AppText( - patient.age.toString(), - color: Colors.black, - fontWeight: FontWeight.normal, - ), - ], - ), - AppText( - "ALLERGIC TO: FOOD, ASPIRIN", - color: Color(0xFFB9382C), - fontWeight: FontWeight.bold, - ), - ], - ) - ], - ), - ), + PatientPageHeaderWidget(patient), Divider( height: 1.0, thickness: 1.0, @@ -489,7 +436,7 @@ class _NewPrescriptionScreenState extends State { context) .size .height * - 0.295, + 0.3019, width: MediaQuery.of( context) .size @@ -870,7 +817,7 @@ class _NewPrescriptionScreenState extends State { children: [ Container( height: MediaQuery.of(context).size.height * - 0.070, + 0.060, width: double.infinity, child: Row( children: [ @@ -878,7 +825,7 @@ class _NewPrescriptionScreenState extends State { width: MediaQuery.of(context) .size .width * - 0.550, + 0.500, child: TextFields( inputFormatters: [ LengthLimitingTextInputFormatter( @@ -916,7 +863,7 @@ class _NewPrescriptionScreenState extends State { width: MediaQuery.of(context) .size .width * - 0.3200, + 0.3700, child: InkWell( onTap: unitsList != null ? () { @@ -961,6 +908,9 @@ class _NewPrescriptionScreenState extends State { ], ), ), + SizedBox( + height: 12, + ), Container( height: MediaQuery.of(context).size.height * 0.070, diff --git a/lib/screens/procedures/add-procedure-form.dart b/lib/screens/procedures/add-procedure-form.dart new file mode 100644 index 00000000..81452c63 --- /dev/null +++ b/lib/screens/procedures/add-procedure-form.dart @@ -0,0 +1,323 @@ +import 'package:doctor_app_flutter/client/base_app_client.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/procedure/ControlsModel.dart'; +import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; +import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.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/dr_app_toast_msg.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_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_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/material.dart'; + +import 'entity_list_checkbox_search_widget.dart'; + +postProcedure( + {ProcedureViewModel model, + String remarks, + String orderType, + PatiantInformtion patient, + List entityList}) async { + PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel(); + List controls = List(); + List controlsProcedure = List(); + + postProcedureReqModel.appointmentNo = patient.appointmentNo; + + postProcedureReqModel.episodeID = patient.episodeNo; + postProcedureReqModel.patientMRN = patient.patientMRN; + entityList.forEach((element) { + controls.add( + Controls(code: "remarks", controlValue: remarks.isEmpty ? '' : remarks), + ); + controls.add( + Controls( + code: "ordertype", + controlValue: + orderType.toString().isNotEmpty ? orderType.toString() : '1'), + ); + }); + + entityList.forEach((element) { + controlsProcedure.add(Procedures( + category: element.categoryID, + procedure: element.procedureId, + controls: controls)); + }); + postProcedureReqModel.procedures = controlsProcedure; + + await model.postProcedure(postProcedureReqModel, patient.patientMRN); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + model.getProcedure(mrn: patient.patientMRN); + } else if (model.state == ViewState.Idle) { + DrAppToastMsg.showSuccesToast('procedure has been added'); + } +} + +void addSelectedProcedure( + context, ProcedureViewModel model, PatiantInformtion patient) { + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (BuildContext bc) { + return AddSelectedProcedure( + model: model, + patient: patient, + ); + }); +} + +class AddSelectedProcedure extends StatefulWidget { + final ProcedureViewModel model; + final PatiantInformtion patient; + + const AddSelectedProcedure({Key key, this.model, this.patient}) + : super(key: key); + @override + _AddSelectedProcedureState createState() => + _AddSelectedProcedureState(patient: patient, model: model); +} + +class _AddSelectedProcedureState extends State { + int selectedType; + ProcedureViewModel model; + PatiantInformtion patient; + _AddSelectedProcedureState({this.patient, this.model}); + TextEditingController procedureController = TextEditingController(); + TextEditingController remarksController = TextEditingController(); + List entityList = List(); + dynamic selectedCategory; + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + return BaseView( + onModelReady: (model) => model.getCategory(), + builder: (BuildContext context, ProcedureViewModel model, Widget child) => + NetworkBaseView( + baseViewModel: model, + child: DraggableScrollableSheet( + minChildSize: 0.90, + initialChildSize: 0.95, + maxChildSize: 1.0, + builder: (BuildContext context, ScrollController scrollController) { + return SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height * 1.20, + child: Padding( + padding: EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context) + .selectProcedures + .toUpperCase(), + fontWeight: FontWeight.w900, + ), + SizedBox( + height: 10.0, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.categoryList != null && + model.categoryList.length > 0 + ? () { + ListSelectDialog dialog = ListSelectDialog( + list: model.categoryList, + attributeName: 'categoryName', + attributeValueId: 'categoryId', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + selectedCategory = selectedValue; + model.getProcedureCategory( + categoryName: selectedCategory[ + 'categoryName']); + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + //model.getProcedureCategory(); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context) + .procedureCategorise, + selectedCategory != null + ? selectedCategory['categoryName'] + : null, + true, + suffixIcon: Icon( + Icons.search, + color: Colors.black, + )), + enabled: false, + ), + ), + ), + if (widget.model.categoriesList.length != 0) + NetworkBaseView( + baseViewModel: model, + child: EntityListCheckboxSearchWidget( + 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), + ), + ), + SizedBox( + height: 15.0, + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Row( + children: [ + AppText( + TranslationBase.of(context).orderType), + Radio( + activeColor: Color(0xFFB9382C), + value: 1, + groupValue: selectedType, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).regular), + Radio( + activeColor: Color(0xFFB9382C), + groupValue: selectedType, + value: 0, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).urgent), + ], + ), + ), + SizedBox( + height: 15.0, + ), + TextFields( + hintText: TranslationBase.of(context).remarks, + controller: remarksController, + minLines: 3, + maxLines: 5, + ), + SizedBox( + height: 50.0, + ), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context) + .addSelectedProcedures, + onPressed: () { + Navigator.pop(context); + postProcedure( + orderType: selectedType.toString(), + entityList: entityList, + patient: patient, + model: widget.model, + remarks: remarksController.text); + }, + ), + ], + ), + ), + ], + ) + ], + ), + ), + ), + ); + }), + ), + ); + } + + bool isEntityListSelected(EntityList masterKey) { + Iterable history = entityList + .where((element) => masterKey.procedureId == element.procedureId); + if (history.length > 0) { + return true; + } + return false; + } + + 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, + ), + ); + } +} diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index d6d38a54..9fb8510c 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -11,10 +11,13 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.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/screens/procedures/add-procedure-form.dart'; import 'package:doctor_app_flutter/screens/procedures/entity_list_checkbox_search_widget.dart'; +import 'package:doctor_app_flutter/screens/procedures/update-procedure.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/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; @@ -58,57 +61,7 @@ class _ProcedureScreenState extends State { child: Container( child: Column( children: [ - Padding( - padding: EdgeInsets.all(12.0), - child: Row( - children: [ - AvatarWidget( - Icon( - patient.genderDescription == "Male" - ? DoctorApp.male - : DoctorApp.female_icon, - size: 70, - color: Colors.white, - ), - ), - SizedBox( - width: 20, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - patient.firstName + ' ' + patient.lastName, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - Row( - children: [ - AppText( - TranslationBase.of(context).age2, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - SizedBox( - width: 5.0, - ), - AppText( - patient.age.toString(), - color: Colors.black, - fontWeight: FontWeight.normal, - ), - ], - ), - AppText( - "ALLERGIC TO: FOOD, ASPIRIN", - color: Color(0xFFB9382C), - fontWeight: FontWeight.bold, - ), - ], - ) - ], - ), - ), + PatientPageHeaderWidget(patient), Divider( height: 1.0, thickness: 1.0, @@ -320,7 +273,7 @@ class _ProcedureScreenState extends State { context) .size .height * - 0.2, + 0.21, width: MediaQuery.of( context) .size @@ -376,6 +329,30 @@ class _ProcedureScreenState extends State { ), ], ), + Row( + children: [ + AppText( + 'Order.NO' + + " : ", + fontWeight: + FontWeight + .w700, + fontSize: + 15.0, + ), + AppText( + model + .procedureList[ + 0] + .entityList[ + index] + .orderNo + .toString(), + fontSize: + 13.0, + ), + ], + ), Row( children: [ Container( @@ -580,445 +557,4 @@ class _ProcedureScreenState extends State { )), ); } - - void updateProcedureForm(context, - {String procedureName, - PatiantInformtion patient, - String procedureId, - String remarks, - String categoreId}) { - ProcedureViewModel model = ProcedureViewModel(); - TextEditingController remarksController = TextEditingController(); - TextEditingController orderController = TextEditingController(); - showModalBottomSheet( - context: context, - isScrollControlled: true, - builder: (BuildContext bc) { - return Container( - height: MediaQuery.of(context).size.height * 0.55, - child: Form( - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - procedureName.toUpperCase(), - fontWeight: FontWeight.w700, - ), - SizedBox( - height: 30.0, - ), - Container( - child: Row( - children: [ - AppText(TranslationBase.of(context).orderType), - Radio( - activeColor: Color(0xFFB9382C), - value: 0, - groupValue: selectedType, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text(TranslationBase.of(context).regular), - Radio( - activeColor: Color(0xFFB9382C), - groupValue: selectedType, - value: 1, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text(TranslationBase.of(context).urgent), - ], - ), - ), - 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( - hintText: remarks, - controller: remarksController, - maxLines: 5, - minLines: 3, - ), - ), - SizedBox( - height: 100.0, - ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of(context) - .updateProcedure - .toUpperCase(), - onPressed: () { - Navigator.pop(context); - updateProcedure( - categorieId: categoreId, - procedureId: procedureId, - patient: patient, - model: model, - remarks: remarksController.text); - // authorizationForm(context); - }, - ), - ], - ), - ), - ], - ), - ), - )); - }); - } -} - -postProcedure( - {ProcedureViewModel model, - String remarks, - PatiantInformtion patient, - List entityList}) async { - PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel(); - List controls = List(); - List controlsProcedure = List(); - - postProcedureReqModel.appointmentNo = patient.appointmentNo; - - postProcedureReqModel.episodeID = patient.episodeNo; - postProcedureReqModel.patientMRN = patient.patientMRN; - entityList.forEach((element) { - controls.add( - Controls(code: "remarks", controlValue: remarks.isEmpty ? '' : remarks), - ); - }); - - entityList.forEach((element) { - controlsProcedure.add(Procedures( - category: element.categoryID, - procedure: element.procedureId, - controls: controls)); - }); - postProcedureReqModel.procedures = controlsProcedure; - - await model.postProcedure(postProcedureReqModel, patient.patientMRN); - - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - model.getProcedure(mrn: patient.patientMRN); - } else if (model.state == ViewState.Idle) { - DrAppToastMsg.showSuccesToast('procedure has been added'); - } -} - -updateProcedure( - {ProcedureViewModel model, - String remarks, - String procedureId, - PatiantInformtion patient, - String categorieId}) async { - UpdateProcedureRequestModel updateProcedureReqModel = - new UpdateProcedureRequestModel(); - List controls = List(); - ProcedureDetail controlsProcedure = new ProcedureDetail(); - - updateProcedureReqModel.appointmentNo = patient.appointmentNo; - - updateProcedureReqModel.episodeID = patient.episodeNo; - updateProcedureReqModel.patientMRN = patient.patientMRN; - updateProcedureReqModel.lineItemNo = 1; - updateProcedureReqModel.orderNo = 0; - - controls.add( - Controls(code: "02", controlValue: remarks.isEmpty ? '' : remarks), - ); - - controlsProcedure.procedure = procedureId; - controlsProcedure.category = categorieId; - controlsProcedure.controls = controls; - - // controlsProcedure.add(ProcedureDetail( - // category: categorieId, procedure: procedureId, controls: controls)); - updateProcedureReqModel.procedureDetail = controlsProcedure; - - await model.updateProcedure( - updateProcedureRequestModel: updateProcedureReqModel, - mrn: patient.patientMRN); - - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - model.getProcedure(mrn: patient.patientMRN); - } else if (model.state == ViewState.Idle) { - DrAppToastMsg.showSuccesToast('procedure has been updated'); - } -} - -void addSelectedProcedure( - context, ProcedureViewModel model, PatiantInformtion patient) { - showModalBottomSheet( - context: context, - isScrollControlled: true, - builder: (BuildContext bc) { - return AddSelectedProcedure( - model: model, - patient: patient, - ); - }); -} - -class AddSelectedProcedure extends StatefulWidget { - final ProcedureViewModel model; - final PatiantInformtion patient; - - const AddSelectedProcedure({Key key, this.model, this.patient}) - : super(key: key); - @override - _AddSelectedProcedureState createState() => - _AddSelectedProcedureState(patient: patient, model: model); -} - -class _AddSelectedProcedureState extends State { - int selectedType; - ProcedureViewModel model; - PatiantInformtion patient; - _AddSelectedProcedureState({this.patient, this.model}); - TextEditingController procedureController = TextEditingController(); - TextEditingController remarksController = TextEditingController(); - List entityList = List(); - dynamic selectedCategory; - setSelectedType(int val) { - setState(() { - selectedType = val; - }); - } - - @override - Widget build(BuildContext context) { - final screenSize = MediaQuery.of(context).size; - return BaseView( - onModelReady: (model) => model.getCategory(), - builder: (BuildContext context, ProcedureViewModel model, Widget child) => - NetworkBaseView( - baseViewModel: model, - child: DraggableScrollableSheet( - minChildSize: 0.90, - initialChildSize: 0.95, - maxChildSize: 1.0, - builder: (BuildContext context, ScrollController scrollController) { - return SingleChildScrollView( - child: Container( - height: MediaQuery.of(context).size.height * 1.20, - child: Padding( - padding: EdgeInsets.all(12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context) - .selectProcedures - .toUpperCase(), - fontWeight: FontWeight.w900, - ), - SizedBox( - height: 10.0, - ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.categoryList != null && - model.categoryList.length > 0 - ? () { - ListSelectDialog dialog = ListSelectDialog( - list: model.categoryList, - attributeName: 'categoryName', - attributeValueId: 'categoryId', - okText: TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - selectedCategory = selectedValue; - model.getProcedureCategory( - categoryName: selectedCategory[ - 'categoryName']); - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - //model.getProcedureCategory(); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context) - .procedureCategorise, - selectedCategory != null - ? selectedCategory['categoryName'] - : null, - true, - suffixIcon: Icon( - Icons.search, - color: Colors.black, - )), - enabled: false, - ), - ), - ), - if (widget.model.categoriesList.length != 0) - NetworkBaseView( - baseViewModel: model, - child: EntityListCheckboxSearchWidget( - 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), - ), - ), - SizedBox( - height: 15.0, - ), - Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Row( - children: [ - AppText( - TranslationBase.of(context).orderType), - Radio( - activeColor: Color(0xFFB9382C), - value: 0, - groupValue: selectedType, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text(TranslationBase.of(context).regular), - Radio( - activeColor: Color(0xFFB9382C), - groupValue: selectedType, - value: 1, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text(TranslationBase.of(context).urgent), - ], - ), - ), - SizedBox( - height: 15.0, - ), - TextFields( - hintText: TranslationBase.of(context).remarks, - controller: remarksController, - minLines: 3, - maxLines: 5, - ), - SizedBox( - height: 50.0, - ), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of(context) - .addSelectedProcedures, - onPressed: () { - Navigator.pop(context); - postProcedure( - entityList: entityList, - patient: patient, - model: widget.model, - remarks: remarksController.text); - }, - ), - ], - ), - ), - ], - ) - ], - ), - ), - ), - ); - }), - ), - ); - } - - bool isEntityListSelected(EntityList masterKey) { - Iterable history = entityList - .where((element) => masterKey.procedureId == element.procedureId); - if (history.length > 0) { - return true; - } - return false; - } - - 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, - ), - ); - } } diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart new file mode 100644 index 00000000..0b0a0c5a --- /dev/null +++ b/lib/screens/procedures/update-procedure.dart @@ -0,0 +1,209 @@ +import 'package:doctor_app_flutter/client/base_app_client.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/procedure/ControlsModel.dart'; +import 'package:doctor_app_flutter/core/model/procedure/update_procedure_request_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.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/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +void updateProcedureForm(context, + {String procedureName, + PatiantInformtion patient, + String orderType, + String procedureId, + String remarks, + String categoreId}) { + ProcedureViewModel model = ProcedureViewModel(); + TextEditingController remarksController = TextEditingController(); + TextEditingController orderController = TextEditingController(); + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (BuildContext bc) { + return UpdateProcedureWidget( + procedureName: procedureName, + remarks: remarks, + remarksController: remarksController, + patient: patient, + model: model, + procedureId: procedureId, + categoryId: categoreId, + ); + }); +} + +class UpdateProcedureWidget extends StatefulWidget { + final PatiantInformtion patient; + final ProcedureViewModel model; + final String procedureName; + final String remarks; + final TextEditingController remarksController; + final String procedureId; + final String categoryId; + + UpdateProcedureWidget( + {this.model, + this.procedureName, + this.remarks, + this.remarksController, + this.patient, + this.procedureId, + this.categoryId}); + @override + _UpdateProcedureWidgetState createState() => _UpdateProcedureWidgetState(); +} + +class _UpdateProcedureWidgetState extends State { + int selectedType = 0; + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + + @override + Widget build(BuildContext context) { + return StatefulBuilder(builder: + (BuildContext context, StateSetter setState /*You can rename this!*/) { + return Container( + height: MediaQuery.of(context).size.height * 0.55, + child: Form( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + widget.procedureName.toUpperCase(), + fontWeight: FontWeight.w700, + ), + SizedBox( + height: 30.0, + ), + Container( + child: Row( + children: [ + AppText(TranslationBase.of(context).orderType), + Radio( + activeColor: Color(0xFFB9382C), + value: 0, + groupValue: selectedType, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).urgent), + Radio( + activeColor: Color(0xFFB9382C), + groupValue: selectedType, + value: 1, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).regular), + ], + ), + ), + 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( + hintText: widget.remarks, + controller: widget.remarksController, + maxLines: 5, + minLines: 3, + ), + ), + SizedBox( + height: 100.0, + ), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context) + .updateProcedure + .toUpperCase(), + onPressed: () { + Navigator.pop(context); + updateProcedure( + orderType: selectedType.toString(), + categorieId: widget.categoryId, + procedureId: widget.procedureId, + patient: widget.patient, + model: widget.model, + remarks: widget.remarksController.text); + // authorizationForm(context); + }, + ), + ], + ), + ), + ], + ), + ), + )); + }); + } + + updateProcedure( + {ProcedureViewModel model, + String remarks, + String orderType, + String procedureId, + PatiantInformtion patient, + String categorieId}) async { + UpdateProcedureRequestModel updateProcedureReqModel = + new UpdateProcedureRequestModel(); + List controls = List(); + ProcedureDetail controlsProcedure = new ProcedureDetail(); + + updateProcedureReqModel.appointmentNo = patient.appointmentNo; + + updateProcedureReqModel.episodeID = patient.episodeNo; + updateProcedureReqModel.patientMRN = patient.patientMRN; + updateProcedureReqModel.lineItemNo = 1; + updateProcedureReqModel.orderNo = 0; + + controls.add( + Controls(code: "remarks", controlValue: remarks.isEmpty ? '' : remarks), + ); + controls.add( + Controls(code: "ordertype", controlValue: "1"), + ); + + controlsProcedure.procedure = procedureId; + controlsProcedure.category = categorieId; + controlsProcedure.controls = controls; + + // controlsProcedure.add(ProcedureDetail( + // category: categorieId, procedure: procedureId, controls: controls)); + updateProcedureReqModel.procedureDetail = controlsProcedure; + + await model.updateProcedure( + updateProcedureRequestModel: updateProcedureReqModel, + mrn: patient.patientMRN); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + model.getProcedure(mrn: patient.patientMRN); + } else if (model.state == ViewState.Idle) { + DrAppToastMsg.showSuccesToast('procedure has been updated'); + } + } +}