import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.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/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; 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/screens/prescription/add_prescription_form.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/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'; 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_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; class NewPrescriptionScreen extends StatefulWidget { @override _NewPrescriptionScreenState createState() => _NewPrescriptionScreenState(); } class _NewPrescriptionScreenState extends State { int testNum = 0; PatiantInformtion patient; @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; patient = routeArgs['patient']; return BaseView( onModelReady: (model) => model.getPrescription(), builder: (BuildContext context, PrescriptionViewModel model, Widget child) => AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).prescription, body: NetworkBaseView( baseViewModel: model, child: SingleChildScrollView( 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, ), ], ) ], ), ), Divider( height: 1.0, thickness: 1.0, color: Colors.grey, ), if (model.prescriptionList.length != 0) SizedBox( height: model.prescriptionList[0].rowcount == 0 ? 200.0 : 10.0), //model.prescriptionList == null if (model.prescriptionList.length != 0) model.prescriptionList[0].rowcount == 0 ? Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ InkWell( onTap: () { addPrescriptionForm(context, model); //model.postPrescription(); }, child: CircleAvatar( radius: 65, backgroundColor: Color(0XFFB8382C), child: CircleAvatar( radius: 60, backgroundColor: Colors.white, child: Icon( Icons.add, color: Colors.black, size: 45.0, ), ), ), ), SizedBox( height: 15.0, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ AppText( TranslationBase.of(context) .noPrescriptionListed, color: Colors.black, fontWeight: FontWeight.w900, ), ], ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ AppText( TranslationBase.of(context).addNow, color: Color(0XFFB8382C), fontWeight: FontWeight.w900, ), ], ), ], ) : Padding( padding: EdgeInsets.all(14.0), child: NetworkBaseView( baseViewModel: model, child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ InkWell( child: Container( height: 50.0, width: 450.0, decoration: BoxDecoration( border: Border.all( color: Colors.grey), borderRadius: BorderRadius.circular(10.0), ), child: Padding( padding: EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ AppText( ' Add more medication', fontWeight: FontWeight.w100, fontSize: 12.5, ), Icon( Icons.add, color: Color(0XFFB8382C), ) ], ), ), ), onTap: () { addPrescriptionForm(context, model); //model.postPrescription(); }, ), SizedBox( height: 15.0, ), ...List.generate( model.prescriptionList[0].rowcount, (index) => Container( //height: 240, child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, // crossAxisAlignment: // CrossAxisAlignment.start, children: [ Container( height: MediaQuery.of(context) .size .height * 0.23, width: MediaQuery.of(context) .size .width * 0.09, child: Column( children: [ AppText( '8\nDEC', color: Colors.green, ) ], ), ), Container( height: MediaQuery.of(context) .size .height * 0.282, width: MediaQuery.of(context) .size .width * 0.77, child: Column( children: [ Row( children: [ AppText( 'Start Date:', fontWeight: FontWeight .w700, fontSize: 14.0, ), Expanded( child: AppText( model .prescriptionList[ 0] .entityList[ index] .startDate, fontSize: 12.0, ), ), SizedBox( width: 6.0, ), AppText( 'Order Type:', fontWeight: FontWeight .w700, fontSize: 14.0, ), Expanded( child: AppText( model .prescriptionList[ 0] .entityList[ index] .orderTypeDescription, fontSize: 13.0, ), ), ], ), SizedBox( height: 5.5, ), Row( children: [ Container( child: Expanded( child: AppText( model .prescriptionList[ 0] .entityList[ index] .medicationName, fontWeight: FontWeight .w700, fontSize: 15.0, ), ), ) ], ), SizedBox( height: 5.5, ), Row( children: [ Expanded( child: AppText( model .prescriptionList[ 0] .entityList[ index] .doseDetail, fontSize: 15.0, ), ) ], ), SizedBox( height: 3.0, ), Row( children: [ AppText( 'Indication: ', fontWeight: FontWeight .w700, fontSize: 17.0, ), Expanded( child: AppText( model .prescriptionList[ 0] .entityList[ index] .indication, fontSize: 15.0), ) ], ), SizedBox( height: 18.0, ), Row( children: [ Expanded( child: AppText( model .prescriptionList[ 0] .entityList[ index] .doctorName, fontWeight: FontWeight .w700, ), ) ], ), Row( children: [ Expanded( child: AppText( model .prescriptionList[ 0] .entityList[ index] .remarks, fontSize: 14.0, ), ), ], ), SizedBox( height: 10.0, ), Divider( height: 0, thickness: 1.0, color: Colors.grey, ), // SizedBox( // height: 40, // ), ], ), ), Container( height: MediaQuery.of(context) .size .height * 0.05, width: MediaQuery.of(context) .size .width * 0.06, child: Column( children: [ InkWell( child: Icon( Icons.edit), onTap: () { updatePrescriptionForm( context, model .prescriptionList[ 0] .entityList[ index] .medicationName, model .prescriptionList[ 0] .entityList[ index] .medicineCode, model, ); //model.postPrescription(); }, ), ], ), ), ], ), ], ), ), ), ], ), ), ) ], ), ), ), )), ); } void updatePrescriptionForm( context, String drugName, int drugId, PrescriptionViewModel model) { TextEditingController remarksController = TextEditingController(); TextEditingController doseController = TextEditingController(); TextEditingController frequencyController = TextEditingController(); TextEditingController routeController = TextEditingController(); showModalBottomSheet( context: context, isScrollControlled: true, builder: (BuildContext bc) { return Container( height: 600, child: Form( child: Padding( padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( drugName.toUpperCase(), fontWeight: FontWeight.w900, ), SizedBox( height: 30.0, ), Column( children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: 'route', controller: routeController, keyboardType: TextInputType.number, ), ), 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: 'Dose', controller: doseController, keyboardType: TextInputType.number, ), ), 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: 'Frequency', controller: frequencyController, keyboardType: TextInputType.number, ), ), 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: 7, minLines: 4, ), ), SizedBox( height: 12.0, ), SizedBox( height: 140.0, ), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), child: Wrap( alignment: WrapAlignment.center, children: [ AppButton( title: 'update prescription'.toUpperCase(), onPressed: () { updatePrescription( model: model, drugId: drugId, remarks: remarksController.text, route: routeController.text, frequency: frequencyController.text, dose: doseController.text); Navigator.pop(context); }, ), ], ), ), ], ), ], ), ), )); }); } updatePrescription({ PrescriptionViewModel model, int drugId, String remarks, String dose, String frequency, String route, }) async { //PrescriptionViewModel model = PrescriptionViewModel(); PostPrescriptionReqModel updatePrescriptionReqModel = new PostPrescriptionReqModel(); List sss = List(); updatePrescriptionReqModel.appointmentNo = 2016055159; updatePrescriptionReqModel.clinicID = 17; updatePrescriptionReqModel.episodeID = 200012330; updatePrescriptionReqModel.patientMRN = 3120877; updatePrescriptionReqModel.vidaAuthTokenID = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiOGFjNDRjZGQtOWE0Mi00M2YxLWE2YTQtMWQ4NzBmZmYwNTUyIiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1OTU2NDkiLCJDbGluaWNJZCI6IjEiLCJyb2xlIjpbIkRPQ1RPUlMiLCJIRUFEIERPQ1RPUlMiLCJBRE1JTklTVFJBVE9SUyIsIlJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiRVIgUkVDRVBUSU9OSVNUIiwiUEhBUk1BQ1kgQUNDT1VOVCBTVEFGRiIsIlBIQVJNQUNZIE5VUlNFIiwiSU5QQVRJRU5UIFBIQVJNQUNJU1QiLCJBRE1JU1NJT04gU1RBRkYiLCJBUFBST1ZBTCBTVEFGRiIsIkNPTlNFTlQgIiwiTUVESUNBTCBSRVBPUlQgLSBTSUNLIExFQVZFIE1BTkFHRVIiXSwibmJmIjoxNjA4NzM2NjY5LCJleHAiOjE2MDk2MDA2NjksImlhdCI6MTYwODczNjY2OX0.9EDgYrbe5fQA2CvgLdFT4s_PL7hD5R_Qggfpv4lDtUY"; sss.add(PrescriptionRequestModel( covered: true, dose: frequency.isNotEmpty ? int.parse(dose) : 1, itemId: drugId, doseUnitId: 1, route: frequency.isNotEmpty ? int.parse(route) : 1, frequency: frequency.isNotEmpty ? int.parse(frequency) : 1, remarks: remarks.isEmpty ? '' : remarks, approvalRequired: true, icdcode10Id: "test2", doseTime: 1, duration: 2, doseStartDate: "2020-12-20T13:07:41.769Z")); updatePrescriptionReqModel.prescriptionRequestModel = sss; //postProcedureReqModel.procedures = controlsProcedure; await model.updatePrescription(updatePrescriptionReqModel); if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error); } else if (model.state == ViewState.Idle) { DrAppToastMsg.showSuccesToast('Medication has been updated'); } } }