Fix add medication button

merge-requests/967/head
RoaaGhali98 4 years ago
parent 5b8211eec4
commit d5e3a79f85

@ -8,7 +8,6 @@ import '../../../core/model/patient/patiant_info_model.dart';
import '../../../core/model/search_drug/get_medication_response_model.dart'; import '../../../core/model/search_drug/get_medication_response_model.dart';
import '../../../core/viewModel/prescription_view_model.dart'; import '../../../core/viewModel/prescription_view_model.dart';
import '../../../widgets/shared/buttons/app_buttons_widget.dart'; import '../../../widgets/shared/buttons/app_buttons_widget.dart';
import 'add_prescription_form.dart';
import 'drugtodrug.dart'; import 'drugtodrug.dart';
class AddDrugWidget extends StatefulWidget { class AddDrugWidget extends StatefulWidget {
@ -16,37 +15,30 @@ class AddDrugWidget extends StatefulWidget {
final List<PrescriptionModel> prescriptionList; final List<PrescriptionModel> prescriptionList;
final MedicineViewModel medicineModel; final MedicineViewModel medicineModel;
final PrescriptionViewModel modelPrescription; final PrescriptionViewModel modelPrescription;
final dynamic units;
final dynamic route;
final dynamic frequency;
final dynamic duration;
final dynamic doseTime;
final dynamic uom;
final dynamic x;
final GetMedicationResponseModel selectedMedication;
final String strength;
final String indication;
final String instruction;
final DateTime selectedDate;
const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel,
this.modelPrescription, this.units, this.route, this.frequency, this.duration, this.doseTime,
this.uom, this.x, this.selectedMedication, this.strength, this.indication, this.instruction, this.selectedDate}) : super(key: key);
const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel, this.modelPrescription}) : super(key: key);
@override @override
_AddDrugWidgetState createState() => _AddDrugWidgetState(); _AddDrugWidgetState createState() => _AddDrugWidgetState();
} }
class _AddDrugWidgetState extends State<AddDrugWidget> { class _AddDrugWidgetState extends State<AddDrugWidget> {
TextEditingController strengthController = TextEditingController();
dynamic route;
dynamic frequency;
dynamic duration;
dynamic doseTime;
dynamic indication;
dynamic units;
dynamic uom;
dynamic box;
dynamic x;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
GetMedicationResponseModel _selectedMedication;
TextEditingController indicationController = TextEditingController();
TextEditingController instructionController = TextEditingController();
DateTime selectedDate;
return Container( return Container(
height: SizeConfig.realScreenHeight * .8, height: SizeConfig.realScreenHeight * .8,
width: SizeConfig.realScreenWidth, width: SizeConfig.realScreenWidth,
@ -66,7 +58,6 @@ class _AddDrugWidgetState extends State<AddDrugWidget> {
title: TranslationBase.of(context).addMedication, title: TranslationBase.of(context).addMedication,
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
widget.medicineModel.postPrescription( widget.medicineModel.postPrescription(
icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty
? widget.medicineModel.patientAssessmentList[0].icdCode10ID ? widget.medicineModel.patientAssessmentList[0].icdCode10ID
@ -75,28 +66,28 @@ class _AddDrugWidgetState extends State<AddDrugWidget> {
: widget.medicineModel.patientAssessmentList[0].icdCode10ID : widget.medicineModel.patientAssessmentList[0].icdCode10ID
.toString() .toString()
: "test", : "test",
dose: strengthController.text, dose: widget.strength,
doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1 doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1
? widget.medicineModel.itemMedicineListUnit[0]['parameterCode'] ? widget.medicineModel.itemMedicineListUnit[0]['parameterCode']
.toString() .toString()
: units['parameterCode'].toString(), : widget.units['parameterCode'].toString(),
patient: widget.patient, patient: widget.patient,
doseTimeIn: doseTime['id'].toString(), doseTimeIn: widget.doseTime['id'].toString(),
model: widget.modelPrescription, model: widget.modelPrescription,
duration: duration['id'].toString(), duration: widget.duration['id'].toString(),
frequency: widget.medicineModel.itemMedicineList.length == 1 frequency: widget.medicineModel.itemMedicineList.length == 1
? widget.medicineModel.itemMedicineList[0]['parameterCode'] ? widget.medicineModel.itemMedicineList[0]['parameterCode']
.toString() .toString()
: frequency['parameterCode'].toString(), : widget.frequency['parameterCode'].toString(),
route: widget.medicineModel.itemMedicineListRoute.length == 1 route: widget.medicineModel.itemMedicineListRoute.length == 1
? widget.medicineModel.itemMedicineListRoute[0]['parameterCode'] ? widget.medicineModel.itemMedicineListRoute[0]['parameterCode']
.toString() .toString()
: route['parameterCode'].toString(), : widget.route['parameterCode'].toString(),
drugId: _selectedMedication.itemId.toString(), drugId: widget.selectedMedication.itemId.toString(),
strength: strengthController.text, strength: widget.strength,
indication: indicationController.text, indication: widget.indication,
instruction: instructionController.text, instruction: widget.instruction,
doseTime: selectedDate, doseTime: widget.selectedDate,
); );
}, },
)) ))

@ -113,8 +113,6 @@ class _AddPrescriptionFormState extends State<AddPrescriptionForm> {
height: spaceBetweenTextFields, height: spaceBetweenTextFields,
), ),
Container( Container(
child: Form(
key: formKey,
child: Column( child: Column(
children: [ children: [
Visibility( Visibility(
@ -160,7 +158,6 @@ class _AddPrescriptionFormState extends State<AddPrescriptionForm> {
], ],
), ),
), ),
),
], ],
), ),
), ),

@ -86,7 +86,6 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
dynamic frequency; dynamic frequency;
dynamic duration; dynamic duration;
dynamic doseTime; dynamic doseTime;
dynamic indication;
dynamic units; dynamic units;
dynamic uom; dynamic uom;
dynamic box; dynamic box;
@ -155,7 +154,9 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
return Column( return Form(
key: formKey,
child: Column(
children: [ children: [
AppText( AppText(
widget.selectedMedication?.description ?? "", widget.selectedMedication?.description ?? "",
@ -431,14 +432,13 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
duration != null && duration != null &&
frequency != null && frequency != null &&
strengthController.text != null) { strengthController.text != null) {
widget.medicineViewModel.getBoxQuantity( // widget.medicineViewModel.getBoxQuantity(
freq: frequency['parameterCode'], // freq: frequency['parameterCode'],
duration: duration['id'], // duration: duration['id'],
itemCode: widget.selectedMedication.itemId, // itemCode: widget.selectedMedication.itemId,
strength: double.parse(strengthController.text), // strength: double.parse(strengthController.text),
); // );
box = widget.medicineViewModel.boxQuintity; box = widget.medicineViewModel.boxQuintity;
return; return;
} }
}); });
@ -515,6 +515,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
), ),
), ),
], ],
),
); );
} }
@ -537,15 +538,27 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
} }
openDrugToDrug( openDrugToDrug(
MedicineViewModel model, PrescriptionViewModel modelPrescription) { MedicineViewModel medicineViewModel, PrescriptionViewModel modelPrescription) {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
builder: (context) { builder: (context) {
return AddDrugWidget( return AddDrugWidget(
patient: widget.patient, patient: widget.patient,
medicineModel: model, medicineModel: widget.medicineViewModel,
modelPrescription: modelPrescription, modelPrescription: widget.prescriptionViewModel,
prescriptionList: widget.prescriptionList, prescriptionList: widget.prescriptionList,
route: route,
doseTime: doseTime,
duration: duration,
frequency: frequency,
units: units,
uom: uom,
x: x,
selectedMedication: widget.selectedMedication,
strength: strengthController.text,
indication: indicationController.text,
instruction: instructionController.text,
selectedDate: selectedDate,
); );
}); });
} }
@ -578,7 +591,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
if (formKey.currentState.validate()) { if (formKey.currentState.validate()) {
Navigator.pop(context); Navigator.pop(context);
openDrugToDrug(model, widget.prescriptionViewModel); openDrugToDrug(model, prescriptionViewModel);
} }
} else { } else {
setState(() { setState(() {

Loading…
Cancel
Save