|
|
|
|
@ -2,6 +2,7 @@ import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/provider/robot_provider.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/service/AnalyticsService.dart';
|
|
|
|
|
@ -9,7 +10,6 @@ import 'package:doctor_app_flutter/core/viewModel/medicine_view_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/locator.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/prescription/prescription_text_filed.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/date-utils.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
|
|
|
|
|
@ -25,19 +25,23 @@ import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:hexcolor/hexcolor.dart';
|
|
|
|
|
import 'package:speech_to_text/speech_recognition_error.dart';
|
|
|
|
|
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
|
|
|
|
import 'add_drug_widget.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'add_drug_widget.dart';
|
|
|
|
|
|
|
|
|
|
class PrescriptionFormWidget extends StatefulWidget {
|
|
|
|
|
final PatiantInformtion patient;
|
|
|
|
|
final List<PrescriptionModel> prescriptionList;
|
|
|
|
|
final PrescriptionViewModel prescriptionViewModel;
|
|
|
|
|
final MedicineViewModel medicineViewModel;
|
|
|
|
|
final GetMedicationResponseModel selectedMedication;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PrescriptionFormWidget({Key key, this.patient, this.prescriptionList,
|
|
|
|
|
this.prescriptionViewModel, this.medicineViewModel,});
|
|
|
|
|
const PrescriptionFormWidget(
|
|
|
|
|
{Key key,
|
|
|
|
|
this.patient,
|
|
|
|
|
this.prescriptionList,
|
|
|
|
|
this.prescriptionViewModel,
|
|
|
|
|
this.medicineViewModel,
|
|
|
|
|
this.selectedMedication});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_PrescriptionFormWidgetState createState() => _PrescriptionFormWidgetState();
|
|
|
|
|
@ -64,11 +68,10 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
final myController = TextEditingController();
|
|
|
|
|
DateTime selectedDate;
|
|
|
|
|
int strengthChar;
|
|
|
|
|
GetMedicationResponseModel _selectedMedication;
|
|
|
|
|
PrescriptionViewModel prescriptionViewModel;
|
|
|
|
|
|
|
|
|
|
GlobalKey key =
|
|
|
|
|
new GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
|
|
|
|
|
new GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
|
|
|
|
|
|
|
|
|
|
TextEditingController drugIdController = TextEditingController();
|
|
|
|
|
TextEditingController doseController = TextEditingController();
|
|
|
|
|
@ -89,7 +92,6 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
dynamic box;
|
|
|
|
|
dynamic x;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setSelectedType(int val) {
|
|
|
|
|
setState(() {
|
|
|
|
|
selectedType = val;
|
|
|
|
|
@ -153,445 +155,366 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final screenSize = MediaQuery.of(context).size;
|
|
|
|
|
return Visibility(
|
|
|
|
|
visible: visibilitySearch,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
AppText(
|
|
|
|
|
_selectedMedication?.description ??
|
|
|
|
|
"",
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 15.0,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(width: 6,),
|
|
|
|
|
AppText(
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.orderType,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 18,),
|
|
|
|
|
Radio(
|
|
|
|
|
activeColor:
|
|
|
|
|
AppGlobal.appRedColor,
|
|
|
|
|
value: 1,
|
|
|
|
|
groupValue: selectedType,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setSelectedType(value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Text(TranslationBase.of(context)
|
|
|
|
|
.regular),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
AppText(
|
|
|
|
|
widget.selectedMedication?.description ?? "",
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 15.0,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 6,
|
|
|
|
|
),
|
|
|
|
|
AppText(
|
|
|
|
|
TranslationBase.of(context).orderType,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 18,
|
|
|
|
|
),
|
|
|
|
|
Radio(
|
|
|
|
|
activeColor: AppGlobal.appRedColor,
|
|
|
|
|
value: 1,
|
|
|
|
|
groupValue: selectedType,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setSelectedType(value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Text(TranslationBase.of(context).regular),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width *
|
|
|
|
|
0.35,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
height: 38,
|
|
|
|
|
validationError:
|
|
|
|
|
strengthError,
|
|
|
|
|
hintText: 'Strength',
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
enabled: true,
|
|
|
|
|
controller:
|
|
|
|
|
strengthController,
|
|
|
|
|
onChanged: (String value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
strengthChar =
|
|
|
|
|
value.length;
|
|
|
|
|
});
|
|
|
|
|
if (strengthChar >= 5) {
|
|
|
|
|
DrAppToastMsg
|
|
|
|
|
.showErrorToast(
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.only5DigitsAllowedForStrength,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
inputType: TextInputType
|
|
|
|
|
.numberWithOptions(
|
|
|
|
|
decimal: true,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 5.0,
|
|
|
|
|
),
|
|
|
|
|
// Container(
|
|
|
|
|
// width: MediaQuery.of(context)
|
|
|
|
|
// .size
|
|
|
|
|
// .width *
|
|
|
|
|
// 0.35,
|
|
|
|
|
// child: AppTextFieldCustom(
|
|
|
|
|
// height: 38,
|
|
|
|
|
// validationError:
|
|
|
|
|
// unitError,
|
|
|
|
|
// hintText: 'Unit',
|
|
|
|
|
// isTextFieldHasSuffix: false,
|
|
|
|
|
// enabled: true,
|
|
|
|
|
// controller:
|
|
|
|
|
// unitController,
|
|
|
|
|
// onChanged: (selectedValue) {
|
|
|
|
|
// setState(() {
|
|
|
|
|
// units = selectedValue;
|
|
|
|
|
// units['isDefault'] = true;
|
|
|
|
|
// });
|
|
|
|
|
// if (strengthChar >= 5) {
|
|
|
|
|
// DrAppToastMsg
|
|
|
|
|
// .showErrorToast(
|
|
|
|
|
// TranslationBase.of(
|
|
|
|
|
// context)
|
|
|
|
|
// .only5DigitsAllowedForStrength,
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// inputType: TextInputType
|
|
|
|
|
// .numberWithOptions(
|
|
|
|
|
// decimal: true,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
width: MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width *
|
|
|
|
|
0.510,
|
|
|
|
|
element: widget.medicineViewModel
|
|
|
|
|
.itemMedicineListUnit
|
|
|
|
|
.length ==
|
|
|
|
|
1
|
|
|
|
|
? widget.medicineViewModel
|
|
|
|
|
.itemMedicineListUnit[0]
|
|
|
|
|
: units,
|
|
|
|
|
elementError: unitError,
|
|
|
|
|
keyName: 'description',
|
|
|
|
|
keyId: 'parameterCode',
|
|
|
|
|
hintText: 'Unit',
|
|
|
|
|
elementList: widget.medicineViewModel
|
|
|
|
|
.itemMedicineListUnit,
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.35,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
height: 38,
|
|
|
|
|
validationError: strengthError,
|
|
|
|
|
hintText: 'Strength',
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
enabled: true,
|
|
|
|
|
controller: strengthController,
|
|
|
|
|
onChanged: (String value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
units = selectedValue;
|
|
|
|
|
units['isDefault'] = true;
|
|
|
|
|
strengthChar = value.length;
|
|
|
|
|
});
|
|
|
|
|
if (strengthChar >= 5) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.only5DigitsAllowedForStrength,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
elementList:
|
|
|
|
|
widget.medicineViewModel.itemMedicineListRoute,
|
|
|
|
|
element: widget.medicineViewModel.itemMedicineListRoute
|
|
|
|
|
.length ==
|
|
|
|
|
1
|
|
|
|
|
? route = widget.medicineViewModel.itemMedicineListRoute[0]
|
|
|
|
|
: route,
|
|
|
|
|
elementError: routeError,
|
|
|
|
|
keyId: 'parameterCode',
|
|
|
|
|
keyName: 'description',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
route = selectedValue;
|
|
|
|
|
route['isDefault'] = true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.route,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
hintText: TranslationBase.of(context).frequency,
|
|
|
|
|
elementError: frequencyError,
|
|
|
|
|
// element: frequency,
|
|
|
|
|
element: widget.medicineViewModel.itemMedicineListRoute
|
|
|
|
|
.length ==
|
|
|
|
|
1
|
|
|
|
|
? frequency = widget.medicineViewModel.itemMedicineListRoute[0]
|
|
|
|
|
: frequency,
|
|
|
|
|
elementList: widget.medicineViewModel.itemMedicineList,
|
|
|
|
|
keyId: 'parameterCode',
|
|
|
|
|
keyName: 'description',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
frequency = selectedValue;
|
|
|
|
|
frequency['isDefault'] = true;
|
|
|
|
|
if (_selectedMedication != null && duration != null && frequency != null && strengthController.text != null) {
|
|
|
|
|
widget.medicineViewModel.getBoxQuantity(
|
|
|
|
|
freq: frequency['parameterCode'],
|
|
|
|
|
duration: duration['id'],
|
|
|
|
|
itemCode: _selectedMedication.itemId,
|
|
|
|
|
strength: double.parse(strengthController.text)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.doseTime,
|
|
|
|
|
elementError: doseTimeError,
|
|
|
|
|
element: doseTime,
|
|
|
|
|
elementList:
|
|
|
|
|
widget.medicineViewModel.medicationDoseTimeList,
|
|
|
|
|
keyId: 'id',
|
|
|
|
|
keyName: 'nameEn',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
doseTime = selectedValue;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
if (widget.medicineViewModel
|
|
|
|
|
.patientAssessmentList.isNotEmpty)
|
|
|
|
|
Container(
|
|
|
|
|
height: screenSize.height * 0.070,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width:
|
|
|
|
|
MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width *
|
|
|
|
|
0.29,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
hintText:
|
|
|
|
|
widget.medicineViewModel
|
|
|
|
|
.patientAssessmentList[
|
|
|
|
|
0]
|
|
|
|
|
.icdCode10ID
|
|
|
|
|
.toString(),
|
|
|
|
|
// indication != null
|
|
|
|
|
// ? indication[
|
|
|
|
|
// 'name']
|
|
|
|
|
// : null,
|
|
|
|
|
|
|
|
|
|
enabled: true,
|
|
|
|
|
),
|
|
|
|
|
inputType: TextInputType.numberWithOptions(
|
|
|
|
|
decimal: true,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width:
|
|
|
|
|
MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width *
|
|
|
|
|
0.57,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
maxLines: 5,
|
|
|
|
|
hintText:
|
|
|
|
|
widget.medicineViewModel
|
|
|
|
|
.patientAssessmentList[
|
|
|
|
|
0]
|
|
|
|
|
.asciiDesc
|
|
|
|
|
.toString(),
|
|
|
|
|
// indication != null
|
|
|
|
|
// ? indication[
|
|
|
|
|
// 'name']
|
|
|
|
|
// : null,
|
|
|
|
|
enabled: true,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.transparent,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () => selectDate(
|
|
|
|
|
context, widget.prescriptionViewModel),
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
validationError:
|
|
|
|
|
strengthError,
|
|
|
|
|
hintText: 'Date',
|
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.calendar_today,
|
|
|
|
|
color: Colors.black,),
|
|
|
|
|
),
|
|
|
|
|
dropDownText: selectedDate != null
|
|
|
|
|
? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
|
|
|
|
|
: null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
controller: strengthController,
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// TextField(
|
|
|
|
|
// decoration:
|
|
|
|
|
// textFieldSelectorDecoration(
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 5.0,
|
|
|
|
|
),
|
|
|
|
|
// Container(
|
|
|
|
|
// width: MediaQuery.of(context)
|
|
|
|
|
// .size
|
|
|
|
|
// .width *
|
|
|
|
|
// 0.35,
|
|
|
|
|
// child: AppTextFieldCustom(
|
|
|
|
|
// height: 38,
|
|
|
|
|
// validationError:
|
|
|
|
|
// unitError,
|
|
|
|
|
// hintText: 'Unit',
|
|
|
|
|
// isTextFieldHasSuffix: false,
|
|
|
|
|
// enabled: true,
|
|
|
|
|
// controller:
|
|
|
|
|
// unitController,
|
|
|
|
|
// onChanged: (selectedValue) {
|
|
|
|
|
// setState(() {
|
|
|
|
|
// units = selectedValue;
|
|
|
|
|
// units['isDefault'] = true;
|
|
|
|
|
// });
|
|
|
|
|
// if (strengthChar >= 5) {
|
|
|
|
|
// DrAppToastMsg
|
|
|
|
|
// .showErrorToast(
|
|
|
|
|
// TranslationBase.of(
|
|
|
|
|
// context)
|
|
|
|
|
// .date,
|
|
|
|
|
// selectedDate != null
|
|
|
|
|
// ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
|
|
|
|
|
// : null,
|
|
|
|
|
// true,
|
|
|
|
|
// suffixIcon: Icon(
|
|
|
|
|
// Icons.calendar_today,
|
|
|
|
|
// color: Colors.black,
|
|
|
|
|
// )),
|
|
|
|
|
// enabled: false,
|
|
|
|
|
// context)
|
|
|
|
|
// .only5DigitsAllowedForStrength,
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// inputType: TextInputType
|
|
|
|
|
// .numberWithOptions(
|
|
|
|
|
// decimal: true,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.510,
|
|
|
|
|
element:
|
|
|
|
|
widget.medicineViewModel.itemMedicineListUnit.length == 1
|
|
|
|
|
? widget.medicineViewModel.itemMedicineListUnit[0]
|
|
|
|
|
: units,
|
|
|
|
|
elementError: unitError,
|
|
|
|
|
keyName: 'description',
|
|
|
|
|
keyId: 'parameterCode',
|
|
|
|
|
hintText: 'Unit',
|
|
|
|
|
elementList: widget.medicineViewModel.itemMedicineListUnit,
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
units = selectedValue;
|
|
|
|
|
units['isDefault'] = true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
element: duration,
|
|
|
|
|
elementError: durationError,
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.duration,
|
|
|
|
|
elementList:
|
|
|
|
|
widget.medicineViewModel.medicationDurationList,
|
|
|
|
|
keyName: 'nameEn',
|
|
|
|
|
keyId: 'id',
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
elementList: widget.medicineViewModel.itemMedicineListRoute,
|
|
|
|
|
element: widget.medicineViewModel.itemMedicineListRoute.length == 1
|
|
|
|
|
? route = widget.medicineViewModel.itemMedicineListRoute[0]
|
|
|
|
|
: route,
|
|
|
|
|
elementError: routeError,
|
|
|
|
|
keyId: 'parameterCode',
|
|
|
|
|
keyName: 'description',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
route = selectedValue;
|
|
|
|
|
route['isDefault'] = true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
hintText: TranslationBase.of(context).route,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
hintText: TranslationBase.of(context).frequency,
|
|
|
|
|
elementError: frequencyError,
|
|
|
|
|
// element: frequency,
|
|
|
|
|
element: widget.medicineViewModel.itemMedicineListRoute.length == 1
|
|
|
|
|
? frequency = widget.medicineViewModel.itemMedicineListRoute[0]
|
|
|
|
|
: frequency,
|
|
|
|
|
elementList: widget.medicineViewModel.itemMedicineList,
|
|
|
|
|
keyId: 'parameterCode',
|
|
|
|
|
keyName: 'description',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
duration = selectedValue;
|
|
|
|
|
if (_selectedMedication !=
|
|
|
|
|
null &&
|
|
|
|
|
frequency = selectedValue;
|
|
|
|
|
frequency['isDefault'] = true;
|
|
|
|
|
if (widget.selectedMedication != null &&
|
|
|
|
|
duration != null &&
|
|
|
|
|
frequency != null &&
|
|
|
|
|
strengthController.text !=
|
|
|
|
|
null) {
|
|
|
|
|
strengthController.text != null) {
|
|
|
|
|
widget.medicineViewModel.getBoxQuantity(
|
|
|
|
|
freq: frequency[
|
|
|
|
|
'parameterCode'],
|
|
|
|
|
duration: duration['id'],
|
|
|
|
|
itemCode:
|
|
|
|
|
_selectedMedication
|
|
|
|
|
.itemId,
|
|
|
|
|
strength: double.parse(
|
|
|
|
|
strengthController
|
|
|
|
|
.text),
|
|
|
|
|
);
|
|
|
|
|
box = widget.medicineViewModel.boxQuintity;
|
|
|
|
|
freq: frequency['parameterCode'],
|
|
|
|
|
duration: duration['id'],
|
|
|
|
|
itemCode: widget.selectedMedication.itemId,
|
|
|
|
|
strength: double.parse(strengthController.text));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
hintText: TranslationBase.of(context).doseTime,
|
|
|
|
|
elementError: doseTimeError,
|
|
|
|
|
element: doseTime,
|
|
|
|
|
elementList: widget.medicineViewModel.medicationDoseTimeList,
|
|
|
|
|
keyId: 'id',
|
|
|
|
|
keyName: 'nameEn',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
doseTime = selectedValue;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
if (widget.medicineViewModel.patientAssessmentList.isNotEmpty)
|
|
|
|
|
Container(
|
|
|
|
|
height: screenSize.height * 0.070,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
hintText: "UOM",
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
dropDownText:
|
|
|
|
|
uom != null ? uom : null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.29,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
hintText: widget
|
|
|
|
|
.medicineViewModel.patientAssessmentList[0].icdCode10ID
|
|
|
|
|
.toString(),
|
|
|
|
|
// indication != null
|
|
|
|
|
// ? indication[
|
|
|
|
|
// 'name']
|
|
|
|
|
// : null,
|
|
|
|
|
|
|
|
|
|
enabled: true,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.57,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
maxLines: 5,
|
|
|
|
|
hintText: widget
|
|
|
|
|
.medicineViewModel.patientAssessmentList[0].asciiDesc
|
|
|
|
|
.toString(),
|
|
|
|
|
// indication != null
|
|
|
|
|
// ? indication[
|
|
|
|
|
// 'name']
|
|
|
|
|
// : null,
|
|
|
|
|
enabled: true,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.transparent,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () => selectDate(context, widget.prescriptionViewModel),
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.boxQuantity,
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
dropDownText: box != null
|
|
|
|
|
? widget.medicineViewModel.boxQuintity.toString()
|
|
|
|
|
validationError: strengthError,
|
|
|
|
|
hintText: 'Date',
|
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.calendar_today,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
dropDownText: selectedDate != null
|
|
|
|
|
? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
|
|
|
|
|
: null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
controller: strengthController,
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// TextField(
|
|
|
|
|
// decoration:
|
|
|
|
|
// textFieldSelectorDecoration(
|
|
|
|
|
// TranslationBase.of(
|
|
|
|
|
// context)
|
|
|
|
|
// .date,
|
|
|
|
|
// selectedDate != null
|
|
|
|
|
// ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
|
|
|
|
|
// : null,
|
|
|
|
|
// true,
|
|
|
|
|
// suffixIcon: Icon(
|
|
|
|
|
// Icons.calendar_today,
|
|
|
|
|
// color: Colors.black,
|
|
|
|
|
// )),
|
|
|
|
|
// enabled: false,
|
|
|
|
|
// ),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
element: duration,
|
|
|
|
|
elementError: durationError,
|
|
|
|
|
hintText: TranslationBase.of(context).duration,
|
|
|
|
|
elementList: widget.medicineViewModel.medicationDurationList,
|
|
|
|
|
keyName: 'nameEn',
|
|
|
|
|
keyId: 'id',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
duration = selectedValue;
|
|
|
|
|
if (widget.selectedMedication != null &&
|
|
|
|
|
duration != null &&
|
|
|
|
|
frequency != null &&
|
|
|
|
|
strengthController.text != null) {
|
|
|
|
|
widget.medicineViewModel.getBoxQuantity(
|
|
|
|
|
freq: frequency['parameterCode'],
|
|
|
|
|
duration: duration['id'],
|
|
|
|
|
itemCode: widget.selectedMedication.itemId,
|
|
|
|
|
strength: double.parse(strengthController.text),
|
|
|
|
|
);
|
|
|
|
|
box = widget.medicineViewModel.boxQuintity;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
hintText: "UOM",
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
dropDownText: uom != null ? uom : null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color:
|
|
|
|
|
HexColor("#CCCCCC"))),
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
TextFields(
|
|
|
|
|
maxLines: 6,
|
|
|
|
|
minLines: 4,
|
|
|
|
|
hintText: TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.instruction,
|
|
|
|
|
controller:
|
|
|
|
|
instructionController,
|
|
|
|
|
//keyboardType: TextInputType.number,
|
|
|
|
|
),
|
|
|
|
|
Positioned(
|
|
|
|
|
top: 0,
|
|
|
|
|
right: 15,
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
DoctorApp.speechtotext,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
size: 35,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
initSpeechState().then(
|
|
|
|
|
(value) =>
|
|
|
|
|
{onVoiceText()});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
hintText: TranslationBase.of(context).boxQuantity,
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
dropDownText: box != null
|
|
|
|
|
? widget.medicineViewModel.boxQuintity.toString()
|
|
|
|
|
: null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFields),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(
|
|
|
|
|
SizeConfig.widthMultiplier * 5),
|
|
|
|
|
child: Wrap(
|
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
AppButton(
|
|
|
|
|
color: Color(0xff359846),
|
|
|
|
|
title: TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.addMedication,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
addMedicationButton( widget.medicineViewModel);
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))),
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
TextFields(
|
|
|
|
|
maxLines: 6,
|
|
|
|
|
minLines: 4,
|
|
|
|
|
hintText: TranslationBase.of(context).instruction,
|
|
|
|
|
controller: instructionController,
|
|
|
|
|
//keyboardType: TextInputType.number,
|
|
|
|
|
),
|
|
|
|
|
Positioned(
|
|
|
|
|
top: 0,
|
|
|
|
|
right: 15,
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
DoctorApp.speechtotext,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
size: 35,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
initSpeechState().then((value) => {onVoiceText()});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFields),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
|
|
|
|
|
child: Wrap(
|
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
AppButton(
|
|
|
|
|
color: Color(0xff359846),
|
|
|
|
|
title: TranslationBase.of(context).addMedication,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
addMedicationButton(widget.medicineViewModel);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -613,7 +536,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openDrugToDrug(MedicineViewModel model, PrescriptionViewModel modelPrescription) {
|
|
|
|
|
openDrugToDrug(
|
|
|
|
|
MedicineViewModel model, PrescriptionViewModel modelPrescription) {
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) {
|
|
|
|
|
@ -626,107 +550,65 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addMedicationButton(MedicineViewModel model) async {
|
|
|
|
|
await locator<
|
|
|
|
|
AnalyticsService>()
|
|
|
|
|
.logEvent(
|
|
|
|
|
eventCategory:
|
|
|
|
|
"Add Prescription Form",
|
|
|
|
|
eventAction:
|
|
|
|
|
"Add Prescription",
|
|
|
|
|
await locator<AnalyticsService>().logEvent(
|
|
|
|
|
eventCategory: "Add Prescription Form",
|
|
|
|
|
eventAction: "Add Prescription",
|
|
|
|
|
);
|
|
|
|
|
if (duration != null &&
|
|
|
|
|
doseTime != null &&
|
|
|
|
|
frequency != null &&
|
|
|
|
|
selectedDate != null &&
|
|
|
|
|
strengthController
|
|
|
|
|
.text !=
|
|
|
|
|
"") {
|
|
|
|
|
if (_selectedMedication
|
|
|
|
|
.isNarcotic ==
|
|
|
|
|
true) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.narcoticMedicineCanOnlyBePrescribedFromVida);
|
|
|
|
|
strengthController.text != "") {
|
|
|
|
|
if (widget.selectedMedication.isNarcotic == true) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(TranslationBase.of(context)
|
|
|
|
|
.narcoticMedicineCanOnlyBePrescribedFromVida);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (double.parse(
|
|
|
|
|
strengthController
|
|
|
|
|
.text) >
|
|
|
|
|
1000.0) {
|
|
|
|
|
DrAppToastMsg
|
|
|
|
|
.showErrorToast(
|
|
|
|
|
"1000 is the MAX for the strength");
|
|
|
|
|
if (double.parse(strengthController.text) > 1000.0) {
|
|
|
|
|
DrAppToastMsg.showErrorToast("1000 is the MAX for the strength");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (double.parse(
|
|
|
|
|
strengthController
|
|
|
|
|
.text) <
|
|
|
|
|
0.0) {
|
|
|
|
|
DrAppToastMsg
|
|
|
|
|
.showErrorToast(
|
|
|
|
|
"strength can't be zero");
|
|
|
|
|
if (double.parse(strengthController.text) < 0.0) {
|
|
|
|
|
DrAppToastMsg.showErrorToast("strength can't be zero");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (formKey.currentState
|
|
|
|
|
.validate()) {
|
|
|
|
|
if (formKey.currentState.validate()) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
openDrugToDrug(model, widget.prescriptionViewModel);
|
|
|
|
|
openDrugToDrug(model, widget.prescriptionViewModel);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
if (duration == null) {
|
|
|
|
|
durationError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
durationError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
durationError = null;
|
|
|
|
|
}
|
|
|
|
|
if (doseTime == null) {
|
|
|
|
|
doseTimeError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
doseTimeError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
doseTimeError = null;
|
|
|
|
|
}
|
|
|
|
|
if (route == null) {
|
|
|
|
|
routeError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
routeError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
routeError = null;
|
|
|
|
|
}
|
|
|
|
|
if (frequency == null) {
|
|
|
|
|
frequencyError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
frequencyError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
frequencyError = null;
|
|
|
|
|
}
|
|
|
|
|
if (units == null) {
|
|
|
|
|
unitError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
unitError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
unitError = null;
|
|
|
|
|
}
|
|
|
|
|
if (strengthController
|
|
|
|
|
.text ==
|
|
|
|
|
"") {
|
|
|
|
|
strengthError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
if (strengthController.text == "") {
|
|
|
|
|
strengthError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
strengthError = null;
|
|
|
|
|
}
|
|
|
|
|
@ -735,5 +617,3 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
formKey.currentState.save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|