|
|
|
|
@ -35,7 +35,8 @@ import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
import 'package:speech_to_text/speech_recognition_error.dart';
|
|
|
|
|
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
|
|
|
|
|
|
|
|
|
addPrescriptionForm(context, PrescriptionViewModel model, PatiantInformtion patient, prescription) {
|
|
|
|
|
addPrescriptionForm(context, PrescriptionViewModel model,
|
|
|
|
|
PatiantInformtion patient, prescription) {
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
context: context,
|
|
|
|
|
@ -60,7 +61,8 @@ postPrescription(
|
|
|
|
|
String? icdCode,
|
|
|
|
|
PatiantInformtion? patient,
|
|
|
|
|
String? patientType}) async {
|
|
|
|
|
PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel();
|
|
|
|
|
PostPrescriptionReqModel postProcedureReqModel =
|
|
|
|
|
new PostPrescriptionReqModel();
|
|
|
|
|
List<PrescriptionRequestModel> prescriptionList = [];
|
|
|
|
|
|
|
|
|
|
postProcedureReqModel.appointmentNo = patient!.appointmentNo;
|
|
|
|
|
@ -125,7 +127,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
DateTime? selectedDate;
|
|
|
|
|
int? strengthChar;
|
|
|
|
|
GetMedicationResponseModel? _selectedMedication;
|
|
|
|
|
GlobalKey key = new GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
|
|
|
|
|
GlobalKey key =
|
|
|
|
|
new GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
|
|
|
|
|
|
|
|
|
|
TextEditingController drugIdController = TextEditingController();
|
|
|
|
|
TextEditingController doseController = TextEditingController();
|
|
|
|
|
@ -169,7 +172,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
onVoiceText() async {
|
|
|
|
|
new SpeechToText(context: context).showAlertDialog(context);
|
|
|
|
|
var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode;
|
|
|
|
|
bool available = await speech.initialize(onStatus: statusListener, onError: errorListener);
|
|
|
|
|
bool available = await speech.initialize(
|
|
|
|
|
onStatus: statusListener, onError: errorListener);
|
|
|
|
|
if (available) {
|
|
|
|
|
speech.listen(
|
|
|
|
|
onResult: resultListener,
|
|
|
|
|
@ -212,7 +216,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> initSpeechState() async {
|
|
|
|
|
bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener);
|
|
|
|
|
bool hasSpeech = await speech.initialize(
|
|
|
|
|
onError: errorListener, onStatus: statusListener);
|
|
|
|
|
print(hasSpeech);
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
}
|
|
|
|
|
@ -257,13 +262,15 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
initialChildSize: 0.98,
|
|
|
|
|
maxChildSize: 0.98,
|
|
|
|
|
minChildSize: 0.9,
|
|
|
|
|
builder: (BuildContext context, ScrollController scrollController) {
|
|
|
|
|
builder:
|
|
|
|
|
(BuildContext context, ScrollController scrollController) {
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height * 1.65,
|
|
|
|
|
color: Color(0xffF8F8F8),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0),
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 12.0, vertical: 10.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
@ -285,8 +292,11 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
widthFactor: 0.9,
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))),
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color: HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: AppTextFormField(
|
|
|
|
|
onTap: () {
|
|
|
|
|
@ -294,7 +304,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
visbiltySearch = true;
|
|
|
|
|
},
|
|
|
|
|
borderColor: Colors.white,
|
|
|
|
|
hintText: TranslationBase.of(context).searchMedicineNameHere,
|
|
|
|
|
hintText: TranslationBase.of(context)
|
|
|
|
|
.searchMedicineNameHere,
|
|
|
|
|
controller: myController,
|
|
|
|
|
onSaved: (value) {},
|
|
|
|
|
onFieldSubmitted: (value) {
|
|
|
|
|
@ -320,9 +331,12 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
// TODO change it secondary button and add loading
|
|
|
|
|
AppButton(
|
|
|
|
|
title: TranslationBase.of(context).search,
|
|
|
|
|
title: TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.search,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
await searchMedicine(context, model);
|
|
|
|
|
await searchMedicine(
|
|
|
|
|
context, model);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -331,23 +345,44 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
),
|
|
|
|
|
if (myController.text != '')
|
|
|
|
|
Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height * 0.5,
|
|
|
|
|
height: MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.height *
|
|
|
|
|
0.5,
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
padding: const EdgeInsets.only(top: 20),
|
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
|
top: 20),
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
itemCount: model.allMedicationList == null
|
|
|
|
|
? 0
|
|
|
|
|
: model.allMedicationList.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
itemCount:
|
|
|
|
|
model.allMedicationList ==
|
|
|
|
|
null
|
|
|
|
|
? 0
|
|
|
|
|
: model
|
|
|
|
|
.allMedicationList
|
|
|
|
|
.length,
|
|
|
|
|
itemBuilder:
|
|
|
|
|
(BuildContext context,
|
|
|
|
|
int index) {
|
|
|
|
|
return InkWell(
|
|
|
|
|
child: MedicineItemWidget(
|
|
|
|
|
label: model.allMedicationList[index].description),
|
|
|
|
|
label: model
|
|
|
|
|
.allMedicationList[
|
|
|
|
|
index]
|
|
|
|
|
.description),
|
|
|
|
|
onTap: () {
|
|
|
|
|
model.getItem(itemID: model.allMedicationList[index].itemId!);
|
|
|
|
|
visbiltyPrescriptionForm = true;
|
|
|
|
|
model.getItem(
|
|
|
|
|
itemID: model
|
|
|
|
|
.allMedicationList[
|
|
|
|
|
index]
|
|
|
|
|
.itemId!);
|
|
|
|
|
visbiltyPrescriptionForm =
|
|
|
|
|
true;
|
|
|
|
|
visbiltySearch = false;
|
|
|
|
|
_selectedMedication = model.allMedicationList[index];
|
|
|
|
|
uom = _selectedMedication!.uom;
|
|
|
|
|
_selectedMedication =
|
|
|
|
|
model.allMedicationList[
|
|
|
|
|
index];
|
|
|
|
|
uom = _selectedMedication!
|
|
|
|
|
.uom;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
@ -366,53 +401,69 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
AppText(
|
|
|
|
|
_selectedMedication?.description ?? "",
|
|
|
|
|
_selectedMedication?.description ??
|
|
|
|
|
"",
|
|
|
|
|
bold: true,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
AppText(
|
|
|
|
|
TranslationBase.of(context).orderType,
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.orderType,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
Radio(
|
|
|
|
|
activeColor: Color(0xFFB9382C),
|
|
|
|
|
activeColor:
|
|
|
|
|
Color(0xFFB9382C),
|
|
|
|
|
value: 1,
|
|
|
|
|
groupValue: selectedType,
|
|
|
|
|
onChanged: (int? value) {
|
|
|
|
|
setSelectedType(value!);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Text(TranslationBase.of(context).regular ?? ""),
|
|
|
|
|
Text(TranslationBase.of(context)
|
|
|
|
|
.regular ??
|
|
|
|
|
""),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.35,
|
|
|
|
|
width: MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width *
|
|
|
|
|
0.35,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
height: 40,
|
|
|
|
|
validationError: strengthError,
|
|
|
|
|
validationError:
|
|
|
|
|
strengthError,
|
|
|
|
|
hintText: 'Strength',
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
enabled: true,
|
|
|
|
|
controller: strengthController,
|
|
|
|
|
controller:
|
|
|
|
|
strengthController,
|
|
|
|
|
onChanged: (String value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
strengthChar = value.length;
|
|
|
|
|
strengthChar =
|
|
|
|
|
value.length;
|
|
|
|
|
});
|
|
|
|
|
if (strengthChar! >= 5) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(
|
|
|
|
|
TranslationBase.of(context).only5DigitsAllowedForStrength,
|
|
|
|
|
DrAppToastMsg
|
|
|
|
|
.showErrorToast(
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.only5DigitsAllowedForStrength,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
inputType: TextInputType.numberWithOptions(
|
|
|
|
|
inputType: TextInputType
|
|
|
|
|
.numberWithOptions(
|
|
|
|
|
decimal: true,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -422,15 +473,23 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
isSubmitted: isSubmitted,
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.517,
|
|
|
|
|
element: model.itemMedicineListUnit.length == 1
|
|
|
|
|
? model.itemMedicineListUnit[0]
|
|
|
|
|
width: MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width *
|
|
|
|
|
0.517,
|
|
|
|
|
element: model
|
|
|
|
|
.itemMedicineListUnit
|
|
|
|
|
.length ==
|
|
|
|
|
1
|
|
|
|
|
? model
|
|
|
|
|
.itemMedicineListUnit[0]
|
|
|
|
|
: units,
|
|
|
|
|
elementError: unitError!,
|
|
|
|
|
keyName: 'description',
|
|
|
|
|
keyId: 'parameterCode',
|
|
|
|
|
hintText: 'Select',
|
|
|
|
|
elementList: model.itemMedicineListUnit,
|
|
|
|
|
elementList: model
|
|
|
|
|
.itemMedicineListUnit,
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
units = selectedValue;
|
|
|
|
|
@ -441,11 +500,15 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
isSubmitted: isSubmitted,
|
|
|
|
|
elementList: model.itemMedicineListRoute,
|
|
|
|
|
element: model.itemMedicineListRoute.length == 1
|
|
|
|
|
elementList:
|
|
|
|
|
model.itemMedicineListRoute,
|
|
|
|
|
element: model.itemMedicineListRoute
|
|
|
|
|
.length ==
|
|
|
|
|
1
|
|
|
|
|
? model.itemMedicineListRoute[0]
|
|
|
|
|
: route,
|
|
|
|
|
elementError: routeError!,
|
|
|
|
|
@ -457,44 +520,69 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
route['isDefault'] = true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
hintText: TranslationBase.of(context).route ?? "",
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.route ??
|
|
|
|
|
"",
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
isSubmitted: isSubmitted,
|
|
|
|
|
hintText: TranslationBase.of(context).frequency ?? "",
|
|
|
|
|
elementError: frequencyError ?? "",
|
|
|
|
|
element: model.itemMedicineList.length == 1
|
|
|
|
|
? frequency = model.itemMedicineList[0]
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.frequency ??
|
|
|
|
|
"",
|
|
|
|
|
elementError:
|
|
|
|
|
frequencyError ?? "",
|
|
|
|
|
element: model.itemMedicineList
|
|
|
|
|
.length ==
|
|
|
|
|
1
|
|
|
|
|
? frequency =
|
|
|
|
|
model.itemMedicineList[0]
|
|
|
|
|
: frequency,
|
|
|
|
|
elementList: model.itemMedicineList,
|
|
|
|
|
elementList:
|
|
|
|
|
model.itemMedicineList,
|
|
|
|
|
keyId: 'parameterCode',
|
|
|
|
|
keyName: 'description',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
frequency = selectedValue;
|
|
|
|
|
frequency['isDefault'] = true;
|
|
|
|
|
if (_selectedMedication != null &&
|
|
|
|
|
if (_selectedMedication !=
|
|
|
|
|
null &&
|
|
|
|
|
duration != null &&
|
|
|
|
|
frequency != null &&
|
|
|
|
|
strengthController.text != null) {
|
|
|
|
|
strengthController.text !=
|
|
|
|
|
null) {
|
|
|
|
|
model.getBoxQuantity(
|
|
|
|
|
freq: frequency['parameterCode'],
|
|
|
|
|
duration: duration['id'],
|
|
|
|
|
itemCode: _selectedMedication!.itemId!,
|
|
|
|
|
strength: double.parse(strengthController.text));
|
|
|
|
|
freq: frequency[
|
|
|
|
|
'parameterCode'],
|
|
|
|
|
duration:
|
|
|
|
|
duration['id'],
|
|
|
|
|
itemCode:
|
|
|
|
|
_selectedMedication!
|
|
|
|
|
.itemId!,
|
|
|
|
|
strength: double.parse(
|
|
|
|
|
strengthController
|
|
|
|
|
.text));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
isSubmitted: isSubmitted,
|
|
|
|
|
hintText: TranslationBase.of(context).doseTime ?? "",
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.doseTime ??
|
|
|
|
|
"",
|
|
|
|
|
elementError: doseTimeError ?? "",
|
|
|
|
|
element: doseTime,
|
|
|
|
|
elementList: model.medicationDoseTimeList,
|
|
|
|
|
elementList:
|
|
|
|
|
model.medicationDoseTimeList,
|
|
|
|
|
keyId: 'id',
|
|
|
|
|
keyName: 'nameEn',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
@ -502,8 +590,10 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
doseTime = selectedValue;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
if (model.patientAssessmentList.isNotEmpty)
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
if (model
|
|
|
|
|
.patientAssessmentList.isNotEmpty)
|
|
|
|
|
Container(
|
|
|
|
|
height: screenSize.height * 0.070,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
@ -511,25 +601,49 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.29,
|
|
|
|
|
width:
|
|
|
|
|
MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width *
|
|
|
|
|
0.29,
|
|
|
|
|
child: TextField(
|
|
|
|
|
decoration: textFieldSelectorDecoration(
|
|
|
|
|
model.patientAssessmentList[0].icdCode10ID.toString(),
|
|
|
|
|
indication != null ? indication['name'] : null,
|
|
|
|
|
false),
|
|
|
|
|
decoration:
|
|
|
|
|
textFieldSelectorDecoration(
|
|
|
|
|
model
|
|
|
|
|
.patientAssessmentList[
|
|
|
|
|
0]
|
|
|
|
|
.icdCode10ID
|
|
|
|
|
.toString(),
|
|
|
|
|
indication != null
|
|
|
|
|
? indication[
|
|
|
|
|
'name']
|
|
|
|
|
: null,
|
|
|
|
|
false),
|
|
|
|
|
enabled: true,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.59,
|
|
|
|
|
width:
|
|
|
|
|
MediaQuery.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width *
|
|
|
|
|
0.59,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: TextField(
|
|
|
|
|
maxLines: 5,
|
|
|
|
|
decoration: textFieldSelectorDecoration(
|
|
|
|
|
model.patientAssessmentList[0].asciiDesc.toString(),
|
|
|
|
|
indication != null ? indication['name'] : null,
|
|
|
|
|
false),
|
|
|
|
|
decoration:
|
|
|
|
|
textFieldSelectorDecoration(
|
|
|
|
|
model
|
|
|
|
|
.patientAssessmentList[
|
|
|
|
|
0]
|
|
|
|
|
.asciiDesc
|
|
|
|
|
.toString(),
|
|
|
|
|
indication != null
|
|
|
|
|
? indication[
|
|
|
|
|
'name']
|
|
|
|
|
: null,
|
|
|
|
|
false),
|
|
|
|
|
enabled: true,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
),
|
|
|
|
|
@ -537,48 +651,66 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
Container(
|
|
|
|
|
height: screenSize.height * 0.070,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () => selectDate(context, widget.model),
|
|
|
|
|
onTap: () => selectDate(
|
|
|
|
|
context, widget.model),
|
|
|
|
|
child: 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,
|
|
|
|
|
)),
|
|
|
|
|
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: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
PrescriptionTextFiled(
|
|
|
|
|
isSubmitted: isSubmitted,
|
|
|
|
|
element: duration,
|
|
|
|
|
elementError: durationError ?? "",
|
|
|
|
|
hintText: TranslationBase.of(context).duration ?? "",
|
|
|
|
|
elementList: model.medicationDurationList,
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.duration ??
|
|
|
|
|
"",
|
|
|
|
|
elementList:
|
|
|
|
|
model.medicationDurationList,
|
|
|
|
|
keyName: 'nameEn',
|
|
|
|
|
keyId: 'id',
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
setState(() {
|
|
|
|
|
duration = selectedValue;
|
|
|
|
|
if (_selectedMedication != null &&
|
|
|
|
|
if (_selectedMedication !=
|
|
|
|
|
null &&
|
|
|
|
|
duration != null &&
|
|
|
|
|
frequency != null &&
|
|
|
|
|
strengthController.text != null) {
|
|
|
|
|
strengthController.text !=
|
|
|
|
|
null) {
|
|
|
|
|
model.getBoxQuantity(
|
|
|
|
|
freq: frequency['parameterCode'],
|
|
|
|
|
freq: frequency[
|
|
|
|
|
'parameterCode'],
|
|
|
|
|
duration: duration['id'],
|
|
|
|
|
itemCode: _selectedMedication!.itemId!,
|
|
|
|
|
strength: double.parse(strengthController.text),
|
|
|
|
|
itemCode:
|
|
|
|
|
_selectedMedication!
|
|
|
|
|
.itemId!,
|
|
|
|
|
strength: double.parse(
|
|
|
|
|
strengthController
|
|
|
|
|
.text),
|
|
|
|
|
);
|
|
|
|
|
box = model.boxQuintity;
|
|
|
|
|
|
|
|
|
|
@ -587,38 +719,53 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
hintText: "UOM",
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
dropDownText: uom != null ? uom : null,
|
|
|
|
|
dropDownText:
|
|
|
|
|
uom != null ? uom : null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: AppTextFieldCustom(
|
|
|
|
|
hintText: TranslationBase.of(context).boxQuantity,
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.boxQuantity,
|
|
|
|
|
isTextFieldHasSuffix: false,
|
|
|
|
|
dropDownText: box != null ? model.boxQuintity.toString() : null,
|
|
|
|
|
dropDownText: box != null
|
|
|
|
|
? model.boxQuintity.toString()
|
|
|
|
|
: null,
|
|
|
|
|
enabled: false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))),
|
|
|
|
|
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,
|
|
|
|
|
hintText: TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.instruction,
|
|
|
|
|
controller:
|
|
|
|
|
instructionController,
|
|
|
|
|
//keyboardType: TextInputType.number,
|
|
|
|
|
),
|
|
|
|
|
Positioned(
|
|
|
|
|
@ -631,51 +778,77 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
size: 35,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
initSpeechState().then((value) => {onVoiceText()});
|
|
|
|
|
initSpeechState().then(
|
|
|
|
|
(value) =>
|
|
|
|
|
{onVoiceText()});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: spaceBetweenTextFileds),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: spaceBetweenTextFileds),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
|
|
|
|
|
margin: EdgeInsets.all(
|
|
|
|
|
SizeConfig.widthMultiplier * 5),
|
|
|
|
|
child: Wrap(
|
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
AppButton(
|
|
|
|
|
color: Color(0xff359846),
|
|
|
|
|
title: TranslationBase.of(context).addMedication,
|
|
|
|
|
title: TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.addMedication,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
onPressed: () 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 (_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);
|
|
|
|
|
{
|
|
|
|
|
@ -765,39 +938,60 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
setState(() {
|
|
|
|
|
isSubmitted = true;
|
|
|
|
|
if (duration == null) {
|
|
|
|
|
durationError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
durationError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
durationError = "";
|
|
|
|
|
}
|
|
|
|
|
if (doseTime == null) {
|
|
|
|
|
doseTimeError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
doseTimeError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
doseTimeError = "";
|
|
|
|
|
}
|
|
|
|
|
if (route == null) {
|
|
|
|
|
routeError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
routeError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
routeError = "";
|
|
|
|
|
}
|
|
|
|
|
if (frequency == null) {
|
|
|
|
|
frequencyError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
frequencyError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
frequencyError = "";
|
|
|
|
|
}
|
|
|
|
|
if (units == null) {
|
|
|
|
|
unitError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
unitError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
unitError = "";
|
|
|
|
|
}
|
|
|
|
|
if (strengthController.text == "") {
|
|
|
|
|
strengthError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
if (strengthController
|
|
|
|
|
.text ==
|
|
|
|
|
"") {
|
|
|
|
|
strengthError =
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fieldRequired;
|
|
|
|
|
} else {
|
|
|
|
|
strengthError = "";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
formKey.currentState!.save();
|
|
|
|
|
formKey.currentState!
|
|
|
|
|
.save();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -840,7 +1034,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InputDecoration textFieldSelectorDecoration(String? hintText, String? selectedText, bool isDropDown,
|
|
|
|
|
InputDecoration textFieldSelectorDecoration(
|
|
|
|
|
String? hintText, String? selectedText, bool isDropDown,
|
|
|
|
|
{Icon? suffixIcon}) {
|
|
|
|
|
return InputDecoration(
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
@ -891,7 +1086,9 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
child: Column(
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
DrugToDrug(widget.patient, getPriscriptionforDrug(widget.prescriptionList, model),
|
|
|
|
|
DrugToDrug(
|
|
|
|
|
widget.patient,
|
|
|
|
|
getPriscriptionforDrug(widget.prescriptionList, model),
|
|
|
|
|
model.patientAssessmentList),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3),
|
|
|
|
|
@ -902,23 +1099,28 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
|
|
|
|
|
postPrescription(
|
|
|
|
|
icdCode: model.patientAssessmentList.isNotEmpty
|
|
|
|
|
? model.patientAssessmentList[0].icdCode10ID.isEmpty
|
|
|
|
|
? model.patientAssessmentList[0].icdCode10ID
|
|
|
|
|
.isEmpty
|
|
|
|
|
? "test"
|
|
|
|
|
: model.patientAssessmentList[0].icdCode10ID.toString()
|
|
|
|
|
: model.patientAssessmentList[0].icdCode10ID
|
|
|
|
|
.toString()
|
|
|
|
|
: "test",
|
|
|
|
|
dose: strengthController.text,
|
|
|
|
|
doseUnit: model.itemMedicineListUnit.length == 1
|
|
|
|
|
? model.itemMedicineListUnit[0]['parameterCode'].toString()
|
|
|
|
|
? model.itemMedicineListUnit[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: units['parameterCode'].toString(),
|
|
|
|
|
patient: widget.patient,
|
|
|
|
|
doseTimeIn: doseTime['id'].toString(),
|
|
|
|
|
model: widget.model,
|
|
|
|
|
duration: duration['id'].toString(),
|
|
|
|
|
frequency: model.itemMedicineList.length == 1
|
|
|
|
|
? model.itemMedicineList[0]['parameterCode'].toString()
|
|
|
|
|
? model.itemMedicineList[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: frequency['parameterCode'].toString(),
|
|
|
|
|
route: model.itemMedicineListRoute.length == 1
|
|
|
|
|
? model.itemMedicineListRoute[0]['parameterCode'].toString()
|
|
|
|
|
? model.itemMedicineListRoute[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: route['parameterCode'].toString(),
|
|
|
|
|
drugId: _selectedMedication!.itemId.toString(),
|
|
|
|
|
strength: strengthController.text,
|
|
|
|
|
@ -937,7 +1139,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getPriscriptionforDrug(List<PrescriptionModel> prescriptionList, MedicineViewModel model) {
|
|
|
|
|
getPriscriptionforDrug(
|
|
|
|
|
List<PrescriptionModel> prescriptionList, MedicineViewModel model) {
|
|
|
|
|
var prescriptionDetails = [];
|
|
|
|
|
if (prescriptionList.length > 0) {
|
|
|
|
|
prescriptionList[0].entityList!.forEach((element) {
|
|
|
|
|
|