|
|
|
|
@ -1,13 +1,20 @@
|
|
|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import '../../../core/enum/viewstate.dart';
|
|
|
|
|
import '../../../core/model/Prescriptions/prescription_model.dart';
|
|
|
|
|
import '../../../core/model/patient/patiant_info_model.dart';
|
|
|
|
|
import '../../../core/model/search_drug/get_medication_response_model.dart';
|
|
|
|
|
import '../../../core/viewModel/prescription_view_model.dart';
|
|
|
|
|
import '../../../util/dr_app_toast_msg.dart';
|
|
|
|
|
import '../../../util/helpers.dart';
|
|
|
|
|
import '../../../widgets/shared/buttons/app_buttons_widget.dart';
|
|
|
|
|
import '../../patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart';
|
|
|
|
|
import 'drugtodrug.dart';
|
|
|
|
|
|
|
|
|
|
class AddDrugWidget extends StatefulWidget {
|
|
|
|
|
@ -39,60 +46,77 @@ class AddDrugWidget extends StatefulWidget {
|
|
|
|
|
class _AddDrugWidgetState extends State<AddDrugWidget> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Container(
|
|
|
|
|
height: SizeConfig.realScreenHeight * .8,
|
|
|
|
|
width: SizeConfig.realScreenWidth,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
DrugToDrug(
|
|
|
|
|
widget.patient,
|
|
|
|
|
widget.medicineModel.getPrescriptionForDrug(
|
|
|
|
|
widget.prescriptionList, widget.medicineModel
|
|
|
|
|
),
|
|
|
|
|
widget.medicineModel.patientAssessmentList),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3),
|
|
|
|
|
child: AppButton(
|
|
|
|
|
title: TranslationBase.of(context).addMedication,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
widget.medicineModel.postPrescription(
|
|
|
|
|
icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty
|
|
|
|
|
? widget.medicineModel.patientAssessmentList[0].icdCode10ID
|
|
|
|
|
.isEmpty
|
|
|
|
|
? "test"
|
|
|
|
|
: widget.medicineModel.patientAssessmentList[0].icdCode10ID
|
|
|
|
|
.toString()
|
|
|
|
|
: "test",
|
|
|
|
|
dose: widget.strength,
|
|
|
|
|
doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1
|
|
|
|
|
? widget.medicineModel.itemMedicineListUnit[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.units['parameterCode'].toString(),
|
|
|
|
|
patient: widget.patient,
|
|
|
|
|
doseTimeIn: widget.doseTime['id'].toString(),
|
|
|
|
|
model: widget.modelPrescription,
|
|
|
|
|
duration: widget.duration['id'].toString(),
|
|
|
|
|
frequency: widget.medicineModel.itemMedicineList.length == 1
|
|
|
|
|
? widget.medicineModel.itemMedicineList[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.frequency['parameterCode'].toString(),
|
|
|
|
|
route: widget.medicineModel.itemMedicineListRoute.length == 1
|
|
|
|
|
? widget.medicineModel.itemMedicineListRoute[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.route['parameterCode'].toString(),
|
|
|
|
|
drugId: widget.selectedMedication.itemId.toString(),
|
|
|
|
|
strength: widget.strength,
|
|
|
|
|
indication: widget.indication,
|
|
|
|
|
instruction: widget.instruction,
|
|
|
|
|
doseTime: widget.selectedDate,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
baseViewModel: widget.medicineModel,
|
|
|
|
|
appBar: BottomSheetTitle(title: "Add Medication",),
|
|
|
|
|
body: Container(
|
|
|
|
|
height: SizeConfig.realScreenHeight * .8,
|
|
|
|
|
width: SizeConfig.realScreenWidth,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
DrugToDrug(
|
|
|
|
|
widget.patient,
|
|
|
|
|
widget.medicineModel.getPrescriptionForDrug(
|
|
|
|
|
widget.prescriptionList, widget.medicineModel
|
|
|
|
|
),
|
|
|
|
|
widget.medicineModel.patientAssessmentList),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
bottomSheet: widget.medicineModel.state == ViewState.BusyLocal || widget.medicineModel.state == ViewState.Busy
|
|
|
|
|
? Container(
|
|
|
|
|
height: 0,
|
|
|
|
|
)
|
|
|
|
|
: BottomSheetDialogButton(
|
|
|
|
|
label: TranslationBase.of(context).addMedication,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await widget.medicineModel.postPrescription(
|
|
|
|
|
isLocalBusy: true,
|
|
|
|
|
icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty
|
|
|
|
|
? widget.medicineModel.patientAssessmentList[0].icdCode10ID
|
|
|
|
|
.isEmpty
|
|
|
|
|
? "test"
|
|
|
|
|
: widget.medicineModel.patientAssessmentList[0].icdCode10ID
|
|
|
|
|
.toString()
|
|
|
|
|
: "test",
|
|
|
|
|
dose: widget.strength,
|
|
|
|
|
doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1
|
|
|
|
|
? widget.medicineModel.itemMedicineListUnit[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.units['parameterCode'].toString(),
|
|
|
|
|
patient: widget.patient,
|
|
|
|
|
doseTimeIn: widget.doseTime['id'].toString(),
|
|
|
|
|
model: widget.modelPrescription,
|
|
|
|
|
duration: widget.duration['id'].toString(),
|
|
|
|
|
frequency: widget.medicineModel.itemMedicineList.length == 1
|
|
|
|
|
? widget.medicineModel.itemMedicineList[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.frequency['parameterCode'].toString(),
|
|
|
|
|
route: widget.medicineModel.itemMedicineListRoute.length == 1
|
|
|
|
|
? widget.medicineModel.itemMedicineListRoute[0]['parameterCode']
|
|
|
|
|
.toString()
|
|
|
|
|
: widget.route['parameterCode'].toString(),
|
|
|
|
|
drugId: widget.selectedMedication.itemId.toString(),
|
|
|
|
|
strength: widget.strength,
|
|
|
|
|
indication: widget.indication,
|
|
|
|
|
instruction: widget.instruction,
|
|
|
|
|
doseTime: widget.selectedDate,
|
|
|
|
|
);
|
|
|
|
|
if (widget.medicineModel.state == ViewState.ErrorLocal) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
Helpers.showErrorToast(widget.medicineModel.error);
|
|
|
|
|
} else if (widget.modelPrescription.state == ViewState.Idle) {
|
|
|
|
|
widget.modelPrescription.getPrescriptions(widget.patient);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
DrAppToastMsg.showSuccesToast('Medication has been added');
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|