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/auth_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.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/note/update_note.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import '../../../../config/shared_pref_kay.dart'; import '../../../../models/patient/patiant_info_model.dart'; import '../../../../util/dr_app_shared_pref.dart'; import '../../../../widgets/shared/app_scaffold_widget.dart'; import '../../../../widgets/shared/app_texts_widget.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class ProgressNoteScreen extends StatefulWidget { final int visitType; const ProgressNoteScreen({Key key, this.visitType}) : super(key: key); @override _ProgressNoteState createState() => _ProgressNoteState(); } class _ProgressNoteState extends State { List notesList; var filteredNotesList; final _controller = TextEditingController(); var _isInit = true; bool isDischargedPatient = false; AuthViewModel authProvider; getProgressNoteList(BuildContext context, PatientViewModel model, {bool isLocalBusy = false}) async { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); String type = await sharedPref.getString(SLECTED_PATIENT_TYPE); print(type); ProgressNoteRequest progressNoteRequest = ProgressNoteRequest( visitType: widget.visitType, // if equal 5 then this will return progress note admissionNo: int.parse(patient.admissionNo), projectID: patient.projectId, tokenID: token, patientTypeID: patient.patientType, languageID: 2); model.getPatientProgressNote(progressNoteRequest.toJson(), isLocalBusy: isLocalBusy).then((c) { notesList = model.patientProgressNoteList; }); } @override Widget build(BuildContext context) { authProvider = Provider.of(context); final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String arrivalType = routeArgs['arrivalType']; if(routeArgs.containsKey('isDischargedPatient')) isDischargedPatient = routeArgs['isDischargedPatient']; return BaseView( onModelReady: (model) => getProgressNoteList(context, model), builder: (_, model, w) => AppScaffold( baseViewModel: model, backgroundColor: Theme.of(context).scaffoldBackgroundColor, // appBarTitle: TranslationBase.of(context).progressNote, appBar: PatientProfileHeaderNewDesignAppBar( patient, patient.patientType.toString() ?? '0', arrivalType), body: model.patientProgressNoteList == null || model.patientProgressNoteList.length == 0 ? DrAppEmbeddedError( error: TranslationBase.of(context).errorNoProgressNote) : Container( color: Colors.grey[200], child: Column( children: [ if(!isDischargedPatient) AddNewOrder( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => UpdateNoteOrder( patientModel: model, patient: patient, visitType: widget.visitType, isUpdate: false, )), ); },label: widget.visitType ==3?'Add a New Order Sheet':'Create a New Progress Note',), Expanded( child: Container( child: ListView.builder( itemCount: model.patientProgressNoteList.length, itemBuilder: (BuildContext ctxt, int index) { return Column( children: [ Container( margin: EdgeInsets.only( left: 10, right: 10, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10), ), padding: EdgeInsets.all(15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (model.patientProgressNoteList[index].status != 2 && model.patientProgressNoteList[index].status != 4 && authProvider.doctorProfile.doctorID == model.patientProgressNoteList[index].createdBy) Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => UpdateNoteOrder( note: model.patientProgressNoteList[ index], patientModel: model, patient: patient, visitType: widget .visitType, isUpdate: true, )), ); }, child: Container( decoration: BoxDecoration( color: Colors.green[600], borderRadius: BorderRadius.circular( 10), ), // color:Colors.red[600], child: Row( children: [ Icon( DoctorApp.edit_1, size: 12, color: Colors.white, ), SizedBox( width: 2, ), AppText( 'Update', fontSize: 10, color: Colors.white, ), ], ), padding: EdgeInsets.all(6), ), ), SizedBox( width: 10, ), InkWell( onTap: () async { showMyDialog( context: context, actionName: "cancel", confirmFun: () async { GifLoaderDialogUtils .showMyDialog( context, ); UpdateNoteReqModel reqModel = UpdateNoteReqModel( admissionNo: int.parse(patient .admissionNo), cancelledNote: true, lineItemNo: model.patientProgressNoteList[index] .lineItemNo, createdBy: model.patientProgressNoteList[index] .createdBy, notes: model.patientProgressNoteList[index] .notes, verifiedNote: false, patientTypeID: patient .patientType, patientOutSA: false, ); await model .updatePatientProgressNote( reqModel); await getProgressNoteList( context, model, isLocalBusy: true); GifLoaderDialogUtils .hideDialog( context); }); }, child: Container( decoration: BoxDecoration( color: Colors.red[600], borderRadius: BorderRadius.circular( 10), ), // color:Colors.red[600], child: Row( children: [ Icon( FontAwesomeIcons.trash, size: 12, color: Colors.white, ), SizedBox( width: 2, ), AppText( 'Cancel', fontSize: 10, color: Colors.white, ), ], ), padding: EdgeInsets.all(6), ), ), SizedBox( width: 10, ), InkWell( onTap: () async { showMyDialog(context: context, actionName: "verify",confirmFun: () async{ GifLoaderDialogUtils .showMyDialog(context); UpdateNoteReqModel reqModel = UpdateNoteReqModel( admissionNo: int.parse( patient.admissionNo), cancelledNote: false, lineItemNo: model.patientProgressNoteList[index] .lineItemNo, createdBy: model.patientProgressNoteList[index] .createdBy, notes: model.patientProgressNoteList[index].notes, verifiedNote: true, patientTypeID: patient.patientType, patientOutSA: false, ); await model .updatePatientProgressNote( reqModel); await getProgressNoteList( context, model, isLocalBusy: true); GifLoaderDialogUtils .hideDialog(context); }); }, child: Container( decoration: BoxDecoration( color: Colors.grey[600], borderRadius: BorderRadius.circular( 10), ), // color:Colors.red[600], child: Row( children: [ Icon( FontAwesomeIcons.check, size: 12, color: Colors.white, ), SizedBox( width: 2, ), AppText( 'Verify', fontSize: 10, color: Colors.white, ), ], ), padding: EdgeInsets.all(6), ), ), SizedBox( width: 10, ) ], ), SizedBox( height: 10, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: MediaQuery.of(context) .size .width * 0.65, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment .start, children: [ AppText( 'Created By: ', fontSize: 10, ), Expanded( child: AppText( model.patientProgressNoteList[index].doctorName??'',fontWeight: FontWeight.w600,fontSize: 12,), ), ], ), if(model.patientProgressNoteList[index].status == 4) AppText( 'Canceled',fontWeight: FontWeight.w600, color: Colors.red.shade700,fontSize: 12,), if(model.patientProgressNoteList[index].status == 2) AppText( 'verified',fontWeight: FontWeight.w600, color: Colors.grey.shade700,fontSize: 12,), ], ), ), Column( children: [ AppText( model.patientProgressNoteList[index] .createdOn != null ? DateUtils .getDayMonthYearDateFormatted( DateUtils.getDateTimeFromServerFormat(model.patientProgressNoteList[index].createdOn)) : DateUtils .getDayMonthYearDateFormatted( DateTime.now()), fontWeight: FontWeight.w600, fontSize: 14, ), AppText( model.patientProgressNoteList[index] .createdOn != null ? DateUtils .getHour( DateUtils.getDateTimeFromServerFormat(model.patientProgressNoteList[index].createdOn )) : DateUtils .getHour( DateTime.now()), fontWeight: FontWeight.w600, fontSize: 14, ), ], crossAxisAlignment: CrossAxisAlignment.end, ) ], ), SizedBox( height: 8, ), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: AppText( model.patientProgressNoteList[index].notes, fontSize: 10, ), ), ]) ], ), ), SizedBox( height: 20, ), ], ); }), ), ), ], ), ), ), ); } showMyDialog({BuildContext context, Function confirmFun, String actionName}) { showDialog( context: context, child: Center( child: Container( width: MediaQuery .of(context) .size .width * 0.8, height: 200, child: AppScaffold( isShowAppBar: false, body: Container( color: Colors.white, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ // SizedBox(height: 20,), SizedBox(height: 10,), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ AppText( "Confirm", fontWeight: FontWeight.w600, color: Colors.black, fontSize: 16,), ], ), SizedBox(height: 10,), DividerWithSpacesAround(), SizedBox(height: 12,), Container( padding: EdgeInsets.all(20), color: Colors.white, child: AppText( 'Are you sure you want $actionName this order?', fontSize: 15, textAlign: TextAlign.center, ), ), SizedBox(height: 8,), DividerWithSpacesAround(), FractionallySizedBox( widthFactor: 0.75, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ FlatButton( child: AppText( "Cancel", fontWeight: FontWeight.w600, color: Colors.black, fontSize: 16,),//Text("Cancel"), onPressed: () { Navigator.of(context).pop(); }), FlatButton( child: AppText( "Confirm", fontWeight: FontWeight.w600, color: Colors.red.shade700, fontSize: 16,), //Text("Confirm", ), onPressed: () async { await confirmFun(); Navigator.of(context).pop(); }) ], ), ) ], ), ), ), ), ), )); } }