diff --git a/lib/config/config.dart b/lib/config/config.dart index 3cfb84c7..b7582800 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -132,11 +132,13 @@ const POST_PHYSICAL_EXAM = const POST_PROGRESS_NOTE = 'Services/DoctorApplication.svc/REST/PostProgressNote'; -const POST_ASSESSMENT = - 'Services/DoctorApplication.svc/REST/PostAssessment'; +const POST_ASSESSMENT = 'Services/DoctorApplication.svc/REST/PostAssessment'; const GET_CATEGORISE_PROCEDURE = 'Services/DoctorApplication.svc/REST/GetProcedure'; +const UPDATE_PROCEDURE = 'Services/DoctorApplication.svc/REST/PatchProcedure'; +const UPDATE_PRESCRIPTION = + 'Services/DoctorApplication.svc/REST/PatchPrescription'; var selectedPatientType = 1; diff --git a/lib/core/service/prescription_service.dart b/lib/core/service/prescription_service.dart index 9d1cb102..ced17cd4 100644 --- a/lib/core/service/prescription_service.dart +++ b/lib/core/service/prescription_service.dart @@ -46,4 +46,21 @@ class PrescriptionService extends BaseService { body: postProcedureReqModel.toJson(), ); } + + Future updatePrescription( + PostPrescriptionReqModel updatePrescriptionReqModel) async { + hasError = false; + //_prescriptionList.clear(); + await baseAppClient.post( + UPDATE_PRESCRIPTION, + onSuccess: (dynamic response, int statusCode) { + print("Accepted"); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: updatePrescriptionReqModel.toJson(), + ); + } } diff --git a/lib/core/service/procedure_service.dart b/lib/core/service/procedure_service.dart index 7ffd9310..c7319eed 100644 --- a/lib/core/service/procedure_service.dart +++ b/lib/core/service/procedure_service.dart @@ -72,4 +72,19 @@ class ProcedureService extends BaseService { super.error = error; }, body: postProcedureReqModel.toJson()); } + + Future updateProcedure() async { + hasError = false; + _procedureList.clear(); + await baseAppClient.post( + GET_CATEGORISE_PROCEDURE, + onSuccess: (dynamic response, int statusCode) { + print("ACCEPTED"); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + ); + } } diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 7923c3d7..14684aeb 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -38,4 +38,19 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + Future updatePrescription( + PostPrescriptionReqModel updatePrescriptionReqModel) async { + hasError = false; + //_insuranceCardService.clearInsuranceCard(); + setState(ViewState.Busy); + await _prescriptionService.updatePrescription(updatePrescriptionReqModel); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.ErrorLocal); + } else { + await getPrescription(); + setState(ViewState.Idle); + } + } } diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index b051d04d..ab4deee1 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -50,4 +50,16 @@ class ProcedureViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + Future updateProcedure() async { + hasError = false; + //_insuranceCardService.clearInsuranceCard(); + setState(ViewState.Busy); + await _procedureService.updateProcedure(); + if (_procedureService.hasError) { + error = _procedureService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } } diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 4f6fe133..2b1e5454 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -1,14 +1,19 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.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/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; 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/screens/prescription/add_prescription_form.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/patients/profile/patient_profile_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/profile_medical_info_widget.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_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; @@ -425,7 +430,29 @@ class _NewPrescriptionScreenState extends State { 0.06, child: Column( children: [ - Icon(Icons.edit) + InkWell( + child: Icon( + Icons.edit), + onTap: () { + updatePrescriptionForm( + context, + model + .prescriptionList[ + 0] + .entityList[ + index] + .medicationName, + model + .prescriptionList[ + 0] + .entityList[ + index] + .medicineCode, + model, + ); + //model.postPrescription(); + }, + ), ], ), ), @@ -446,4 +473,171 @@ class _NewPrescriptionScreenState extends State { )), ); } + + void updatePrescriptionForm( + context, String drugName, int drugId, PrescriptionViewModel model) { + TextEditingController remarksController = TextEditingController(); + TextEditingController doseController = TextEditingController(); + TextEditingController frequencyController = TextEditingController(); + TextEditingController routeController = TextEditingController(); + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (BuildContext bc) { + return Container( + height: 600, + child: Form( + child: Padding( + padding: + EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + drugName.toUpperCase(), + fontWeight: FontWeight.w900, + ), + SizedBox( + height: 30.0, + ), + Column( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: 'route', + controller: routeController, + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: 'Dose', + controller: doseController, + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: 'Frequency', + controller: frequencyController, + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: 'Remarks', + controller: remarksController, + maxLines: 7, + minLines: 4, + ), + ), + SizedBox( + height: 12.0, + ), + SizedBox( + height: 140.0, + ), + Container( + margin: + EdgeInsets.all(SizeConfig.widthMultiplier * 2), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: 'update prescription'.toUpperCase(), + onPressed: () { + updatePrescription( + model: model, + drugId: drugId, + remarks: remarksController.text, + route: routeController.text, + frequency: frequencyController.text, + dose: doseController.text); + Navigator.pop(context); + }, + ), + ], + ), + ), + ], + ), + ], + ), + ), + )); + }); + } + + updatePrescription({ + PrescriptionViewModel model, + int drugId, + String remarks, + String dose, + String frequency, + String route, + }) async { + //PrescriptionViewModel model = PrescriptionViewModel(); + PostPrescriptionReqModel updatePrescriptionReqModel = + new PostPrescriptionReqModel(); + List sss = List(); + + updatePrescriptionReqModel.appointmentNo = 2016055159; + updatePrescriptionReqModel.clinicID = 17; + updatePrescriptionReqModel.episodeID = 200012330; + updatePrescriptionReqModel.patientMRN = 3120877; + updatePrescriptionReqModel.vidaAuthTokenID = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiOGFjNDRjZGQtOWE0Mi00M2YxLWE2YTQtMWQ4NzBmZmYwNTUyIiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1OTU2NDkiLCJDbGluaWNJZCI6IjEiLCJyb2xlIjpbIkRPQ1RPUlMiLCJIRUFEIERPQ1RPUlMiLCJBRE1JTklTVFJBVE9SUyIsIlJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiRVIgUkVDRVBUSU9OSVNUIiwiUEhBUk1BQ1kgQUNDT1VOVCBTVEFGRiIsIlBIQVJNQUNZIE5VUlNFIiwiSU5QQVRJRU5UIFBIQVJNQUNJU1QiLCJBRE1JU1NJT04gU1RBRkYiLCJBUFBST1ZBTCBTVEFGRiIsIkNPTlNFTlQgIiwiTUVESUNBTCBSRVBPUlQgLSBTSUNLIExFQVZFIE1BTkFHRVIiXSwibmJmIjoxNjA4NzM2NjY5LCJleHAiOjE2MDk2MDA2NjksImlhdCI6MTYwODczNjY2OX0.9EDgYrbe5fQA2CvgLdFT4s_PL7hD5R_Qggfpv4lDtUY"; + sss.add(PrescriptionRequestModel( + covered: true, + dose: frequency.isNotEmpty ? int.parse(dose) : 1, + itemId: drugId, + doseUnitId: 1, + route: frequency.isNotEmpty ? int.parse(route) : 1, + frequency: frequency.isNotEmpty ? int.parse(frequency) : 1, + remarks: remarks.isEmpty ? '' : remarks, + approvalRequired: true, + icdcode10Id: "test2", + doseTime: 1, + duration: 2, + doseStartDate: "2020-12-20T13:07:41.769Z")); + updatePrescriptionReqModel.prescriptionRequestModel = sss; + //postProcedureReqModel.procedures = controlsProcedure; + + await model.updatePrescription(updatePrescriptionReqModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else if (model.state == ViewState.Idle) { + DrAppToastMsg.showSuccesToast('Medication has been updated'); + } + } }