Fix the drug to drug page

merge-requests/967/head
RoaaGhali98 4 years ago
parent 5f3f509b8c
commit 0147481c27

@ -167,56 +167,6 @@ class PrescriptionService extends LookupService {
List<GetAllergiesResModel> allergy,
PatiantInformtion patient,
List<dynamic> prescription) async {
// Map<String, dynamic> request = {
// "Prescription": {
// "objPatientInfo": {"Gender": "Male", "Age": "21/06/1967"},
// "objVitalSign": {"Height": "180", "Weight": "37"},
// "objPrescriptionItems": [
// {
// "DrugId": "83-20-00-30-20-03-03",
// "DrugName": "WARFARIN 1 MG TAB 28'S (N)",
// "Dose": "1",
// "DoseType": "04",
// "Unit": "actuation(s)",
// "FrequencyType": "1/3/Day",
// "Duration": "3/Day",
// "IsScreen": "true"
// },
// {
// "DrugId": "64-20-00-10-00-03-15",
// "DrugName": "PANADOL 500 MG TAB 24'S(DIS)",
// "Dose": "1",
// "DoseType": "04",
// "Unit": "MG",
// "FrequencyType": "3/1/Day",
// "Duration": "4/Day",
// "RouteID": "24",
// "IsScreen": "true"
// }
// ],
// "objAllergies": {
// "Allergy": {
// "objProperties": {"Id": "26", "Name": "phenoxymethylpenicillin"}
// }
// },
// "objDiagnosis": {
// "Diagnosis": {
// "objProperties": {"Id": "A01.1", "Name": "Paratyphoid fever A"}
// }
// },
// "IsDoctor": "false",
// "IsPharmacist": "false"
// },
// "IPAdress": "10.10.10.10",
// "Channel": 9,
// "LanguageID": 2,
// "VersionID": 5.3,
// "SessionID": "BlUSkYymTt",
// "IsLoginForDoctorApp": true,
// "PatientOutSA": 0,
// "TokenID": "@dm!n",
// "OutSA": true
// };
Map<String, dynamic> request = {
"Prescription": {
"objPatientInfo": {

@ -9,6 +9,7 @@ import 'package:doctor_app_flutter/core/service/patient_medical_file/procedure/p
import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentReqModel.dart';
import 'package:doctor_app_flutter/core/model/SOAP/GetAssessmentResModel.dart';
import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_container.dart';
import 'package:flutter/cupertino.dart';
import '../../locator.dart';
import '../../util/dr_app_toast_msg.dart';
@ -158,7 +159,14 @@ class MedicineViewModel extends BaseViewModel {
String doseUnit,
String icdCode,
PatiantInformtion patient,
String patientType}) async {
String patientType,
bool isLocalBusy = false,
BuildContext context, PrescriptionRequestModel prescriptionRequestModel}) async {
if (isLocalBusy) {
setState(ViewState.BusyLocal);
} else {
setState(ViewState.Busy);
}
PostPrescriptionReqModel postProcedureReqModel =
new PostPrescriptionReqModel();
List<PrescriptionRequestModel> prescriptionList = List();
@ -182,13 +190,16 @@ class MedicineViewModel extends BaseViewModel {
duration: duration.isEmpty ? 1 : int.parse(duration),
doseStartDate: doseTime.toIso8601String()));
postProcedureReqModel.prescriptionRequestModel = prescriptionList;
await model.postPrescription(postProcedureReqModel, patient.patientMRN);
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
} else if (model.state == ViewState.Idle) {
model.getPrescriptions(patient);
DrAppToastMsg.showSuccesToast('Medication has been added');
await _prescriptionService.postPrescription(postProcedureReqModel);
if (_prescriptionService.hasError) {
error = _prescriptionService.error;
if (isLocalBusy) {
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Error);
}
} else {
setState(ViewState.Idle);
}
}

@ -118,7 +118,7 @@ class PrescriptionViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getPrescription({int mrn}) async {
Future getPrescription({int mrn, BuildContext context}) async {
hasError = false;
//_insuranceCardService.clearInsuranceCard();
setState(ViewState.BusyLocal);

@ -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,7 +46,10 @@ class AddDrugWidget extends StatefulWidget {
class _AddDrugWidgetState extends State<AddDrugWidget> {
@override
Widget build(BuildContext context) {
return Container(
return AppScaffold(
baseViewModel: widget.medicineModel,
appBar: BottomSheetTitle(title: "Add Medication",),
body: Container(
height: SizeConfig.realScreenHeight * .8,
width: SizeConfig.realScreenWidth,
child: SingleChildScrollView(
@ -52,13 +62,19 @@ class _AddDrugWidgetState extends State<AddDrugWidget> {
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(
],
)),
),
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
@ -89,10 +105,18 @@ class _AddDrugWidgetState extends State<AddDrugWidget> {
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();
}
},
))
],
)),
),
);
}
}

@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_container.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:flutter/material.dart';
@ -38,8 +39,8 @@ class _DrugToDrug extends State<DrugToDrug> {
];
VitalSignsViewModel model = new VitalSignsViewModel();
SOAPViewModel model2 = new SOAPViewModel();
VitalSignsViewModel vitalSignsViewModel = new VitalSignsViewModel();
SOAPViewModel soapViewModel = new SOAPViewModel();
@override
void initState() {
@ -52,18 +53,18 @@ class _DrugToDrug extends State<DrugToDrug> {
Widget build(BuildContext context) {
return isLoaded == true
? BaseView<PrescriptionViewModel>(
onModelReady: (model3) => model3.getDrugToDrug(
model.patientVitalSigns,
onModelReady: (prescriptionViewModel) => prescriptionViewModel.getDrugToDrug(
vitalSignsViewModel.patientVitalSigns,
widget.listAssessment,
model2.patientAllergiesList,
soapViewModel.patientAllergiesList,
widget.patient,
widget.prescription),
builder: (BuildContext context, PrescriptionViewModel model3,
builder: (BuildContext context, PrescriptionViewModel prescriptionViewModel,
Widget child) =>
NetworkBaseView(
baseViewModel: model3,
baseViewModel: prescriptionViewModel,
child: Container(
height: SizeConfig.realScreenHeight * .4,
height: SizeConfig.realScreenHeight * .9,
child: new ListView.builder(
itemCount: expandableList.length,
itemBuilder: (context, i) {
@ -73,7 +74,7 @@ class _DrugToDrug extends State<DrugToDrug> {
' ' +
'(' +
getDrugInfo(expandableList[i]['level'],
model3)
prescriptionViewModel)
.length
.toString() +
')',
@ -81,7 +82,7 @@ class _DrugToDrug extends State<DrugToDrug> {
fontWeight: FontWeight.bold,
),
children: getDrugInfo(
expandableList[i]['level'], model3)
expandableList[i]['level'], prescriptionViewModel)
.map((item) {
return Container(
padding: EdgeInsets.all(10),
@ -93,10 +94,8 @@ class _DrugToDrug extends State<DrugToDrug> {
}))))
: Container(
height: SizeConfig.realScreenHeight * .45,
child: Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
)));
child: GifLoaderContainer()
);
}
getTypeID() async {
@ -119,17 +118,17 @@ class _DrugToDrug extends State<DrugToDrug> {
editedBy: '');
/// TODO Elham* rename model to meaning full not just modle with number
await model.getPatientVitalSign(widget.patient);
await model2.getPatientAllergy(generalGetReqForSOAP);
await model2.getMasterLookup(MasterKeysService.DiagnosisType);
if (model.state == ViewState.Idle && model2.state == ViewState.Idle) {
await vitalSignsViewModel.getPatientVitalSign(widget.patient);
await soapViewModel.getPatientAllergy(generalGetReqForSOAP);
await soapViewModel.getMasterLookup(MasterKeysService.DiagnosisType);
if (vitalSignsViewModel.state == ViewState.Idle && soapViewModel.state == ViewState.Idle) {
setState(() {
isLoaded = true;
});
}
}
List<dynamic> getDrugInfo(level, model3) {
return model3.drugToDrug.where((i) => i['Severity'] == level).toList();
List<dynamic> getDrugInfo(level, prescriptionViewModel) {
return prescriptionViewModel.drugToDrug.where((i) => i['Severity'] == level).toList();
}
}

@ -26,6 +26,7 @@ import 'package:hexcolor/hexcolor.dart';
import 'package:speech_to_text/speech_recognition_error.dart';
import 'package:speech_to_text/speech_to_text.dart' as stt;
import '../../../widgets/transitions/slide_up_page.dart';
import 'add_drug_widget.dart';
class PrescriptionFormWidget extends StatefulWidget {
@ -590,8 +591,31 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
}
if (formKey.currentState.validate()) {
Navigator.pop(context);
openDrugToDrug(model, prescriptionViewModel);
Navigator.push(
context,
SlideUpPageRoute(
widget: AddDrugWidget(
patient: widget.patient,
medicineModel: widget.medicineViewModel,
modelPrescription: widget.prescriptionViewModel,
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,
),
),
);
// Navigator.pop(context);
// openDrugToDrug(model, prescriptionViewModel);
}
} else {
setState(() {

Loading…
Cancel
Save