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/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/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:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; void addPrescriptionForm(context) { TextEditingController durationController = TextEditingController(); TextEditingController doseController = TextEditingController(); final GlobalKey _formKey = GlobalKey(); final double spaceBetweenTextFileds = 12; showModalBottomSheet( isScrollControlled: true, context: context, builder: (BuildContext bc) { return SingleChildScrollView( child: Container( height: 700, 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: AppTextFormField( labelText: TranslationBase.of(context).searchMedicine, borderColor: Colors.white, textInputType: TextInputType.text, inputFormatter: ONLY_LETTERS, ), ), SizedBox( height: spaceBetweenTextFileds, ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( labelText: TranslationBase.of(context).orderType, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( labelText: TranslationBase.of(context).strength, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( labelText: TranslationBase.of(context).route, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( labelText: TranslationBase.of(context).frequency, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( labelText: TranslationBase.of(context).doseTime, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, controller: doseController, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( labelText: TranslationBase.of(context).indication, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( labelText: TranslationBase.of(context).fromDate, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, ), ), SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( labelText: TranslationBase.of(context).duration, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, controller: durationController, validator: (value) { if (value == null || value == "") 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: AppTextFormField( labelText: TranslationBase.of(context).instruction, borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, ), ), SizedBox(height: spaceBetweenTextFileds), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), child: Wrap( alignment: WrapAlignment.center, children: [ AppButton( title: TranslationBase.of(context).addMedication, onPressed: () { //prescriptionWarning(context); postProcedure( duration: durationController.text, dose: doseController.text); Navigator.pop(context); }, ), ], ), ), ], ), ), ), ], ), ), ), ); }); } postProcedure({String duration, String dose}) async { PrescriptionViewModel model = new PrescriptionViewModel(); PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); List sss = List(); postProcedureReqModel.appointmentNo = 2016055175; postProcedureReqModel.clinicID = 1; postProcedureReqModel.episodeID = 200012335; postProcedureReqModel.patientMRN = 1234; postProcedureReqModel.vidaAuthTokenID = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiOGFjNDRjZGQtOWE0Mi00M2YxLWE2YTQtMWQ4NzBmZmYwNTUyIiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1OTU2NDkiLCJDbGluaWNJZCI6IjEiLCJyb2xlIjpbIkRPQ1RPUlMiLCJIRUFEIERPQ1RPUlMiLCJBRE1JTklTVFJBVE9SUyIsIlJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiRVIgUkVDRVBUSU9OSVNUIiwiUEhBUk1BQ1kgQUNDT1VOVCBTVEFGRiIsIlBIQVJNQUNZIE5VUlNFIiwiSU5QQVRJRU5UIFBIQVJNQUNJU1QiLCJBRE1JU1NJT04gU1RBRkYiLCJBUFBST1ZBTCBTVEFGRiIsIkNPTlNFTlQgIiwiTUVESUNBTCBSRVBPUlQgLSBTSUNLIExFQVZFIE1BTkFHRVIiXSwibmJmIjoxNjA4NzM2NjY5LCJleHAiOjE2MDk2MDA2NjksImlhdCI6MTYwODczNjY2OX0.9EDgYrbe5fQA2CvgLdFT4s_PL7hD5R_Qggfpv4lDtUY"; sss.add(PrescriptionRequestModel( covered: true, dose: int.parse(dose), itemId: 8, doseUnitId: 1, route: 1, frequency: 1, remarks: "test2", 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 { DrAppToastMsg.showSuccesToast('Medication has been added'); } }