From 6877244d0e385aebb4e7fe0d2348bcb4ab9f8385 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 2 Jul 2023 15:57:29 +0300 Subject: [PATCH 1/2] CR# 5805 Ask Doc Improvements dev completed. --- lib/config/config.dart | 1 + lib/config/localized_values.dart | 3 + .../service/medical/ask_doctor_services.dart | 33 +++ .../ask_doctor/ViewDoctorResponsesPage.dart | 248 +++++++++++++++++- .../medical/ask_doctor/doctor_response.dart | 20 +- lib/uitl/translations_delegate_base.dart | 3 + 6 files changed, 287 insertions(+), 21 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 5ff4e6f1..4981aca0 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -419,6 +419,7 @@ var UPDATE_READ_STATUS = 'Services/Patients.svc/REST/UpdateReadStatus'; var INSERT_CALL_INFO = 'Services/Doctors.svc/REST/InsertCallInfo'; var INSERT_APPOINTMENT_QUESTION = 'Services/OUTPs.svc/REST/insertAppointmentQuestion'; +var RATE_DOCTOR_RESPONSE = 'Services/OUTPs.svc/REST/insertAppointmentQuestionRating'; var GET_PATIENT_ALLERGIES = 'Services/Patients.svc/REST/GetPatientAllergies'; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index d64a2fe6..f08b9c41 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1884,4 +1884,7 @@ const Map localizedValues = { "pharmaLiveCareJoinConsultation": {"en": "Join the virtual consultation from booth", "ar": "انضم إلى الاستشارة الافتراضية من الكبينة"}, "pharmaLiveCareJoinConsultation1": {"en": "Wait for the doctor in the pharma booth to join you", "ar": "انتظر حتى ينضم إليك الطبيب في كبينة لايف كير الصيدلية"}, "emergencyServicesSubtitle": {"en": "Always at your service", "ar": "في خدمتكم دائما"}, + "rateDoctorResponse": {"en": "Rate Doctor Response", "ar": "تقييم استجابة الطبيب"}, + "comments": {"en": "Comments", "ar": "تعليقات"}, + "rateDoctorResponseHeading": {"en": "Please rate the doctor response:", "ar": "يرجى تقييم استجابة الطبيب:"}, }; \ No newline at end of file diff --git a/lib/core/service/medical/ask_doctor_services.dart b/lib/core/service/medical/ask_doctor_services.dart index 84c4f9d1..a6482431 100644 --- a/lib/core/service/medical/ask_doctor_services.dart +++ b/lib/core/service/medical/ask_doctor_services.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/ask_doctor/AskDoctorReqTypes.dart'; import 'package:diplomaticquarterapp/core/model/ask_doctor/DoctorResponse.dart'; @@ -113,4 +115,35 @@ class AskDoctorService extends BaseService { super.error = error; }, body: body); } + + Future rateDoctorResponse({int transactionNo, int questionType, int rate, String notes, String mobileNo, String idNo, String patientName, int projectID, String language}) async { + hasError = false; + dynamic localRes; + Map body = Map(); + body['MobileNo'] = mobileNo; + body['IdentificationNo'] = idNo; + body['PatientName'] = patientName; + body['IsUserLoggedIn'] = true; + body['ProjectID'] = projectID; + body['UILanguage'] = language; + body['BrowserInfo'] = Platform.localHostname; + body['COCTypeName'] = 3; + body['FormTypeID'] = 3; + body['DeviceInfo'] = Platform.localHostname; + body['Resolution'] = "400x847"; + body['AppVersion'] = VERSION_ID; + body['ForDemo'] = false; + body['isVidaPlus'] = false; + body['TransactionNo'] = transactionNo; + body['QuestionType'] = questionType; + body['Rate'] = rate; + body['Notes'] = notes; + await baseAppClient.post(RATE_DOCTOR_RESPONSE, onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + return Future.value(localRes); + } } diff --git a/lib/pages/medical/ask_doctor/ViewDoctorResponsesPage.dart b/lib/pages/medical/ask_doctor/ViewDoctorResponsesPage.dart index 489e9281..c6fdb47f 100644 --- a/lib/pages/medical/ask_doctor/ViewDoctorResponsesPage.dart +++ b/lib/pages/medical/ask_doctor/ViewDoctorResponsesPage.dart @@ -1,21 +1,39 @@ import 'package:diplomaticquarterapp/core/model/ask_doctor/DoctorResponse.dart'; +import 'package:diplomaticquarterapp/core/service/medical/ask_doctor_services.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/ask_doctor_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; -class ViewDoctorResponsesPage extends StatelessWidget { +class ViewDoctorResponsesPage extends StatefulWidget { final DoctorResponse doctorResponse; const ViewDoctorResponsesPage({Key key, this.doctorResponse}) : super(key: key); + @override + State createState() => _ViewDoctorResponsesPageState(); +} + +class _ViewDoctorResponsesPageState extends State { + int rate = 1; + TextEditingController textController = new TextEditingController(); + ProjectViewModel projectViewModel; + @override Widget build(BuildContext context) { + projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.updateReadStatus(transactionNo: doctorResponse.transactionNo), + onModelReady: (model) => model.updateReadStatus(transactionNo: widget.doctorResponse.transactionNo), builder: (_, model, w) => AppScaffold( isShowAppBar: true, showNewAppBar: true, @@ -44,7 +62,7 @@ class ViewDoctorResponsesPage extends StatelessWidget { itemBuilder: (context, _index) { return Container( padding: const EdgeInsets.only(left: 20, right: 12, top: 12, bottom: 12), - height: 130, + height: 160, decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10.0), @@ -64,7 +82,7 @@ class ViewDoctorResponsesPage extends StatelessWidget { children: [ Container( child: Text( - (doctorResponse.doctorName ?? ""), + (widget.doctorResponse.doctorName ?? ""), style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, @@ -75,7 +93,7 @@ class ViewDoctorResponsesPage extends StatelessWidget { ), Container( child: Text( - (DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(doctorResponse.createdOn)) ?? ""), + (DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(widget.doctorResponse.createdOn)) ?? ""), style: TextStyle( fontSize: 14, color: Color(0xff2E303A), @@ -86,7 +104,7 @@ class ViewDoctorResponsesPage extends StatelessWidget { Container( margin: EdgeInsets.only(top: 10.0), child: Text( - doctorResponse.transactions[_index]['InfoStatusDescription'], + widget.doctorResponse.transactions[_index]['DoctorResponse'], style: TextStyle( fontSize: 16, color: Color(0xff2E303A), @@ -94,11 +112,227 @@ class ViewDoctorResponsesPage extends StatelessWidget { ), ), ), + Container( + margin: EdgeInsets.only(top: 10.0), + child: DefaultButton( + TranslationBase.of(context).rateDoctorResponse, + () { + openResponseRateDialog(context); + }, + color: CustomColors.accentColor, + ), + ), ], ), ); }, separatorBuilder: (context, index) => SizedBox(height: 14), - itemCount: doctorResponse.transactions.length); + itemCount: widget.doctorResponse.transactions.length); + } + + void openResponseRateDialog(BuildContext context) { + showModalBottomSheet( + context: context, + enableDrag: true, + isDismissible: true, + isScrollControlled: true, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12)), + ), + backgroundColor: Colors.white, + builder: (context) { + return StatefulBuilder(builder: (BuildContext context, StateSetter setState) { + return Container( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + height: 16.0, + ), + Text( + TranslationBase.of(context).rateDoctorResponseHeading, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.64, + ), + ), + Padding( + padding: const EdgeInsets.all(24.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Container( + margin: rate == 1 ? EdgeInsets.only(left: 3.0, right: 3.0) : EdgeInsets.only(left: 0.0, right: 0.0), + decoration: rate == 1 + ? BoxDecoration(borderRadius: BorderRadius.circular(100), border: Border.all(width: 3, color: CustomColors.green)) + : BoxDecoration(borderRadius: BorderRadius.circular(100), border: Border.all(width: 3, color: CustomColors.white)), + child: IconButton( + onPressed: () { + rate = 1; + setState(() {}); + }, + iconSize: 35, + icon: SvgPicture.asset('assets/images/new/appointment-rating/5.svg'), + ), + ), + Container( + margin: rate == 0 ? EdgeInsets.only(left: 3.0, right: 3.0) : EdgeInsets.only(left: 0.0, right: 0.0), + decoration: rate == 0 + ? BoxDecoration(borderRadius: BorderRadius.circular(100), border: Border.all(width: 3, color: CustomColors.green)) + : BoxDecoration(borderRadius: BorderRadius.circular(100), border: Border.all(width: 3, color: CustomColors.white)), + child: IconButton( + onPressed: () { + rate = 0; + setState(() {}); + }, + iconSize: 35, + icon: SvgPicture.asset('assets/images/new/appointment-rating/1.svg'), + ), + ), + ], + ), + ), + if (rate == 0) + Container( + padding: const EdgeInsets.all(24.0), + child: Padding( + padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), + child: inputWidget(TranslationBase.of(context).comments, "", textController, isEnable: true), + ), + ), + SizedBox( + height: 16.0, + ), + Container( + margin: EdgeInsets.fromLTRB(24.0, 0.0, 24.0, 24.0), + child: DefaultButton( + TranslationBase.of(context).submit, + () { + rateDoctorResponse(); + }, + color: CustomColors.accentColor, + ), + ), + ], + ), + ); + }); + }).then((value) { + rate = 1; + setState(() {}); + }); + } + + void rateDoctorResponse() { + GifLoaderDialogUtils.showMyDialog(context); + AskDoctorService service = new AskDoctorService(); + service + .rateDoctorResponse( + transactionNo: widget.doctorResponse.transactionNo, + questionType: widget.doctorResponse.requestType, + rate: rate, + notes: textController.text, + mobileNo: projectViewModel.user.mobileNumber, + idNo: projectViewModel.user.patientIdentificationNo, + patientName: projectViewModel.user.firstName + " " + projectViewModel.user.lastName, + projectID: widget.doctorResponse.projectID, + language: projectViewModel.isArabic ? "ar" : "en") + .then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res['MessageStatus'] == 1) { + AppToast.showSuccessToast(message: res['SuccessMsg']); + Navigator.of(context).pop(); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + } + }).catchError((err) { + print(err); + GifLoaderDialogUtils.hideDialog(context); + }); + } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: isEnable ? Colors.white : CustomColors.grey2.withOpacity(0.4), + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.all(40.0), + keyboardType: TextInputType.text, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + fillColor: CustomColors.accentColor, + hintStyle: TextStyle( + fontSize: isEnable ? 14 : 24, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: isEnable ? Color(0xff575757) : CustomColors.black, + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); } } diff --git a/lib/pages/medical/ask_doctor/doctor_response.dart b/lib/pages/medical/ask_doctor/doctor_response.dart index 37e5f1c9..0dd9b9a1 100644 --- a/lib/pages/medical/ask_doctor/doctor_response.dart +++ b/lib/pages/medical/ask_doctor/doctor_response.dart @@ -85,24 +85,20 @@ class DoctorResponse extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(8.0), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts('${doctor.doctorName}'), SizedBox( height: 5, ), - Texts( - '${doctor.requestTypeDescription}'), + Texts('${doctor.requestTypeDescription}'), ], ), ), ), Padding( padding: const EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0), - child: Icon(projectViewModel.isArabic - ? Icons.arrow_forward_ios - : Icons.arrow_back_ios), + child: Icon(projectViewModel.isArabic ? Icons.arrow_back_ios : Icons.arrow_forward_ios), ) ], ), @@ -158,24 +154,20 @@ class DoctorResponse extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(8.0), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts('${doctor.doctorName}'), SizedBox( height: 5, ), - Texts( - '${doctor.requestTypeDescription}'), + Texts('${doctor.requestTypeDescription}'), ], ), ), ), Padding( padding: const EdgeInsets.all(8.0), - child: Icon(projectViewModel.isArabic - ? Icons.arrow_forward_ios - : Icons.arrow_back_ios), + child: Icon(projectViewModel.isArabic ? Icons.arrow_back_ios : Icons.arrow_forward_ios), ) ], ), diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index bdaa3798..e0b93147 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2892,6 +2892,9 @@ class TranslationBase { String get pharmaLiveCareJoinConsultation => localizedValues["pharmaLiveCareJoinConsultation"][locale.languageCode]; String get pharmaLiveCareJoinConsultation1 => localizedValues["pharmaLiveCareJoinConsultation1"][locale.languageCode]; String get emergencyServicesSubtitle => localizedValues["emergencyServicesSubtitle"][locale.languageCode]; + String get rateDoctorResponse => localizedValues["rateDoctorResponse"][locale.languageCode]; + String get comments => localizedValues["comments"][locale.languageCode]; + String get rateDoctorResponseHeading => localizedValues["rateDoctorResponseHeading"][locale.languageCode]; } From f2ab76eb247c34ecb48350a1aeddf7e00a6ed257 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 9 Jul 2023 10:17:29 +0300 Subject: [PATCH 2/2] updates --- lib/core/service/medical/ask_doctor_services.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/core/service/medical/ask_doctor_services.dart b/lib/core/service/medical/ask_doctor_services.dart index a6482431..bfb45e77 100644 --- a/lib/core/service/medical/ask_doctor_services.dart +++ b/lib/core/service/medical/ask_doctor_services.dart @@ -109,6 +109,8 @@ class AskDoctorService extends BaseService { body['AppointmentNo'] = doctorList.appointmentNo; body['ClinicID'] = doctorList.clinicID; body['QuestionType'] = num.parse(requestType); + body['RequestType'] = num.parse(requestType); + body['RequestTypeID'] = num.parse(requestType); await baseAppClient.post(INSERT_CALL_INFO, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true;