refactoring my code
parent
23c826b37f
commit
d66811546f
@ -0,0 +1,746 @@
|
|||||||
|
import 'package:doctor_app_flutter/client/base_app_client.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/patient/patiant_info_model.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/TextFields.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:hexcolor/hexcolor.dart';
|
||||||
|
|
||||||
|
class UpdatePrescriptionForm extends StatefulWidget {
|
||||||
|
final String drugName;
|
||||||
|
final String doseStreangth;
|
||||||
|
final int drugId;
|
||||||
|
final String remarks;
|
||||||
|
final PatiantInformtion patient;
|
||||||
|
final String duration;
|
||||||
|
final String route;
|
||||||
|
final String dose;
|
||||||
|
final String doseUnit;
|
||||||
|
final String enteredRemarks;
|
||||||
|
final String startDate;
|
||||||
|
final String frequency;
|
||||||
|
final PrescriptionViewModel model;
|
||||||
|
|
||||||
|
UpdatePrescriptionForm(
|
||||||
|
{this.drugName,
|
||||||
|
this.doseStreangth,
|
||||||
|
this.drugId,
|
||||||
|
this.remarks,
|
||||||
|
this.patient,
|
||||||
|
this.duration,
|
||||||
|
this.route,
|
||||||
|
this.dose,
|
||||||
|
this.startDate,
|
||||||
|
this.doseUnit,
|
||||||
|
this.enteredRemarks,
|
||||||
|
this.frequency,
|
||||||
|
this.model});
|
||||||
|
@override
|
||||||
|
_UpdatePrescriptionFormState createState() => _UpdatePrescriptionFormState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
||||||
|
TextEditingController strengthController = TextEditingController();
|
||||||
|
TextEditingController remarksController = TextEditingController();
|
||||||
|
int testNum = 0;
|
||||||
|
int strengthChar;
|
||||||
|
PatiantInformtion patient;
|
||||||
|
dynamic route;
|
||||||
|
dynamic doseTime;
|
||||||
|
dynamic frequencyUpdate;
|
||||||
|
dynamic updatedDuration;
|
||||||
|
dynamic units;
|
||||||
|
|
||||||
|
List<dynamic> doseTimeList;
|
||||||
|
List<dynamic> routeList;
|
||||||
|
List<dynamic> frequencyList;
|
||||||
|
List<dynamic> durationList;
|
||||||
|
List<dynamic> unitsList;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
routeList = List();
|
||||||
|
doseTimeList = List();
|
||||||
|
frequencyList = List();
|
||||||
|
durationList = List();
|
||||||
|
unitsList = List();
|
||||||
|
|
||||||
|
dynamic unit1 = {"id": 1, "name": "MG"};
|
||||||
|
dynamic unit2 = {"id": 2, "name": "MCG"};
|
||||||
|
dynamic unit3 = {"id": 3, "name": "GM"};
|
||||||
|
dynamic frequency1 = {"id": 2, "name": "2 Times a day"};
|
||||||
|
dynamic frequency2 = {"id": 3, "name": "3 Times a day"};
|
||||||
|
dynamic frequency3 = {"id": 4, "name": "4 Times a day"};
|
||||||
|
dynamic frequency4 = {"id": 8, "name": "As Needed"};
|
||||||
|
dynamic frequency5 = {"id": 9, "name": "Bed Time"};
|
||||||
|
dynamic frequency6 = {"id": 11, "name": "Every Other Day"};
|
||||||
|
dynamic frequency7 = {"id": 29, "name": "Every Eight Hours"};
|
||||||
|
dynamic frequency8 = {"id": 34, "name": "As Directed"};
|
||||||
|
dynamic frequency9 = {"id": 22, "name": "Once Per Month"};
|
||||||
|
dynamic frequency10 = {"id": 2, "name": "3 Times a day"};
|
||||||
|
dynamic frequency11 = {"id": 21, "name": "Every 3 hours"};
|
||||||
|
dynamic frequency12 = {"id": 20, "name": "Once a Week"};
|
||||||
|
dynamic frequency13 = {"id": 12, "name": "Every Half Hour"};
|
||||||
|
dynamic frequency14 = {"id": 10, "name": "4 Times a Day"};
|
||||||
|
dynamic frequency15 = {"id": 24, "name": "Once Every 2 Months"};
|
||||||
|
dynamic frequency16 = {"id": 25, "name": "Every One Hour"};
|
||||||
|
dynamic frequency17 = {"id": 26, "name": "Every Two Hours"};
|
||||||
|
dynamic frequency18 = {"id": 28, "name": "Every Six Hours"};
|
||||||
|
dynamic doseTime1 = {"id": 1, "name": "Before Meals"};
|
||||||
|
dynamic doseTime2 = {"id": 2, "name": "After Meals"};
|
||||||
|
dynamic doseTime3 = {"id": 3, "name": "With Meals"};
|
||||||
|
dynamic doseTime4 = {"id": 4, "name": "In The Morning"};
|
||||||
|
dynamic doseTime5 = {"id": 5, "name": "In the Evening"};
|
||||||
|
dynamic doseTime6 = {"id": 6, "name": "After Supper"};
|
||||||
|
dynamic doseTime7 = {"id": 7, "name": "With Supper"};
|
||||||
|
dynamic doseTime8 = {"id": 8, "name": "Before Breakfast"};
|
||||||
|
dynamic doseTime9 = {"id": 9, "name": "In the Afternoon"};
|
||||||
|
dynamic doseTime10 = {"id": 10, "name": "While wake"};
|
||||||
|
dynamic doseTime11 = {"id": 12, "name": "Any Time"};
|
||||||
|
dynamic doseTime12 = {"id": 21, "name": "Bed Time"};
|
||||||
|
dynamic doseTime13 = {"id": 13, "name": "30 Minutes Before Meals"};
|
||||||
|
dynamic doseTime14 = {"id": 14, "name": "1 Hour Before Meals"};
|
||||||
|
dynamic doseTime15 = {"id": 15, "name": "2 Hours After Meal"};
|
||||||
|
dynamic doseTime16 = {"id": 16, "name": "After Breakfast"};
|
||||||
|
dynamic doseTime17 = {"id": 17, "name": "Before Lunch"};
|
||||||
|
dynamic doseTime18 = {"id": 18, "name": "After Lunch"};
|
||||||
|
dynamic doseTime19 = {"id": 20, "name": "After Dinner"};
|
||||||
|
dynamic doseTime20 = {"id": 21, "name": "Bed Time"};
|
||||||
|
dynamic doseTime21 = {"id": 11, "name": "Now"};
|
||||||
|
dynamic route1 = {"id": 7, "name": "By Mouth"};
|
||||||
|
dynamic route2 = {"id": 10, "name": "Inhale by Mouth"};
|
||||||
|
dynamic route3 = {"id": 15, "name": "for INJECTION"};
|
||||||
|
dynamic route4 = {"id": 17, "name": "Drops"};
|
||||||
|
dynamic route5 = {"id": 18, "name": "Rub On"};
|
||||||
|
dynamic route6 = {"id": 20, "name": "Spary"};
|
||||||
|
dynamic route7 = {"id": 27, "name": "In Both EYES"};
|
||||||
|
dynamic route8 = {"id": 28, "name": "In Both Ears"};
|
||||||
|
dynamic route9 = {"id": 32, "name": "Intramuscular"};
|
||||||
|
dynamic route10 = {"id": 60, "name": "TRANSDERMAL"};
|
||||||
|
dynamic route11 = {"id": 59, "name": "OROPHARYNGEAL"};
|
||||||
|
dynamic route12 = {"id": 15, "name": "for INJECTION"};
|
||||||
|
dynamic route13 = {"id": 58, "name": "SUBCUTANEOUS"};
|
||||||
|
dynamic route14 = {"id": 57, "name": "NASOGASTRIC"};
|
||||||
|
dynamic route15 = {"id": 56, "name": "IRRIGATION"};
|
||||||
|
dynamic route16 = {"id": 55, "name": "INTRAVITREAL"};
|
||||||
|
dynamic route17 = {"id": 54, "name": "INTRAVENOUS BOLUS"};
|
||||||
|
dynamic route18 = {"id": 51, "name": "EPIDURAL"};
|
||||||
|
dynamic route19 = {"id": 47, "name": "Parenteral"};
|
||||||
|
dynamic route20 = {"id": 43, "name": "IM"};
|
||||||
|
dynamic route21 = {"id": 42, "name": "IV"};
|
||||||
|
dynamic route22 = {"id": 41, "name": "Sublingual"};
|
||||||
|
dynamic route23 = {"id": 40, "name": "For Nebulization"};
|
||||||
|
dynamic route24 = {"id": 39, "name": "Nasal"};
|
||||||
|
dynamic route25 = {"id": 37, "name": "Inserted into Vagina"};
|
||||||
|
dynamic route26 = {"id": 36, "name": "Inserted into Rectum"};
|
||||||
|
dynamic route27 = {"id": 31, "name": "In Each Nostril"};
|
||||||
|
dynamic duration1 = {"id": 1, "name": "For 1 Day"};
|
||||||
|
dynamic duration2 = {"id": 2, "name": "For 2 Days"};
|
||||||
|
dynamic duration3 = {"id": 3, "name": "For 3 Days"};
|
||||||
|
dynamic duration4 = {"id": 4, "name": "For 4 Days"};
|
||||||
|
dynamic duration5 = {"id": 5, "name": "For 5 Days"};
|
||||||
|
dynamic duration6 = {"id": 6, "name": "For 6 Days"};
|
||||||
|
dynamic duration7 = {"id": 7, "name": "For 7 Days"};
|
||||||
|
dynamic duration8 = {"id": 8, "name": "For 8 Days"};
|
||||||
|
dynamic duration9 = {"id": 9, "name": "For 9 Days"};
|
||||||
|
dynamic duration10 = {"id": 10, "name": "For 10 Days"};
|
||||||
|
dynamic duration11 = {"id": 14, "name": "For 14 Days"};
|
||||||
|
dynamic duration12 = {"id": 21, "name": "For 21 Days"};
|
||||||
|
dynamic duration13 = {"id": 30, "name": "For 30 Days"};
|
||||||
|
dynamic duration14 = {"id": 45, "name": "For 45 Days"};
|
||||||
|
dynamic duration15 = {"id": 60, "name": "For 60 Days"};
|
||||||
|
dynamic duration16 = {"id": 90, "name": "For 90 Days"};
|
||||||
|
|
||||||
|
durationList.add(duration1);
|
||||||
|
durationList.add(duration2);
|
||||||
|
durationList.add(duration3);
|
||||||
|
durationList.add(duration4);
|
||||||
|
durationList.add(duration5);
|
||||||
|
durationList.add(duration6);
|
||||||
|
durationList.add(duration7);
|
||||||
|
durationList.add(duration8);
|
||||||
|
durationList.add(duration9);
|
||||||
|
durationList.add(duration10);
|
||||||
|
durationList.add(duration11);
|
||||||
|
durationList.add(duration12);
|
||||||
|
durationList.add(duration13);
|
||||||
|
durationList.add(duration14);
|
||||||
|
durationList.add(duration15);
|
||||||
|
durationList.add(duration16);
|
||||||
|
frequencyList.add(frequency1);
|
||||||
|
frequencyList.add(frequency2);
|
||||||
|
frequencyList.add(frequency3);
|
||||||
|
frequencyList.add(frequency4);
|
||||||
|
frequencyList.add(frequency5);
|
||||||
|
frequencyList.add(frequency6);
|
||||||
|
frequencyList.add(frequency7);
|
||||||
|
frequencyList.add(frequency8);
|
||||||
|
frequencyList.add(frequency9);
|
||||||
|
frequencyList.add(frequency10);
|
||||||
|
frequencyList.add(frequency11);
|
||||||
|
frequencyList.add(frequency12);
|
||||||
|
frequencyList.add(frequency13);
|
||||||
|
frequencyList.add(frequency14);
|
||||||
|
frequencyList.add(frequency15);
|
||||||
|
frequencyList.add(frequency16);
|
||||||
|
frequencyList.add(frequency17);
|
||||||
|
frequencyList.add(frequency18);
|
||||||
|
doseTimeList.add(doseTime1);
|
||||||
|
doseTimeList.add(doseTime2);
|
||||||
|
doseTimeList.add(doseTime3);
|
||||||
|
doseTimeList.add(doseTime4);
|
||||||
|
doseTimeList.add(doseTime5);
|
||||||
|
doseTimeList.add(doseTime6);
|
||||||
|
doseTimeList.add(doseTime7);
|
||||||
|
doseTimeList.add(doseTime8);
|
||||||
|
doseTimeList.add(doseTime9);
|
||||||
|
doseTimeList.add(doseTime10);
|
||||||
|
doseTimeList.add(doseTime11);
|
||||||
|
doseTimeList.add(doseTime12);
|
||||||
|
doseTimeList.add(doseTime13);
|
||||||
|
doseTimeList.add(doseTime14);
|
||||||
|
doseTimeList.add(doseTime15);
|
||||||
|
doseTimeList.add(doseTime16);
|
||||||
|
doseTimeList.add(doseTime17);
|
||||||
|
doseTimeList.add(doseTime18);
|
||||||
|
doseTimeList.add(doseTime19);
|
||||||
|
doseTimeList.add(doseTime20);
|
||||||
|
doseTimeList.add(doseTime21);
|
||||||
|
routeList.add(route1);
|
||||||
|
routeList.add(route2);
|
||||||
|
routeList.add(route3);
|
||||||
|
routeList.add(route4);
|
||||||
|
routeList.add(route5);
|
||||||
|
routeList.add(route6);
|
||||||
|
routeList.add(route7);
|
||||||
|
routeList.add(route8);
|
||||||
|
routeList.add(route9);
|
||||||
|
routeList.add(route10);
|
||||||
|
routeList.add(route11);
|
||||||
|
routeList.add(route12);
|
||||||
|
routeList.add(route13);
|
||||||
|
routeList.add(route14);
|
||||||
|
routeList.add(route15);
|
||||||
|
routeList.add(route16);
|
||||||
|
routeList.add(route17);
|
||||||
|
routeList.add(route18);
|
||||||
|
routeList.add(route19);
|
||||||
|
routeList.add(route20);
|
||||||
|
routeList.add(route21);
|
||||||
|
routeList.add(route22);
|
||||||
|
routeList.add(route23);
|
||||||
|
routeList.add(route24);
|
||||||
|
routeList.add(route25);
|
||||||
|
routeList.add(route26);
|
||||||
|
routeList.add(route27);
|
||||||
|
unitsList.add(unit1);
|
||||||
|
unitsList.add(unit2);
|
||||||
|
unitsList.add(unit3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return StatefulBuilder(builder:
|
||||||
|
(BuildContext context, StateSetter setState /*You can rename this!*/) {
|
||||||
|
return DraggableScrollableSheet(
|
||||||
|
initialChildSize: 0.90,
|
||||||
|
maxChildSize: 0.90,
|
||||||
|
minChildSize: 0.6,
|
||||||
|
builder: (BuildContext context, ScrollController scrollController) {
|
||||||
|
return Container(
|
||||||
|
height: MediaQuery.of(context).size.height * 1.0,
|
||||||
|
child: Form(
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
EdgeInsets.symmetric(horizontal: 20.0, vertical: 12.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
AppText(
|
||||||
|
widget.drugName.toUpperCase(),
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10.0,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).size.height * 0.060,
|
||||||
|
width: double.infinity,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width *
|
||||||
|
0.500,
|
||||||
|
child: TextFields(
|
||||||
|
inputFormatters: [
|
||||||
|
LengthLimitingTextInputFormatter(4)
|
||||||
|
],
|
||||||
|
hintText:
|
||||||
|
TranslationBase.of(context).strength,
|
||||||
|
controller: strengthController,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
onChanged: (String value) {
|
||||||
|
setState(() {
|
||||||
|
strengthChar = value.length;
|
||||||
|
});
|
||||||
|
if (strengthChar >= 4) {
|
||||||
|
DrAppToastMsg.showErrorToast(
|
||||||
|
"Only 4 Digits allowed for strength");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// validator: (value) {
|
||||||
|
// if (value.isEmpty &&
|
||||||
|
// strengthController.text.length >
|
||||||
|
// 4)
|
||||||
|
// return TranslationBase.of(context)
|
||||||
|
// .emptyMessage;
|
||||||
|
// else
|
||||||
|
// return null;
|
||||||
|
// },
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 10.0,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width *
|
||||||
|
0.3700,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: unitsList != null
|
||||||
|
? () {
|
||||||
|
ListSelectDialog dialog =
|
||||||
|
ListSelectDialog(
|
||||||
|
list: unitsList,
|
||||||
|
attributeName: 'name',
|
||||||
|
attributeValueId: 'id',
|
||||||
|
okText:
|
||||||
|
TranslationBase.of(context)
|
||||||
|
.ok,
|
||||||
|
okFunction: (selectedValue) {
|
||||||
|
setState(() {
|
||||||
|
units = selectedValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
showDialog(
|
||||||
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder:
|
||||||
|
(BuildContext context) {
|
||||||
|
return dialog;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: TextField(
|
||||||
|
decoration: textFieldSelectorDecoration(
|
||||||
|
'UNIT Type',
|
||||||
|
units != null
|
||||||
|
? units['name']
|
||||||
|
: null,
|
||||||
|
true),
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).size.height * 0.070,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: routeList != null
|
||||||
|
? () {
|
||||||
|
ListSelectDialog dialog =
|
||||||
|
ListSelectDialog(
|
||||||
|
list: routeList,
|
||||||
|
attributeName: 'name',
|
||||||
|
attributeValueId: 'id',
|
||||||
|
okText:
|
||||||
|
TranslationBase.of(context).ok,
|
||||||
|
okFunction: (selectedValue) {
|
||||||
|
setState(() {
|
||||||
|
route = selectedValue;
|
||||||
|
});
|
||||||
|
if (route == null) {
|
||||||
|
route = route['id'];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
showDialog(
|
||||||
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return dialog;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: TextField(
|
||||||
|
decoration: textFieldSelectorDecoration(
|
||||||
|
'Route',
|
||||||
|
route != null ? route['name'] : null,
|
||||||
|
true),
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 12.0,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).size.height * 0.070,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: doseTimeList != null
|
||||||
|
? () {
|
||||||
|
ListSelectDialog dialog =
|
||||||
|
ListSelectDialog(
|
||||||
|
list: doseTimeList,
|
||||||
|
attributeName: 'name',
|
||||||
|
attributeValueId: 'id',
|
||||||
|
okText:
|
||||||
|
TranslationBase.of(context).ok,
|
||||||
|
okFunction: (selectedValue) {
|
||||||
|
setState(() {
|
||||||
|
doseTime = selectedValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
showDialog(
|
||||||
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return dialog;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: TextField(
|
||||||
|
decoration: textFieldSelectorDecoration(
|
||||||
|
TranslationBase.of(context).doseTime,
|
||||||
|
doseTime != null
|
||||||
|
? doseTime['name']
|
||||||
|
: null,
|
||||||
|
true),
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 12.0,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).size.height * 0.070,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: frequencyList != null
|
||||||
|
? () {
|
||||||
|
ListSelectDialog dialog =
|
||||||
|
ListSelectDialog(
|
||||||
|
list: frequencyList,
|
||||||
|
attributeName: 'name',
|
||||||
|
attributeValueId: 'id',
|
||||||
|
okText:
|
||||||
|
TranslationBase.of(context).ok,
|
||||||
|
okFunction: (selectedValue) {
|
||||||
|
setState(() {
|
||||||
|
frequencyUpdate = selectedValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
showDialog(
|
||||||
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return dialog;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: TextField(
|
||||||
|
decoration: textFieldSelectorDecoration(
|
||||||
|
TranslationBase.of(context).frequency,
|
||||||
|
frequencyUpdate != null
|
||||||
|
? frequencyUpdate['name']
|
||||||
|
: null,
|
||||||
|
true),
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 12.0,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).size.height * 0.070,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: durationList != null
|
||||||
|
? () {
|
||||||
|
ListSelectDialog dialog =
|
||||||
|
ListSelectDialog(
|
||||||
|
list: durationList,
|
||||||
|
attributeName: 'name',
|
||||||
|
attributeValueId: 'id',
|
||||||
|
okText:
|
||||||
|
TranslationBase.of(context).ok,
|
||||||
|
okFunction: (selectedValue) {
|
||||||
|
setState(() {
|
||||||
|
updatedDuration = selectedValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
showDialog(
|
||||||
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return dialog;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: TextField(
|
||||||
|
decoration: textFieldSelectorDecoration(
|
||||||
|
TranslationBase.of(context).duration,
|
||||||
|
updatedDuration != null
|
||||||
|
? updatedDuration['name'].toString()
|
||||||
|
: null,
|
||||||
|
true),
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: widget.remarks,
|
||||||
|
controller: remarksController,
|
||||||
|
maxLines: 7,
|
||||||
|
minLines: 4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 12.0,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.12,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.all(
|
||||||
|
SizeConfig.widthMultiplier * 2),
|
||||||
|
child: Wrap(
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
AppButton(
|
||||||
|
title: 'update prescription'.toUpperCase(),
|
||||||
|
onPressed: () {
|
||||||
|
updatePrescription(
|
||||||
|
newDoseStreangth:
|
||||||
|
strengthController.text.isNotEmpty
|
||||||
|
? strengthController.text
|
||||||
|
: widget.doseStreangth,
|
||||||
|
newUnit: units != null
|
||||||
|
? units['id'].toString()
|
||||||
|
: widget.doseUnit,
|
||||||
|
doseUnit: widget.doseUnit,
|
||||||
|
doseStreangth: widget.doseStreangth,
|
||||||
|
duration: widget.duration,
|
||||||
|
startDate: widget.startDate,
|
||||||
|
doseId: widget.dose,
|
||||||
|
frequencyId: widget.frequency,
|
||||||
|
routeId: widget.route,
|
||||||
|
patient: widget.patient,
|
||||||
|
model: widget.model,
|
||||||
|
newDuration: updatedDuration != null
|
||||||
|
? updatedDuration['id'].toString()
|
||||||
|
: widget.duration,
|
||||||
|
drugId: widget.drugId,
|
||||||
|
remarks: remarksController.text,
|
||||||
|
route: route != null
|
||||||
|
? route['id'].toString()
|
||||||
|
: widget.route,
|
||||||
|
frequency: frequencyUpdate != null
|
||||||
|
? frequencyUpdate['id'].toString()
|
||||||
|
: widget.frequency,
|
||||||
|
dose: doseTime != null
|
||||||
|
? doseTime['id'].toString()
|
||||||
|
: widget.dose,
|
||||||
|
enteredRemarks:
|
||||||
|
widget.enteredRemarks);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
InputDecoration textFieldSelectorDecoration(
|
||||||
|
String hintText, String selectedText, bool isDropDown,
|
||||||
|
{Icon suffixIcon}) {
|
||||||
|
return InputDecoration(
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
disabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
hintText: selectedText != null ? selectedText : hintText,
|
||||||
|
suffixIcon: isDropDown
|
||||||
|
? suffixIcon != null
|
||||||
|
? suffixIcon
|
||||||
|
: Icon(
|
||||||
|
Icons.arrow_drop_down,
|
||||||
|
color: Colors.black,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePrescription(
|
||||||
|
{PrescriptionViewModel model,
|
||||||
|
int drugId,
|
||||||
|
String frequencyId,
|
||||||
|
String remarks,
|
||||||
|
String dose,
|
||||||
|
String doseId,
|
||||||
|
String frequency,
|
||||||
|
String route,
|
||||||
|
String routeId,
|
||||||
|
String startDate,
|
||||||
|
String doseUnit,
|
||||||
|
String doseStreangth,
|
||||||
|
String newDoseStreangth,
|
||||||
|
String duration,
|
||||||
|
String newDuration,
|
||||||
|
String newUnit,
|
||||||
|
String enteredRemarks,
|
||||||
|
PatiantInformtion patient}) async {
|
||||||
|
//PrescriptionViewModel model = PrescriptionViewModel();
|
||||||
|
PostPrescriptionReqModel updatePrescriptionReqModel =
|
||||||
|
new PostPrescriptionReqModel();
|
||||||
|
List<PrescriptionRequestModel> sss = List();
|
||||||
|
|
||||||
|
updatePrescriptionReqModel.appointmentNo = patient.appointmentNo;
|
||||||
|
updatePrescriptionReqModel.clinicID = patient.clinicId;
|
||||||
|
updatePrescriptionReqModel.episodeID = patient.episodeNo;
|
||||||
|
updatePrescriptionReqModel.patientMRN = patient.patientMRN;
|
||||||
|
|
||||||
|
sss.add(PrescriptionRequestModel(
|
||||||
|
covered: true,
|
||||||
|
dose: newDoseStreangth.isNotEmpty
|
||||||
|
? int.parse(newDoseStreangth)
|
||||||
|
: int.parse(doseStreangth),
|
||||||
|
//frequency.isNotEmpty ? int.parse(dose) : 1,
|
||||||
|
itemId: drugId,
|
||||||
|
doseUnitId:
|
||||||
|
newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit),
|
||||||
|
route: route.isNotEmpty ? int.parse(route) : int.parse(routeId),
|
||||||
|
frequency: frequency.isNotEmpty
|
||||||
|
? int.parse(frequency)
|
||||||
|
: int.parse(frequencyId),
|
||||||
|
remarks: remarks.isEmpty ? enteredRemarks : remarks,
|
||||||
|
approvalRequired: true,
|
||||||
|
icdcode10Id: "test2",
|
||||||
|
doseTime: dose.isNotEmpty ? int.parse(dose) : int.parse(doseId),
|
||||||
|
duration: newDuration.isNotEmpty
|
||||||
|
? int.parse(newDuration)
|
||||||
|
: int.parse(duration),
|
||||||
|
doseStartDate: startDate));
|
||||||
|
updatePrescriptionReqModel.prescriptionRequestModel = sss;
|
||||||
|
//postProcedureReqModel.procedures = controlsProcedure;
|
||||||
|
|
||||||
|
await model.updatePrescription(
|
||||||
|
updatePrescriptionReqModel, patient.patientMRN);
|
||||||
|
|
||||||
|
if (model.state == ViewState.ErrorLocal) {
|
||||||
|
helpers.showErrorToast(model.error);
|
||||||
|
} else if (model.state == ViewState.Idle) {
|
||||||
|
DrAppToastMsg.showSuccesToast('Medication has been updated');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updatePrescriptionForm(
|
||||||
|
{context,
|
||||||
|
String drugName,
|
||||||
|
int drugId,
|
||||||
|
String remarks,
|
||||||
|
PrescriptionViewModel model,
|
||||||
|
PatiantInformtion patient,
|
||||||
|
String rouat,
|
||||||
|
String frequency,
|
||||||
|
String dose,
|
||||||
|
String duration,
|
||||||
|
String doseStreangth,
|
||||||
|
String doseUnit,
|
||||||
|
String enteredRemarks,
|
||||||
|
String startDate}) {
|
||||||
|
TextEditingController remarksController = TextEditingController();
|
||||||
|
TextEditingController doseController = TextEditingController();
|
||||||
|
TextEditingController frequencyController = TextEditingController();
|
||||||
|
TextEditingController routeController = TextEditingController();
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return UpdatePrescriptionForm(
|
||||||
|
drugName: drugName,
|
||||||
|
patient: patient,
|
||||||
|
doseStreangth: doseStreangth,
|
||||||
|
remarks: remarks,
|
||||||
|
drugId: drugId,
|
||||||
|
enteredRemarks: enteredRemarks,
|
||||||
|
duration: duration,
|
||||||
|
dose: dose,
|
||||||
|
doseUnit: doseUnit,
|
||||||
|
frequency: frequency,
|
||||||
|
route: rouat,
|
||||||
|
startDate: startDate,
|
||||||
|
model: model,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue