import 'package:doctor_app_flutter/config/shared_pref_kay.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/note/CreateNoteModel.dart'; import 'package:doctor_app_flutter/core/model/note/note_model.dart'; import 'package:doctor_app_flutter/core/model/note/update_note_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.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/models/patient/progress_note_request.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/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/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; class UpdateNoteOrder extends StatefulWidget { final NoteModel note; final PatientViewModel patientModel; final PatiantInformtion patient; final int visitType; final bool isUpdate; const UpdateNoteOrder( {Key key, this.note, this.patientModel, this.patient, this.visitType, this.isUpdate}) : super(key: key); @override _UpdateNoteOrderState createState() => _UpdateNoteOrderState(); } class _UpdateNoteOrderState extends State { int selectedType; bool isSubmitted = false; TextEditingController progressNoteController = TextEditingController(); setSelectedType(int val) { setState(() { selectedType = val; }); } @override Widget build(BuildContext context) { if (widget.note != null) { progressNoteController.text = widget.note.notes; } return AppScaffold( isShowAppBar: false, backgroundColor: Theme .of(context) .scaffoldBackgroundColor, body: SingleChildScrollView( child: Container( height: MediaQuery .of(context) .size .height * 1.0, child: Padding( padding: EdgeInsets.all(0.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ BottomSheetTitle(title: widget.visitType == 3 ? 'Add Order Sheet' : 'Add Progress Note',), SizedBox( height: 10.0, ), Center( child: FractionallySizedBox( widthFactor: 0.9, child: Column( children: [ AppTextFieldCustom( hintText: widget.visitType == 3 ? 'Add Order Sheet' : 'Add Progress Note', //TranslationBase.of(context).addProgressNote, controller: progressNoteController, maxLines: 25, minLines: 10, hasBorder: true, validationError:progressNoteController.text.isEmpty&&isSubmitted?TranslationBase.of(context).emptyMessage:null , ), ], ), ), ), ], ), ), ), ), bottomSheet: Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), child: Wrap( alignment: WrapAlignment.center, children: [ AppButton( title: widget.visitType == 3 ? 'Add Order Sheet' : 'Add Progress Note', color: Color(0xff359846), // disabled: progressNoteController.text.isEmpty, fontWeight: FontWeight.w700, onPressed: () async { setState(() { isSubmitted = true; }); if (progressNoteController.text.isNotEmpty) { GifLoaderDialogUtils.showMyDialog(context); Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = DoctorProfileModel .fromJson(profile); if (widget.isUpdate) { UpdateNoteReqModel reqModel = UpdateNoteReqModel( admissionNo: int.parse(widget.patient .admissionNo), cancelledNote: false, lineItemNo: 30, createdBy: widget.note.createdBy, notes: progressNoteController.text , verifiedNote: false, patientTypeID: widget.patient.patientType, patientOutSA: false, ); await widget.patientModel.updatePatientProgressNote(reqModel); } else { CreateNoteModel reqModel = CreateNoteModel( admissionNo: int.parse(widget.patient .admissionNo), createdBy: doctorProfile.doctorID, visitType: widget.visitType, patientID: widget.patient.patientId, nursingRemarks: ' ', patientTypeID: widget.patient.patientType, patientOutSA: false, notes: progressNoteController.text ); await widget.patientModel.createPatientProgressNote(reqModel); } if (widget.patientModel.state == ViewState.ErrorLocal) { Helpers.showErrorToast( Helpers.generateContactAdminMsg()); } else { ProgressNoteRequest progressNoteRequest = ProgressNoteRequest( visitType: widget.visitType, // if equal 5 then this will return progress note admissionNo: int.parse(widget.patient .admissionNo), projectID: widget.patient.projectId, patientTypeID: widget.patient.patientType, languageID: 2); await widget.patientModel.getPatientProgressNote( progressNoteRequest.toJson()); } GifLoaderDialogUtils.hideDialog(context); Navigator.of(context).pop(); } } ), ], ), ), ); // return BaseView( // builder: (BuildContext context, PatientViewModel model, Widget child) => // AppScaffold( // isShowAppBar: false, // backgroundColor: Theme // .of(context) // .scaffoldBackgroundColor, // body: SingleChildScrollView( // child: Container( // height: MediaQuery // .of(context) // .size // .height * 1.0, // child: Padding( // padding: EdgeInsets.all(0.0), // child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // BottomSheetTitle(title: widget.visitType == 3 // ? 'Add Order Sheet' // : 'Add Progress Note',), // SizedBox( // height: 10.0, // ), // // Center( // child: FractionallySizedBox( // widthFactor: 0.9, // child: Column( // children: [ // AppTextFieldCustom( // hintText: widget.visitType == 3 // ? 'Add Order Sheet' // : 'Add Progress Note', // //TranslationBase.of(context).addProgressNote, // controller: progressNoteController, // maxLines: 25, // minLines: 10, // hasBorder: true, // validationError:progressNoteController.text.isEmpty&&isSubmitted?TranslationBase.of(context).emptyMessage:null , // // ), // ], // ), // ), // ), // // ], // ), // ), // ), // ), // bottomSheet: Container( // margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), // child: Wrap( // alignment: WrapAlignment.center, // children: [ // AppButton( // title: widget.visitType == 3 // ? 'Add Order Sheet' // : 'Add Progress Note', // color: Color(0xff359846), // // disabled: progressNoteController.text.isEmpty, // fontWeight: FontWeight.w700, // onPressed: () async { // setState(() { // isSubmitted = true; // }); // if (progressNoteController.text.isNotEmpty) { // GifLoaderDialogUtils.showMyDialog(context); // Map profile = await sharedPref.getObj(DOCTOR_PROFILE); // // DoctorProfileModel doctorProfile = DoctorProfileModel // .fromJson(profile); // // // if (widget.isUpdate) { // UpdateNoteReqModel reqModel = UpdateNoteReqModel( // admissionNo: int.parse(widget.patient // .admissionNo), // cancelledNote: false, // lineItemNo: 30, // createdBy: widget.note.createdBy, // notes: progressNoteController.text // // , // verifiedNote: false, // // patientTypeID: widget.patient.patientType, // patientOutSA: false, // ); // await model.updatePatientProgressNote(reqModel); // } else { // CreateNoteModel reqModel = CreateNoteModel( // admissionNo: int.parse(widget.patient // .admissionNo), // createdBy: doctorProfile.doctorID, // visitType: widget.visitType, // patientID: widget.patient.patientId, // nursingRemarks: ' ', // patientTypeID: widget.patient.patientType, // patientOutSA: false, // // notes: progressNoteController.text // ); // // await model.createPatientProgressNote(reqModel); // } // // if (model.state == ViewState.ErrorLocal) { // Helpers.showErrorToast( // Helpers.generateContactAdminMsg()); // } else { // ProgressNoteRequest progressNoteRequest = // ProgressNoteRequest( // visitType: widget.visitType, // // if equal 5 then this will return progress note // admissionNo: int.parse(widget.patient // .admissionNo), // projectID: widget.patient.projectId, // patientTypeID: widget.patient.patientType, // languageID: 2); // await widget.patientModel.getPatientProgressNote( // progressNoteRequest.toJson()); // } // // GifLoaderDialogUtils.hideDialog(context); // Navigator.of(context).pop(); // } // } // ), // ], // ), // ), // ), // ); } }