diff --git a/lib/config/config.dart b/lib/config/config.dart index 8a4f4399..5b1bbf4d 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -661,6 +661,10 @@ var GET_BLOOD_DONATION_PROJECTS_LIST = 'Services/OUTPs.svc/REST/BD_getProjectsHa var GET_BLOOD_DONATION_FREE_SLOTS = 'Services/OUTPs.svc/REST/BD_GetFreeSlots'; +var GET_WE_CARE_TOUR_URL = 'Services/Consent.svc/Rest/Consent_VirtualJurny_Url_GetByProjectID'; + +var GET_DENTAL_INSTRUCTIONS = 'Services/OUTPs.svc/Rest/getProcedureNotification'; + //PAYFORT var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails"; var addPayFortApplePayResponse = "Services/PayFort_Serv.svc/REST/AddResponse"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 57e3671e..5a775c5b 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1974,4 +1974,6 @@ const Map localizedValues = { "locationTimeoutError": {"en": "Unable to fetch your location, Please try again.", "ar": "غير قادر على جلب موقعك، يرجى المحاولة مرة أخرى."}, "loadMore": {"en": "Load More", "ar": "تحميل المزيد"}, "selectHospitalBloodDonation": {"en": "Please select the hospital you want to book an appointment with: ", "ar": "يرجى اختيار المستشفى الذي تريد حجز موعد معه:"}, + "wecare": {"en": "We Care", "ar": "نحن نهتم"}, + "myinstructions": {"en": "My Instructions", "ar": "تعليماتي"}, }; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index d0097c22..92317c62 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -192,7 +192,7 @@ class BaseAppClient { // body['IdentificationNo'] = 1023854217; // body['MobileNo'] = "531940021"; //0560717232 - // body['PatientID'] = 3300938; //4609100 + // body['PatientID'] = 4767804; //4609100 // body['TokenID'] = "@dm!n"; // Patient ID: 3027574 diff --git a/lib/models/get_dental_instructions_response_model.dart b/lib/models/get_dental_instructions_response_model.dart new file mode 100644 index 00000000..6f2f8621 --- /dev/null +++ b/lib/models/get_dental_instructions_response_model.dart @@ -0,0 +1,77 @@ +class GetDentalInstructionsResponseModel { + List data; + dynamic message; + int status; + + GetDentalInstructionsResponseModel({this.data, this.message, this.status}); + + GetDentalInstructionsResponseModel.fromJson(Map json) { + if (json['Data'] != null) { + data = []; + json['Data'].forEach((v) { + data.add(new Data.fromJson(v)); + }); + } + message = json['message']; + status = json['status']; + } + + Map toJson() { + final Map data = new Map(); + if (this.data != null) { + data['Data'] = this.data.map((v) => v.toJson()).toList(); + } + data['message'] = this.message; + data['status'] = this.status; + return data; + } +} + +class Data { + String createdOn; + String mobileNo; + int patientId; + int procedureId; + int projectId; + String setupId; + String smsContent; + int sourceReferenceNo; + String sourceType; + + Data( + {this.createdOn, + this.mobileNo, + this.patientId, + this.procedureId, + this.projectId, + this.setupId, + this.smsContent, + this.sourceReferenceNo, + this.sourceType}); + + Data.fromJson(Map json) { + createdOn = json['createdOn']; + mobileNo = json['mobileNo']; + patientId = json['patientId']; + procedureId = json['procedureId']; + projectId = json['projectId']; + setupId = json['setupId']; + smsContent = json['smsContent']; + sourceReferenceNo = json['sourceReferenceNo']; + sourceType = json['sourceType']; + } + + Map toJson() { + final Map data = new Map(); + data['createdOn'] = this.createdOn; + data['mobileNo'] = this.mobileNo; + data['patientId'] = this.patientId; + data['procedureId'] = this.procedureId; + data['projectId'] = this.projectId; + data['setupId'] = this.setupId; + data['smsContent'] = this.smsContent; + data['sourceReferenceNo'] = this.sourceReferenceNo; + data['sourceType'] = this.sourceType; + return data; + } +} diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index da1863f3..5999c8b0 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -70,8 +70,8 @@ class _Login extends State { super.initState(); // if (BASE_URL.contains("uat.")) { - // nationalIDorFile.text = "2344670985"; - // mobileNumberController.text = mobileNo = "0537503378"; + // nationalIDorFile.text = "2001273"; + // mobileNumberController.text = mobileNo = "0555416043"; // } getRegisterData(); /* else { @@ -150,7 +150,11 @@ class _Login extends State { DefaultButton( TranslationBase.of(context).login, () { - if (!isButtonDisabled) this.startLogin(); + if (isButtonDisabled) { + AppToast.showErrorToast(message: "National ID can only contain numbers"); + } else { + this.startLogin(); + } }, disabledColor: Color(0xff575757), ), @@ -251,13 +255,13 @@ class _Login extends State { void validateForm() { if (util.validateIDBox(nationalIDorFile.text, loginType) == true && - util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { + (countryCode == "971" ? true : util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true)) { setState(() { isButtonDisabled = false; }); } else { setState(() { - isButtonDisabled = false; + isButtonDisabled = true; }); } } @@ -291,7 +295,7 @@ class _Login extends State { this.checkActivationCode(); } } - // else { + // } else { // ConfirmDialog activationDialog = new ConfirmDialog( // context: context, // confirmMessage: TranslationBase.of(context).accountDeactivatedMsg, @@ -354,7 +358,7 @@ class _Login extends State { } this.authService.checkActivationCode(request, code).then((result) async { sharedPref.remove(FAMILY_FILE); - // registerGeoZones(); + registerGeoZones(); projectViewModel.setPrivilege(privilegeList: result); result = CheckActivationCode.fromJson(result); result.list.isFamily = false; diff --git a/lib/pages/medical/dental_instructions_page.dart b/lib/pages/medical/dental_instructions_page.dart new file mode 100644 index 00000000..a704d620 --- /dev/null +++ b/lib/pages/medical/dental_instructions_page.dart @@ -0,0 +1,85 @@ +import 'package:diplomaticquarterapp/models/get_dental_instructions_response_model.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; + +class DentalInstructionsPage extends StatefulWidget { + const DentalInstructionsPage(); + + @override + State createState() => _DentalInstructionsPageState(); +} + +class _DentalInstructionsPageState extends State { + GetDentalInstructionsResponseModel getDentalInstructionsResponseModel; + + @override + void initState() { + WidgetsBinding.instance.addPostFrameCallback((_) { + getDentalInstructions(); + }); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: TranslationBase.of(context).myinstructions, + isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + isShowDecPage: false, + backgroundColor: CustomColors.appBackgroudGrey2Color, + body: Container( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + getDentalInstructionsResponseModel != null && getDentalInstructionsResponseModel.data.isNotEmpty + ? ListView.builder( + itemCount: getDentalInstructionsResponseModel.data.length, + shrinkWrap: true, + itemBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only(top: 16.0, bottom: 16.0), + child: Text( + getDentalInstructionsResponseModel.data[index].smsContent, + style: TextStyle( + fontSize: 14.0, + letterSpacing: -0.56, + color: Color(0xff575757), + ), + ), + ); + }, + ) + : Center(child: getNoDataWidget(context)), + ], + ), + ), + ), + ), + ); + } + + getDentalInstructions() { + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService service = new ClinicListService(); + service.getDentalInstructions().then((res) { + print(res["ProcedureNotificationResponse"]); + getDentalInstructionsResponseModel = GetDentalInstructionsResponseModel.fromJson(res["ProcedureNotificationResponse"]); + GifLoaderDialogUtils.hideDialog(context); + setState(() {}); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + AppToast.showErrorToast(message: err.toString()); + }); + } +} diff --git a/lib/pages/medical/medical_profile_page_new.dart b/lib/pages/medical/medical_profile_page_new.dart index e2a8f0af..376c924a 100644 --- a/lib/pages/medical/medical_profile_page_new.dart +++ b/lib/pages/medical/medical_profile_page_new.dart @@ -1,15 +1,21 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/time_line_new_widget.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; class MedicalProfilePageNew extends StatefulWidget { Function()? onTap; @@ -26,11 +32,15 @@ class _MedicalProfilePageState extends State { List medical = []; ProjectViewModel? projectViewModel; + List projectsList = []; + HospitalsModel _selectedHospital; + @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); var appoCountProvider = Provider.of(context); - List myMedicalList = Utils.myMedicalList(projectViewModel: projectViewModel, context: context, count: appoCountProvider.count, isLogin: projectViewModel!.isLogin); + List myMedicalList = + Utils.myMedicalList(projectViewModel: projectViewModel, context: context, count: appoCountProvider.count, isLogin: projectViewModel.isLogin, onWeCareClick: openWeCareProjectSelection); return BaseView( onModelReady: (model) => model.getAppointmentHistory(isForTimeLine: true), builder: (_, model, widget1) => AppScaffold( @@ -100,6 +110,62 @@ class _MedicalProfilePageState extends State { ), ); } + + openWeCareProjectSelection() { + int _selectedHospitalIndex = -1; + int languageID = projectViewModel.isArabic ? 1 : 2; + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService service = new ClinicListService(); + List projectsListLocal = []; + service.getProjectsList(languageID, context).then((res) { + if (res['MessageStatus'] == 1) { + setState(() { + res['ListProject'].forEach((v) { + projectsListLocal.add(new HospitalsModel.fromJson(v)); + }); + projectsList = projectsListLocal; + }); + GifLoaderDialogUtils.hideDialog(context); + List list = [ + for (int i = 0; i < projectsList.length; i++) RadioSelectionDialogModel(projectsList[i].name + ' ${projectsList[i].distanceInKilometers} ' + TranslationBase.of(context).km, i), + ]; + showDialog( + context: context, + builder: (cxt) => RadioSelectionDialog( + buttonText: TranslationBase.of(context).confirm, + listData: list, + selectedIndex: _selectedHospitalIndex, + isScrollable: true, + onValueSelected: (index) { + _selectedHospitalIndex = index; + _selectedHospital = projectsList[index]; + openWeCareURL(_selectedHospital.iD); + // setState(() {}); + }, + ), + ); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + }).catchError((err) { + print(err); + }); + } + + openWeCareURL(int projectID) { + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService service = new ClinicListService(); + service.getWeCareURL(projectID).then((res) { + print(res["Consent_VirtualJurny_Url_GetByProjectIDList"][0]["Url"]); + Uri uri = Uri.parse(res["Consent_VirtualJurny_Url_GetByProjectIDList"][0]["Url"]); + GifLoaderDialogUtils.hideDialog(context); + launchUrl(uri, mode: LaunchMode.inAppWebView); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + AppToast.showErrorToast(message: err.toString()); + }); + } } class Medical { diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 79e51e0c..82e52ae7 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -416,4 +416,27 @@ class ClinicListService extends BaseService { return Future.value(localRes); } + + Future getWeCareURL(int projectID) async { + Map request = {"ProjectID": projectID}; + dynamic localRes; + await baseAppClient.post(GET_WE_CARE_TOUR_URL, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + + Future getDentalInstructions() async { + Map request = {}; + dynamic localRes; + await baseAppClient.post(GET_DENTAL_INSTRUCTIONS, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 981d789c..46f4807c 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2961,6 +2961,9 @@ class TranslationBase { String get locationTimeoutError => localizedValues["locationTimeoutError"][locale.languageCode]; String get loadMore => localizedValues["loadMore"][locale.languageCode]; String get selectHospitalBloodDonation => localizedValues["selectHospitalBloodDonation"][locale.languageCode]; + String get wecare => localizedValues["wecare"][locale.languageCode]; + String get myinstructions => localizedValues["myinstructions"][locale.languageCode]; + } diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 4cb14dc0..55431476 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -25,6 +25,7 @@ import 'package:diplomaticquarterapp/pages/medical/active_medications/ActiveMedi import 'package:diplomaticquarterapp/pages/medical/allergies_page.dart'; import 'package:diplomaticquarterapp/pages/medical/ask_doctor/ask_doctor_home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/balance/my_balance_page.dart'; +import 'package:diplomaticquarterapp/pages/medical/dental_instructions_page.dart'; import 'package:diplomaticquarterapp/pages/medical/doctor/doctor_home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/eye/EyeMeasurementsPage.dart'; import 'package:diplomaticquarterapp/pages/medical/labs/labs_home_page.dart'; @@ -170,7 +171,7 @@ class Utils { String loginIDPattern(int loginType) { var length = loginType == 1 ? 10 : 1; - return "([0-9]{$length})"; + return "([0-9]{" + length.toString() + "}\$)"; } static showProgressDialog(context, [String message = "Loading..."]) async { @@ -221,7 +222,7 @@ class Utils { return RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email); } - static List myMedicalList({ProjectViewModel? projectViewModel, BuildContext? context, bool? isLogin, count}) { + static List myMedicalList({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count, Function onWeCareClick}) { List medical = []; medical.add(InkWell( @@ -382,6 +383,30 @@ class Utils { ), )); + medical.add(InkWell( + onTap: () => onWeCareClick(), + child: MedicalProfileItem( + title: TranslationBase.of(context).wecare, + imagePath: 'assets/images/new-design/virtual_tour_icon.png', + isPngImage: true, + subTitle: TranslationBase.of(context).service, + isEnable: projectViewModel.havePrivilege(85), + ), + )); + + medical.add(InkWell( + onTap: () { + Navigator.push(context, FadePage(page: DentalInstructionsPage())); + }, + child: MedicalProfileItem( + title: TranslationBase.of(context).myinstructions, + imagePath: 'medical_instructions.svg', + isPngImage: false, + subTitle: TranslationBase.of(context).service, + isEnable: projectViewModel.havePrivilege(85), + ), + )); + medical.add(InkWell( onTap: () => projectViewModel.havePrivilege(14) ? Navigator.push(context, FadePage(page: EyeMeasurementsPage())) : null, child: MedicalProfileItem( @@ -919,13 +944,13 @@ openAppStore({String? androidPackageName, String? iOSAppID, bool isHuawei = fals if (Platform.isAndroid) { assert(!(androidPackageName == null), "Should have valid value in androidPackageName parameter"); if (isHuawei) { - launch("appmarket://details?id=com.ejada.hmg"); + launchUrl(Uri.parse("appmarket://details?id=com.ejada.hmg")); } else { - launch("market://details?id=com.ejada.hmg"); + launchUrl(Uri.parse("market://details?id=com.ejada.hmg")); } } else if (Platform.isIOS) { assert((iOSAppID == null), "Should have valid value in iOSAppID parameter"); - launch("https://itunes.apple.com/kr/app/apple-store/$iOSAppID)"); + launchUrl(Uri.parse("https://itunes.apple.com/kr/app/apple-store/$iOSAppID)")); } } diff --git a/lib/widgets/dialogs/radio_selection_dialog.dart b/lib/widgets/dialogs/radio_selection_dialog.dart index 934b18f0..2a4178b7 100644 --- a/lib/widgets/dialogs/radio_selection_dialog.dart +++ b/lib/widgets/dialogs/radio_selection_dialog.dart @@ -15,11 +15,13 @@ class RadioSelectionDialog extends StatefulWidget { final int? selectedIndex; final bool? isScrollable; final bool? isShowSearch; + final String? buttonText; - const RadioSelectionDialog({Key? key, this.onValueSelected, this.listData, this.selectedIndex, this.isScrollable = false, this.isShowSearch = false}) : super(key: key); + const RadioSelectionDialog({Key key, this.onValueSelected, this.listData, this.selectedIndex, this.isScrollable = false, this.isShowSearch = false, this.buttonText = ""}) : super(key: key); @override State createState() => new RadioSelectionDialogState(); + } class RadioSelectionDialogState extends State { @@ -163,7 +165,7 @@ class RadioSelectionDialogState extends State { children: [ Expanded( child: DefaultButton( - TranslationBase.of(context).save, + widget.buttonText.isNotEmpty ? widget.buttonText : TranslationBase.of(context).save, () { Navigator.pop(context); widget.onValueSelected!(selectedIndex); diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 5aa48c9a..f75517bd 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -155,6 +155,10 @@ class _AppDrawerState extends State { height: 1, ), ), + mHeight(20.0), + (user != null && projectProvider.isLogin) + ? Image.network("https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=${user.patientID.toString()}", fit: BoxFit.fill, height: 73.5, width: 73.5) + : Container(), ], ), ),