From 854f42ce96fdfdccf91625502e9ca6288fc829ef Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 5 Aug 2021 10:23:37 +0300 Subject: [PATCH] Create Doctor Response working fine --- .../service/home/doctor_reply_service.dart | 18 ++- .../viewModel/doctor_replay_view_model.dart | 22 ++++ .../request_create_doctor_response.dart | 48 ++++++++ .../{ => replay}/request_doctor_reply.dart | 0 lib/screens/doctor/doctor_repaly_chat.dart | 116 +++++++++--------- 5 files changed, 148 insertions(+), 56 deletions(-) create mode 100644 lib/models/doctor/replay/request_create_doctor_response.dart rename lib/models/doctor/{ => replay}/request_doctor_reply.dart (100%) diff --git a/lib/core/service/home/doctor_reply_service.dart b/lib/core/service/home/doctor_reply_service.dart index 2ffb3ee8..8cf9b010 100644 --- a/lib/core/service/home/doctor_reply_service.dart +++ b/lib/core/service/home/doctor_reply_service.dart @@ -1,8 +1,9 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart'; +import 'package:doctor_app_flutter/models/doctor/replay/request_create_doctor_response.dart'; import 'package:doctor_app_flutter/models/doctor/request_add_referred_doctor_remarks.dart'; -import 'package:doctor_app_flutter/models/doctor/request_doctor_reply.dart'; +import 'package:doctor_app_flutter/models/doctor/replay/request_doctor_reply.dart'; import 'package:doctor_app_flutter/models/patient/my_referral/my_referral_patient_model.dart'; import 'package:doctor_app_flutter/models/patient/request_my_referral_patient_model.dart'; @@ -59,4 +60,19 @@ class DoctorReplyService extends BaseService { }, ); } + Future createDoctorResponse( + CreateDoctorResponseModel createDoctorResponseModel) async { + hasError = false; + await baseAppClient.post( + CREATE_DOCTOR_RESPONSE, + body: createDoctorResponseModel.toJson(), + onSuccess: (dynamic body, int statusCode) { + print("succsss"); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + ); + } } diff --git a/lib/core/viewModel/doctor_replay_view_model.dart b/lib/core/viewModel/doctor_replay_view_model.dart index 18f1a9f5..aec7f71d 100644 --- a/lib/core/viewModel/doctor_replay_view_model.dart +++ b/lib/core/viewModel/doctor_replay_view_model.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/home/doctor_reply_service.dart'; import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart'; +import 'package:doctor_app_flutter/models/doctor/replay/request_create_doctor_response.dart'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -31,4 +32,25 @@ class DoctorReplayViewModel extends BaseViewModel { } else setState(ViewState.Idle); } + + Future createDoctorResponse( + String response, ListGtMyPatientsQuestions model) async { + await getDoctorProfile(); + CreateDoctorResponseModel createDoctorResponseModel = + CreateDoctorResponseModel( + transactionNo: model.transactionNo.toString(), + doctorResponse: response, + infoStatus: 3, + createdBy:this.doctorProfile.doctorID, + infoEnteredBy: this.doctorProfile.doctorID, + setupID:"010266" + ); + setState(ViewState.BusyLocal); + await _doctorReplyService.createDoctorResponse(createDoctorResponseModel); + if (_doctorReplyService.hasError) { + error = _doctorReplyService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } } diff --git a/lib/models/doctor/replay/request_create_doctor_response.dart b/lib/models/doctor/replay/request_create_doctor_response.dart new file mode 100644 index 00000000..49e421d9 --- /dev/null +++ b/lib/models/doctor/replay/request_create_doctor_response.dart @@ -0,0 +1,48 @@ +class CreateDoctorResponseModel { + String setupID; + int projectID; + String transactionNo; + int infoEnteredBy; + int infoStatus; + int createdBy; + int editedBy; + String doctorResponse; + int doctorID; + + CreateDoctorResponseModel( + {this.setupID, + this.projectID, + this.transactionNo, + this.infoEnteredBy, + this.infoStatus, + this.createdBy, + this.editedBy, + this.doctorResponse, + this.doctorID}); + + CreateDoctorResponseModel.fromJson(Map json) { + setupID = json['SetupID']; + projectID = json['ProjectID']; + transactionNo = json['TransactionNo']; + infoEnteredBy = json['InfoEnteredBy']; + infoStatus = json['InfoStatus']; + createdBy = json['CreatedBy']; + editedBy = json['EditedBy']; + doctorResponse = json['DoctorResponse']; + doctorID = json['DoctorID']; + } + + Map toJson() { + final Map data = new Map(); + data['SetupID'] = this.setupID; + data['ProjectID'] = this.projectID; + data['TransactionNo'] = this.transactionNo; + data['InfoEnteredBy'] = this.infoEnteredBy; + data['InfoStatus'] = this.infoStatus; + data['CreatedBy'] = this.createdBy; + data['EditedBy'] = this.editedBy; + data['DoctorResponse'] = this.doctorResponse; + data['DoctorID'] = this.doctorID; + return data; + } +} diff --git a/lib/models/doctor/request_doctor_reply.dart b/lib/models/doctor/replay/request_doctor_reply.dart similarity index 100% rename from lib/models/doctor/request_doctor_reply.dart rename to lib/models/doctor/replay/request_doctor_reply.dart diff --git a/lib/screens/doctor/doctor_repaly_chat.dart b/lib/screens/doctor/doctor_repaly_chat.dart index 14e446e8..a071596b 100644 --- a/lib/screens/doctor/doctor_repaly_chat.dart +++ b/lib/screens/doctor/doctor_repaly_chat.dart @@ -1,10 +1,16 @@ import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart'; import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_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 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -220,61 +226,61 @@ class DoctorReplayChat extends StatelessWidget { ), ), - // Positioned( - // bottom: 0, - // child: Container( - // width:MediaQuery.of(context).size.width * 1, - // // height: MediaQuery.of(context).size.height * 0.12, - // child: Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // FractionallySizedBox( - // child: Container( - // - // child: TextFields( - // borderRadius: 0, - // hintText: TranslationBase - // .of(context) - // .typeHereToReply, - // fontSize: 13.5, - // - // suffixIcon: FontAwesomeIcons.arrowRight, - // suffixIconColor: Colors.green, - // onSuffixTap: ()async { - // GifLoaderDialogUtils.showMyDialog(context); - // await model.replay(msgController.text, reply); - // if(model.state == ViewState.ErrorLocal) { - // Helpers.showErrorToast("An error happened while you are replaying"); - // } else { - // DrAppToastMsg.showSuccesToast("Thank you for your replay "); - // await previousModel.getDoctorReply(); - // Navigator.pop(context); - // } - // GifLoaderDialogUtils.hideDialog(context); - // - // - // - // - // }, - // // hintColor: Colors.black, - // fontWeight: FontWeight.w600, - // maxLines: 50, - // minLines: 3, - // controller: msgController, - // validator: (value) { - // if (value == null || value == "") - // return TranslationBase.of(context) - // .emptyMessage; - // else - // return null; - // }), - // - // ), - // ), - // ], - // ), - // ), - // ) + Positioned( + bottom: 0, + child: Container( + width:MediaQuery.of(context).size.width * 1, + height: MediaQuery.of(context).size.height * 0.12, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + FractionallySizedBox( + child: Container( + + child: TextFields( + borderRadius: 0, + hintText: TranslationBase + .of(context) + .typeHereToReply, + fontSize: 13.5, + + suffixIcon: FontAwesomeIcons.arrowRight, + suffixIconColor: Colors.green, + onSuffixTap: ()async { + GifLoaderDialogUtils.showMyDialog(context); + await model.createDoctorResponse(msgController.text, reply); + if(model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } else { + DrAppToastMsg.showSuccesToast("Thank you for your replay "); + await previousModel.getDoctorReply(); + Navigator.pop(context); + } + GifLoaderDialogUtils.hideDialog(context); + + + + + }, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 50, + minLines: 3, + controller: msgController, + validator: (value) { + if (value == null || value == "") + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }), + + ), + ), + ], + ), + ), + ) ],