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/models/livecare/transfer_to_admin.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_screen.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_warnings.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/dynamic_elements.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_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'; import 'package:intl/intl.dart'; class AddPrescriptionFormScreen extends StatefulWidget { @override _AddPrescriptionFormScreenState createState() => _AddPrescriptionFormScreenState(); } class _AddPrescriptionFormScreenState extends State { PrescriptionViewModel model = PrescriptionViewModel(); // PostPrescriptionReqModel addPrescriptionModel = PostPrescriptionReqModel(); // List sss = List(); // void _presentDatePicker(id) { // showDatePicker( // context: context, // initialDate: DateTime.now(), // firstDate: DateTime(2019), // lastDate: DateTime(2050), // ).then((pickedDate) { // if (pickedDate == null) { // return; // } // setState(() { // // var selectedDate = DateFormat.yMd().format(pickedDate); // final df = new DateFormat('yyyy-MM-dd'); // model.startDate = df.format(pickedDate); // // strengthController.text = sss.add(PrescriptionRequestModel(doseStartDate: '')); // //addSickLeave.startDate = selectedDate; // }); // }); // } @override Widget build(BuildContext context) { return addPrescriptionForm(context, model); } } addPrescriptionForm(context, PrescriptionViewModel model) { TextEditingController durationController = TextEditingController(); TextEditingController strengthController = TextEditingController(); TextEditingController routeController = TextEditingController(); TextEditingController frequencyController = TextEditingController(); TextEditingController indicationController = TextEditingController(); TextEditingController instructionController = TextEditingController(); TextEditingController drugIdController = TextEditingController(); TextEditingController doseController = TextEditingController(); final GlobalKey formKey = GlobalKey(); final double spaceBetweenTextFileds = 12; showModalBottomSheet( isScrollControlled: true, context: context, builder: (BuildContext bc) { return //BaseView( //onModelReady: (model) => model.getDrugs(), //builder: (BuildContext context, PrescriptionViewModel model, //Widget child) => DraggableScrollableSheet( initialChildSize: 0.90, maxChildSize: 0.90, minChildSize: 0.9, builder: (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( child: Container( height: 980, child: Padding( padding: EdgeInsets.symmetric( horizontal: 12.0, vertical: 10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, //mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AppText( TranslationBase.of(context) .medicines .toUpperCase(), fontWeight: FontWeight.w900, ), SizedBox( height: spaceBetweenTextFileds, ), Container( child: Form( key: formKey, child: Column( //mainAxisAlignment: MainAxisAlignment.end, children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context) .searchMedicine, controller: drugIdController, keyboardType: TextInputType.number, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }), ), SizedBox( height: spaceBetweenTextFileds, ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context) .orderType, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context) .strength, keyboardType: TextInputType.number, controller: strengthController, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context).route, controller: routeController, keyboardType: TextInputType.number, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context) .frequency, controller: frequencyController, keyboardType: TextInputType.number, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context) .doseTime, controller: doseController, keyboardType: TextInputType.number, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context) .indication, controller: indicationController, keyboardType: TextInputType.number, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context) .fromDate, keyboardType: TextInputType.datetime, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( hintText: TranslationBase.of(context) .duration, // borderColor: Colors.white, keyboardType: TextInputType.number, controller: durationController, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: TextFields( maxLines: 6, minLines: 4, hintText: TranslationBase.of(context) .instruction, controller: instructionController, //keyboardType: TextInputType.number, validator: (value) { if (value.isEmpty) return TranslationBase.of(context) .emptyMessage; else return null; }, ), ), SizedBox(height: spaceBetweenTextFileds), Container( margin: EdgeInsets.all( SizeConfig.widthMultiplier * 5), child: Wrap( alignment: WrapAlignment.center, children: [ AppButton( title: TranslationBase.of(context) .addMedication, onPressed: () { formKey.currentState.save(); if (formKey.currentState .validate()) { postProcedure( model: model, duration: durationController.text, dose: doseController.text, frequency: frequencyController.text, route: routeController.text, drugId: drugIdController.text, strength: strengthController.text, indication: indicationController.text, instruction: indicationController.text, ); Navigator.pop(context); } { // Navigator.push( // context, // MaterialPageRoute( // builder: (context) => // NewPrescriptionScreen()), // ); } }, ), ], ), ), ], ), ), ), ], ), ), ), ); }); //); }); } // openAllergiesList(BuildContext context) { // showModalBottomSheet( // backgroundColor: Colors.white, // isScrollControlled: true, // context: context, // builder: (context) { // return AddAllergies( // addAllergiesFun: (MySelectedAllergy mySelectedAllergy) { // setState(() { // widget.myAllergiesList.add(mySelectedAllergy); // Navigator.of(context).pop(); // }); // }, // ); // }); // } postProcedure( {String duration, String dose, String drugId, String strength, String route, String frequency, String indication, String instruction, PrescriptionViewModel model}) async { PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); List sss = List(); postProcedureReqModel.appointmentNo = 2016055159; postProcedureReqModel.clinicID = 17; postProcedureReqModel.episodeID = 200012330; postProcedureReqModel.patientMRN = 3120877; postProcedureReqModel.vidaAuthTokenID = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiOGFjNDRjZGQtOWE0Mi00M2YxLWE2YTQtMWQ4NzBmZmYwNTUyIiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1OTU2NDkiLCJDbGluaWNJZCI6IjEiLCJyb2xlIjpbIkRPQ1RPUlMiLCJIRUFEIERPQ1RPUlMiLCJBRE1JTklTVFJBVE9SUyIsIlJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiRVIgUkVDRVBUSU9OSVNUIiwiUEhBUk1BQ1kgQUNDT1VOVCBTVEFGRiIsIlBIQVJNQUNZIE5VUlNFIiwiSU5QQVRJRU5UIFBIQVJNQUNJU1QiLCJBRE1JU1NJT04gU1RBRkYiLCJBUFBST1ZBTCBTVEFGRiIsIkNPTlNFTlQgIiwiTUVESUNBTCBSRVBPUlQgLSBTSUNLIExFQVZFIE1BTkFHRVIiXSwibmJmIjoxNjA4NzM2NjY5LCJleHAiOjE2MDk2MDA2NjksImlhdCI6MTYwODczNjY2OX0.9EDgYrbe5fQA2CvgLdFT4s_PL7hD5R_Qggfpv4lDtUY"; sss.add(PrescriptionRequestModel( covered: true, dose: int.parse(dose), itemId: int.parse(drugId), doseUnitId: 1, route: int.parse(route), frequency: int.parse(frequency), remarks: instruction, approvalRequired: true, icdcode10Id: "test2", doseTime: 1, duration: int.parse(duration), doseStartDate: "2020-12-20T13:07:41.769Z")); postProcedureReqModel.prescriptionRequestModel = sss; //postProcedureReqModel.procedures = controlsProcedure; await model.postPrescription(postProcedureReqModel); if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error); } else if (model.state == ViewState.Idle) { DrAppToastMsg.showSuccesToast('Medication has been added'); } }