From 213d104d57b2121a89a2e5ff7258eb45688d7136 Mon Sep 17 00:00:00 2001 From: Haroon Amjad Date: Sun, 1 Aug 2021 10:32:17 +0300 Subject: [PATCH] Covid test procedure selection implemented --- lib/config/config.dart | 3 + lib/config/localized_values.dart | 6 +- .../CovidTestProceduresResponse.dart | 32 +++++ .../Covid-DriveThru/Covid-TimeSlots.dart | 22 +-- .../covid-drivethru-location.dart | 127 +++++------------- .../covid-payment-details.dart | 113 +++++++++++++++- lib/pages/landing/home_page.dart | 6 +- .../appointment_services/GetDoctorsList.dart | 3 +- .../covid-drivethru/covid-drivethru.dart | 39 +++++- lib/uitl/translations_delegate_base.dart | 4 +- 10 files changed, 240 insertions(+), 115 deletions(-) create mode 100644 lib/models/CovidDriveThru/CovidTestProceduresResponse.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 40e0a300..62fedb16 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -370,6 +370,9 @@ const CHECK_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = const GET_COVID_DRIVETHRU_PROJECT_LIST = 'Services/Doctors.svc/REST/COVID19_ProjectDriveThroughTestingCenter'; +const GET_COVID_DRIVETHRU_PROCEDURES_LIST = + 'Services/Doctors.svc/REST/COVID19_GetTestProcedures'; + const GET_COVID_DRIVETHRU_PAYMENT_INFO = 'Services/Doctors.svc/REST/COVID19_GetPatientPaymentInormation'; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 534c0cc6..f1ad075f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -2019,5 +2019,9 @@ const Map localizedValues = { "ar": "علاقة الطالب" }, "newReferral": {"en": "New Referral", "ar": "إحالة جديدة"}, - "searchForReferrals": {"en": "Search For Referrals", "ar": "ابحث عن الإحالات"} + "searchForReferrals": {"en": "Search For Referrals", "ar": "ابحث عن الإحالات"}, + "covid-select-procedure": { + "en": "Please select the procedure:", + "ar": "الرجاء تحديد الإجراء:" + } }; diff --git a/lib/models/CovidDriveThru/CovidTestProceduresResponse.dart b/lib/models/CovidDriveThru/CovidTestProceduresResponse.dart new file mode 100644 index 00000000..c104a1fc --- /dev/null +++ b/lib/models/CovidDriveThru/CovidTestProceduresResponse.dart @@ -0,0 +1,32 @@ +class CovidTestProceduresResponse { + String procedureID; + String procedureName; + String procedureNameN; + int projectID; + String setupID; + + CovidTestProceduresResponse( + {this.procedureID, + this.procedureName, + this.procedureNameN, + this.projectID, + this.setupID}); + + CovidTestProceduresResponse.fromJson(Map json) { + procedureID = json['ProcedureID']; + procedureName = json['ProcedureName']; + procedureNameN = json['ProcedureNameN']; + projectID = json['ProjectID']; + setupID = json['SetupID']; + } + + Map toJson() { + final Map data = new Map(); + data['ProcedureID'] = this.procedureID; + data['ProcedureName'] = this.procedureName; + data['ProcedureNameN'] = this.procedureNameN; + data['ProjectID'] = this.projectID; + data['SetupID'] = this.setupID; + return data; + } +} diff --git a/lib/pages/Covid-DriveThru/Covid-TimeSlots.dart b/lib/pages/Covid-DriveThru/Covid-TimeSlots.dart index 04a7178f..c12dd877 100644 --- a/lib/pages/Covid-DriveThru/Covid-TimeSlots.dart +++ b/lib/pages/Covid-DriveThru/Covid-TimeSlots.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart import 'package:diplomaticquarterapp/models/Appointments/FreeSlot.dart'; import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart'; import 'package:diplomaticquarterapp/models/Appointments/timeSlot.dart'; +import 'package:diplomaticquarterapp/models/CovidDriveThru/CovidTestProceduresResponse.dart'; import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-payment-alert.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/covid-drivethru/covid-drivethru.dart'; @@ -27,6 +28,7 @@ class CovidTimeSlots extends StatefulWidget { static DateTime selectedAppoDateTime; static String selectedDate; static String selectedTime; + CovidTestProceduresResponse selectedProcedure; int selectedClinicID; int selectedDoctorID; @@ -35,7 +37,7 @@ class CovidTimeSlots extends StatefulWidget { PatientShareResponse patientShareResponse; - CovidTimeSlots({@required this.projectID}); + CovidTimeSlots({@required this.projectID, @required this.selectedProcedure}); @override _CovidTimeSlotsState createState() => _CovidTimeSlotsState(); @@ -94,10 +96,12 @@ class _CovidTimeSlotsState extends State super.dispose(); } - void _onDaySelected(DateTime day, List events, ProjectViewModel projectViewModel) { + void _onDaySelected( + DateTime day, List events, ProjectViewModel projectViewModel) { final DateFormat formatter = DateFormat('yyyy-MM-dd'); setState(() { - this.selectedDate = DateUtil.getWeekDayMonthDayYearDateFormatted(day, projectViewModel.isArabic ? "ar" : "en"); + this.selectedDate = DateUtil.getWeekDayMonthDayYearDateFormatted( + day, projectViewModel.isArabic ? "ar" : "en"); openTimeSlotsPickerForDate(day, docFreeSlots); CovidTimeSlots.selectedDate = formatter.format(day); print(CovidTimeSlots.selectedDate); @@ -260,7 +264,8 @@ class _CovidTimeSlotsState extends State onPressed: () { bookCovidTestAppointment(); }, - child: Text(TranslationBase.of(context).bookNow, style: TextStyle(fontSize: 18.0)), + child: Text(TranslationBase.of(context).bookNow, + style: TextStyle(fontSize: 18.0)), ), ), ), @@ -355,11 +360,7 @@ class _CovidTimeSlotsState extends State }, ), onDaySelected: (date, event, _) { - _onDaySelected( - date, - event, - projectViewModel - ); + _onDaySelected(date, event, projectViewModel); _animationController.forward(from: 0.0); }, onVisibleDaysChanged: _onVisibleDaysChanged, @@ -494,7 +495,8 @@ class _CovidTimeSlotsState extends State docObject.projectID, CovidTimeSlots.selectedTime, CovidTimeSlots.selectedDate, - context) + context, + widget.selectedProcedure.procedureID) .then((res) { if (res['MessageStatus'] == 1) { AppToast.showSuccessToast(message: "Appointment Booked Successfully"); diff --git a/lib/pages/Covid-DriveThru/covid-drivethru-location.dart b/lib/pages/Covid-DriveThru/covid-drivethru-location.dart index 749d9140..9bccd300 100644 --- a/lib/pages/Covid-DriveThru/covid-drivethru-location.dart +++ b/lib/pages/Covid-DriveThru/covid-drivethru-location.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/CovidDriveThru/CovidPaymentInfoResponse.dart'; +import 'package:diplomaticquarterapp/models/CovidDriveThru/CovidTestProceduresResponse.dart'; import 'package:diplomaticquarterapp/models/CovidDriveThru/DriveThroughTestingCenterModel.dart'; import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-payment-details.dart'; import 'package:diplomaticquarterapp/routes.dart'; @@ -22,6 +23,7 @@ class CovidDrivethruLocation extends StatefulWidget { class _CovidDrivethruLocationState extends State { String projectDropdownValue; List projectsList = []; + List proceduresList = []; bool isLocationSelected = false; String projectLat = ""; String projectLong = ""; @@ -35,7 +37,10 @@ class _CovidDrivethruLocationState extends State { @override void initState() { WidgetsBinding.instance.addPostFrameCallback((_) { - if (projectViewModel.isLogin) getProjectsList(context); + if (projectViewModel.isLogin) { + getProjectsList(context); + getTestProcedures(context); + } }); super.initState(); } @@ -241,91 +246,6 @@ class _CovidDrivethruLocationState extends State { ), ), ), - // bottomSheet: Container( - // height: MediaQuery.of(context).size.height * 0.15, - // width: double.infinity, - // child: Column( - // children: [ - // Container( - // margin: EdgeInsets.only(top: 10.0), - // child: ButtonTheme( - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(10.0), - // ), - // minWidth: MediaQuery.of(context).size.width * 0.91, - // height: 45.0, - // child: RaisedButton( - // color: new Color(0xFFc5272d), - // textColor: Colors.white, - // disabledTextColor: Colors.white, - // disabledColor: Colors.red[300], - // onPressed: () { - // getDirections(); - // }, - // child: Text(TranslationBase.of(context).getDirections, - // style: TextStyle(fontSize: 18.0)), - // ), - // ), - // ), - // Container( - // margin: EdgeInsets.fromLTRB(10.0, 5.0, 10.0, 5.0), - // child: Flex( - // direction: Axis.horizontal, - // children: [ - // Expanded( - // flex: 1, - // child: Container( - // margin: EdgeInsets.fromLTRB(10.0, 0.0, 5.0, 0.0), - // child: ButtonTheme( - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(10.0), - // ), - // minWidth: MediaQuery.of(context).size.width * 0.7, - // height: 45.0, - // child: RaisedButton( - // color: new Color(0xFF60686b), - // textColor: Colors.white, - // disabledTextColor: Colors.white, - // disabledColor: Colors.grey[500], - // onPressed: () { - // back(); - // }, - // child: Text(TranslationBase.of(context).back, - // style: TextStyle(fontSize: 18.0)), - // ), - // ), - // ), - // ), - // Expanded( - // flex: 1, - // child: Container( - // margin: EdgeInsets.fromLTRB(10.0, 0.0, 5.0, 0.0), - // child: ButtonTheme( - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(10.0), - // ), - // minWidth: MediaQuery.of(context).size.width * 0.7, - // height: 45.0, - // child: RaisedButton( - // color: new Color(0xFF60686b), - // textColor: Colors.white, - // disabledTextColor: Colors.white, - // disabledColor: Colors.grey[500], - // onPressed: () { - // next(); - // }, - // child: Text(TranslationBase.of(context).next, - // style: TextStyle(fontSize: 18.0)), - // ), - // ), - // ), - // ), - // ], - // ), - // ), - // ], - // ), - // ), ); } @@ -368,21 +288,18 @@ class _CovidDrivethruLocationState extends State { getPaymentInfo(BuildContext context, String projectID) { CovidDriveThruService service = new CovidDriveThruService(); - CovidPaymentInfoResponse covidPaymentInfoResponse = new CovidPaymentInfoResponse(); - GifLoaderDialogUtils.showMyDialog(context); - service - .getCovidPaymentInformation(context, int.parse(projectID)) + .getCovidPaymentInformation( + context, int.parse(projectID), proceduresList[0].procedureID) .then((res) { GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { setState(() { covidPaymentInfoResponse = CovidPaymentInfoResponse.fromJson(res['COVID19_PatientShare']); - print(covidPaymentInfoResponse.procedureNameField); }); Navigator.push( context, @@ -390,6 +307,7 @@ class _CovidDrivethruLocationState extends State { page: CovidPaymentDetails( covidPaymentInfoResponse: covidPaymentInfoResponse, projectID: int.parse(projectID), + proceduresList: proceduresList, ))); } else {} }).catchError((err) { @@ -397,13 +315,36 @@ class _CovidDrivethruLocationState extends State { }); } + getTestProcedures(BuildContext context) { + CovidDriveThruService service = new CovidDriveThruService(); + GifLoaderDialogUtils.showMyDialog(context); + + CovidTestProceduresResponse covidTestProceduresResponse = + new CovidTestProceduresResponse(); + + service.getCovidTestProceduresList(context).then((res) { + if (res['MessageStatus'] == 1) { + print(res); + setState(() { + res['COVID19_TestProceduresList'].forEach((v) { + proceduresList.add(new CovidTestProceduresResponse.fromJson(v)); + }); + }); + print(proceduresList.length); + print(proceduresList[0].procedureName); + GifLoaderDialogUtils.hideDialog(context); + } else {} + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } + getProjectsList(BuildContext context) { CovidDriveThruService service = new CovidDriveThruService(); GifLoaderDialogUtils.showMyDialog(context); service.getCovidProjectsList(context).then((res) { - print(res); if (res['MessageStatus'] == 1) { - print(res); setState(() { res['List_COVID19_ProjectDriveThroughTestingCenter'].forEach((v) { projectsList.add(new DriveThroughTestingCenterModel.fromJson(v)); diff --git a/lib/pages/Covid-DriveThru/covid-payment-details.dart b/lib/pages/Covid-DriveThru/covid-payment-details.dart index edf5e612..488dd3bf 100644 --- a/lib/pages/Covid-DriveThru/covid-payment-details.dart +++ b/lib/pages/Covid-DriveThru/covid-payment-details.dart @@ -1,5 +1,8 @@ import 'package:diplomaticquarterapp/models/CovidDriveThru/CovidPaymentInfoResponse.dart'; +import 'package:diplomaticquarterapp/models/CovidDriveThru/CovidTestProceduresResponse.dart'; import 'package:diplomaticquarterapp/pages/Covid-DriveThru/Covid-TimeSlots.dart'; +import 'package:diplomaticquarterapp/services/covid-drivethru/covid-drivethru.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -10,9 +13,13 @@ import 'package:flutter_svg/flutter_svg.dart'; class CovidPaymentDetails extends StatefulWidget { CovidPaymentInfoResponse covidPaymentInfoResponse; int projectID; + List proceduresList; + CovidTestProceduresResponse selectedProcedure; CovidPaymentDetails( - {@required this.covidPaymentInfoResponse, @required this.projectID}); + {@required this.covidPaymentInfoResponse, + @required this.projectID, + @required this.proceduresList}); @override _CovidPaymentDetailsState createState() => _CovidPaymentDetailsState(); @@ -21,6 +28,13 @@ class CovidPaymentDetails extends StatefulWidget { class _CovidPaymentDetailsState extends State { bool isAgree = false; + @override + void initState() { + print(widget.proceduresList[0].procedureName); + widget.selectedProcedure = widget.proceduresList[0]; + super.initState(); + } + @override Widget build(BuildContext context) { return AppScaffold( @@ -28,7 +42,7 @@ class _CovidPaymentDetailsState extends State { isShowAppBar: true, body: SingleChildScrollView( child: Container( - margin: EdgeInsets.fromLTRB(15.0, 15.0, 15.0, 0.0), + margin: EdgeInsets.fromLTRB(15.0, 15.0, 15.0, 100.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -82,13 +96,75 @@ class _CovidPaymentDetailsState extends State { borderRadius: BorderRadius.circular(10.0), color: Colors.white), margin: EdgeInsets.fromLTRB(0.0, 30.0, 0.0, 5.0), - padding: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 20.0), + padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 20.0), child: Column( children: [ Container( alignment: Alignment.center, margin: - EdgeInsets.only(left: 0.0, right: 20.0, top: 30.0), + EdgeInsets.only(left: 0.0, right: 20.0, top: 10.0), + child: Text( + TranslationBase.of(context).covidSelectProcedure, + style: TextStyle( + color: Colors.black, + fontSize: 20.0, + fontWeight: FontWeight.bold)), + ), + ...List.generate( + widget.proceduresList.length, + (index) => Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 1, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + setState(() { + widget.selectedProcedure = + widget.proceduresList[index]; + }); + }, + child: ListTile( + title: Text( + widget.proceduresList[index] + .procedureName, + style: TextStyle(fontSize: 14.0)), + leading: Radio( + value: widget.proceduresList[index], + groupValue: widget.selectedProcedure, + activeColor: Colors.red[800], + toggleable: true, + onChanged: (value) { + setState(() { + widget.selectedProcedure = value; + print(widget + .selectedProcedure.procedureName); + getPaymentInfo( + context, + widget.projectID.toString(), + widget.selectedProcedure + .procedureID); + }); + }, + ), + ), + ), + ) + ], + ), + ], + ), + ), + Divider(), + Container( + alignment: Alignment.center, + margin: + EdgeInsets.only(left: 0.0, right: 20.0, top: 10.0), child: Text(TranslationBase.of(context).testFee, style: TextStyle( color: Colors.black, @@ -238,6 +314,7 @@ class _CovidPaymentDetailsState extends State { FadePage( page: CovidTimeSlots( projectID: widget.projectID, + selectedProcedure: widget.selectedProcedure, ))); } @@ -245,6 +322,34 @@ class _CovidPaymentDetailsState extends State { Navigator.pop(context); } + getPaymentInfo( + BuildContext context, String projectID, String selectedProcedureID) { + CovidDriveThruService service = new CovidDriveThruService(); + GifLoaderDialogUtils.showMyDialog(context); + service + .getCovidPaymentInformation( + context, int.parse(projectID), selectedProcedureID) + .then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res['MessageStatus'] == 1) { + setState(() { + widget.covidPaymentInfoResponse = + CovidPaymentInfoResponse.fromJson(res['COVID19_PatientShare']); + }); + // Navigator.push( + // context, + // FadePage( + // page: CovidPaymentDetails( + // covidPaymentInfoResponse: covidPaymentInfoResponse, + // projectID: int.parse(projectID), + // proceduresList: proceduresList, + // ))); + } else {} + }).catchError((err) { + print(err); + }); + } + _getNormalText(text) { return Container( margin: EdgeInsets.only(top: 20.0, right: 10.0), diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index cab34c08..1804e274 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -115,8 +115,8 @@ class _HomePageState extends State { ), child: SvgPicture.asset( 'assets/images/new-design/covid-19-car.svg', - width: 45.0, - height: 45.0), + width: 35.0, + height: 35.0), ), Container( margin: EdgeInsets.only( @@ -144,7 +144,7 @@ class _HomePageState extends State { context) .size .width * - 0.14, + 0.1, height: 25.0, child: RaisedButton( color: Colors diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 65fe2b04..4bb5a6ac 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -321,7 +321,7 @@ class DoctorsListService extends BaseService { } Future insertAppointment(int docID, int clinicID, int projectID, - String selectedTime, String selectedDate, BuildContext context) async { + String selectedTime, String selectedDate, BuildContext context, [String procedureID]) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { @@ -341,6 +341,7 @@ class DoctorsListService extends BaseService { "StartTime": selectedTime, "SelectedTime": selectedTime, "EndTime": selectedTime, + "ProcedureID": procedureID, "InitialSlotDuration": 0, "StrAppointmentDate": selectedDate, "IsVirtual": false, diff --git a/lib/services/covid-drivethru/covid-drivethru.dart b/lib/services/covid-drivethru/covid-drivethru.dart index 3943a8b3..35e8fb2f 100644 --- a/lib/services/covid-drivethru/covid-drivethru.dart +++ b/lib/services/covid-drivethru/covid-drivethru.dart @@ -50,7 +50,43 @@ class CovidDriveThruService extends BaseService { return Future.value(localRes); } - Future getCovidPaymentInformation(BuildContext context, int projectID) async { + Future getCovidTestProceduresList(BuildContext context) async { + Map request; + + if (await this.sharedPref.getObject(USER_PROFILE) != null) { + var data = AuthenticatedUser.fromJson( + await this.sharedPref.getObject(USER_PROFILE)); + authUser = data; + } + + var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + Request req = appGlobal.getPublicRequest(); + request = { + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": "10.20.10.20", + "VersionID": req.VersionID, + "Channel": req.Channel, + "generalid": 'Cs2020@2016\$2958', + "PatientOutSA": authUser.outSA, + "TokenID": "", + "DeviceTypeID": req.DeviceTypeID, + "SessionID": "YckwoXhUmWBsnHKEKig", + "PatientID": authUser.patientID != null ? authUser.patientID : 0, + "License": true + }; + + dynamic localRes; + + await baseAppClient.post(GET_COVID_DRIVETHRU_PROCEDURES_LIST, + onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + + Future getCovidPaymentInformation(BuildContext context, int projectID, String procedureID) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { @@ -65,6 +101,7 @@ class CovidDriveThruService extends BaseService { "LanguageID": languageID == 'ar' ? 1 : 2, "IPAdress": "10.20.10.20", "ProjectID": projectID, + "ProcedureId": procedureID, "VersionID": req.VersionID, "Channel": req.Channel, "generalid": 'Cs2020@2016\$2958', diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index fa6374ec..ce1905bc 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1632,8 +1632,8 @@ class TranslationBase { String get newReferral => localizedValues["newReferral"][locale.languageCode]; String get searchForReferrals => localizedValues["searchForReferrals"][locale.languageCode]; - - + String get covidSelectProcedure => + localizedValues["covid-select-procedure"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {