From 4ecf9fe4b97439b9050445b3dcea9c712457b7c2 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 15 Apr 2021 15:16:11 +0300 Subject: [PATCH] add doctor replay --- lib/core/service/doctor_reply_service.dart | 11 +- .../viewModel/doctor_replay_view_model.dart | 2 +- .../list_gt_my_patients_question_model.dart | 28 +- lib/screens/doctor/doctor_repaly_chat.dart | 428 +++++++++++------- lib/screens/doctor/doctor_reply_screen.dart | 12 +- lib/widgets/doctor/doctor_reply_widget.dart | 2 +- 6 files changed, 291 insertions(+), 192 deletions(-) diff --git a/lib/core/service/doctor_reply_service.dart b/lib/core/service/doctor_reply_service.dart index 44fb2287..4096c8b2 100644 --- a/lib/core/service/doctor_reply_service.dart +++ b/lib/core/service/doctor_reply_service.dart @@ -33,13 +33,13 @@ class DoctorReplyService extends BaseService { } Future replay( - String referredDoctorRemarks, MyReferralPatientModel model) async { + String referredDoctorRemarks, ListGtMyPatientsQuestions model) async { RequestMyReferralPatientModel _requestMyReferralPatient = RequestMyReferralPatientModel(); RequestAddReferredDoctorRemarks _requestAddReferredDoctorRemarks = RequestAddReferredDoctorRemarks(); - _requestAddReferredDoctorRemarks.admissionNo = model.admissionNo; + _requestAddReferredDoctorRemarks.admissionNo = model.admissionNo.toString(); _requestAddReferredDoctorRemarks.patientID = model.patientID; _requestAddReferredDoctorRemarks.referredDoctorRemarks = referredDoctorRemarks; @@ -49,9 +49,10 @@ class DoctorReplyService extends BaseService { ADD_REFERRED_DOCTOR_REMARKS, body: _requestAddReferredDoctorRemarks.toJson(), onSuccess: (dynamic body, int statusCode) { - model.referredDoctorRemarks = referredDoctorRemarks; - listMyReferralPatientModel[listMyReferralPatientModel.indexOf(model)] = - model; + print("succsss"); + // model.referredDoctorRemarks = referredDoctorRemarks; + // listMyReferralPatientModel[listMyReferralPatientModel.indexOf(model)] = + // model; }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/viewModel/doctor_replay_view_model.dart b/lib/core/viewModel/doctor_replay_view_model.dart index f010bf60..09e0a622 100644 --- a/lib/core/viewModel/doctor_replay_view_model.dart +++ b/lib/core/viewModel/doctor_replay_view_model.dart @@ -21,7 +21,7 @@ class DoctorReplayViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future replay(String referredDoctorRemarks, MyReferralPatientModel model) async { + Future replay(String referredDoctorRemarks, ListGtMyPatientsQuestions model) async { setState(ViewState.BusyLocal); await _doctorReplyService.replay(referredDoctorRemarks, model); if (_doctorReplyService.hasError) { diff --git a/lib/models/doctor/list_gt_my_patients_question_model.dart b/lib/models/doctor/list_gt_my_patients_question_model.dart index 0d2cff9a..b6c5cc2a 100644 --- a/lib/models/doctor/list_gt_my_patients_question_model.dart +++ b/lib/models/doctor/list_gt_my_patients_question_model.dart @@ -2,6 +2,8 @@ import 'package:doctor_app_flutter/util/helpers.dart'; + + class ListGtMyPatientsQuestions { String setupID; int projectID; @@ -24,9 +26,9 @@ class ListGtMyPatientsQuestions { String dateofBirth; String mobileNumber; String emailAddress; - String doctorResponse; - String infoStatus; - Null clinicID; + int admissionNo; + int referringDoctor; + int lineItemNo; String age; String genderDescription; bool isVidaCall; @@ -53,9 +55,9 @@ class ListGtMyPatientsQuestions { this.dateofBirth, this.mobileNumber, this.emailAddress, - this.doctorResponse, - this.infoStatus, - this.clinicID, + this.admissionNo, + this.referringDoctor, + this.lineItemNo, this.age, this.genderDescription, this.isVidaCall}); @@ -69,7 +71,6 @@ class ListGtMyPatientsQuestions { doctorID = json['DoctorID']; requestType = json['RequestType']; requestDate = Helpers.convertStringToDate(json['RequestDate']) ; - requestTime = json['RequestTime']; remarks = json['Remarks']; status = json['Status']; @@ -83,9 +84,9 @@ class ListGtMyPatientsQuestions { dateofBirth = json['DateofBirth']; mobileNumber = json['MobileNumber']; emailAddress = json['EmailAddress']; - doctorResponse = json['DoctorResponse']; - infoStatus = json['InfoStatus']; - clinicID = json['ClinicID']; + admissionNo = json['AdmissionNo']; + referringDoctor = json['ReferringDoctor']; + lineItemNo = json['LineItemNo']; age = json['Age']; genderDescription = json['GenderDescription']; isVidaCall = json['IsVidaCall']; @@ -114,12 +115,13 @@ class ListGtMyPatientsQuestions { data['DateofBirth'] = this.dateofBirth; data['MobileNumber'] = this.mobileNumber; data['EmailAddress'] = this.emailAddress; - data['DoctorResponse'] = this.doctorResponse; - data['InfoStatus'] = this.infoStatus; - data['ClinicID'] = this.clinicID; + data['AdmissionNo'] = this.admissionNo; + data['ReferringDoctor'] = this.referringDoctor; + data['LineItemNo'] = this.lineItemNo; data['Age'] = this.age; data['GenderDescription'] = this.genderDescription; data['IsVidaCall'] = this.isVidaCall; return data; } } + diff --git a/lib/screens/doctor/doctor_repaly_chat.dart b/lib/screens/doctor/doctor_repaly_chat.dart index d183406b..5a8b9a53 100644 --- a/lib/screens/doctor/doctor_repaly_chat.dart +++ b/lib/screens/doctor/doctor_repaly_chat.dart @@ -1,9 +1,15 @@ +import 'package:doctor_app_flutter/client/base_app_client.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/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/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/doctor/doctor_reply_screen.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/translations_delegate_base.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_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -30,6 +36,7 @@ class DoctorReplayChat extends StatelessWidget { baseViewModel: model, isShowAppBar: false, body: Container( + height: MediaQuery.of(context).size.height * 1, color: Color(0XFFF2F2F2), child: Stack( children: [ @@ -81,34 +88,34 @@ class DoctorReplayChat extends StatelessWidget { color: Color(0xFF2B353E))) ], ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - InkWell( - onTap: () { - // TODO: move to doctor profile - }, - child: RichText( - text: TextSpan( - style: TextStyle( - fontSize: 1.6 * - SizeConfig.textMultiplier, - color: Colors.black), - children: [ - new TextSpan( - text: - 'Tap here to view patient profile' - .toString(), - style: TextStyle( - fontFamily: 'Poppins', - fontSize: 12)), - ], - ), - ), - ), - ], - ), + // Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // children: [ + // InkWell( + // onTap: () { + // // TODO: move to doctor profile + // }, + // child: RichText( + // text: TextSpan( + // style: TextStyle( + // fontSize: 1.6 * + // SizeConfig.textMultiplier, + // color: Colors.black), + // children: [ + // new TextSpan( + // text: + // 'Tap here to view patient profile' + // .toString(), + // style: TextStyle( + // fontFamily: 'Poppins', + // fontSize: 12)), + // ], + // ), + // ), + // ), + // ], + // ), ], ), ), @@ -137,34 +144,57 @@ class DoctorReplayChat extends StatelessWidget { ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - margin: EdgeInsets.only(top: 5), - width: 60, - height: 60, - child: Image.asset( - 1 == 1 - ? 'assets/images/male_avatar.png' - : 'assets/images/female_avatar.png', - fit: BoxFit.cover, - ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: EdgeInsets.only(top: 5), + width: 60, + height: 60, + child: Image.asset( + 1 == 1 + ? 'assets/images/male_avatar.png' + : 'assets/images/female_avatar.png', + fit: BoxFit.cover, + ), + ), + Divider(), + SizedBox(width: 10,), + Container( + width: MediaQuery.of(context).size.width * 0.30, + child: AppText( + reply.patientName + .toString(), + fontSize: 14, + fontFamily: 'Poppins', + color: Colors.white, + fontWeight: FontWeight.bold, + // fontSize: 18 + ), + ) + ], ), Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ AppText( - "07 Jan 2021", - fontSize: 2.5 * SizeConfig.textMultiplier, - fontFamily: 'Poppins', + reply.createdOn !=null?DateUtils.getDayMonthYearDateFormatted(DateUtils.getDateTimeFromServerFormat(reply.createdOn)):DateUtils.getDayMonthYearDateFormatted(DateTime.now()), + fontWeight: FontWeight + .w600, color: Colors.white, - // fontSize: 18 + fontSize: 14, ), AppText( - "07:00 PM", - fontSize: 2.5 * SizeConfig.textMultiplier, + reply.createdOn !=null?DateUtils.getHour(DateUtils.getDateTimeFromServerFormat(reply.createdOn)):DateUtils.getHour(DateTime.now()), + fontSize: 14, fontFamily: 'Poppins', color: Colors.white, // fontSize: 18 @@ -187,7 +217,7 @@ class DoctorReplayChat extends StatelessWidget { child: Container( width: MediaQuery.of(context).size.width * 0.7, child: AppText( - "This procedure should be taken only when the patient is below 99o", + reply.remarks, fontSize: 15, fontFamily: 'Poppins', color: Colors.white, @@ -203,91 +233,91 @@ class DoctorReplayChat extends StatelessWidget { ), ), SizedBox(height: 30,), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( - // color: Color(0xFF2B353E), - width: MediaQuery.of(context).size.width * 0.8, - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - color: Colors.white,// Color(0xFF2B353E), - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - border: Border.all( - color: HexColor('#707070') , - width: 0.30), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(top: 5), - width: 60, - height: 60, - child: Image.asset( - 1 == 1 - ? 'assets/images/male_avatar.png' - : 'assets/images/female_avatar.png', - fit: BoxFit.cover, - ), - ), - Column( - children: [ - AppText( - "07 Jan 2021", - fontSize: 2.5 * SizeConfig.textMultiplier, - fontFamily: 'Poppins', - color: Color(0xFF2B353E), - // fontSize: 18 - ), - AppText( - "07:00 PM", - fontSize: 2.5 * SizeConfig.textMultiplier, - fontFamily: 'Poppins', - color: Color(0xFF2B353E), - // fontSize: 18 - ), - ], - ), - ], - ), - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - width: MediaQuery.of(context).size.width * 0.7, - child: AppText( - "This procedure should be taken only when the patient is below 99o", - fontSize: 15, - fontFamily: 'Poppins', - color: Color(0xFF2B353E), - // fontSize: 18 - ), - ), - ), - ], - ), - ], - ), - ], - ), - ), - ], - ), + // Row( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Container( + // // color: Color(0xFF2B353E), + // width: MediaQuery.of(context).size.width * 0.8, + // padding: EdgeInsets.all(5), + // decoration: BoxDecoration( + // color: Colors.white,// Color(0xFF2B353E), + // borderRadius: BorderRadius.all( + // Radius.circular(10.0), + // ), + // border: Border.all( + // color: HexColor('#707070') , + // width: 0.30), + // ), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Container( + // margin: EdgeInsets.only(top: 5), + // width: 60, + // height: 60, + // child: Image.asset( + // 1 == 1 + // ? 'assets/images/male_avatar.png' + // : 'assets/images/female_avatar.png', + // fit: BoxFit.cover, + // ), + // ), + // Column( + // children: [ + // AppText( + // "07 Jan 2021", + // fontSize: 2.5 * SizeConfig.textMultiplier, + // fontFamily: 'Poppins', + // color: Color(0xFF2B353E), + // // fontSize: 18 + // ), + // AppText( + // "07:00 PM", + // fontSize: 2.5 * SizeConfig.textMultiplier, + // fontFamily: 'Poppins', + // color: Color(0xFF2B353E), + // // fontSize: 18 + // ), + // ], + // ), + // ], + // ), + // SizedBox( + // height: 10, + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Column( + // children: [ + // Padding( + // padding: const EdgeInsets.all(8.0), + // child: Container( + // width: MediaQuery.of(context).size.width * 0.7, + // child: AppText( + // "This procedure should be taken only when the patient is below 99o", + // fontSize: 15, + // fontFamily: 'Poppins', + // color: Color(0xFF2B353E), + // // fontSize: 18 + // ), + // ), + // ), + // ], + // ), + // ], + // ), + // ], + // ), + // ), + // ], + // ), ], ), ), @@ -296,48 +326,114 @@ class DoctorReplayChat extends StatelessWidget { ], ), ), - ], - ), - ), - bottomSheet: Container( - width: double.infinity, - // height: MediaQuery.of(context).size.height * 0.12, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - FractionallySizedBox( + + Positioned( + bottom: 0, child: Container( - child: TextFields( - borderRadius: 0, - hasLabelText: msgController.text != '' - ? true - : false, - showLabelText: false, - hintText: "\n"+TranslationBase - .of(context) - .typeHereToReply, - fontSize: 13.5, + 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, + hasLabelText: msgController.text != '' + ? true + : false, + showLabelText: false, + hintText: "\n"+TranslationBase + .of(context) + .typeHereToReply, + fontSize: 13.5, - suffixIcon: FontAwesomeIcons.arrowRight, - suffixIconColor: Colors.green, - // 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; - }), + suffixIcon: FontAwesomeIcons.arrowRight, + suffixIconColor: Colors.green, + onSuffixTap: ()async { + 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 "); + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + DoctorReplyScreen())); + } + + + + + }, + // 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; + }), + + ), + ), + ], + ), ), - ), + ) ], + + ), - ) + ), + // bottomSheet: Container( + // width: double.infinity, + // // height: MediaQuery.of(context).size.height * 0.12, + // child: Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // FractionallySizedBox( + // child: Container( + // child: TextFields( + // borderRadius: 0, + // hasLabelText: msgController.text != '' + // ? true + // : false, + // showLabelText: false, + // hintText: "\n"+TranslationBase + // .of(context) + // .typeHereToReply, + // fontSize: 13.5, + // + // suffixIcon: FontAwesomeIcons.arrowRight, + // suffixIconColor: Colors.green, + // onSuffixTap: (){ + // model.replay(msgController.text, reply); + // }, + // // 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; + // }), + // + // ), + // ), + // ], + // ), + // ) )); } } diff --git a/lib/screens/doctor/doctor_reply_screen.dart b/lib/screens/doctor/doctor_reply_screen.dart index 2f5549fb..c9b9b478 100644 --- a/lib/screens/doctor/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_reply_screen.dart @@ -39,12 +39,12 @@ class DoctorReplyScreen extends StatelessWidget { children: model.listDoctorWorkingHoursTable.map((reply) { return InkWell( - onTap: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (BuildContext context) => - // DoctorReplayChat(reply: reply))); + onTap: reply.status != 2?null:() { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + DoctorReplayChat(reply: reply))); }, child: DoctorReplyWidget(reply: reply), ); diff --git a/lib/widgets/doctor/doctor_reply_widget.dart b/lib/widgets/doctor/doctor_reply_widget.dart index d056f816..fbdfe686 100644 --- a/lib/widgets/doctor/doctor_reply_widget.dart +++ b/lib/widgets/doctor/doctor_reply_widget.dart @@ -50,7 +50,7 @@ class _DoctorReplyWidgetState extends State { color: Colors.black), children: [ new TextSpan( - text: widget.reply.status==2 ? TranslationBase.of(context).replied :TranslationBase.of(context).unReplied , + text: widget.reply.status==2 ? "Active":widget.reply.status==1?"Hold":"Cancelled",//TranslationBase.of(context).replied :TranslationBase.of(context).unReplied , style: TextStyle( color: widget.reply.status == 2 ? Color(0xFF2E303A)