|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
|
|
|
|
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/get_medication_response_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/post_prescrition_req_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart';
|
|
|
|
|
@ -8,6 +10,7 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/base/base_view.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/Text.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';
|
|
|
|
|
@ -31,6 +34,7 @@ class UpdatePrescriptionForm extends StatefulWidget {
|
|
|
|
|
final String enteredRemarks;
|
|
|
|
|
final String startDate;
|
|
|
|
|
final String frequency;
|
|
|
|
|
final String drugNameGeneric;
|
|
|
|
|
final PrescriptionViewModel model;
|
|
|
|
|
|
|
|
|
|
UpdatePrescriptionForm(
|
|
|
|
|
@ -46,7 +50,8 @@ class UpdatePrescriptionForm extends StatefulWidget {
|
|
|
|
|
this.doseUnit,
|
|
|
|
|
this.enteredRemarks,
|
|
|
|
|
this.frequency,
|
|
|
|
|
this.model});
|
|
|
|
|
this.model,
|
|
|
|
|
this.drugNameGeneric});
|
|
|
|
|
@override
|
|
|
|
|
_UpdatePrescriptionFormState createState() => _UpdatePrescriptionFormState();
|
|
|
|
|
}
|
|
|
|
|
@ -62,6 +67,9 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
dynamic frequencyUpdate;
|
|
|
|
|
dynamic updatedDuration;
|
|
|
|
|
dynamic units;
|
|
|
|
|
GetMedicationResponseModel newSelectedMedication;
|
|
|
|
|
GlobalKey key =
|
|
|
|
|
new GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -80,7 +88,7 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
await model.getMedicationRoute();
|
|
|
|
|
await model.getMedicationFrequency();
|
|
|
|
|
await model.getMedicationDoseTime();
|
|
|
|
|
await model.getMedicationIndications();
|
|
|
|
|
//await model.getMedicationIndications();
|
|
|
|
|
route = model.getLookupById(model.medicationRouteList, widget.route);
|
|
|
|
|
doseTime =
|
|
|
|
|
model.getLookupById(model.medicationDoseTimeList, widget.dose);
|
|
|
|
|
@ -96,13 +104,13 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
NetworkBaseView(
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
child: DraggableScrollableSheet(
|
|
|
|
|
initialChildSize: 0.90,
|
|
|
|
|
maxChildSize: 0.90,
|
|
|
|
|
initialChildSize: 0.95,
|
|
|
|
|
maxChildSize: 0.99,
|
|
|
|
|
minChildSize: 0.6,
|
|
|
|
|
builder:
|
|
|
|
|
(BuildContext context, ScrollController scrollController) {
|
|
|
|
|
return Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height * 1.0,
|
|
|
|
|
height: MediaQuery.of(context).size.height * 1.3,
|
|
|
|
|
child: Form(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
@ -119,6 +127,78 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height *
|
|
|
|
|
0.070,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: model.allMedicationList != null
|
|
|
|
|
? () {
|
|
|
|
|
setState(() {
|
|
|
|
|
newSelectedMedication = null;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: newSelectedMedication == null
|
|
|
|
|
? AutoCompleteTextField<
|
|
|
|
|
GetMedicationResponseModel>(
|
|
|
|
|
decoration:
|
|
|
|
|
textFieldSelectorDecoration(
|
|
|
|
|
widget.drugNameGeneric,
|
|
|
|
|
newSelectedMedication != null
|
|
|
|
|
? newSelectedMedication
|
|
|
|
|
.genericName
|
|
|
|
|
: null,
|
|
|
|
|
true,
|
|
|
|
|
),
|
|
|
|
|
itemSubmitted: (item) => setState(
|
|
|
|
|
() => newSelectedMedication =
|
|
|
|
|
item),
|
|
|
|
|
key: key,
|
|
|
|
|
suggestions:
|
|
|
|
|
model.allMedicationList,
|
|
|
|
|
itemBuilder: (context,
|
|
|
|
|
suggestion) =>
|
|
|
|
|
new Padding(
|
|
|
|
|
child: Texts(suggestion
|
|
|
|
|
.description +
|
|
|
|
|
'/' +
|
|
|
|
|
suggestion.genericName),
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.all(8.0)),
|
|
|
|
|
itemSorter: (a, b) => 1,
|
|
|
|
|
itemFilter: (suggestion, input) =>
|
|
|
|
|
suggestion.genericName
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.startsWith(
|
|
|
|
|
input.toLowerCase()) ||
|
|
|
|
|
suggestion.description
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.startsWith(
|
|
|
|
|
input.toLowerCase()) ||
|
|
|
|
|
suggestion.keywords
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.startsWith(
|
|
|
|
|
input.toLowerCase()),
|
|
|
|
|
)
|
|
|
|
|
: TextField(
|
|
|
|
|
decoration:
|
|
|
|
|
textFieldSelectorDecoration(
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.searchMedicineNameHere,
|
|
|
|
|
newSelectedMedication != null
|
|
|
|
|
? newSelectedMedication
|
|
|
|
|
.description +
|
|
|
|
|
('${newSelectedMedication.genericName}')
|
|
|
|
|
: null,
|
|
|
|
|
true,
|
|
|
|
|
),
|
|
|
|
|
enabled: false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 12,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height *
|
|
|
|
|
0.060,
|
|
|
|
|
@ -428,18 +508,23 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
'update prescription'.toUpperCase(),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
updatePrescription(
|
|
|
|
|
newDrugId:
|
|
|
|
|
newSelectedMedication != null
|
|
|
|
|
? newSelectedMedication
|
|
|
|
|
.itemId
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.drugId,
|
|
|
|
|
newDoseStreangth:
|
|
|
|
|
strengthController
|
|
|
|
|
.text.isNotEmpty
|
|
|
|
|
? strengthController.text
|
|
|
|
|
: widget.doseStreangth,
|
|
|
|
|
newUnit: units !=
|
|
|
|
|
null
|
|
|
|
|
newUnit: units != null
|
|
|
|
|
? units['id'].toString()
|
|
|
|
|
: widget.doseUnit,
|
|
|
|
|
doseUnit: widget.doseUnit,
|
|
|
|
|
doseStreangth: widget
|
|
|
|
|
.doseStreangth,
|
|
|
|
|
doseStreangth:
|
|
|
|
|
widget.doseStreangth,
|
|
|
|
|
duration: widget.duration,
|
|
|
|
|
startDate: widget.startDate,
|
|
|
|
|
doseId: widget.dose,
|
|
|
|
|
@ -447,25 +532,20 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
routeId: widget.route,
|
|
|
|
|
patient: widget.patient,
|
|
|
|
|
model: widget.model,
|
|
|
|
|
newDuration:
|
|
|
|
|
updatedDuration !=
|
|
|
|
|
null
|
|
|
|
|
? updatedDuration[
|
|
|
|
|
'id']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.duration,
|
|
|
|
|
newDuration: updatedDuration !=
|
|
|
|
|
null
|
|
|
|
|
? updatedDuration['id']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.duration,
|
|
|
|
|
drugId: widget.drugId,
|
|
|
|
|
remarks: remarksController.text,
|
|
|
|
|
route: route !=
|
|
|
|
|
null
|
|
|
|
|
route: route != null
|
|
|
|
|
? route['id'].toString()
|
|
|
|
|
: widget.route,
|
|
|
|
|
frequency:
|
|
|
|
|
frequencyUpdate !=
|
|
|
|
|
null
|
|
|
|
|
? frequencyUpdate['id']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.frequency,
|
|
|
|
|
frequency: frequencyUpdate != null
|
|
|
|
|
? frequencyUpdate['id']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.frequency,
|
|
|
|
|
dose: doseTime != null
|
|
|
|
|
? doseTime['id'].toString()
|
|
|
|
|
: widget.dose,
|
|
|
|
|
@ -524,6 +604,7 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
updatePrescription(
|
|
|
|
|
{PrescriptionViewModel model,
|
|
|
|
|
int drugId,
|
|
|
|
|
int newDrugId,
|
|
|
|
|
String frequencyId,
|
|
|
|
|
String remarks,
|
|
|
|
|
String dose,
|
|
|
|
|
@ -556,7 +637,7 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
? int.parse(newDoseStreangth)
|
|
|
|
|
: int.parse(doseStreangth),
|
|
|
|
|
//frequency.isNotEmpty ? int.parse(dose) : 1,
|
|
|
|
|
itemId: drugId,
|
|
|
|
|
itemId: newDrugId != 0 ? newDrugId : drugId,
|
|
|
|
|
doseUnitId:
|
|
|
|
|
newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit),
|
|
|
|
|
route: route.isNotEmpty ? int.parse(route) : int.parse(routeId),
|
|
|
|
|
@ -588,6 +669,7 @@ class _UpdatePrescriptionFormState extends State<UpdatePrescriptionForm> {
|
|
|
|
|
void updatePrescriptionForm(
|
|
|
|
|
{context,
|
|
|
|
|
String drugName,
|
|
|
|
|
String drugNameGeneric,
|
|
|
|
|
int drugId,
|
|
|
|
|
String remarks,
|
|
|
|
|
PrescriptionViewModel model,
|
|
|
|
|
@ -622,6 +704,7 @@ void updatePrescriptionForm(
|
|
|
|
|
route: rouat,
|
|
|
|
|
startDate: startDate,
|
|
|
|
|
model: model,
|
|
|
|
|
drugNameGeneric: drugNameGeneric,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|