update prescription

merge-requests/294/head
hussam al-habibeh 5 years ago
parent 539f7facc7
commit 9ec78763dc

@ -127,78 +127,78 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
), ),
Column( Column(
children: [ children: [
Container( // Container(
height: MediaQuery.of(context).size.height * // height: MediaQuery.of(context).size.height *
0.070, // 0.070,
child: InkWell( // child: InkWell(
onTap: model.allMedicationList != null // onTap: model.allMedicationList != null
? () { // ? () {
setState(() { // setState(() {
newSelectedMedication = null; // newSelectedMedication = null;
}); // });
} // }
: null, // : null,
child: newSelectedMedication == null // child: newSelectedMedication == null
? AutoCompleteTextField< // ? AutoCompleteTextField<
GetMedicationResponseModel>( // GetMedicationResponseModel>(
decoration: // decoration:
textFieldSelectorDecoration( // textFieldSelectorDecoration(
widget.drugNameGeneric, // widget.drugNameGeneric,
newSelectedMedication != null // newSelectedMedication != null
? newSelectedMedication // ? newSelectedMedication
.genericName // .genericName
: null, // : null,
true, // true,
), // ),
itemSubmitted: (item) => setState( // itemSubmitted: (item) => setState(
() => newSelectedMedication = // () => newSelectedMedication =
item), // item),
key: key, // key: key,
suggestions: // suggestions:
model.allMedicationList, // model.allMedicationList,
itemBuilder: (context, // itemBuilder: (context,
suggestion) => // suggestion) =>
new Padding( // new Padding(
child: Texts(suggestion // child: Texts(suggestion
.description + // .description +
'/' + // '/' +
suggestion.genericName), // suggestion.genericName),
padding: // padding:
EdgeInsets.all(8.0)), // EdgeInsets.all(8.0)),
itemSorter: (a, b) => 1, // itemSorter: (a, b) => 1,
itemFilter: (suggestion, input) => // itemFilter: (suggestion, input) =>
suggestion.genericName // suggestion.genericName
.toLowerCase() // .toLowerCase()
.startsWith( // .startsWith(
input.toLowerCase()) || // input.toLowerCase()) ||
suggestion.description // suggestion.description
.toLowerCase() // .toLowerCase()
.startsWith( // .startsWith(
input.toLowerCase()) || // input.toLowerCase()) ||
suggestion.keywords // suggestion.keywords
.toLowerCase() // .toLowerCase()
.startsWith( // .startsWith(
input.toLowerCase()), // input.toLowerCase()),
) // )
: TextField( // : TextField(
decoration: // decoration:
textFieldSelectorDecoration( // textFieldSelectorDecoration(
TranslationBase.of(context) // TranslationBase.of(context)
.searchMedicineNameHere, // .searchMedicineNameHere,
newSelectedMedication != null // newSelectedMedication != null
? newSelectedMedication // ? newSelectedMedication
.description + // .description +
('${newSelectedMedication.genericName}') // ('${newSelectedMedication.genericName}')
: null, // : null,
true, // true,
), // ),
enabled: false, // enabled: false,
), // ),
), // ),
), // ),
SizedBox( // SizedBox(
height: 12, // height: 12,
), // ),
Container( Container(
height: MediaQuery.of(context).size.height * height: MediaQuery.of(context).size.height *
0.060, 0.060,
@ -508,23 +508,18 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
'update prescription'.toUpperCase(), 'update prescription'.toUpperCase(),
onPressed: () { onPressed: () {
updatePrescription( updatePrescription(
newDrugId:
newSelectedMedication != null
? newSelectedMedication
.itemId
.toString()
: widget.drugId,
newDoseStreangth: newDoseStreangth:
strengthController strengthController
.text.isNotEmpty .text.isNotEmpty
? strengthController.text ? strengthController.text
: widget.doseStreangth, : widget.doseStreangth,
newUnit: units != null newUnit: units !=
null
? units['id'].toString() ? units['id'].toString()
: widget.doseUnit, : widget.doseUnit,
doseUnit: widget.doseUnit, doseUnit: widget.doseUnit,
doseStreangth: doseStreangth: widget
widget.doseStreangth, .doseStreangth,
duration: widget.duration, duration: widget.duration,
startDate: widget.startDate, startDate: widget.startDate,
doseId: widget.dose, doseId: widget.dose,
@ -532,20 +527,25 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
routeId: widget.route, routeId: widget.route,
patient: widget.patient, patient: widget.patient,
model: widget.model, model: widget.model,
newDuration: updatedDuration != newDuration:
null updatedDuration !=
? updatedDuration['id'] null
.toString() ? updatedDuration[
: widget.duration, 'id']
.toString()
: widget.duration,
drugId: widget.drugId, drugId: widget.drugId,
remarks: remarksController.text, remarks: remarksController.text,
route: route != null route: route !=
null
? route['id'].toString() ? route['id'].toString()
: widget.route, : widget.route,
frequency: frequencyUpdate != null frequency:
? frequencyUpdate['id'] frequencyUpdate !=
.toString() null
: widget.frequency, ? frequencyUpdate['id']
.toString()
: widget.frequency,
dose: doseTime != null dose: doseTime != null
? doseTime['id'].toString() ? doseTime['id'].toString()
: widget.dose, : widget.dose,
@ -604,7 +604,7 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
updatePrescription( updatePrescription(
{PrescriptionViewModel model, {PrescriptionViewModel model,
int drugId, int drugId,
int newDrugId, String newDrugId,
String frequencyId, String frequencyId,
String remarks, String remarks,
String dose, String dose,
@ -637,7 +637,7 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
? int.parse(newDoseStreangth) ? int.parse(newDoseStreangth)
: int.parse(doseStreangth), : int.parse(doseStreangth),
//frequency.isNotEmpty ? int.parse(dose) : 1, //frequency.isNotEmpty ? int.parse(dose) : 1,
itemId: newDrugId != 0 ? newDrugId : drugId, itemId: drugId,
doseUnitId: doseUnitId:
newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit), newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit),
route: route.isNotEmpty ? int.parse(route) : int.parse(routeId), route: route.isNotEmpty ? int.parse(route) : int.parse(routeId),

Loading…
Cancel
Save