diff --git a/assets/images/png/cc_ar.png b/assets/images/png/cc_ar.png
new file mode 100644
index 00000000..e4388ba2
Binary files /dev/null and b/assets/images/png/cc_ar.png differ
diff --git a/assets/images/png/cc_en.png b/assets/images/png/cc_en.png
new file mode 100644
index 00000000..c11cf5e6
Binary files /dev/null and b/assets/images/png/cc_en.png differ
diff --git a/assets/images/svg/all_payment_method.svg b/assets/images/svg/all_payment_method.svg
new file mode 100644
index 00000000..ef72e6ac
--- /dev/null
+++ b/assets/images/svg/all_payment_method.svg
@@ -0,0 +1,34 @@
+
diff --git a/assets/images/svg/comprehensive_checkup.svg b/assets/images/svg/comprehensive_checkup.svg
new file mode 100644
index 00000000..885d9a7d
--- /dev/null
+++ b/assets/images/svg/comprehensive_checkup.svg
@@ -0,0 +1,6 @@
+
diff --git a/assets/images/svg/e-referral.svg b/assets/images/svg/e-referral.svg
new file mode 100644
index 00000000..3262779c
--- /dev/null
+++ b/assets/images/svg/e-referral.svg
@@ -0,0 +1,7 @@
+
diff --git a/assets/images/svg/ic_rrt_vehicle.svg b/assets/images/svg/ic_rrt_vehicle.svg
new file mode 100644
index 00000000..d858fb4e
--- /dev/null
+++ b/assets/images/svg/ic_rrt_vehicle.svg
@@ -0,0 +1,5 @@
+
diff --git a/assets/images/svg/mada.svg b/assets/images/svg/mada.svg
new file mode 100644
index 00000000..99fd1326
--- /dev/null
+++ b/assets/images/svg/mada.svg
@@ -0,0 +1,9 @@
+
diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index b276dd7c..6a5d34f1 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -1,7 +1,7 @@
import Flutter
import UIKit
-import FirebaseCore
-import FirebaseMessaging
+//import FirebaseCore
+//import FirebaseMessaging
import GoogleMaps
@main
@objc class AppDelegate: FlutterAppDelegate {
@@ -10,13 +10,13 @@ import GoogleMaps
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("AIzaSyB6TERnxIr0yJ3qG4ULBZbu0sAD4tGqtng")
- FirebaseApp.configure()
+// FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:Data){
- Messaging.messaging().apnsToken = deviceToken
+// Messaging.messaging().apnsToken = deviceToken
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
}
diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart
index 3d5f3379..aa534f6d 100644
--- a/lib/core/api/api_client.dart
+++ b/lib/core/api/api_client.dart
@@ -88,22 +88,22 @@ class ApiClientImp implements ApiClient {
@override
post(
- String endPoint, {
- required Map body,
- required Function(dynamic response, int statusCode, {int? messageStatus, String? errorMessage}) onSuccess,
- required Function(String error, int statusCode, {int? messageStatus, Failure? failureType}) onFailure,
- bool isAllowAny = false,
- bool isExternal = false,
- bool isRCService = false,
- bool isPaymentServices = false,
- bool bypassConnectionCheck = true,
- }) async {
+ String endPoint, {
+ required Map body,
+ required Function(dynamic response, int statusCode, {int? messageStatus, String? errorMessage}) onSuccess,
+ required Function(String error, int statusCode, {int? messageStatus, Failure? failureType}) onFailure,
+ bool isAllowAny = false,
+ bool isExternal = false,
+ bool isRCService = false,
+ bool isPaymentServices = false,
+ bool bypassConnectionCheck = true,
+ }) async {
String url;
if (isExternal) {
url = endPoint;
} else {
if (isRCService) {
- url = RC_BASE_URL + endPoint;
+ url = ApiConsts.rcBaseUrl + endPoint;
} else {
url = ApiConsts.baseUrl + endPoint;
}
@@ -119,7 +119,8 @@ class ApiClientImp implements ApiClient {
} else {}
if (body.containsKey('isDentalAllowedBackend')) {
- body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') ? body['isDentalAllowedBackend'] ?? IS_DENTAL_ALLOWED_BACKEND : IS_DENTAL_ALLOWED_BACKEND;
+ body['isDentalAllowedBackend'] =
+ body.containsKey('isDentalAllowedBackend') ? body['isDentalAllowedBackend'] ?? IS_DENTAL_ALLOWED_BACKEND : IS_DENTAL_ALLOWED_BACKEND;
}
if (!body.containsKey('IsPublicRequest')) {
@@ -136,9 +137,9 @@ class ApiClientImp implements ApiClient {
body['PatientType'] = PATIENT_TYPE_ID.toString();
}
- // TODO : These should be from the appState
if (user != null) {
body['TokenID'] = body['TokenID'] ?? token;
+
body['PatientID'] = body['PatientID'] ?? user.patientId;
body['PatientOutSA'] = body.containsKey('PatientOutSA') ? body['PatientOutSA'] ?? user.outSa : user.outSa;
@@ -160,7 +161,7 @@ class ApiClientImp implements ApiClient {
// body['VersionID'] = ApiConsts.appVersionID.toString();
if (!isExternal) {
- body['VersionID'] = "50.0";
+ body['VersionID'] = ApiConsts.appVersionID.toString();
body['Channel'] = ApiConsts.appChannelId.toString();
body['IPAdress'] = ApiConsts.appIpAddress;
body['generalid'] = ApiConsts.appGeneralId;
@@ -174,6 +175,7 @@ class ApiClientImp implements ApiClient {
}
// body['TokenID'] = "@dm!n";
+ // body['PatientID'] = 4772429;
// body['PatientID'] = 1231755;
// body['PatientTypeID'] = 1;
//
@@ -182,9 +184,10 @@ class ApiClientImp implements ApiClient {
}
body.removeWhere((key, value) => value == null);
- log("body: ${json.encode(body)}");
log("uri: ${Uri.parse(url.trim())}");
+ log("body: ${json.encode(body)}");
+
final bool networkStatus = await Utils.checkConnection(bypassConnectionCheck: bypassConnectionCheck);
if (!networkStatus) {
@@ -199,7 +202,10 @@ class ApiClientImp implements ApiClient {
final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers);
final int statusCode = response.statusCode;
+ log("uri: ${Uri.parse(url.trim())}");
+ log("body: ${json.encode(body)}");
log("response.body: ${response.body}");
+ // log("response.body: ${response.body}");
if (statusCode < 200 || statusCode >= 400) {
onFailure('Error While Fetching data', statusCode, failureType: StatusCodeFailure("Error While Fetching data"));
logApiEndpointError(endPoint, 'Error While Fetching data', statusCode);
@@ -210,35 +216,44 @@ class ApiClientImp implements ApiClient {
onSuccess(parsed, statusCode, messageStatus: 1, errorMessage: "");
} else {
onSuccess(parsed, statusCode,
- messageStatus: parsed.contains('MessageStatus') ? parsed['MessageStatus'] : 1, errorMessage: parsed.contains('ErrorEndUserMessage') ? parsed['ErrorEndUserMessage'] : "");
+ messageStatus: (parsed is Map && parsed.containsKey('MessageStatus')) ? parsed['MessageStatus'] : 1,
+ errorMessage: (parsed is Map && parsed.containsKey('ErrorEndUserMessage')) ? parsed['ErrorEndUserMessage'] : "");
}
} else {
if (parsed['Response_Message'] != null) {
- onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
+ onSuccess(parsed, statusCode,
+ messageStatus: (parsed is Map && parsed.containsKey('MessageStatus')) ? parsed['MessageStatus'] : 1,
+ errorMessage: (parsed is Map && parsed.containsKey('ErrorEndUserMessage')) ? parsed['ErrorEndUserMessage'] : "");
} else {
if (parsed['ErrorType'] == 4) {
//TODO : handle app update
- onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode, failureType: AppUpdateFailure("parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']"));
+ onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode,
+ failureType: AppUpdateFailure("parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']"));
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
}
if (parsed['ErrorType'] == 2) {
- // todo: handle Logout
+ // todo_section: handle Logout
onFailure(
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode,
- failureType: UnAuthenticatedUserFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'] ?? "User is not Authenticated", url: url),
+ failureType:
+ UnAuthenticatedUserFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'] ?? "User is not Authenticated", url: url),
);
// logApiEndpointError(endPoint, "session logged out", statusCode);
}
if (isAllowAny) {
- onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
+ onSuccess(parsed, statusCode,
+ messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
} else if (parsed['IsAuthenticated'] == null) {
if (parsed['isSMSSent'] == true) {
- onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
+ onSuccess(parsed, statusCode,
+ messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
} else if (parsed['MessageStatus'] == 1) {
- onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
+ onSuccess(parsed, statusCode,
+ messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
} else if (parsed['Result'] == 'OK') {
- onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
+ onSuccess(parsed, statusCode,
+ messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
} else {
onFailure(
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
@@ -248,16 +263,19 @@ class ApiClientImp implements ApiClient {
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
}
} else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) {
- onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
+ onSuccess(parsed, statusCode,
+ messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
} else if (parsed['IsAuthenticated'] == false) {
onFailure(
"User is not Authenticated",
statusCode,
- failureType: UnAuthenticatedUserFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'] ?? "User is not Authenticated", url: url),
+ failureType:
+ UnAuthenticatedUserFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'] ?? "User is not Authenticated", url: url),
);
} else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) {
if (parsed['SameClinicApptList'] != null) {
- onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
+ onSuccess(parsed, statusCode,
+ messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
} else {
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) {
if (parsed['ErrorSearchMsg'] == null) {
@@ -276,7 +294,6 @@ class ApiClientImp implements ApiClient {
logApiEndpointError(endPoint, parsed['ErrorSearchMsg'], statusCode);
}
} else {
-
onFailure(
parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode,
@@ -287,7 +304,8 @@ class ApiClientImp implements ApiClient {
}
} else {
if (parsed['SameClinicApptList'] != null) {
- onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
+ onSuccess(parsed, statusCode,
+ messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
} else {
if (parsed['message'] != null) {
onFailure(
@@ -338,9 +356,9 @@ class ApiClientImp implements ApiClient {
url = endPoint;
} else {
if (isRCService) {
- url = RC_BASE_URL + endPoint;
+ url = ApiConsts.rcBaseUrl + endPoint;
} else {
- url = BASE_URL + endPoint;
+ url = ApiConsts.baseUrl + endPoint;
}
}
if (queryParams != null) {
@@ -351,7 +369,7 @@ class ApiClientImp implements ApiClient {
debugPrint("URL : $url");
// print("Body : ${json.encode(body)}");
- if (await Utils.checkConnection()) {
+ if (await Utils.checkConnection(bypassConnectionCheck: true)) {
final response = await http.get(
Uri.parse(url.trim()),
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart
index 29ec562f..a1f40629 100644
--- a/lib/core/api_consts.dart
+++ b/lib/core/api_consts.dart
@@ -1,10 +1,6 @@
import 'package:amazon_payfort/amazon_payfort.dart';
import 'package:hmg_patient_app_new/core/enums.dart';
-var MAX_SMALL_SCREEN = 660;
-final OPENTOK_API_KEY = '46209962';
-// final OPENTOK_API_KEY = '47464241';
-
// PACKAGES and OFFERS
var EXA_CART_API_BASE_URL = 'https://mdlaboratories.com/offersdiscounts';
// var EXA_CART_API_BASE_URL = 'http://10.200.101.75:9000';
@@ -50,8 +46,6 @@ var PHARMACY_REDIRECT_URL = 'https://bit.ly/AlhabibPharmacy';
// RC API URL
// var RC_BASE_URL = 'https://rc.hmg.com/';
-var RC_BASE_URL = 'https://rc.hmg.com/uat/';
-
// var RC_BASE_URL = 'https://ms.hmg.com/rc/';
var PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity';
@@ -265,7 +259,6 @@ var CANCEL_APPOINTMENT = "Services/Doctors.svc/REST/CancelAppointment";
var GENERATE_QR_APPOINTMENT = "Services/Doctors.svc/REST/GenerateQRAppointmentNo";
//URL send email appointment QR
-var EMAIL_QR_APPOINTMENT = "Services/Notifications.svc/REST/sendEmailForOnLineCheckin";
//URL check payment status
var CHECK_PAYMENT_STATUS = "Services/PayFort_Serv.svc/REST/GetRequestStatusByRequestID";
@@ -275,14 +268,8 @@ var CREATE_ADVANCE_PAYMENT = "Services/Doctors.svc/REST/CreateAdvancePayment";
var HIS_CREATE_ADVANCE_PAYMENT = "Services/Patients.svc/REST/HIS_CreateAdvancePayment";
-var ER_CREATE_ADVANCE_PAYMENT = "services/Doctors.svc/REST/ER_CreateAdvancePaymentForClinic";
-
-var ER_INSERT_ADVANCE_PAYMENT = "services/Doctors.svc/REST/ER_InsertEROnlinePaymentDetails";
-
var ADD_ADVANCE_NUMBER_REQUEST = 'Services/PayFort_Serv.svc/REST/AddAdvancedNumberRequest';
-var GENERATE_ANCILLARY_ORDERS_INVOICE = 'Services/Doctors.svc/REST/AutoGenerateAncillaryOrderInvoice';
-
var IS_ALLOW_ASK_DOCTOR = 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult';
var GET_CALL_REQUEST_TYPE = 'Services/Doctors.svc/REST/GetCallRequestType_LOV';
var ADD_VIDA_REQUEST = 'Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart';
@@ -308,8 +295,6 @@ var GET_LIVECARE_CLINIC_TIMING = 'Services/ER_VirtualCall.svc/REST/PatientER_Get
var GET_ER_APPOINTMENT_FEES = 'Services/DoctorApplication.svc/REST/GetERAppointmentFees';
var GET_ER_APPOINTMENT_TIME = 'Services/ER_VirtualCall.svc/REST/GetRestTime';
-var CHECK_PATIENT_DERMA_PACKAGE = 'Services/OUTPs.svc/REST/getPatientPackageComponentsForOnlineCheckIn';
-
var ADD_NEW_CALL_FOR_PATIENT_ER = 'Services/DoctorApplication.svc/REST/NewCallForPatientER';
var GET_LIVECARE_HISTORY = 'Services/ER_VirtualCall.svc/REST/GetPatientErVirtualHistory';
@@ -534,12 +519,6 @@ var ADD_HHC_ORDER_RC = "api/HHC/add";
var GET_ALL_HHC_ORDERS_RC = 'api/hhc/list';
var UPDATE_HHC_ORDER_RC = 'api/hhc/update';
-// CMC RC SERVICES
-var GET_ALL_CMC_SERVICES_RC = 'api/cmc/getallcmc';
-var ADD_CMC_ORDER_RC = 'api/cmc/add';
-var GET_ALL_CMC_ORDERS_RC = 'api/cmc/list';
-var UPDATE_CMC_ORDER_RC = 'api/cmc/update';
-
// RRT RC SERVICES
var ADD_RRT_ORDER_RC = "api/rrt/add";
var GET_ALL_RRT_ORDERS_RC = "api/rrt/list";
@@ -721,6 +700,8 @@ const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo';
const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_InsertUpdate';
+var ER_CREATE_ADVANCE_PAYMENT = "services/Doctors.svc/REST/ER_CreateAdvancePaymentForClinic";
+
//family Files
const FAMILY_FILES = 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatus';
@@ -736,11 +717,7 @@ class ApiConsts {
static String baseUrl = 'https://hmgwebservices.com/'; // HIS API URL PROD
- static String RCBaseUrl = 'https://rc.hmg.com/'; // RC API URL PROD
-
- static String SELECT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_SELECTDeviceIMEIbyIMEI';
-
- static num VERSION_ID = 18.9;
+ static String rcBaseUrl = 'https://rc.hmg.com/'; // RC API URL PROD
static var payFortEnvironment = FortEnvironment.production;
static var applePayMerchantId = "merchant.com.hmgwebservices";
@@ -767,7 +744,7 @@ class ApiConsts {
TAMARA_URL = "https://mdlaboratories.com/tamaralive/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://mdlaboratories.com/tamaralive/Home/GetInstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://mdlaboratories.com/tamaralive/api/OnlineTamara/order_status?orderid=';
- RCBaseUrl = 'https://rc.hmg.com/';
+ rcBaseUrl = 'https://rc.hmg.com/';
break;
case AppEnvironmentTypeEnum.dev:
baseUrl = "https://uat.hmgwebservices.com/";
@@ -777,7 +754,7 @@ class ApiConsts {
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
- RCBaseUrl = 'https://rc.hmg.com/test/';
+ rcBaseUrl = 'https://rc.hmg.com/uat/';
break;
case AppEnvironmentTypeEnum.uat:
baseUrl = "https://uat.hmgwebservices.com/";
@@ -787,7 +764,7 @@ class ApiConsts {
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
- RCBaseUrl = 'https://rc.hmg.com/test/';
+ rcBaseUrl = 'https://rc.hmg.com/uat/';
break;
case AppEnvironmentTypeEnum.preProd:
baseUrl = "https://webservices.hmg.com/";
@@ -797,7 +774,7 @@ class ApiConsts {
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
- RCBaseUrl = 'https://rc.hmg.com/';
+ rcBaseUrl = 'https://rc.hmg.com/';
break;
case AppEnvironmentTypeEnum.qa:
baseUrl = "https://uat.hmgwebservices.com/";
@@ -807,7 +784,7 @@ class ApiConsts {
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
- RCBaseUrl = 'https://rc.hmg.com/test/';
+ rcBaseUrl = 'https://rc.hmg.com/uat/';
break;
case AppEnvironmentTypeEnum.staging:
baseUrl = "https://uat.hmgwebservices.com/";
@@ -817,7 +794,7 @@ class ApiConsts {
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
- RCBaseUrl = 'https://rc.hmg.com/test/';
+ rcBaseUrl = 'https://rc.hmg.com/uat/';
break;
}
}
@@ -849,8 +826,33 @@ class ApiConsts {
static final String removeFileFromFamilyMembers = 'Services/Authentication.svc/REST/ActiveDeactive_PatientFile';
static final String acceptAndRejectFamilyFile = 'Services/Authentication.svc/REST/Update_FileStatus';
- // static values for Api
- static final double appVersionID = 18.7;
+ // Ancillary Order Apis
+ static final String getOnlineAncillaryOrderList = 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderList';
+ static final String getOnlineAncillaryOrderProcList = 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderProcList';
+ static final String generateAncillaryOrderInvoice = 'Services/Doctors.svc/REST/AutoGenerateAncillaryOrderInvoice';
+ static final String autoGenerateAncillaryOrdersInvoice = 'Services/Doctors.svc/REST/AutoGenerateAncillaryOrderInvoice';
+ static final String getRequestStatusByRequestID = 'Services/PayFort_Serv.svc/REST/GetRequestStatusByRequestID';
+
+ //Payment APIs
+ static final String applePayInsertRequest = "Services/PayFort_Serv.svc/REST/PayFort_ApplePayRequestData_Insert";
+ static final String createAdvancePayments = 'Services/Patients.svc/REST/HIS_CreateAdvancePayment';
+ static final String addAdvanceNumberRequest = 'Services/PayFort_Serv.svc/REST/AddAdvancedNumberRequest';
+
+ // RC COMPREHENSIVE MEDICAL CHECKUP ServIces
+ static final String allCMCOrdersRc = 'api/cmc/list';
+ static final String allCMCServicesRc = 'api/cmc/getallcmc';
+ static final String updateCMCOrder = 'api/cmc/update';
+ static final String addCMCOrder = 'api/cmc/add';
+ static final String getHospitalsList = 'Services/Lists.svc/REST/GetProject';
+
+ // RC HOME HEALTHCARE ServIces
+ static final String allHHCOrdersRc = 'api/hhc/list';
+ static final String allHHCServicesRc = 'api/HHC/getallhhc';
+ static final String updateHHCOrder = 'api/hhc/update';
+ static final String addHHCOrder = 'api/HHC/add';
+
+ // ************ static values for Api ****************
+ static final double appVersionID = 19.3;
static final int appChannelId = 3;
static final String appIpAddress = "10.20.10.20";
static final String appGeneralId = "Cs2020@2016\$2958";
diff --git a/lib/core/app_assets.dart b/lib/core/app_assets.dart
index e8215ba2..5fccc6e7 100644
--- a/lib/core/app_assets.dart
+++ b/lib/core/app_assets.dart
@@ -171,6 +171,10 @@ class AppAssets {
static const String to_arrow = '$svgBasePath/to_arrow.svg';
static const String dual_arrow = '$svgBasePath/to_arrow.svg';
static const String forward_arrow_medium = '$svgBasePath/forward_arrow_medium.svg';
+ static const String eReferral = '$svgBasePath/e-referral.svg';
+ static const String comprehensiveCheckup = '$svgBasePath/comprehensive_checkup.svg';
+ static const String all_payment_method = '$svgBasePath/all_payment_method.svg';
+ static const String ic_rrt_vehicle = '$svgBasePath/ic_rrt_vehicle.svg';
//bottom navigation//
@@ -200,6 +204,8 @@ class AppAssets {
static const String visa = '$pngBasePath/visa.png';
static const String lockIcon = '$pngBasePath/lock-icon.png';
static const String dummy_user = '$pngBasePath/dummy_user.png';
+ static const String comprehensiveCheckupEn = '$pngBasePath/cc_en.png';
+ static const String comprehensiveCheckupAr = '$pngBasePath/cc_er.png';
}
class AppAnimations {
diff --git a/lib/core/dependencies.dart b/lib/core/dependencies.dart
index cc9d88d2..6c452476 100644
--- a/lib/core/dependencies.dart
+++ b/lib/core/dependencies.dart
@@ -15,6 +15,8 @@ import 'package:hmg_patient_app_new/features/emergency_services/emergency_servic
import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_repo.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
+import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_repo.dart';
+import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart';
import 'package:hmg_patient_app_new/features/immediate_livecare/immediate_livecare_repo.dart';
import 'package:hmg_patient_app_new/features/immediate_livecare/immediate_livecare_view_model.dart';
import 'package:hmg_patient_app_new/features/insurance/insurance_repo.dart';
@@ -35,6 +37,8 @@ import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_mo
import 'package:hmg_patient_app_new/features/profile_settings/profile_settings_view_model.dart';
import 'package:hmg_patient_app_new/features/radiology/radiology_repo.dart';
import 'package:hmg_patient_app_new/features/radiology/radiology_view_model.dart';
+import 'package:hmg_patient_app_new/features/todo_section/todo_section_repo.dart';
+import 'package:hmg_patient_app_new/features/todo_section/todo_section_view_model.dart';
import 'package:hmg_patient_app_new/services/analytics/analytics_service.dart';
import 'package:hmg_patient_app_new/services/cache_service.dart';
import 'package:hmg_patient_app_new/services/dialog_service.dart';
@@ -44,7 +48,6 @@ import 'package:hmg_patient_app_new/services/localauth_service.dart';
import 'package:hmg_patient_app_new/services/logger_service.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
import 'package:hmg_patient_app_new/widgets/date_range_selector/viewmodel/date_range_view_model.dart';
-import 'package:http/http.dart';
import 'package:local_auth/local_auth.dart';
import 'package:logger/web.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -102,46 +105,37 @@ class AppDependencies {
getIt.registerLazySingleton(() => PrescriptionsRepoImp(loggerService: getIt(), apiClient: getIt()));
getIt.registerLazySingleton(() => InsuranceRepoImp(loggerService: getIt(), apiClient: getIt()));
getIt.registerLazySingleton(() => PayfortRepoImp(loggerService: getIt(), apiClient: getIt()));
- getIt.registerLazySingleton(() => LocalAuthService(loggerService: getIt(), localAuth: getIt()));
+ getIt.registerLazySingleton(
+ () => LocalAuthService(loggerService: getIt(), localAuth: getIt()),
+ );
getIt.registerLazySingleton(() => HabibWalletRepoImp(loggerService: getIt(), apiClient: getIt()));
getIt.registerLazySingleton(() => MedicalFileRepoImp(loggerService: getIt(), apiClient: getIt()));
getIt.registerLazySingleton(() => ImmediateLiveCareRepoImp(loggerService: getIt(), apiClient: getIt()));
getIt.registerLazySingleton(() => EmergencyServicesRepoImp(loggerService: getIt(), apiClient: getIt()));
- getIt.registerLazySingleton(
- () => LocationRepoImpl(apiClient: getIt()));
+ getIt.registerLazySingleton(() => TodoSectionRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerLazySingleton(() => LocationRepoImpl(apiClient: getIt()));
getIt.registerLazySingleton(() => ContactUsRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerLazySingleton(() => HmgServicesRepoImp(loggerService: getIt(), apiClient: getIt()));
// ViewModels
// Global/shared VMs → LazySingleton
- getIt.registerLazySingleton(
- () => LabViewModel(labRepo: getIt(), errorHandlerService: getIt(), navigationService: getIt()),
- );
+ getIt.registerLazySingleton(() => LabViewModel(labRepo: getIt(), errorHandlerService: getIt(), navigationService: getIt()));
getIt.registerLazySingleton(
() => RadiologyViewModel(
radiologyRepo: getIt(),
errorHandlerService: getIt(),
+ navigationService: getIt()
),
);
- getIt.registerLazySingleton(
- () => PrescriptionsViewModel(
- prescriptionsRepo: getIt(),
- errorHandlerService: getIt(),
- ),
- );
+ getIt.registerLazySingleton(() => PrescriptionsViewModel(prescriptionsRepo: getIt(), errorHandlerService: getIt(), navServices: getIt()));
- getIt.registerLazySingleton(
- () => InsuranceViewModel(
- insuranceRepo: getIt(),
- errorHandlerService: getIt(),
- ),
- );
+ getIt.registerLazySingleton(() => InsuranceViewModel(insuranceRepo: getIt(), errorHandlerService: getIt()));
getIt.registerLazySingleton(
- () => MyAppointmentsViewModel(myAppointmentsRepo: getIt(), errorHandlerService: getIt(), appState: getIt()),
- );
+ () => MyAppointmentsViewModel(myAppointmentsRepo: getIt(), errorHandlerService: getIt(), appState: getIt()));
getIt.registerLazySingleton(
() => PayfortViewModel(
@@ -165,7 +159,13 @@ class AppDependencies {
);
getIt.registerLazySingleton(
- () => BookAppointmentsViewModel(bookAppointmentsRepo: getIt(), errorHandlerService: getIt(), navigationService: getIt(), myAppointmentsViewModel: getIt(), locationUtils: getIt(), dialogService: getIt()),
+ () => BookAppointmentsViewModel(
+ bookAppointmentsRepo: getIt(),
+ errorHandlerService: getIt(),
+ navigationService: getIt(),
+ myAppointmentsViewModel: getIt(),
+ locationUtils: getIt(),
+ dialogService: getIt()),
);
getIt.registerLazySingleton(
@@ -179,51 +179,49 @@ class AppDependencies {
getIt.registerLazySingleton(
() => AuthenticationViewModel(
- authenticationRepo: getIt(), cacheService: getIt(), navigationService: getIt(), dialogService: getIt(), appState: getIt(), errorHandlerService: getIt(), localAuthService: getIt()),
+ authenticationRepo: getIt(),
+ cacheService: getIt(),
+ navigationService: getIt(),
+ dialogService: getIt(),
+ appState: getIt(),
+ errorHandlerService: getIt(),
+ localAuthService: getIt()),
);
getIt.registerLazySingleton(() => ProfileSettingsViewModel());
- getIt.registerLazySingleton(
- () => DateRangeSelectorRangeViewModel(),
- );
+ getIt.registerLazySingleton(() => DateRangeSelectorRangeViewModel());
- getIt.registerLazySingleton(
- () => DoctorFilterViewModel(),
- );
+ getIt.registerLazySingleton(() => DoctorFilterViewModel());
getIt.registerLazySingleton(
- () =>
- AppointmentViaRegionViewmodel(
- navigationService: getIt(),
- appState: getIt(),
- ),
+ () => AppointmentViaRegionViewmodel(navigationService: getIt(), appState: getIt()),
);
getIt.registerLazySingleton(
() => EmergencyServicesViewModel(
- locationUtils: getIt(),
- navServices: getIt(),
- emergencyServicesRepo: getIt(),
- appState: getIt(),
- errorHandlerService: getIt(),
- appointmentRepo: getIt(),
- dialogService: getIt()
- ),
+ locationUtils: getIt(),
+ navServices: getIt(),
+ emergencyServicesRepo: getIt(),
+ appState: getIt(),
+ errorHandlerService: getIt(),
+ appointmentRepo: getIt(),
+ dialogService: getIt()),
);
getIt.registerLazySingleton(
- () => LocationViewModel(
- locationRepo: getIt(),
- errorHandlerService: getIt(),
- ),
+ () => LocationViewModel(locationRepo: getIt(), errorHandlerService: getIt()),
);
getIt.registerLazySingleton(
- () => ContactUsViewModel(
- contactUsRepo: getIt(),
- appState: getIt(),
- errorHandlerService: getIt(),
- ),
+ () => ContactUsViewModel(contactUsRepo: getIt(), appState: getIt(), errorHandlerService: getIt()),
+ );
+
+ getIt.registerLazySingleton(
+ () => TodoSectionViewModel(todoSectionRepo: getIt(), errorHandlerService: getIt()),
+ );
+
+ getIt.registerLazySingleton(
+ () => HmgServicesViewModel(bookAppointmentsRepo: getIt(), hmgServicesRepo: getIt(), errorHandlerService: getIt()),
);
// Screen-specific VMs → Factory
diff --git a/lib/core/utils/date_util.dart b/lib/core/utils/date_util.dart
index d58aef60..e6856dbc 100644
--- a/lib/core/utils/date_util.dart
+++ b/lib/core/utils/date_util.dart
@@ -6,19 +6,19 @@ class DateUtil {
/// convert String To Date function
/// [date] String we want to convert
static DateTime convertStringToDate(String? date) {
- print("the date is $date");
+
if (date == null) return DateTime.now();
if (date.isEmpty) return DateTime.now();
- const start = "/Date(";
- const end = "+0300)";
- final startIndex = date.indexOf(start);
- final endIndex = date.indexOf(end, startIndex + start.length);
- return DateTime.fromMillisecondsSinceEpoch(int.parse(
- date.substring(startIndex + start.length, endIndex),
- ));
-
+ const start = "/Date(";
+ const end = "+0300)";
+ final startIndex = date.indexOf(start);
+ final endIndex = date.indexOf(end, startIndex + start.length);
+ return DateTime.fromMillisecondsSinceEpoch(int.parse(
+ date.substring(startIndex + start.length, endIndex),
+ ))
+ ;
}
static DateTime convertStringToDateSaudiTimezone(String date, int projectId) {
@@ -36,10 +36,10 @@ class DateUtil {
// .add(Duration(hours: 4));
// } else {
return DateTime.fromMillisecondsSinceEpoch(
- int.parse(
- date.substring(startIndex + start.length, endIndex),
- ),
- isUtc: true)
+ int.parse(
+ date.substring(startIndex + start.length, endIndex),
+ ),
+ isUtc: true)
.add(Duration(hours: 3));
// }
} else {
@@ -156,7 +156,13 @@ class DateUtil {
static String getDateFormatted(String date) {
DateTime dateObj = DateUtil.convertStringToDate(date);
- return DateUtil.getWeekDay(dateObj.weekday) + ", " + dateObj.day.toString() + " " + DateUtil.getMonth(dateObj.month) + " " + dateObj.year.toString();
+ return DateUtil.getWeekDay(dateObj.weekday) +
+ ", " +
+ dateObj.day.toString() +
+ " " +
+ DateUtil.getMonth(dateObj.month) +
+ " " +
+ dateObj.year.toString();
}
static String getISODateFormat(DateTime dateTime) {
@@ -352,12 +358,41 @@ class DateUtil {
if (dateTime != null) {
return lang == 'en'
? getWeekDayEnglish(dateTime.weekday) + ", " + getMonth(dateTime.month) + " " + dateTime.day.toString() + " " + dateTime.year.toString()
- : getWeekDayArabic(dateTime.weekday) + ", " + dateTime.day.toString() + " " + getMonthArabic(dateTime.month) + " " + dateTime.year.toString();
+ : getWeekDayArabic(dateTime.weekday) +
+ ", " +
+ dateTime.day.toString() +
+ " " +
+ getMonthArabic(dateTime.month) +
+ " " +
+ dateTime.year.toString();
} else {
return "";
}
}
+ static String getDateStringForNearestSlot(String date) {
+ DateTime dateObj = DateUtil.convertStringToDate(date);
+ return DateUtil.getWeekDay(dateObj.weekday) +
+ ", " +
+ dateObj.day.toString() +
+ " " +
+ DateUtil.getMonth(dateObj.month) +
+ " " +
+ dateObj.year.toString() +
+ " " +
+ dateObj.hour.toString() +
+ ":" +
+ getMinute(dateObj);
+ }
+
+ static String getMinute(DateTime dateObj) {
+ if (dateObj.minute == 0) {
+ return dateObj.minute.toString() + "0";
+ } else {
+ return dateObj.minute.toString();
+ }
+ }
+
static String getMonthDayYearLangDateFormatted(DateTime dateTime, String lang) {
if (dateTime != null) {
return lang == 'en'
@@ -381,7 +416,9 @@ class DateUtil {
static String getMonthYearLangDateFormatted(DateTime dateTime, String lang) {
if (dateTime != null) {
- return lang == 'en' ? getMonth(dateTime.month) + " " + dateTime.year.toString() : getMonthArabic(dateTime.month) + " " + dateTime.year.toString();
+ return lang == 'en'
+ ? getMonth(dateTime.month) + " " + dateTime.year.toString()
+ : getMonthArabic(dateTime.month) + " " + dateTime.year.toString();
} else {
return "";
}
@@ -488,10 +525,8 @@ class DateUtil {
}
}
-
-extension OnlyDate on DateTime{
-
- DateTime provideDateOnly(){
+extension OnlyDate on DateTime {
+ DateTime provideDateOnly() {
return DateTime(this.year, month, day);
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/utils/request_utils.dart b/lib/core/utils/request_utils.dart
index a4ea9365..e57039cb 100644
--- a/lib/core/utils/request_utils.dart
+++ b/lib/core/utils/request_utils.dart
@@ -1,3 +1,5 @@
+import 'dart:developer';
+
import 'package:easy_localization/easy_localization.dart';
import 'package:hijri_gregorian_calendar/hijri_gregorian_calendar.dart';
import 'package:hmg_patient_app_new/core/api_consts.dart';
@@ -96,6 +98,7 @@ class RequestUtils {
request.patientIdentificationID = request.nationalID = (registeredData.patientIdentificationId ?? 0);
request.dob = registeredData.dob;
request.isRegister = registeredData.isRegister;
+ log("nationIdText: ${nationIdText}");
} else {
if (fileNo) {
request.patientID = patientId ?? int.parse(nationIdText);
@@ -199,7 +202,8 @@ class RequestUtils {
return request;
}
- static dynamic getUserSignupCompletionRequest({String? fullName, String? emailAddress, GenderTypeEnum? gender, MaritalStatusTypeEnum? maritalStatus}) {
+ static dynamic getUserSignupCompletionRequest(
+ {String? fullName, String? emailAddress, GenderTypeEnum? gender, MaritalStatusTypeEnum? maritalStatus}) {
AppState appState = getIt.get();
bool isDubai = appState.getUserRegistrationPayload.patientOutSa == 1 ? true : false;
@@ -215,11 +219,19 @@ class RequestUtils {
return {
"Patientobject": {
"TempValue": true,
- "PatientIdentificationType":
- (isDubai ? appState.getUserRegistrationPayload.patientIdentificationId?.toString().substring(0, 1) : appState.getNHICUserData.idNumber!.substring(0, 1)) == "1" ? 1 : 2,
- "PatientIdentificationNo": isDubai ? appState.getUserRegistrationPayload.patientIdentificationId.toString() : appState.getNHICUserData.idNumber.toString(),
+ "PatientIdentificationType": (isDubai
+ ? appState.getUserRegistrationPayload.patientIdentificationId?.toString().substring(0, 1)
+ : appState.getNHICUserData.idNumber!.substring(0, 1)) ==
+ "1"
+ ? 1
+ : 2,
+ "PatientIdentificationNo":
+ isDubai ? appState.getUserRegistrationPayload.patientIdentificationId.toString() : appState.getNHICUserData.idNumber.toString(),
"MobileNumber": appState.getUserRegistrationPayload.patientMobileNumber ?? 0,
- "PatientOutSA": (appState.getUserRegistrationPayload.zipCode == CountryEnum.saudiArabia.countryCode || appState.getUserRegistrationPayload.zipCode == '+966') ? 0 : 1,
+ "PatientOutSA": (appState.getUserRegistrationPayload.zipCode == CountryEnum.saudiArabia.countryCode ||
+ appState.getUserRegistrationPayload.zipCode == '+966')
+ ? 0
+ : 1,
"FirstNameN": isDubai ? "..." : appState.getNHICUserData.firstNameAr,
"FirstName": isDubai ? (names.isNotEmpty ? names[0] : "...") : appState.getNHICUserData.firstNameEn,
"MiddleNameN": isDubai ? "..." : appState.getNHICUserData.secondNameAr,
@@ -233,7 +245,10 @@ class RequestUtils {
"eHealthIDField": isDubai ? null : appState.getNHICUserData.healthId,
"DateofBirthN": date,
"EmailAddress": emailAddress,
- "SourceType": (appState.getUserRegistrationPayload.zipCode == CountryEnum.saudiArabia.countryCode || appState.getUserRegistrationPayload.zipCode == '+966') ? "1" : "2",
+ "SourceType": (appState.getUserRegistrationPayload.zipCode == CountryEnum.saudiArabia.countryCode ||
+ appState.getUserRegistrationPayload.zipCode == '+966')
+ ? "1"
+ : "2",
"PreferredLanguage": appState.getLanguageCode() == "ar" ? (isDubai ? "1" : 1) : (isDubai ? "2" : 2),
"Marital": isDubai
? (maritalStatus == MaritalStatusTypeEnum.single
@@ -247,20 +262,25 @@ class RequestUtils {
? '1'
: '2'),
},
- "PatientIdentificationID": isDubai ? appState.getUserRegistrationPayload.patientIdentificationId.toString() : appState.getNHICUserData.idNumber.toString(),
+ "PatientIdentificationID":
+ isDubai ? appState.getUserRegistrationPayload.patientIdentificationId.toString() : appState.getNHICUserData.idNumber.toString(),
"PatientMobileNumber": appState.getUserRegistrationPayload.patientMobileNumber.toString()[0] == '0'
? appState.getUserRegistrationPayload.patientMobileNumber
: '0${appState.getUserRegistrationPayload.patientMobileNumber}',
"DOB": dob,
"IsHijri": appState.getUserRegistrationPayload.isHijri,
- "PatientOutSA": (appState.getUserRegistrationPayload.zipCode == CountryEnum.saudiArabia.countryCode || appState.getUserRegistrationPayload.zipCode == '+966') ? 0 : 1,
+ "PatientOutSA": (appState.getUserRegistrationPayload.zipCode == CountryEnum.saudiArabia.countryCode ||
+ appState.getUserRegistrationPayload.zipCode == '+966')
+ ? 0
+ : 1,
"isDentalAllowedBackend": appState.getUserRegistrationPayload.isDentalAllowedBackend,
"ZipCode": appState.getUserRegistrationPayload.zipCode,
if (!isDubai) "HealthId": appState.getNHICUserData.healthId,
};
}
- static Future getAddFamilyRequest({required String nationalIDorFile, required String mobileNo, required String countryCode}) async {
+ static Future getAddFamilyRequest(
+ {required String nationalIDorFile, required String mobileNo, required String countryCode}) async {
FamilyFileRequest request = FamilyFileRequest();
int? loginType = 0;
diff --git a/lib/core/utils/utils.dart b/lib/core/utils/utils.dart
index c05fe8bb..e3b108fc 100644
--- a/lib/core/utils/utils.dart
+++ b/lib/core/utils/utils.dart
@@ -102,8 +102,9 @@ class Utils {
? getMonthArabic(dateTime.month) + " " + dateTime.day.toString() + ", " + dateTime.year.toString()
: getMonth(dateTime.month) + " " + dateTime.day.toString() + ", " + dateTime.year.toString();
}
+
static String getDayMonthYearDateFormatted(DateTime? dateTime) {
- if(dateTime == null ) return "";
+ if (dateTime == null) return "";
return appState.isArabic()
? "${dateTime.day.toString()} ${getMonthArabic(dateTime.month)}, ${dateTime.year.toString()}"
: "${dateTime.day.toString()} ${getMonth(dateTime.month)}, ${dateTime.year.toString()}";
@@ -323,7 +324,8 @@ class Utils {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: isSmallWidget ? 0.h : 48.h),
- Lottie.asset(AppAnimations.noData, repeat: false, reverse: false, frameRate: FrameRate(60), width: width.h, height: height.h, fit: BoxFit.fill),
+ Lottie.asset(AppAnimations.noData,
+ repeat: false, reverse: false, frameRate: FrameRate(60), width: width.h, height: height.h, fit: BoxFit.fill),
SizedBox(height: 16.h),
(noDataText ?? LocaleKeys.noDataAvailable.tr())
.toText16(weight: FontWeight.w500, color: AppColors.greyTextColor, isCenter: true)
@@ -339,7 +341,8 @@ class Utils {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- Lottie.asset(AppAnimations.loadingAnimation, repeat: true, reverse: false, frameRate: FrameRate(60), width: 100.h, height: 100.h, fit: BoxFit.fill),
+ Lottie.asset(AppAnimations.loadingAnimation,
+ repeat: true, reverse: false, frameRate: FrameRate(60), width: 100.h, height: 100.h, fit: BoxFit.fill),
SizedBox(height: 8.h),
(loadingText ?? LocaleKeys.loadingText.tr()).toText16(color: AppColors.blackColor, isCenter: true),
SizedBox(height: 8.h),
@@ -365,7 +368,8 @@ class Utils {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- Lottie.asset(AppAnimations.errorAnimation, repeat: true, reverse: false, frameRate: FrameRate(60), width: 100.h, height: 100.h, fit: BoxFit.fill),
+ Lottie.asset(AppAnimations.errorAnimation,
+ repeat: true, reverse: false, frameRate: FrameRate(60), width: 100.h, height: 100.h, fit: BoxFit.fill),
SizedBox(height: 8.h),
(loadingText ?? LocaleKeys.loadingText.tr()).toText16(color: AppColors.blackColor),
SizedBox(height: 8.h),
@@ -373,14 +377,21 @@ class Utils {
).center;
}
- static Widget getWarningWidget({String? loadingText, bool isShowActionButtons = false, Widget? bodyWidget, Function? onConfirmTap, Function? onCancelTap}) {
+ static Widget getWarningWidget({
+ String? loadingText,
+ bool isShowActionButtons = false,
+ Widget? bodyWidget,
+ Function? onConfirmTap,
+ Function? onCancelTap,
+ }) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- Lottie.asset(AppAnimations.warningAnimation, repeat: false, reverse: false, frameRate: FrameRate(60), width: 128.h, height: 128.h, fit: BoxFit.fill),
+ Lottie.asset(AppAnimations.warningAnimation,
+ repeat: false, reverse: false, frameRate: FrameRate(60), width: 100.h, height: 100.h, fit: BoxFit.fill),
SizedBox(height: 8.h),
- (loadingText ?? LocaleKeys.loadingText.tr()).toText14(color: AppColors.blackColor, letterSpacing: 0),
+ (loadingText ?? LocaleKeys.loadingText.tr()).toText15(color: AppColors.blackColor, letterSpacing: 0),
SizedBox(height: 16.h),
bodyWidget ?? SizedBox.shrink(),
SizedBox(height: 16.h),
@@ -698,7 +709,7 @@ class Utils {
fit: fit,
errorBuilder: errorBuilder ??
(_, __, ___) {
- //todo change the error builder icon that it is returning
+ //todo_section change the error builder icon that it is returning
return Utils.buildSvgWithAssets(width: iconW, height: iconH, icon: AppAssets.no_visit_icon);
},
);
@@ -748,14 +759,15 @@ class Utils {
);
}
- static Widget getPaymentAmountWithSymbol2(num habibWalletAmount,
- {double iconSize = 14,
+ static Widget getPaymentAmountWithSymbol2(
+ num habibWalletAmount, {
+ double iconSize = 14,
double? fontSize,
double? letterSpacing,
FontWeight? fontWeight,
Color iconColor = AppColors.textColor,
- Color textColor = AppColors.blackColor,
- bool isSaudiCurrency = true,
+ Color textColor = AppColors.blackColor,
+ bool isSaudiCurrency = true,
bool isExpanded = true,
}) {
return RichText(
@@ -772,7 +784,7 @@ class Utils {
style: TextStyle(
color: textColor,
fontSize: fontSize ?? 32.f,
- letterSpacing: letterSpacing??-4,
+ letterSpacing: letterSpacing ?? -4,
fontWeight: fontWeight ?? FontWeight.w600,
height: 1),
),
@@ -816,7 +828,7 @@ class Utils {
static Future createFileFromString(String encodedStr, String ext) async {
Uint8List bytes = base64.decode(encodedStr);
String dir = (await getApplicationDocumentsDirectory()).path;
- File file = File("$dir/" + DateTime.now().millisecondsSinceEpoch.toString() + "." + ext);
+ File file = File("$dir/${DateTime.now().millisecondsSinceEpoch}.$ext");
await file.writeAsBytes(bytes);
return file.path;
}
@@ -834,7 +846,12 @@ class Utils {
static PatientDoctorAppointmentList? convertToPatientDoctorAppointmentList(HospitalsModel? hospital) {
if (hospital == null) return null;
return PatientDoctorAppointmentList(
- filterName: hospital.name, distanceInKMs: hospital.distanceInKilometers?.toString(), projectTopName: hospital.name, projectBottomName: hospital.name, model: hospital, isHMC: hospital.isHMC);
+ filterName: hospital.name,
+ distanceInKMs: hospital.distanceInKilometers?.toString(),
+ projectTopName: hospital.name,
+ projectBottomName: hospital.name,
+ model: hospital,
+ isHMC: hospital.isHMC);
}
static bool havePrivilege(int id) {
@@ -848,7 +865,4 @@ class Utils {
}
return isHavePrivilege;
}
-
-
-
}
diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart
index 1a6d1ccf..250453df 100644
--- a/lib/extensions/string_extensions.dart
+++ b/lib/extensions/string_extensions.dart
@@ -41,12 +41,14 @@ extension EmailValidator on String {
FontWeight? weight,
bool isBold = false,
bool isUnderLine = false,
+ bool isCenter = false,
int? maxlines,
FontStyle? fontStyle,
TextOverflow? textOverflow,
double letterSpacing = 0}) =>
Text(
this,
+ textAlign: isCenter ? TextAlign.center : null,
maxLines: maxlines,
overflow: textOverflow,
style: TextStyle(
@@ -223,6 +225,7 @@ extension EmailValidator on String {
FontWeight? weight,
TextOverflow? textOverflow,
double? letterSpacing = -0.4,
+ Color decorationColor =AppColors.errorColor
}) =>
Text(
this,
@@ -236,6 +239,7 @@ extension EmailValidator on String {
overflow: textOverflow,
fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.normal),
decoration: isUnderLine ? TextDecoration.underline : null,
+ decorationColor: decorationColor
),
);
diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart
index 424aa882..70f10bbf 100644
--- a/lib/extensions/widget_extensions.dart
+++ b/lib/extensions/widget_extensions.dart
@@ -1,9 +1,8 @@
-import 'package:hmg_patient_app_new/core/enums.dart';
-import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:flutter/material.dart';
-import 'package:flutter/widgets.dart';
+import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/extensions/int_extensions.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
+import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:shimmer/shimmer.dart';
import 'package:sizer/sizer.dart';
import 'package:smooth_corner/smooth_corner.dart';
@@ -19,7 +18,8 @@ extension WidgetExtensions on Widget {
Widget paddingAll(double _value) => Padding(padding: EdgeInsets.all(_value), child: this);
- Widget paddingSymmetrical(double horizontal, double vertical) => Padding(padding: EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical), child: this);
+ Widget paddingSymmetrical(double horizontal, double vertical) =>
+ Padding(padding: EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical), child: this);
Widget paddingOnly({double left = 0.0, double right = 0.0, double top = 0.0, double bottom = 0.0}) =>
Padding(padding: EdgeInsetsDirectional.only(start: left, end: right, top: top, bottom: bottom), child: this);
@@ -99,7 +99,7 @@ extension WidgetExtensions on Widget {
bool disablePadding = false,
double radius = 20,
Color? color,
- Color borderColor = AppColors.buttonColor,
+ Color? borderColor,
bool disableWidth = false,
bool isAlignment = false}) {
return Container(
@@ -110,7 +110,7 @@ extension WidgetExtensions on Widget {
),
color: color,
border: Border.all(
- color: borderColor,
+ color: borderColor ?? Colors.transparent,
width: disableWidth ? 2 : 1,
),
),
diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart
index bcdacac6..3260ea57 100644
--- a/lib/features/authentication/authentication_view_model.dart
+++ b/lib/features/authentication/authentication_view_model.dart
@@ -339,7 +339,7 @@ class AuthenticationViewModel extends ChangeNotifier {
_navigationService.pop();
});
},
- activationCode: null, //todo silent login case halded on the repo itself..
+ activationCode: null, //todo_section silent login case halded on the repo itself..
);
}
}
diff --git a/lib/features/book_appointments/book_appointments_view_model.dart b/lib/features/book_appointments/book_appointments_view_model.dart
index f24766bc..5d5fc713 100644
--- a/lib/features/book_appointments/book_appointments_view_model.dart
+++ b/lib/features/book_appointments/book_appointments_view_model.dart
@@ -3,7 +3,6 @@ import 'dart:async';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
-import 'package:hmg_patient_app_new/core/cache_consts.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/location_util.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
@@ -105,8 +104,7 @@ class BookAppointmentsViewModel extends ChangeNotifier {
List searchedRegionList = [];
List facilityList = ["hmgHospitals", "hmcMedicalClinic"];
List searchedHospitalList = [];
- List
- searchedPatientDoctorAppointmentHospitalsList = [];
+ List searchedPatientDoctorAppointmentHospitalsList = [];
List searchedClinicList = [];
PatientDoctorAppointmentList? selectedHospitalForFilters;
@@ -114,15 +112,14 @@ class BookAppointmentsViewModel extends ChangeNotifier {
String? selectedClinicForFilters;
bool applyFilters = false;
-
///variables for laser clinic
- List femaleLaserCategory = [
+ List femaleLaserCategory = [
LaserCategoryType(1, 'bodyString'),
LaserCategoryType(2, 'face'),
- LaserCategoryType(10,'bikini'),
+ LaserCategoryType(10, 'bikini'),
LaserCategoryType(11, 'retouch'),
];
- List maleLaserCategory =[
+ List maleLaserCategory = [
LaserCategoryType(1, 'body'),
LaserCategoryType(2, 'face'),
LaserCategoryType(11, 'retouch'),
@@ -136,9 +133,13 @@ class BookAppointmentsViewModel extends ChangeNotifier {
bool isBodyPartsLoading = false;
int duration = 0;
-
BookAppointmentsViewModel(
- {required this.bookAppointmentsRepo, required this.errorHandlerService, required this.navigationService, required this.myAppointmentsViewModel, required this.locationUtils, required this.dialogService }) {
+ {required this.bookAppointmentsRepo,
+ required this.errorHandlerService,
+ required this.navigationService,
+ required this.myAppointmentsViewModel,
+ required this.locationUtils,
+ required this.dialogService}) {
initBookAppointmentViewModel();
}
@@ -287,7 +288,8 @@ class BookAppointmentsViewModel extends ChangeNotifier {
Future getLiveCareScheduleClinics({Function(dynamic)? onSuccess, Function(String)? onError}) async {
liveCareClinicsList.clear();
- final result = await bookAppointmentsRepo.getLiveCareScheduleClinics(_appState.getAuthenticatedUser()!.age!, _appState.getAuthenticatedUser()!.gender!);
+ final result =
+ await bookAppointmentsRepo.getLiveCareScheduleClinics(_appState.getAuthenticatedUser()!.age!, _appState.getAuthenticatedUser()!.gender!);
result.fold(
(failure) async => await errorHandlerService.handleError(failure: failure),
@@ -309,8 +311,9 @@ class BookAppointmentsViewModel extends ChangeNotifier {
Future getLiveCareDoctorsList({Function(dynamic)? onSuccess, Function(String)? onError}) async {
doctorsList.clear();
- final result =
- await bookAppointmentsRepo.getLiveCareDoctorsList(selectedLiveCareClinic.serviceID!, _appState.getAuthenticatedUser()!.age!, _appState.getAuthenticatedUser()!.gender!, onError: onError);
+ final result = await bookAppointmentsRepo.getLiveCareDoctorsList(
+ selectedLiveCareClinic.serviceID!, _appState.getAuthenticatedUser()!.age!, _appState.getAuthenticatedUser()!.gender!,
+ onError: onError);
result.fold(
(failure) async {
@@ -333,10 +336,15 @@ class BookAppointmentsViewModel extends ChangeNotifier {
}
//TODO: Make the API dynamic with parameters for ProjectID, isNearest, languageID, doctorId, doctorName
- Future getDoctorsList({int projectID = 0, bool isNearest = false, int doctorId = 0, String doctorName = "", Function(dynamic)? onSuccess, Function(String)? onError}) async {
+ Future getDoctorsList(
+ {int projectID = 0, bool isNearest = true, int doctorId = 0,
+ String doctorName = "",
+ Function(dynamic)? onSuccess,
+ Function(String)? onError}) async {
doctorsList.clear();
projectID = currentlySelectedHospitalFromRegionFlow != null ? int.parse(currentlySelectedHospitalFromRegionFlow!) : projectID;
- final result = await bookAppointmentsRepo.getDoctorsList(selectedClinic.clinicID ?? 0, projectID, isNearest, doctorId, doctorName, isContinueDentalPlan: isContinueDentalPlan);
+ final result =
+ await bookAppointmentsRepo.getDoctorsList(selectedClinic.clinicID ?? 0, projectID, doctorName.isNotEmpty ? false : isNearest, doctorId, doctorName, isContinueDentalPlan: isContinueDentalPlan);
result.fold(
(failure) async {
@@ -365,7 +373,13 @@ class BookAppointmentsViewModel extends ChangeNotifier {
}
Future getMappedDoctors(
- {int projectID = 0, bool isNearest = false, int doctorId = 0, String doctorName = "", isContinueDentalPlan = false, Function(dynamic)? onSuccess, Function(String)? onError}) async {
+ {int projectID = 0,
+ bool isNearest = false,
+ int doctorId = 0,
+ String doctorName = "",
+ isContinueDentalPlan = false,
+ Function(dynamic)? onSuccess,
+ Function(String)? onError}) async {
filteredHospitalList = null;
hospitalList = null;
isRegionListLoading = true;
@@ -374,10 +388,10 @@ class BookAppointmentsViewModel extends ChangeNotifier {
final result = await bookAppointmentsRepo.getDoctorsList(selectedClinic.clinicID ?? 0, projectID, isNearest, doctorId, doctorName);
result.fold(
- (failure) async {
+ (failure) async {
onError?.call("No doctors found for the search criteria".needTranslation);
},
- (apiResponse) async {
+ (apiResponse) async {
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
@@ -401,7 +415,8 @@ class BookAppointmentsViewModel extends ChangeNotifier {
}
Future getDoctorProfile({Function(dynamic)? onSuccess, Function(String)? onError}) async {
- final result = await bookAppointmentsRepo.getDoctorProfile(selectedDoctor.clinicID ?? 0, selectedDoctor.projectID ?? 0, selectedDoctor.doctorID ?? 0, onError: onError);
+ final result = await bookAppointmentsRepo
+ .getDoctorProfile(selectedDoctor.clinicID ?? 0, selectedDoctor.projectID ?? 0, selectedDoctor.doctorID ?? 0, onError: onError);
result.fold(
(failure) async {},
@@ -457,7 +472,8 @@ class BookAppointmentsViewModel extends ChangeNotifier {
// :
date = DateUtil.convertStringToDateSaudiTimezone(element, int.parse(selectedDoctor.projectID.toString()));
slotsList.add(FreeSlot(date, ['slot']));
- docFreeSlots.add(TimeSlot(isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date, vidaDate: element));
+ docFreeSlots.add(TimeSlot(
+ isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date, vidaDate: element));
});
notifyListeners();
@@ -476,8 +492,8 @@ class BookAppointmentsViewModel extends ChangeNotifier {
final DateFormat dateFormatter = DateFormat('yyyy-MM-dd');
Map _eventsParsed;
- final result = await bookAppointmentsRepo.getLiveCareDoctorFreeSlots(
- selectedDoctor.clinicID ?? 0, selectedLiveCareClinic.serviceID ?? 0, selectedDoctor.projectID ?? 0, selectedDoctor.doctorID ?? 0, isBookingForLiveCare,
+ final result = await bookAppointmentsRepo.getLiveCareDoctorFreeSlots(selectedDoctor.clinicID ?? 0, selectedLiveCareClinic.serviceID ?? 0,
+ selectedDoctor.projectID ?? 0, selectedDoctor.doctorID ?? 0, isBookingForLiveCare,
onError: onError);
result.fold(
@@ -501,7 +517,8 @@ class BookAppointmentsViewModel extends ChangeNotifier {
// :
date = DateUtil.convertStringToDateSaudiTimezone(element, int.parse(selectedDoctor.projectID.toString()));
slotsList.add(FreeSlot(date, ['slot']));
- docFreeSlots.add(TimeSlot(isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date, vidaDate: element));
+ docFreeSlots.add(TimeSlot(
+ isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date, vidaDate: element));
});
notifyListeners();
@@ -513,7 +530,10 @@ class BookAppointmentsViewModel extends ChangeNotifier {
);
}
- Future cancelAppointment({required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async {
+ Future cancelAppointment(
+ {required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel,
+ Function(dynamic)? onSuccess,
+ Function(String)? onError}) async {
final result = await bookAppointmentsRepo.cancelAppointment(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel);
result.fold(
@@ -597,13 +617,15 @@ class BookAppointmentsViewModel extends ChangeNotifier {
await cancelAppointment(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel).then((val) async {
navigationService.pop();
Future.delayed(Duration(milliseconds: 50)).then((value) async {});
- LoadingUtils.showFullScreenLoader(barrierDismissible: true, isSuccessDialog: false, loadingText: "Booking your appointment...".needTranslation);
+ LoadingUtils.showFullScreenLoader(
+ barrierDismissible: true, isSuccessDialog: false, loadingText: "Booking your appointment...".needTranslation);
await insertSpecificAppointment(
onError: (err) {},
onSuccess: (apiResp) async {
LoadingUtils.hideFullScreenLoader();
await Future.delayed(Duration(milliseconds: 50)).then((value) async {
- LoadingUtils.showFullScreenLoader(barrierDismissible: true, isSuccessDialog: true, loadingText: LocaleKeys.appointmentSuccess.tr());
+ LoadingUtils.showFullScreenLoader(
+ barrierDismissible: true, isSuccessDialog: true, loadingText: LocaleKeys.appointmentSuccess.tr());
await Future.delayed(Duration(milliseconds: 4000)).then((value) {
LoadingUtils.hideFullScreenLoader();
Navigator.pushAndRemoveUntil(
@@ -693,13 +715,15 @@ class BookAppointmentsViewModel extends ChangeNotifier {
await cancelAppointment(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel).then((val) async {
navigationService.pop();
Future.delayed(Duration(milliseconds: 50)).then((value) async {});
- LoadingUtils.showFullScreenLoader(barrierDismissible: true, isSuccessDialog: false, loadingText: "Booking your appointment...".needTranslation);
+ LoadingUtils.showFullScreenLoader(
+ barrierDismissible: true, isSuccessDialog: false, loadingText: "Booking your appointment...".needTranslation);
await insertSpecificAppointment(
onError: (err) {},
onSuccess: (apiResp) async {
LoadingUtils.hideFullScreenLoader();
await Future.delayed(Duration(milliseconds: 50)).then((value) async {
- LoadingUtils.showFullScreenLoader(barrierDismissible: true, isSuccessDialog: true, loadingText: LocaleKeys.appointmentSuccess.tr());
+ LoadingUtils.showFullScreenLoader(
+ barrierDismissible: true, isSuccessDialog: true, loadingText: LocaleKeys.appointmentSuccess.tr());
await Future.delayed(Duration(milliseconds: 4000)).then((value) {
LoadingUtils.hideFullScreenLoader();
Navigator.pushAndRemoveUntil(
@@ -773,7 +797,9 @@ class BookAppointmentsViewModel extends ChangeNotifier {
} else {
filteredHospitalList = RegionList();
- var list = isHMG ? hospitalList?.registeredDoctorMap![selectedRegionId]!.hmgDoctorList : hospitalList?.registeredDoctorMap![selectedRegionId]!.hmcDoctorList;
+ var list = isHMG
+ ? hospitalList?.registeredDoctorMap![selectedRegionId]!.hmgDoctorList
+ : hospitalList?.registeredDoctorMap![selectedRegionId]!.hmcDoctorList;
if (list != null && list.isEmpty) {
notifyListeners();
@@ -856,12 +882,8 @@ class BookAppointmentsViewModel extends ChangeNotifier {
notifyListeners();
}
- void setSelections(
- List? selectedFacilityForFilters,
- List? selectedRegionForFilters,
- String? selectedClinicForFilters,
- PatientDoctorAppointmentList? selectedHospitalForFilters,
- bool applyFilters) {
+ void setSelections(List? selectedFacilityForFilters, List? selectedRegionForFilters, String? selectedClinicForFilters,
+ PatientDoctorAppointmentList? selectedHospitalForFilters, bool applyFilters) {
this.selectedFacilityForFilters = selectedFacilityForFilters;
this.selectedClinicForFilters = selectedClinicForFilters;
this.selectedHospitalForFilters = selectedHospitalForFilters;
@@ -872,17 +894,14 @@ class BookAppointmentsViewModel extends ChangeNotifier {
void getFiltersFromDoctorList() {
doctorsList.forEach((element) {
- if (!searchedRegionList
- .contains(element.getRegionName(_appState.isArabic()))) {
- searchedRegionList
- .add(element.getRegionName(_appState.isArabic()) ?? "");
+ if (!searchedRegionList.contains(element.getRegionName(_appState.isArabic()))) {
+ searchedRegionList.add(element.getRegionName(_appState.isArabic()) ?? "");
}
if (!searchedHospitalList.contains(element.projectName)) {
- searchedPatientDoctorAppointmentHospitalsList
- .add(PatientDoctorAppointmentList()
- ..filterName = element.projectName
- ..isHMC = element.isHMC
- ..distanceInKMs = "0");
+ searchedPatientDoctorAppointmentHospitalsList.add(PatientDoctorAppointmentList()
+ ..filterName = element.projectName
+ ..isHMC = element.isHMC
+ ..distanceInKMs = "0");
searchedHospitalList.add(element.projectName ?? "");
}
if (!searchedClinicList.contains(element.clinicName)) {
@@ -939,27 +958,15 @@ class BookAppointmentsViewModel extends ChangeNotifier {
return doctorsList;
}
var list = doctorsList.where((element) {
- var isInSelectedRegion = (selectedRegionForFilters?.isEmpty == true)
- ? true
- : selectedRegionForFilters
- ?.any((region) => region == element.getRegionName(isArabic()));
- var shouldApplyFacilityFilter =
- (selectedFacilityForFilters?.isEmpty == true) ? false : true;
- var isHMC = (selectedFacilityForFilters?.isEmpty == true)
- ? true
- : selectedFacilityForFilters?.any((item) => item.contains("hmc"));
- var isInSelectedClinic = (selectedClinicForFilters == null)
- ? true
- : selectedClinicForFilters == element.clinicName;
- var isInSelectedHospital = (selectedHospitalForFilters == null)
- ? true
- : element.projectName == selectedHospitalForFilters?.filterName;
+ var isInSelectedRegion =
+ (selectedRegionForFilters?.isEmpty == true) ? true : selectedRegionForFilters?.any((region) => region == element.getRegionName(isArabic()));
+ var shouldApplyFacilityFilter = (selectedFacilityForFilters?.isEmpty == true) ? false : true;
+ var isHMC = (selectedFacilityForFilters?.isEmpty == true) ? true : selectedFacilityForFilters?.any((item) => item.contains("hmc"));
+ var isInSelectedClinic = (selectedClinicForFilters == null) ? true : selectedClinicForFilters == element.clinicName;
+ var isInSelectedHospital = (selectedHospitalForFilters == null) ? true : element.projectName == selectedHospitalForFilters?.filterName;
var facilityFilter = ((shouldApplyFacilityFilter == true) ? isHMC : true);
- return (isInSelectedRegion ?? true) &&
- (facilityFilter ?? true) &&
- isInSelectedClinic &&
- isInSelectedHospital;
+ return (isInSelectedRegion ?? true) && (facilityFilter ?? true) && isInSelectedClinic && isInSelectedHospital;
}).toList();
return list;
}
@@ -1003,7 +1010,8 @@ class BookAppointmentsViewModel extends ChangeNotifier {
dentalChiefComplaintsList.clear();
notifyListeners();
int patientID = _appState.isAuthenticated ? _appState.getAuthenticatedUser()!.patientId ?? -1 : -1;
- final result = await bookAppointmentsRepo.getDentalChiefComplaintsList(patientID: patientID, projectID: int.parse(currentlySelectedHospitalFromRegionFlow ?? "0"), clinicID: 17);
+ final result = await bookAppointmentsRepo.getDentalChiefComplaintsList(
+ patientID: patientID, projectID: int.parse(currentlySelectedHospitalFromRegionFlow ?? "0"), clinicID: 17);
result.fold(
(failure) async => await errorHandlerService.handleError(failure: failure),
@@ -1051,7 +1059,7 @@ class BookAppointmentsViewModel extends ChangeNotifier {
);
}
- setBodyType(int bodyType){
+ setBodyType(int bodyType) {
selectedBodyTypeIndex = bodyType;
selectedCategory = 0;
selectedBodyPartList = [];
@@ -1059,33 +1067,33 @@ class BookAppointmentsViewModel extends ChangeNotifier {
notifyListeners();
}
- FutureOr getLaserClinic() async{
+ FutureOr getLaserClinic() async {
isBodyPartsLoading = true;
int id = bodyTypes[selectedBodyTypeIndex][selectedCategory].laserCategoryID;
int projectID = currentlySelectedHospitalFromRegionFlow != null ? int.parse(currentlySelectedHospitalFromRegionFlow!) : 0;
int languageID = _appState.isArabic() ? 1 : 0;
final result = await bookAppointmentsRepo.getLaserClinics(id, projectID, languageID);
result.fold(
- (failure) {
+ (failure) {
isBodyPartsLoading = false;
notifyListeners();
},
- (apiResponse) {isBodyPartsLoading = false;
+ (apiResponse) {
+ isBodyPartsLoading = false;
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
- List response =apiResponse.data!;
- if(response.first.category == 2 || response.first.category == 10 ) response.remove(response.first);
+ List response = apiResponse.data!;
+ if (response.first.category == 2 || response.first.category == 10) response.remove(response.first);
laserBodyPartsList = response;
}
- notifyListeners();
-
+ notifyListeners();
},
);
}
int getDuration() {
- var duration = 0;
+ var duration = 0;
var lowerUpperLegsList = selectedBodyPartList.where((element) => element.mappingCode == "47" || element.mappingCode == "48")?.toList() ?? [];
var upperLowerArmsList = selectedBodyPartList.where((element) => element.mappingCode == "40" || element.mappingCode == "41")?.toList() ?? [];
@@ -1110,21 +1118,25 @@ class BookAppointmentsViewModel extends ChangeNotifier {
}
void setSelectedBodyPart(LaserBodyPart part) {
- if(selectedBodyPartList.contains(part)){
+ if (selectedBodyPartList.contains(part)) {
selectedBodyPartList.remove(part);
this.duration = getDuration();
notifyListeners();
} else {
- if(this.duration == 90){
- dialogService.showErrorBottomSheet(message: "Duration can not exceed 90 min".needTranslation,);
+ if (this.duration == 90) {
+ dialogService.showErrorBottomSheet(
+ message: "Duration can not exceed 90 min".needTranslation,
+ );
return;
}
selectedBodyPartList.add(part);
var duration = getDuration();
- if(duration > 90){
+ if (duration > 90) {
selectedBodyPartList.remove(part);
- dialogService.showErrorBottomSheet(message: "Duration Exceeds 90 min".needTranslation,);
+ dialogService.showErrorBottomSheet(
+ message: "Duration Exceeds 90 min".needTranslation,
+ );
return;
}
this.duration = duration;
@@ -1137,10 +1149,10 @@ class BookAppointmentsViewModel extends ChangeNotifier {
}
String getLaserProcedureNameWRTLanguage(LaserBodyPart part) {
- if(_appState.isArabic()){
- return part.bodyPartN??"";
- }else {
- return part.bodyPart??"";
+ if (_appState.isArabic()) {
+ return part.bodyPartN ?? "";
+ } else {
+ return part.bodyPart ?? "";
}
}
diff --git a/lib/features/contact_us/contact_us_repo.dart b/lib/features/contact_us/contact_us_repo.dart
index f2b11693..3e96f919 100644
--- a/lib/features/contact_us/contact_us_repo.dart
+++ b/lib/features/contact_us/contact_us_repo.dart
@@ -3,14 +3,18 @@ import 'package:hmg_patient_app_new/core/api/api_client.dart';
import 'package:hmg_patient_app_new/core/api_consts.dart';
import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart';
import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart';
+import 'package:hmg_patient_app_new/features/contact_us/models/req_models/request_insert_coc_item.dart';
import 'package:hmg_patient_app_new/features/contact_us/models/resp_models/get_hmg_locations.dart';
import 'package:hmg_patient_app_new/features/contact_us/models/resp_models/get_patient_ic_projects.dart';
+import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
import 'package:hmg_patient_app_new/services/logger_service.dart';
abstract class ContactUsRepo {
Future>>> getHMGLocations();
Future>>> getLiveChatProjectsList();
+
+ Future>> insertCOCItem({required RequestInsertCOCItem requestInsertCOCItem, PatientAppointmentHistoryResponseModel? patientSelectedAppointment});
}
class ContactUsRepoImp implements ContactUsRepo {
@@ -72,13 +76,57 @@ class ContactUsRepoImp implements ContactUsRepo {
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final list = response['List_PatientICProjects'];
- final hmgLocations = list.map((item) => GetPatientICProjectsModel.fromJson(item as Map)).toList().cast();
+ final liveChatProjectsList = list.map((item) => GetPatientICProjectsModel.fromJson(item as Map)).toList().cast();
apiResponse = GenericApiModel>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: null,
- data: hmgLocations,
+ data: liveChatProjectsList,
+ );
+ } catch (e) {
+ failure = DataParsingFailure(e.toString());
+ }
+ },
+ );
+ if (failure != null) return Left(failure!);
+ if (apiResponse == null) return Left(ServerFailure("Unknown error"));
+ return Right(apiResponse!);
+ } catch (e) {
+ return Left(UnknownFailure(e.toString()));
+ }
+ }
+
+ @override
+ Future>> insertCOCItem({required RequestInsertCOCItem requestInsertCOCItem, PatientAppointmentHistoryResponseModel? patientSelectedAppointment}) async {
+ final Map body = requestInsertCOCItem.toJson();
+
+ if (patientSelectedAppointment != null) {
+ body['AppoinmentNo'] = patientSelectedAppointment.appointmentNo;
+ body['AppointmentDate'] = patientSelectedAppointment.appointmentDate;
+ body['ClinicID'] = patientSelectedAppointment.clinicID;
+ body['ClinicName'] = patientSelectedAppointment.clinicName;
+ body['DoctorID'] = patientSelectedAppointment.doctorID;
+ body['DoctorName'] = patientSelectedAppointment.doctorNameObj;
+ body['ProjectName'] = patientSelectedAppointment.projectName;
+ }
+
+ try {
+ GenericApiModel? apiResponse;
+ Failure? failure;
+ await apiClient.post(
+ SEND_FEEDBACK,
+ body: body,
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ apiResponse = GenericApiModel(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: null,
+ data: response,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
diff --git a/lib/features/contact_us/contact_us_view_model.dart b/lib/features/contact_us/contact_us_view_model.dart
index 7826bd1d..11857003 100644
--- a/lib/features/contact_us/contact_us_view_model.dart
+++ b/lib/features/contact_us/contact_us_view_model.dart
@@ -1,7 +1,15 @@
+import 'dart:io';
+
import 'package:flutter/material.dart';
+import 'package:hmg_patient_app_new/core/api_consts.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
+import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/features/contact_us/contact_us_repo.dart';
+import 'package:hmg_patient_app_new/features/contact_us/models/feedback_type.dart';
+import 'package:hmg_patient_app_new/features/contact_us/models/req_models/request_insert_coc_item.dart';
import 'package:hmg_patient_app_new/features/contact_us/models/resp_models/get_hmg_locations.dart';
+import 'package:hmg_patient_app_new/features/contact_us/models/resp_models/get_patient_ic_projects.dart';
+import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
class ContactUsViewModel extends ChangeNotifier {
@@ -11,17 +19,43 @@ class ContactUsViewModel extends ChangeNotifier {
bool isHMGLocationsListLoading = false;
bool isHMGHospitalsListSelected = true;
+ bool isLiveChatProjectsListLoading = false;
+ bool isSendFeedbackTabSelected = true;
List hmgHospitalsLocationsList = [];
List hmgPharmacyLocationsList = [];
+ List liveChatProjectsList = [];
+
+ int selectedLiveChatProjectIndex = -1;
+
+ List feedbackAttachmentList = [];
+
+ PatientAppointmentHistoryResponseModel? patientFeedbackSelectedAppointment;
+
+ List feedbackTypeList = [
+ FeedbackType(id: 1, nameEN: "Complaint for appointment", nameAR: 'شكوى على موعد'),
+ FeedbackType(id: 2, nameEN: "Complaint without appointment", nameAR: 'شكوى بدون موعد'),
+ FeedbackType(id: 3, nameEN: "Question", nameAR: 'سؤال'),
+ FeedbackType(id: 4, nameEN: "Appreciation", nameAR: 'تقدير'),
+ FeedbackType(id: 6, nameEN: "Suggestion", nameAR: 'إقتراح'),
+ FeedbackType(id: 5, nameEN: "Not classified", nameAR: 'غير محدد'),
+ ];
+
+ FeedbackType selectedFeedbackType = FeedbackType(id: 5, nameEN: "Not classified", nameAR: 'غير محدد');
+
ContactUsViewModel({required this.contactUsRepo, required this.errorHandlerService, required this.appState});
initContactUsViewModel() {
isHMGLocationsListLoading = true;
isHMGHospitalsListSelected = true;
+ isLiveChatProjectsListLoading = true;
hmgHospitalsLocationsList.clear();
hmgPharmacyLocationsList.clear();
+ liveChatProjectsList.clear();
+ feedbackAttachmentList.clear();
+ selectedFeedbackType = FeedbackType(id: 5, nameEN: "Not classified", nameAR: 'غير محدد');
+ setPatientFeedbackSelectedAppointment(null);
getHMGLocations();
notifyListeners();
}
@@ -31,6 +65,36 @@ class ContactUsViewModel extends ChangeNotifier {
notifyListeners();
}
+ setSelectedLiveChatProjectIndex(int index) {
+ selectedLiveChatProjectIndex = index;
+ notifyListeners();
+ }
+
+ setIsSendFeedbackTabSelected(bool isSelected) {
+ isSendFeedbackTabSelected = isSelected;
+ notifyListeners();
+ }
+
+ setSelectedFeedbackType(FeedbackType feedbackType) {
+ selectedFeedbackType = feedbackType;
+ notifyListeners();
+ }
+
+ addFeedbackAttachment(String attachmentPath) {
+ feedbackAttachmentList.add(attachmentPath);
+ notifyListeners();
+ }
+
+ removeFeedbackAttachment(String attachmentPath) {
+ feedbackAttachmentList.remove(attachmentPath);
+ notifyListeners();
+ }
+
+ setPatientFeedbackSelectedAppointment(PatientAppointmentHistoryResponseModel? appointment) {
+ patientFeedbackSelectedAppointment = appointment;
+ notifyListeners();
+ }
+
Future getHMGLocations({Function(dynamic)? onSuccess, Function(String)? onError}) async {
isHMGLocationsListLoading = true;
hmgHospitalsLocationsList.clear();
@@ -62,4 +126,73 @@ class ContactUsViewModel extends ChangeNotifier {
},
);
}
+
+ Future getLiveChatProjectsList({Function(dynamic)? onSuccess, Function(String)? onError}) async {
+ isLiveChatProjectsListLoading = true;
+ liveChatProjectsList.clear();
+
+ notifyListeners();
+
+ final result = await contactUsRepo.getLiveChatProjectsList();
+
+ result.fold(
+ (failure) async => await errorHandlerService.handleError(failure: failure),
+ (apiResponse) {
+ if (apiResponse.messageStatus == 2) {
+ // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
+ } else if (apiResponse.messageStatus == 1) {
+ liveChatProjectsList = apiResponse.data!;
+ liveChatProjectsList.sort((a, b) => b.distanceInKilometers.compareTo(a.distanceInKilometers));
+ isLiveChatProjectsListLoading = false;
+ notifyListeners();
+ if (onSuccess != null) {
+ onSuccess(apiResponse);
+ }
+ }
+ },
+ );
+ }
+
+ Future insertCOCItem({required String subject, required String message, Function(dynamic)? onSuccess, Function(String)? onError}) async {
+ RequestInsertCOCItem requestInsertCOCItem = RequestInsertCOCItem();
+ requestInsertCOCItem.attachment = feedbackAttachmentList.isNotEmpty ? feedbackAttachmentList.first : "";
+ requestInsertCOCItem.title = subject;
+ requestInsertCOCItem.details = message;
+ requestInsertCOCItem.cOCTypeName = selectedFeedbackType.id.toString();
+ requestInsertCOCItem.formTypeID = selectedFeedbackType.id.toString();
+ requestInsertCOCItem.mobileNo = "966${Utils.getPhoneNumberWithoutZero(appState.getAuthenticatedUser()!.mobileNumber!)}";
+ requestInsertCOCItem.isUserLoggedIn = true;
+ requestInsertCOCItem.projectID = 0;
+ requestInsertCOCItem.patientName = "${appState.getAuthenticatedUser()!.firstName!} ${appState.getAuthenticatedUser()!.lastName!}";
+ requestInsertCOCItem.fileName = "";
+ requestInsertCOCItem.appVersion = ApiConsts.appVersionID;
+ requestInsertCOCItem.uILanguage = appState.isArabic() ? "ar" : "en"; //TODO Change it to be dynamic
+ requestInsertCOCItem.browserInfo = Platform.localHostname;
+ requestInsertCOCItem.deviceInfo = Platform.localHostname;
+ requestInsertCOCItem.resolution = "400x847";
+ requestInsertCOCItem.projectID = 0;
+ requestInsertCOCItem.tokenID = "C0c@@dm!n?T&A&A@Barcha202029582948";
+ requestInsertCOCItem.identificationNo = int.parse(appState.getAuthenticatedUser()!.patientIdentificationNo!);
+ if (BASE_URL.contains('uat')) {
+ requestInsertCOCItem.forDemo = true;
+ } else {
+ requestInsertCOCItem.forDemo = false;
+ }
+
+ final result = await contactUsRepo.insertCOCItem(requestInsertCOCItem: requestInsertCOCItem, patientSelectedAppointment: patientFeedbackSelectedAppointment);
+
+ result.fold(
+ (failure) async => await errorHandlerService.handleError(failure: failure),
+ (apiResponse) {
+ if (apiResponse.messageStatus == 2) {
+ // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
+ } else if (apiResponse.messageStatus == 1) {
+ notifyListeners();
+ if (onSuccess != null) {
+ onSuccess(apiResponse);
+ }
+ }
+ },
+ );
+ }
}
diff --git a/lib/features/contact_us/models/feedback_type.dart b/lib/features/contact_us/models/feedback_type.dart
new file mode 100644
index 00000000..ff1025af
--- /dev/null
+++ b/lib/features/contact_us/models/feedback_type.dart
@@ -0,0 +1,11 @@
+class FeedbackType {
+ final int id;
+ final String nameEN;
+ final String nameAR;
+
+ FeedbackType({
+ required this.id,
+ required this.nameEN,
+ required this.nameAR,
+ });
+}
diff --git a/lib/features/contact_us/models/req_models/request_insert_coc_item.dart b/lib/features/contact_us/models/req_models/request_insert_coc_item.dart
new file mode 100644
index 00000000..e285999c
--- /dev/null
+++ b/lib/features/contact_us/models/req_models/request_insert_coc_item.dart
@@ -0,0 +1,137 @@
+class RequestInsertCOCItem {
+ bool? isUserLoggedIn;
+ String? mobileNo;
+ int? identificationNo;
+ int? patientID;
+ int? patientOutSA;
+ int? patientTypeID;
+ String? tokenID;
+ String? patientName;
+ int? projectID;
+ String? fileName;
+ String? attachment;
+ String? uILanguage;
+ String? browserInfo;
+ String? cOCTypeName;
+ String? formTypeID;
+ String? details;
+ String? deviceInfo;
+ String? deviceType;
+ String? title;
+ String? resolution;
+ double? versionID;
+ int? channel;
+ int? languageID;
+ String? iPAdress;
+ String? generalid;
+ String? sessionID;
+ bool? isDentalAllowedBackend;
+ int? deviceTypeID;
+ int? patientType;
+ double? appVersion;
+ bool? forDemo;
+
+ RequestInsertCOCItem(
+ {this.isUserLoggedIn,
+ this.mobileNo,
+ this.identificationNo,
+ this.patientID,
+ this.patientOutSA,
+ this.patientTypeID,
+ this.tokenID,
+ this.patientName,
+ this.projectID,
+ this.fileName,
+ this.attachment,
+ this.uILanguage,
+ this.browserInfo,
+ this.cOCTypeName,
+ this.formTypeID,
+ this.details,
+ this.deviceInfo,
+ this.deviceType,
+ this.title,
+ this.resolution,
+ this.versionID,
+ this.channel,
+ this.languageID,
+ this.iPAdress,
+ this.generalid,
+ this.sessionID,
+ this.isDentalAllowedBackend,
+ this.deviceTypeID,
+ this.patientType,
+ this.appVersion,
+ this.forDemo});
+
+ RequestInsertCOCItem.fromJson(Map json) {
+ isUserLoggedIn = json['IsUserLoggedIn'];
+ mobileNo = json['MobileNo'];
+ identificationNo = json['IdentificationNo'];
+ patientID = json['PatientID'];
+ patientOutSA = json['PatientOutSA'];
+ patientTypeID = json['PatientTypeID'];
+ tokenID = json['TokenID'];
+ patientName = json['PatientName'];
+ projectID = json['ProjectID'];
+ fileName = json['FileName'];
+ attachment = json['Attachment'];
+ uILanguage = json['UILanguage'];
+ browserInfo = json['BrowserInfo'];
+ cOCTypeName = json['COCTypeName'];
+ formTypeID = json['FormTypeID'];
+ details = json['Details'];
+ deviceInfo = json['DeviceInfo'];
+ deviceType = json['DeviceType'];
+ title = json['Title'];
+ resolution = json['Resolution'];
+ versionID = json['VersionID'];
+ channel = json['Channel'];
+ languageID = json['LanguageID'];
+ iPAdress = json['IPAdress'];
+ generalid = json['generalid'];
+ sessionID = json['SessionID'];
+ isDentalAllowedBackend = json['isDentalAllowedBackend'];
+ deviceTypeID = json['DeviceTypeID'];
+ patientType = json['PatientType'];
+ appVersion = json['AppVersion'];
+ forDemo = json['ForDemo'];
+ }
+
+ Map toJson() {
+ final Map data = new Map();
+ data['IsUserLoggedIn'] = this.isUserLoggedIn;
+ data['MobileNo'] = this.mobileNo;
+ data['IdentificationNo'] = this.identificationNo;
+ data['PatientID'] = this.patientID;
+ data['PatientOutSA'] = this.patientOutSA;
+ data['PatientTypeID'] = this.patientTypeID;
+ data['TokenID'] = this.tokenID;
+ data['PatientName'] = this.patientName;
+ data['ProjectID'] = this.projectID;
+ data['FileName'] = this.fileName;
+ data['Attachment'] = this.attachment;
+ data['UILanguage'] = this.uILanguage;
+ data['BrowserInfo'] = this.browserInfo;
+ data['COCTypeName'] = this.cOCTypeName;
+ data['FormTypeID'] = this.formTypeID;
+ data['Details'] = this.details;
+ data['DeviceInfo'] = this.deviceInfo;
+ data['DeviceType'] = this.deviceType;
+ data['Title'] = this.title;
+ data['Resolution'] = this.resolution;
+ data['VersionID'] = this.versionID;
+ data['Channel'] = this.channel;
+ data['LanguageID'] = this.languageID;
+ data['IPAdress'] = this.iPAdress;
+ data['generalid'] = this.generalid;
+ data['SessionID'] = this.sessionID;
+ data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
+ data['DeviceTypeID'] = this.deviceTypeID;
+ data['PatientType'] = this.patientType;
+ data['AppVersion'] = this.appVersion;
+ data['ForDemo'] = this.forDemo;
+
+ return data;
+ }
+}
diff --git a/lib/features/emergency_services/emergency_services_repo.dart b/lib/features/emergency_services/emergency_services_repo.dart
index b81356ea..c63f0ee6 100644
--- a/lib/features/emergency_services/emergency_services_repo.dart
+++ b/lib/features/emergency_services/emergency_services_repo.dart
@@ -1,3 +1,5 @@
+import 'dart:developer';
+
import 'package:dartz/dartz.dart';
import 'package:hmg_patient_app_new/core/api/api_client.dart';
import 'package:hmg_patient_app_new/core/api_consts.dart';
@@ -6,9 +8,11 @@ import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/request_model/PatientER_RC.dart';
+import 'package:hmg_patient_app_new/features/emergency_services/models/request_model/RRTRequestModel.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/AmbulanceRequestOrdersModel.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/EROnlineCheckInPaymentDetailsResponse.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/ProjectAvgERWaitingTime.dart';
+import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/RRTServiceData.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/rrt_procedures_response_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
import 'package:hmg_patient_app_new/services/logger_service.dart';
@@ -16,7 +20,7 @@ import 'package:hmg_patient_app_new/services/logger_service.dart';
import 'models/resp_model/PatientERTransportationMethod.dart';
abstract class EmergencyServicesRepo {
- Future>>> getRRTProcedures();
+ Future>>> getRRTProcedures(int languageId);
Future>>> getNearestEr({int? id, int? projectID});
@@ -26,10 +30,15 @@ abstract class EmergencyServicesRepo {
Future>> checkPatientERPaymentInformation({int projectID});
- Future>> ER_CreateAdvancePayment(
- {required int projectID, required AuthenticatedUser authUser, required num paymentAmount, required String paymentMethodName, required String paymentReference});
+ Future>> createAdvancePaymentForER(
+ {required int projectID,
+ required AuthenticatedUser authUser,
+ required num paymentAmount,
+ required String paymentMethodName,
+ required String paymentReference});
- Future>> addAdvanceNumberRequest({required String advanceNumber, required String paymentReference, required String appointmentNo});
+ Future>> addAdvanceNumberRequest(
+ {required String advanceNumber, required String paymentReference, required String appointmentNo});
Future>> getProjectIDFromNFC({required String nfcCode});
@@ -37,13 +46,18 @@ abstract class EmergencyServicesRepo {
Future>>> getTransportationMethods({int? id});
-
Future>> submitAmbulanceRequest(PatientER_RC request);
Future>>> getTransportationOrders({int? id});
Future>> cancelOrder(int? iD, int patientId);
+ Future>> submitRRTRequest(RRTRequestModel request);
+
+ Future>> getRRTOrders({int? id});
+
+ Future>> cancelRRTOrder(int? iD);
+ Future>> getTermsAndCondition();
}
class EmergencyServicesRepoImp implements EmergencyServicesRepo {
@@ -68,7 +82,8 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
try {
final list = response['List_ProjectAvgERWaitingTime'];
- final clinicsList = list.map((item) => ProjectAvgERWaitingTime.fromJson(item as Map)).toList().cast();
+ final clinicsList =
+ list.map((item) => ProjectAvgERWaitingTime.fromJson(item as Map)).toList().cast();
apiResponse = GenericApiModel>(
messageStatus: messageStatus,
statusCode: statusCode,
@@ -89,8 +104,8 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
}
@override
- Future>>> getRRTProcedures() async {
- Map mapDevice = {"ProjectID": 15};
+ Future>>> getRRTProcedures(int languageId) async {
+ Map mapDevice = {"ProjectID": 15, "languageID":1};
try {
GenericApiModel>? apiResponse;
@@ -104,7 +119,8 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final list = response['Vida_ProcedureList'];
- final proceduresList = list.map((item) => RRTProceduresResponseModel.fromJson(item as Map)).toList().cast();
+ final proceduresList =
+ list.map((item) => RRTProceduresResponseModel.fromJson(item as Map)).toList().cast();
apiResponse = GenericApiModel>(
messageStatus: messageStatus,
@@ -141,7 +157,10 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final list = response['response']['transportationservices'];
- final proceduresList = list.map((item) => PatientERTransportationMethod.fromJson(item as Map)).toList().cast();
+ final proceduresList = list
+ .map((item) => PatientERTransportationMethod.fromJson(item as Map))
+ .toList()
+ .cast();
apiResponse = GenericApiModel>(
messageStatus: messageStatus,
@@ -240,7 +259,7 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
Failure? failure;
await apiClient.post(
body: {},
- "$GET_ALL_TRANSPORTATIONS_ORDERS?patientID=$id",
+ "$GET_ALL_TRANSPORTATIONS_ORDERS?patientID=$id",
isRCService: true,
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
@@ -248,7 +267,8 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final list = response['response'];
- final proceduresList = list.map((item) => AmbulanceRequestOrdersModel.fromJson(item as Map)).toList().cast();
+ final proceduresList =
+ list.map((item) => AmbulanceRequestOrdersModel.fromJson(item as Map)).toList().cast();
apiResponse = GenericApiModel>(
messageStatus: messageStatus,
@@ -318,13 +338,11 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
await apiClient.post(
CHECK_PATIENT_ER_ADVANCE_BALANCE,
body: mapDevice,
- onFailure: (error, statusCode, {messageStatus, failureType}) {
- failure = failureType;
- },
+ onFailure: (error, statusCode, {messageStatus, failureType}) => failure = failureType,
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final bool patientHasERBalance = response['BalanceAmount'] > 0;
- print(patientHasERBalance);
+ log(patientHasERBalance.toString());
apiResponse = GenericApiModel(
messageStatus: messageStatus,
statusCode: statusCode,
@@ -344,7 +362,6 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
}
}
-
@override
Future>> checkPatientERPaymentInformation({int? projectID}) async {
Map mapDevice = {"ClinicID": 10, "ProjectID": projectID ?? 0};
@@ -381,8 +398,12 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
}
@override
- Future> ER_CreateAdvancePayment(
- {required int projectID, required AuthenticatedUser authUser, required num paymentAmount, required String paymentMethodName, required String paymentReference}) async {
+ Future> createAdvancePaymentForER(
+ {required int projectID,
+ required AuthenticatedUser authUser,
+ required num paymentAmount,
+ required String paymentMethodName,
+ required String paymentReference}) async {
Map mapDevice = {
"LanguageID": 1,
"ERAdvanceAmount": {
@@ -412,7 +433,7 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final vidaAdvanceNumber = response['ER_AdvancePaymentResponse']['AdvanceNumber'].toString();
- print(vidaAdvanceNumber);
+ log(vidaAdvanceNumber);
apiResponse = GenericApiModel(
messageStatus: messageStatus,
statusCode: statusCode,
@@ -433,7 +454,8 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
}
@override
- Future> addAdvanceNumberRequest({required String advanceNumber, required String paymentReference, required String appointmentNo}) async {
+ Future> addAdvanceNumberRequest(
+ {required String advanceNumber, required String paymentReference, required String appointmentNo}) async {
Map requestBody = {
"AdvanceNumber": advanceNumber,
"AdvanceNumber_VP": advanceNumber,
@@ -545,4 +567,155 @@ class EmergencyServicesRepoImp implements EmergencyServicesRepo {
return Left(UnknownFailure(e.toString()));
}
}
+
+ @override
+ Future>> submitRRTRequest(RRTRequestModel request) async {
+ try {
+ GenericApiModel? apiResponse;
+ Failure? failure;
+ await apiClient.post(
+ body: request.toJson(),
+ ADD_RRT_ORDER_RC,
+ isRCService: true,
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ apiResponse = GenericApiModel(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: null,
+ data: true,
+ );
+ } catch (e) {
+ failure = DataParsingFailure(e.toString());
+ }
+ },
+ );
+ if (failure != null) return Left(failure!);
+ if (apiResponse == null) return Left(ServerFailure("Unknown error"));
+ return Right(apiResponse!);
+ } catch (e) {
+ return Left(UnknownFailure(e.toString()));
+ }
+ }
+
+ @override
+ Future>> cancelRRTOrder(int? iD) async{
+ try {
+ GenericApiModel? apiResponse;
+
+ Map request = {"Id": iD, "ClickButton": 14};
+
+ Failure? failure;
+ await apiClient.post(
+ body: request,
+ UPDATE_RRT_ORDER_RC,
+ isRCService: true,
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ apiResponse = GenericApiModel(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: null,
+ data: true,
+ );
+ } catch (e) {
+ failure = DataParsingFailure(e.toString());
+ }
+ },
+ );
+ if (failure != null) return Left(failure!);
+ if (apiResponse == null) return Left(ServerFailure("Unknown error"));
+ return Right(apiResponse!);
+ } catch (e) {
+ return Left(UnknownFailure(e.toString()));
+ }
+
+ }
+
+ @override
+ Future>> getRRTOrders({int? id}) async {
+ try {
+ GenericApiModel? apiResponse;
+ Failure? failure;
+ await apiClient.post(
+ body: {},
+ GET_ALL_RRT_ORDERS_RC,
+ isRCService: true,
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ final list = response['response'];
+
+ RRTServiceData serviceData = RRTServiceData();
+ list.forEach((item) {
+ if (item["StatusId"] == 1 || item["StatusId"] == 2) {
+ // Pending
+ serviceData.pendingOrders.add(GetCMCAllOrdersResponseModel.fromJson(item));
+ }
+ serviceData.completedOrders.add(GetCMCAllOrdersResponseModel.fromJson(item));
+ });
+
+ apiResponse = GenericApiModel(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: null,
+ data: serviceData,
+ );
+ } catch (e) {
+ failure = DataParsingFailure(e.toString());
+ }
+ },
+ );
+ if (failure != null) return Left(failure!);
+ if (apiResponse == null) return Left(ServerFailure("Unknown error"));
+ return Right(apiResponse!);
+ } catch (e) {
+ return Left(UnknownFailure(e.toString()));
+ }
+ }
+
+ @override
+ Future>> getTermsAndCondition() async {
+ try {
+ GenericApiModel? apiResponse;
+ Failure? failure;
+ await apiClient.post(
+ body: {},
+ GET_USER_TERMS,
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ final agreement = response['UserAgreementContent'];
+ apiResponse = GenericApiModel(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: null,
+ data: agreement,
+ );
+
+ } catch (e) {
+ failure = DataParsingFailure(e.toString());
+ }
+ },
+ );
+ if (failure != null) return Left(failure!);
+ if (apiResponse == null) return Left(ServerFailure("Unknown error"));
+ return Right(apiResponse!);
+ } catch (e) {
+ return Left(UnknownFailure(e.toString()));
+ }
+
+ }
+
+
}
diff --git a/lib/features/emergency_services/emergency_services_view_model.dart b/lib/features/emergency_services/emergency_services_view_model.dart
index ec651933..a7130031 100644
--- a/lib/features/emergency_services/emergency_services_view_model.dart
+++ b/lib/features/emergency_services/emergency_services_view_model.dart
@@ -2,22 +2,31 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart' as GMSMapServices;
+import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/location_util.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/doctor_response_mapper.dart';
+import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
+import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
+import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart';
import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_repo.dart';
+import 'package:hmg_patient_app_new/features/emergency_services/models/OrderDisplay.dart';
+import 'package:hmg_patient_app_new/features/emergency_services/models/request_model/RRTRequestModel.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/EROnlineCheckInPaymentDetailsResponse.dart';
+import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/RRTServiceData.dart';
+import 'package:hmg_patient_app_new/features/location/location_view_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/facility_selection.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/AmbulanceCallingPlace.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/request_model/PatientER_RC.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/AmbulanceRequestOrdersModel.dart';
+import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/EROnlineCheckInPaymentDetailsResponse.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/PatientERTransportationMethod.dart'
show PatientERTransportationMethod;
import 'package:hmg_patient_app_new/features/emergency_services/models/resp_model/ProjectAvgERWaitingTime.dart';
@@ -25,23 +34,28 @@ import 'package:hmg_patient_app_new/features/emergency_services/models/resp_mode
import 'package:hmg_patient_app_new/features/location/PlaceDetails.dart' show PlaceDetails;
import 'package:hmg_patient_app_new/features/location/PlacePrediction.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/facility_selection.dart';
-import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/doctor_list_api_response.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_repo.dart';
import 'package:hmg_patient_app_new/presentation/authentication/login.dart';
+import 'package:hmg_patient_app_new/presentation/emergency_services/RRT/rrt_map_screen.dart';
+import 'package:hmg_patient_app_new/presentation/emergency_services/RRT/rrt_request_type_select.dart';
+import 'package:hmg_patient_app_new/presentation/emergency_services/RRT/terms_and_condition.dart';
import 'package:hmg_patient_app_new/presentation/emergency_services/call_ambulance/call_ambulance_page.dart';
-import 'package:hmg_patient_app_new/presentation/emergency_services/er_online_checkin/er_online_checkin_home.dart';
-import 'package:hmg_patient_app_new/presentation/emergency_services/er_online_checkin/er_online_checkin_payment_details_page.dart';
import 'package:hmg_patient_app_new/presentation/emergency_services/call_ambulance/requesting_services_page.dart';
import 'package:hmg_patient_app_new/presentation/emergency_services/call_ambulance/tracking_screen.dart';
+import 'package:hmg_patient_app_new/presentation/emergency_services/er_online_checkin/er_online_checkin_home.dart';
+import 'package:hmg_patient_app_new/presentation/emergency_services/er_online_checkin/er_online_checkin_payment_details_page.dart';
import 'package:hmg_patient_app_new/presentation/emergency_services/nearest_er_page.dart';
import 'package:hmg_patient_app_new/routes/app_routes.dart' show AppRoutes;
import 'package:hmg_patient_app_new/services/dialog_service.dart';
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
+import 'package:hmg_patient_app_new/theme/colors.dart';
+import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
import 'package:hmg_patient_app_new/widgets/expandable_bottom_sheet/model/BottomSheetType.dart';
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
+import 'package:hmg_patient_app_new/widgets/map/map_utility_screen.dart';
import 'package:hmg_patient_app_new/widgets/order_tracking/order_tracking_state.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:huawei_map/huawei_map.dart' as HMSCameraServices;
@@ -71,7 +85,6 @@ class EmergencyServicesViewModel extends ChangeNotifier {
List nearestERList = [];
List nearestERFilteredList = [];
- List RRTProceduresList = [];
List? hospitalList;
List? hmgHospitalList;
@@ -83,7 +96,7 @@ class EmergencyServicesViewModel extends ChangeNotifier {
int hmcCount = 0;
bool pickupFromInsideTheLocation = true;
List? appointments;
- List? orders = [];
+ List? ambulanceOrders = [];
//ambulance selection data section
List transportationOptions = [];
@@ -91,7 +104,6 @@ class EmergencyServicesViewModel extends ChangeNotifier {
AmbulanceCallingPlace callingPlace = AmbulanceCallingPlace.FROM_HOSPITAL;
AmbulanceDirection ambulanceDirection = AmbulanceDirection.ONE_WAY;
- late RRTProceduresResponseModel selectedRRTProcedure;
bool patientHasAdvanceERBalance = false;
bool isERBookAppointment = false;
@@ -99,13 +111,27 @@ class EmergencyServicesViewModel extends ChangeNotifier {
BottomSheetType bottomSheetType = BottomSheetType.FIXED;
+ ///RRT request data
+ List RRTProceduresList = [];
+ RRTProceduresResponseModel? selectedRRTProcedure;
+ bool agreedToTermsAndCondition = false;
+ RRTServiceData? ordersRRT;
+ TextEditingController rrtNotes = TextEditingController();
+
+
+ List allOrders = [];
+ List orderDisplayList = [];
+ bool historyLoading= false;
+ OrderDislpay currentlyDisplayedOrder = OrderDislpay.ALL;
+
+
+
setSelectedRRTProcedure(RRTProceduresResponseModel procedure) {
selectedRRTProcedure = procedure;
notifyListeners();
}
- get isGMSAvailable
- {
+ get isGMSAvailable {
return appState.isGMSAvailable;
}
@@ -132,11 +158,25 @@ class EmergencyServicesViewModel extends ChangeNotifier {
bool isMyAppointmentsLoading = false;
+ String? termsAndConditions;
+
Future getRRTProcedures({Function(dynamic)? onSuccess, Function(String)? onError}) async {
+
+ print("the app state is ${appState.isAuthenticated}");
+ if (!appState.isAuthenticated) {
+ dialogService.showErrorBottomSheet(
+ message: "You Need To Login First To Continue".needTranslation,
+ onOkPressed: () {
+ navServices.pop();
+ getIt().onLoginPressed();
+ });
+ return;
+ }
+
RRTProceduresList.clear();
notifyListeners();
- final result = await emergencyServicesRepo.getRRTProcedures();
+ final result = await emergencyServicesRepo.getRRTProcedures(appState.getLanguageID());
result.fold(
(failure) async => await errorHandlerService.handleError(failure: failure),
@@ -173,7 +213,8 @@ class EmergencyServicesViewModel extends ChangeNotifier {
if (query.isEmpty) {
nearestERFilteredList = nearestERList;
} else {
- nearestERFilteredList = nearestERList.where((er) => er.projectName != null && er.projectName!.toLowerCase().contains(query.toLowerCase())).toList();
+ nearestERFilteredList =
+ nearestERList.where((er) => er.projectName != null && er.projectName!.toLowerCase().contains(query.toLowerCase())).toList();
}
notifyListeners();
}
@@ -232,7 +273,7 @@ class EmergencyServicesViewModel extends ChangeNotifier {
}
handleGMSMapCameraMoved(GMSMapServices.CameraPosition value) {
- //todo handle the camera moved position for GMS devices
+ //todo_section handle the camera moved position for GMS devices
}
HMSCameraServices.CameraPosition getHMSLocation() {
@@ -240,7 +281,7 @@ class EmergencyServicesViewModel extends ChangeNotifier {
}
handleHMSMapCameraMoved(HMSCameraServices.CameraPosition value) {
- //todo handle the camera moved position for HMS devices
+ //todo_section handle the camera moved position for HMS devices
}
void navigateTOAmbulancePage() {
@@ -256,8 +297,7 @@ class EmergencyServicesViewModel extends ChangeNotifier {
onSuccess: (position) {
updateBottomSheetState(BottomSheetType.FIXED);
navServices.push(
- CustomPageRoute(
- page: CallAmbulancePage(), direction: AxisDirection.down),
+ CustomPageRoute(page: CallAmbulancePage(), direction: AxisDirection.down),
);
});
} else {
@@ -265,9 +305,7 @@ class EmergencyServicesViewModel extends ChangeNotifier {
message: "You Need To Login First To Continue".needTranslation,
onOkPressed: () {
navServices.pop();
- navServices.pushAndReplace(
- AppRoutes.loginScreen
- );
+ navServices.pushAndReplace(AppRoutes.loginScreen);
});
}
}
@@ -299,19 +337,20 @@ class EmergencyServicesViewModel extends ChangeNotifier {
void setIsGMSAvailable(bool value) {
notifyListeners();
}
+
Future checkPatientERAdvanceBalance({Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await emergencyServicesRepo.checkPatientERAdvanceBalance();
result.fold(
// (failure) async => await errorHandlerService.handleError(failure: failure),
- (failure) {
+ (failure) {
patientHasAdvanceERBalance = false;
isERBookAppointment = true;
if (onSuccess != null) {
onSuccess(failure.message);
}
},
- (apiResponse) {
+ (apiResponse) {
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
patientHasAdvanceERBalance = false;
@@ -332,12 +371,12 @@ class EmergencyServicesViewModel extends ChangeNotifier {
final result = await emergencyServicesRepo.checkPatientERPaymentInformation(projectID: selectedHospital!.iD);
result.fold(
- (failure) {
+ (failure) {
if (onError != null) {
onError(failure.message);
}
},
- (apiResponse) {
+ (apiResponse) {
if (apiResponse.messageStatus == 2) {
} else if (apiResponse.messageStatus == 1) {
erOnlineCheckInPaymentDetailsResponse = apiResponse.data!;
@@ -350,8 +389,9 @@ class EmergencyServicesViewModel extends ChangeNotifier {
);
}
- Future ER_CreateAdvancePayment({required String paymentMethodName, required String paymentReference, Function(dynamic)? onSuccess, Function(String)? onError}) async {
- final result = await emergencyServicesRepo.ER_CreateAdvancePayment(
+ Future ER_CreateAdvancePayment(
+ {required String paymentMethodName, required String paymentReference, Function(dynamic)? onSuccess, Function(String)? onError}) async {
+ final result = await emergencyServicesRepo.createAdvancePaymentForER(
projectID: selectedHospital!.iD,
authUser: appState.getAuthenticatedUser()!,
paymentAmount: erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!,
@@ -359,12 +399,12 @@ class EmergencyServicesViewModel extends ChangeNotifier {
paymentReference: paymentReference);
result.fold(
- (failure) {
+ (failure) {
if (onError != null) {
onError(failure.message);
}
},
- (apiResponse) {
+ (apiResponse) {
if (apiResponse.messageStatus == 2) {
} else if (apiResponse.messageStatus == 1) {
// erOnlineCheckInPaymentDetailsResponse = apiResponse.data!;
@@ -378,12 +418,17 @@ class EmergencyServicesViewModel extends ChangeNotifier {
}
Future addAdvanceNumberRequest(
- {required String advanceNumber, required String paymentReference, required String appointmentNo, Function(dynamic)? onSuccess, Function(String)? onError}) async {
- final result = await emergencyServicesRepo.addAdvanceNumberRequest(advanceNumber: advanceNumber, paymentReference: paymentReference, appointmentNo: appointmentNo);
+ {required String advanceNumber,
+ required String paymentReference,
+ required String appointmentNo,
+ Function(dynamic)? onSuccess,
+ Function(String)? onError}) async {
+ final result = await emergencyServicesRepo.addAdvanceNumberRequest(
+ advanceNumber: advanceNumber, paymentReference: paymentReference, appointmentNo: appointmentNo);
result.fold(
- (failure) async => await errorHandlerService.handleError(failure: failure),
- (apiResponse) {
+ (failure) async => await errorHandlerService.handleError(failure: failure),
+ (apiResponse) {
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
@@ -401,12 +446,12 @@ class EmergencyServicesViewModel extends ChangeNotifier {
result.fold(
// (failure) async => await errorHandlerService.handleError(failure: failure),
- (failure) {
+ (failure) {
if (onError != null) {
onError(failure.message);
}
},
- (apiResponse) {
+ (apiResponse) {
if (apiResponse.messageStatus == 2) {
if (onError != null) {
onError(apiResponse.errorMessage!);
@@ -426,12 +471,12 @@ class EmergencyServicesViewModel extends ChangeNotifier {
result.fold(
// (failure) async => await errorHandlerService.handleError(failure: failure),
- (failure) {
+ (failure) {
if (onError != null) {
onError(failure.message);
}
},
- (apiResponse) {
+ (apiResponse) {
if (apiResponse.messageStatus == 2) {
if (onError != null) {
onError(apiResponse.data["InvoiceResponse"]["Message"]);
@@ -457,16 +502,13 @@ class EmergencyServicesViewModel extends ChangeNotifier {
onOkPressed: () {
navServices.pop();
print("inside the ok button");
- getIt().onLoginPressed();
+ getIt().onLoginPressed();
});
return;
}
- if (transportationOptions.isNotEmpty) return;
-
int? id = appState.getAuthenticatedUser()?.patientId;
- LoaderBottomSheet.showLoader(
- loadingText: "Getting Ambulance Transport Option".needTranslation);
+ LoaderBottomSheet.showLoader(loadingText: "Getting Ambulance Transport Option".needTranslation);
notifyListeners();
var response = await emergencyServicesRepo.getTransportationMethods(id: id);
@@ -485,8 +527,7 @@ class EmergencyServicesViewModel extends ChangeNotifier {
Future getTransportationMethods() async {
int? id = appState.getAuthenticatedUser()?.patientId;
- LoaderBottomSheet.showLoader(
- loadingText: "Getting Ambulance Transport Option".needTranslation);
+ LoaderBottomSheet.showLoader(loadingText: "Getting Ambulance Transport Option".needTranslation);
notifyListeners();
var response = await emergencyServicesRepo.getTransportationMethods(id: id);
@@ -597,11 +638,7 @@ class EmergencyServicesViewModel extends ChangeNotifier {
sourceList = hmcHospitalList;
break;
}
- displayList = sourceList
- ?.where((hospital) =>
- hospital.name != null &&
- hospital.name!.toLowerCase().contains(query.toLowerCase()))
- .toList();
+ displayList = sourceList?.where((hospital) => hospital.name != null && hospital.name!.toLowerCase().contains(query.toLowerCase())).toList();
notifyListeners();
}
@@ -620,7 +657,6 @@ class EmergencyServicesViewModel extends ChangeNotifier {
notifyListeners();
}
-
void setSelectedHospital(HospitalsModel? hospital) {
selectedHospital = hospital;
notifyListeners();
@@ -668,13 +704,12 @@ class EmergencyServicesViewModel extends ChangeNotifier {
}
Future updateAppointment(bool value) async {
-
if (value) {
await getAppointments();
} else {
clearAppointmentData();
}
- if(appointments?.isNotEmpty == true) {
+ if (appointments?.isNotEmpty == true) {
haveAnAppointment = value;
}
notifyListeners();
@@ -729,18 +764,24 @@ class EmergencyServicesViewModel extends ChangeNotifier {
}
Future getTransportationOrders({bool shouldNavigateToTrackingScreen = false, bool showLoader = false}) async {
- if(shouldNavigateToTrackingScreen == false && showLoader ) {
+ if (shouldNavigateToTrackingScreen == false && showLoader) {
LoaderBottomSheet.showLoader(loadingText: "Fetching Orders");
}
int? id = appState.getAuthenticatedUser()?.patientId;
+ historyLoading = true;
+ notifyListeners();
var response = await emergencyServicesRepo.getTransportationOrders(id: id);
- if(shouldNavigateToTrackingScreen == false && showLoader ) {
- LoaderBottomSheet.hideLoader();}
+ if (shouldNavigateToTrackingScreen == false && showLoader) {
+ LoaderBottomSheet.hideLoader();
+ }
response.fold(
(failure) async {
+ historyLoading = false;
+ notifyListeners();
if (shouldNavigateToTrackingScreen) {
- navServices.pushAndRemoveUntil(CustomPageRoute(page: TrackingScreen(state: OrderTrackingState.waitingForCall)), ModalRoute.withName("/EmergencyServicesPage"));
+ navServices.pushAndRemoveUntil(
+ CustomPageRoute(page: TrackingScreen(state: OrderTrackingState.waitingForCall)), ModalRoute.withName("/EmergencyServicesPage"));
}
},
(apiResponse) {
@@ -753,8 +794,12 @@ class EmergencyServicesViewModel extends ChangeNotifier {
)),
ModalRoute.withName("/EmergencyServicesPage"));
}
-
- orders = apiResponse.data;
+ historyLoading = false;
+ ambulanceOrders = apiResponse.data;
+ allOrders.clear();
+ allOrders.addAll(ambulanceOrders??[]);
+ allOrders.addAll(ordersRRT?.completedOrders??[]);
+ changeOrderDisplayItems(OrderDislpay.ALL);
notifyListeners();
},
);
@@ -828,10 +873,10 @@ class EmergencyServicesViewModel extends ChangeNotifier {
Future cancelOrder(AmbulanceRequestOrdersModel? order, {bool shouldPop = false}) async {
dialogService.showCommonBottomSheetWithoutH(
- message: "Do you want to cancel the order".needTranslation,
+ message: "Do you want to cancel the request".needTranslation,
onOkPressed: () async {
navServices.pop();
- LoaderBottomSheet.showLoader(loadingText: "Cancelling Order".needTranslation);
+ LoaderBottomSheet.showLoader(loadingText: "Cancelling request".needTranslation);
var response = await emergencyServicesRepo.cancelOrder(order?.iD, appState.getAuthenticatedUser()?.patientId ?? 0);
LoaderBottomSheet.hideLoader();
response.fold((failure) => errorHandlerService.handleError(failure: failure), (success) {
@@ -843,4 +888,215 @@ class EmergencyServicesViewModel extends ChangeNotifier {
navServices.pop();
});
}
+
+
+ RRTRequestModel createRRTRequest(GeocodeResult? result, PlaceDetails? place, PlacePrediction? placePrediction){
+ AuthenticatedUser? user = appState.getAuthenticatedUser();
+ if (user == null) throw Exception("Authentication Required to Continue");
+
+ RRTRequestModel rrtRequestModel = new RRTRequestModel();
+ Procedures procedures = new Procedures();
+ rrtRequestModel.procedures = [];
+
+
+ procedures.serviceID = selectedRRTProcedure?.procedureID;
+
+ rrtRequestModel.latitude = ((result?.geometry.location.lat) ?? place?.lat);
+ rrtRequestModel.longitude = ((result?.geometry.location.lat) ?? place?.lat);
+ rrtRequestModel.additionalDetails = "";
+ rrtRequestModel.nationality = user.nationalityId;
+ rrtRequestModel.paymentAmount = selectedRRTProcedure?.patientShareWithTax;
+ rrtRequestModel.nearestProjectId = 0;
+ rrtRequestModel.patientId = user.patientId;
+ rrtRequestModel.patientOutSa = user.outSa;
+ rrtRequestModel.procedures!.add(procedures);
+
+ return rrtRequestModel;
+ }
+
+ ///method to toggle the value for the aggremnent to the terms and conditon for the rrt
+ void setTermsAndConditions(bool value) {
+ agreedToTermsAndCondition = value;
+ notifyListeners();
+ }
+
+ FutureOr submitRRTRequest(GeocodeResult? result, PlaceDetails? place, PlacePrediction? placePrediction) async {
+ RRTRequestModel request = createRRTRequest(result, place, placePrediction);
+ navServices.push(CustomPageRoute(page: RequestingServicesPage()));
+
+ var response = await emergencyServicesRepo.submitRRTRequest(request);
+ response.fold((failure) {
+ navServices.pushAndRemoveUntil(
+ CustomPageRoute(
+ page: TrackingScreen(
+ isRRTOrder: true,
+ state: OrderTrackingState.failed,
+ )),
+ ModalRoute.withName("/EmergencyServicesPage"));
+ }, (success) {
+ getRRTOrders(shouldNavigateToTrackingScreen: true);
+ });
+ }
+
+ Future getRRTOrders({bool shouldNavigateToTrackingScreen = false, bool showLoader = false}) async {
+ if(shouldNavigateToTrackingScreen == false && showLoader ) {
+ LoaderBottomSheet.showLoader(loadingText: "Fetching Orders");
+ }
+ historyLoading = true;
+ notifyListeners();
+ int? id = appState.getAuthenticatedUser()?.patientId;
+
+ var response = await emergencyServicesRepo.getRRTOrders(id: id);
+ if(shouldNavigateToTrackingScreen == false && showLoader ) {
+ LoaderBottomSheet.hideLoader();}
+ response.fold(
+ (failure) async {
+ historyLoading = false;
+ notifyListeners();
+ if (shouldNavigateToTrackingScreen) {
+ navServices.pushAndRemoveUntil(CustomPageRoute(page: TrackingScreen(isRRTOrder: true,state: OrderTrackingState.waitingForCall)), ModalRoute.withName("/EmergencyServicesPage"));
+ }
+ },
+ (apiResponse) {
+ if (shouldNavigateToTrackingScreen) {
+ navServices.pushAndRemoveUntil(
+ CustomPageRoute(
+ page: TrackingScreen(
+ state: OrderTrackingState.waitingForCall,
+ isRRTOrder: true,
+ rrtOrder: apiResponse.data?.pendingOrders.first,
+ )),
+ ModalRoute.withName("/EmergencyServicesPage"));
+ }
+ historyLoading = false;
+ ordersRRT = apiResponse.data;
+ allOrders.clear();
+ allOrders.addAll(ambulanceOrders??[]);
+ allOrders.addAll(ordersRRT?.completedOrders??[]);
+ changeOrderDisplayItems(OrderDislpay.ALL);
+ notifyListeners();
+ },
+ );
+ }
+
+
+ FutureOr cancelRRTOrder(int? orderID, {bool shouldPop = false}) async {
+ dialogService.showCommonBottomSheetWithoutH(
+ message: "Do you want to cancel the request".needTranslation,
+ onOkPressed: () async {
+ navServices.pop();
+ LoaderBottomSheet.showLoader(loadingText: "Cancelling request".needTranslation);
+ var response = await emergencyServicesRepo.cancelRRTOrder(orderID);
+ LoaderBottomSheet.hideLoader();
+ response.fold((failure) => errorHandlerService.handleError(failure: failure), (success) {
+ getRRTOrders();
+ if (shouldPop) navServices.pop();
+ });
+ },
+ onCancelPressed: () {
+ navServices.pop();
+ });
+ }
+
+ void changeOrderDisplayItems(OrderDislpay currentlyDisplayedOrder){
+ this.currentlyDisplayedOrder = currentlyDisplayedOrder;
+ switch(currentlyDisplayedOrder){
+ case OrderDislpay.ALL:
+ orderDisplayList = allOrders;
+ break;
+ case OrderDislpay.RRT:
+ orderDisplayList = ordersRRT?.completedOrders ?? [];
+ break;
+ case OrderDislpay.AMBULANCE:
+ orderDisplayList = ambulanceOrders??[];
+ break;
+ }
+ notifyListeners();
+ }
+
+ void openRRT(){
+ print("the app state is ${appState.isAuthenticated}");
+ if (appState.isAuthenticated) {
+ if(agreedToTermsAndCondition == false){
+ dialogService.showErrorBottomSheet(message: "You Need To Agree To Terms And Conditions".needTranslation, onOkPressed: (){
+ if(navServices.context == null ) return;
+ showCommonBottomSheetWithoutHeight(
+ navServices.context!,
+ padding: EdgeInsets.only(top: 24.h),
+ titleWidget: Transform.flip(
+ flipX: isArabic,
+ child: Utils.buildSvgWithAssets(
+ icon: AppAssets.arrow_back,
+ iconColor: Color(0xff2B353E),
+ fit: BoxFit.contain,
+ ),
+ ).onPress(() {
+ navServices.pop();
+ }),
+ // title: "Rapid Response Team (RRT)".needTranslation,
+ child: RrtRequestTypeSelect(),
+ isFullScreen: false,
+ isCloseButtonVisible: true,
+ hasBottomPadding: false,
+ backgroundColor: AppColors.bottomSheetBgColor,
+ callBackFunc: () {
+ navServices.pop();
+ },
+ );
+ });
+ return;
+ }
+ placeValueInController();
+ locationUtils!.getLocation(
+ isShowConfirmDialog: true,
+ onSuccess: (position) async {
+ updateBottomSheetState(BottomSheetType.FIXED);
+ bool result = await navServices.push(
+ CustomPageRoute(
+ page: MapUtilityScreen(
+ confirmButtonString: "Submit Request".needTranslation,
+ titleString: "Select Location".needTranslation,
+ subTitleString: "Please select the location".needTranslation,
+ isGmsAvailable: appState.isGMSAvailable,
+ ),
+ direction: AxisDirection.down),
+ );
+ if(result){
+ LocationViewModel locationViewModel = getIt.get();
+ GeocodeResponse? response = locationViewModel.geocodeResponse;
+ PlaceDetails? placeDetails = locationViewModel.placeDetails;
+ PlacePrediction? placePrediction = locationViewModel.selectedPrediction;
+ submitRRTRequest(response?.results.first, placeDetails, placePrediction);
+ }
+
+ });
+ } else{
+ dialogService.showErrorBottomSheet(
+ message: "You Need To Login First To Continue".needTranslation,
+ onOkPressed: () {
+ navServices.pop();
+ getIt().onLoginPressed();
+ });
+ }
+ }
+ clearRRTData(){
+ selectedRRTProcedure = null;
+ }
+
+
+ FutureOr getTermsAndConditions() async {
+ LoaderBottomSheet.showLoader(loadingText: "Fetching Terms And Conditions".needTranslation);
+ var response = await emergencyServicesRepo.getTermsAndCondition();
+ LoaderBottomSheet.hideLoader();
+ response.fold((failure)=>errorHandlerService.handleError(failure: failure),(success){
+ termsAndConditions = success.data;
+ print("the response terms are $termsAndConditions");
+ notifyListeners();
+ navServices.push(
+ CustomPageRoute(
+ page: TermsAndCondition(termsAndCondition:success.data??""), direction: AxisDirection.down),
+ );
+ });
+ }
+
}
diff --git a/lib/features/emergency_services/models/OrderDisplay.dart b/lib/features/emergency_services/models/OrderDisplay.dart
new file mode 100644
index 00000000..9f1e929d
--- /dev/null
+++ b/lib/features/emergency_services/models/OrderDisplay.dart
@@ -0,0 +1,3 @@
+enum OrderDislpay{
+ ALL,RRT,AMBULANCE
+}
\ No newline at end of file
diff --git a/lib/features/emergency_services/models/request_model/RRTRequestModel.dart b/lib/features/emergency_services/models/request_model/RRTRequestModel.dart
new file mode 100644
index 00000000..dfb5b1b2
--- /dev/null
+++ b/lib/features/emergency_services/models/request_model/RRTRequestModel.dart
@@ -0,0 +1,75 @@
+class RRTRequestModel {
+ num? patientId;
+ int? patientOutSa;
+ bool? isOutPatient;
+ int? nearestProjectId;
+ num? longitude;
+ num? latitude;
+ String? additionalDetails;
+ String? nationality;
+ num? paymentAmount;
+ List? procedures;
+
+ RRTRequestModel(
+ {this.patientId,
+ this.patientOutSa,
+ this.isOutPatient,
+ this.nearestProjectId,
+ this.longitude,
+ this.latitude,
+ this.additionalDetails,
+ this.nationality,
+ this.paymentAmount,
+ this.procedures});
+
+ RRTRequestModel.fromJson(Map json) {
+ patientId = json['patientId'];
+ patientOutSa = json['patientOutSa'];
+ isOutPatient = json['isOutPatient'];
+ nearestProjectId = json['nearestProjectId'];
+ longitude = json['longitude'];
+ latitude = json['latitude'];
+ additionalDetails = json['additionalDetails'];
+ nationality = json['nationality'];
+ paymentAmount = json['paymentAmount'];
+ if (json['procedures'] != null) {
+ procedures = [];
+ json['procedures'].forEach((v) {
+ procedures!.add(new Procedures.fromJson(v));
+ });
+ }
+ }
+
+ Map toJson() {
+ final Map data = new Map();
+ data['patientId'] = this.patientId;
+ data['patientOutSa'] = this.patientOutSa;
+ data['isOutPatient'] = this.isOutPatient;
+ data['nearestProjectId'] = this.nearestProjectId;
+ data['longitude'] = this.longitude;
+ data['latitude'] = this.latitude;
+ data['additionalDetails'] = this.additionalDetails;
+ data['nationality'] = this.nationality;
+ data['paymentAmount'] = this.paymentAmount;
+ if (this.procedures != null) {
+ data['procedures'] = this.procedures!.map((v) => v.toJson()).toList();
+ }
+ return data;
+ }
+}
+
+class Procedures {
+ String? serviceID;
+
+ Procedures({this.serviceID});
+
+ Procedures.fromJson(Map json) {
+ serviceID = json['ServiceID'];
+ }
+
+ Map toJson() {
+ final Map data = new Map();
+ data['ServiceID'] = this.serviceID;
+ return data;
+ }
+}
diff --git a/lib/features/emergency_services/models/request_model/service_price.dart b/lib/features/emergency_services/models/request_model/service_price.dart
new file mode 100644
index 00000000..abb57be6
--- /dev/null
+++ b/lib/features/emergency_services/models/request_model/service_price.dart
@@ -0,0 +1,53 @@
+class ServicePrice {
+ String? currency;
+ dynamic maxPrice;
+ dynamic maxTotalPrice;
+ dynamic maxVAT;
+ dynamic minPrice;
+ dynamic minTotalPrice;
+ dynamic minVAT;
+ dynamic price;
+ dynamic totalPrice;
+ dynamic vat;
+
+ ServicePrice({
+ this.currency,
+ this.maxPrice,
+ this.maxTotalPrice,
+ this.maxVAT,
+ this.minPrice,
+ this.minTotalPrice,
+ this.minVAT,
+ this.price,
+ this.totalPrice,
+ this.vat});
+
+ ServicePrice.fromJson(dynamic json) {
+ currency = json["Currency"];
+ maxPrice = json["MaxPrice"];
+ maxTotalPrice = json["MaxTotalPrice"];
+ maxVAT = json["MaxVAT"];
+ minPrice = json["MinPrice"];
+ minTotalPrice = json["MinTotalPrice"];
+ minVAT = json["MinVAT"];
+ price = json["Price"];
+ totalPrice = json["TotalPrice"];
+ vat = json["VAT"];
+ }
+
+ Map toJson() {
+ var map = {};
+ map["Currency"] = currency;
+ map["MaxPrice"] = maxPrice;
+ map["MaxTotalPrice"] = maxTotalPrice;
+ map["MaxVAT"] = maxVAT;
+ map["MinPrice"] = minPrice;
+ map["MinTotalPrice"] = minTotalPrice;
+ map["MinVAT"] = minVAT;
+ map["Price"] = price;
+ map["TotalPrice"] = totalPrice;
+ map["VAT"] = vat;
+ return map;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/features/emergency_services/models/resp_model/RRTServiceData.dart b/lib/features/emergency_services/models/resp_model/RRTServiceData.dart
new file mode 100644
index 00000000..e4e7ce7c
--- /dev/null
+++ b/lib/features/emergency_services/models/resp_model/RRTServiceData.dart
@@ -0,0 +1,406 @@
+class RRTServiceData {
+ List pendingOrders = [];
+ List completedOrders = [];
+ ServicePrice servicePrice = ServicePrice();
+}
+
+class GetCMCAllOrdersResponseModel {
+ int? iD;
+ int? patientId;
+ int? patientOutSa;
+ bool? isOutPatient;
+ int? projectId;
+ int? nearestProjectId;
+ dynamic longitude;
+ dynamic latitude;
+ dynamic appointmentNo;
+ dynamic dischargeId;
+ int? statusId;
+ int? serviceId;
+ int? channel;
+ Orderpayment? orderpayment;
+ dynamic orderselectedservice;
+ dynamic wforder;
+ dynamic orderapprovalobj;
+ String? created;
+ dynamic createdBy;
+ dynamic modified;
+ dynamic modifiedBy;
+ bool? isDeleted;
+ String? statusText;
+ int? paymentStatus;
+ dynamic clientRequestid;
+ dynamic paymentStatusText;
+ String? projectName;
+ String? nearestProjectName;
+ dynamic paymentAmount;
+ WFOrder? wFOrder;
+ String? serviceText;
+ bool? isSentForApproval;
+ int? exaCartOrderId;
+ bool? isTimer;
+ int? timeSeconds;
+ int? totalPendingSeconds;
+ int? timeMinute;
+ int? timeHour;
+ int? timeTotalSeconds;
+ int? timeTotalMinute;
+ int? timeTotalHour;
+ dynamic approvalStatus;
+ bool? isActive;
+ int? clickButton;
+ List? procedures;
+ dynamic pickupLocation;
+ dynamic dropOffLocation;
+ dynamic clinicName;
+ dynamic doctorName;
+ dynamic branch;
+ dynamic time;
+ dynamic notes;
+
+ GetCMCAllOrdersResponseModel(
+ {this.iD,
+ this.patientId,
+ this.patientOutSa,
+ this.isOutPatient,
+ this.projectId,
+ this.nearestProjectId,
+ this.longitude,
+ this.latitude,
+ this.appointmentNo,
+ this.dischargeId,
+ this.statusId,
+ this.serviceId,
+ this.channel,
+ this.orderpayment,
+ this.orderselectedservice,
+ this.wforder,
+ this.orderapprovalobj,
+ this.created,
+ this.createdBy,
+ this.modified,
+ this.modifiedBy,
+ this.isDeleted,
+ this.statusText,
+ this.paymentStatus,
+ this.clientRequestid,
+ this.paymentStatusText,
+ this.projectName,
+ this.nearestProjectName,
+ this.paymentAmount,
+ this.wFOrder,
+ this.serviceText,
+ this.isSentForApproval,
+ this.exaCartOrderId,
+ this.isTimer,
+ this.timeSeconds,
+ this.totalPendingSeconds,
+ this.timeMinute,
+ this.timeHour,
+ this.timeTotalSeconds,
+ this.timeTotalMinute,
+ this.timeTotalHour,
+ this.approvalStatus,
+ this.isActive,
+ this.clickButton,
+ this.procedures,
+ this.pickupLocation,
+ this.dropOffLocation,
+ this.clinicName,
+ this.doctorName,
+ this.branch,
+ this.time,
+ this.notes});
+
+ GetCMCAllOrdersResponseModel.fromJson(Map json) {
+ iD = json['ID'];
+ patientId = json['PatientId'];
+ patientOutSa = json['PatientOutSa'];
+ isOutPatient = json['IsOutPatient'];
+ projectId = json['ProjectId'];
+ nearestProjectId = json['NearestProjectId'];
+ longitude = json['Longitude'];
+ latitude = json['Latitude'];
+ appointmentNo = json['AppointmentNo'];
+ dischargeId = json['DischargeId'];
+ statusId = json['StatusId'];
+ serviceId = json['ServiceId'];
+ channel = json['Channel'];
+ orderpayment = json['orderpayment'] != null
+ ? new Orderpayment.fromJson(json['orderpayment'])
+ : null;
+ orderselectedservice = json['orderselectedservice'];
+ wforder = json['wforder'];
+ orderapprovalobj = json['orderapprovalobj'];
+ created = json['Created'];
+ createdBy = json['CreatedBy'];
+ modified = json['Modified'];
+ modifiedBy = json['ModifiedBy'];
+ isDeleted = json['IsDeleted'];
+ statusText = json['StatusText'];
+ paymentStatus = json['PaymentStatus'];
+ clientRequestid = json['ClientRequestid'];
+ paymentStatusText = json['PaymentStatusText'];
+ projectName = json['ProjectName'];
+ nearestProjectName = json['NearestProjectName'];
+ paymentAmount = json['PaymentAmount'];
+ wFOrder = json['WF_order'] != null
+ ? new WFOrder.fromJson(json['WF_order'])
+ : null;
+ serviceText = json['ServiceText'];
+ isSentForApproval = json['isSentForApproval'];
+ exaCartOrderId = json['ExaCart_OrderId'];
+ isTimer = json['isTimer'];
+ timeSeconds = json['TimeSeconds'];
+ totalPendingSeconds = json['TotalPendingSeconds'];
+ timeMinute = json['TimeMinute'];
+ timeHour = json['TimeHour'];
+ timeTotalSeconds = json['TimeTotalSeconds'];
+ timeTotalMinute = json['TimeTotalMinute'];
+ timeTotalHour = json['TimeTotalHour'];
+ approvalStatus = json['ApprovalStatus'];
+ isActive = json['isActive'];
+ clickButton = json['ClickButton'];
+ pickupLocation = json['PickupLocation'];
+ dropOffLocation = json['DropOffLocation'];
+ clinicName = json['clinicName'];
+ doctorName = json['DoctorName'];
+ branch = json['Branch'];
+ time = json['Time'];
+ notes = json['Notes'];
+ }
+
+ Map toJson() {
+ final Map data = new Map();
+ data['ID'] = this.iD;
+ data['PatientId'] = this.patientId;
+ data['PatientOutSa'] = this.patientOutSa;
+ data['IsOutPatient'] = this.isOutPatient;
+ data['ProjectId'] = this.projectId;
+ data['NearestProjectId'] = this.nearestProjectId;
+ data['Longitude'] = this.longitude;
+ data['Latitude'] = this.latitude;
+ data['AppointmentNo'] = this.appointmentNo;
+ data['DischargeId'] = this.dischargeId;
+ data['StatusId'] = this.statusId;
+ data['ServiceId'] = this.serviceId;
+ data['Channel'] = this.channel;
+ if (this.orderpayment != null) {
+ data['orderpayment'] = this.orderpayment!.toJson();
+ }
+ data['orderselectedservice'] = this.orderselectedservice;
+
+ data['wforder'] = this.wforder;
+ data['orderapprovalobj'] = this.orderapprovalobj;
+ data['Created'] = this.created;
+ data['CreatedBy'] = this.createdBy;
+ data['Modified'] = this.modified;
+ data['ModifiedBy'] = this.modifiedBy;
+ data['IsDeleted'] = this.isDeleted;
+ data['StatusText'] = this.statusText;
+ data['PaymentStatus'] = this.paymentStatus;
+ data['ClientRequestid'] = this.clientRequestid;
+ data['PaymentStatusText'] = this.paymentStatusText;
+ data['ProjectName'] = this.projectName;
+ data['NearestProjectName'] = this.nearestProjectName;
+ data['PaymentAmount'] = this.paymentAmount;
+ if (this.wFOrder != null) {
+ data['WF_order'] = this.wFOrder!.toJson();
+ }
+ data['ServiceText'] = this.serviceText;
+ data['isSentForApproval'] = this.isSentForApproval;
+ data['ExaCart_OrderId'] = this.exaCartOrderId;
+ data['isTimer'] = this.isTimer;
+ data['TimeSeconds'] = this.timeSeconds;
+ data['TotalPendingSeconds'] = this.totalPendingSeconds;
+ data['TimeMinute'] = this.timeMinute;
+ data['TimeHour'] = this.timeHour;
+ data['TimeTotalSeconds'] = this.timeTotalSeconds;
+ data['TimeTotalMinute'] = this.timeTotalMinute;
+ data['TimeTotalHour'] = this.timeTotalHour;
+ data['ApprovalStatus'] = this.approvalStatus;
+ data['isActive'] = this.isActive;
+ data['ClickButton'] = this.clickButton;
+ data['PickupLocation'] = this.pickupLocation;
+ data['DropOffLocation'] = this.dropOffLocation;
+ data['clinicName'] = this.clinicName;
+ data['DoctorName'] = this.doctorName;
+ data['Branch'] = this.branch;
+ data['Time'] = this.time;
+ data['Notes'] = this.notes;
+ return data;
+ }
+}
+
+class Orderpayment {
+ int? iD;
+ int? orderId;
+ dynamic clientRequestId;
+ dynamic totalAmount;
+ int? paymentStatus;
+ dynamic order;
+ String? created;
+ dynamic createdBy;
+ dynamic modified;
+ dynamic modifiedBy;
+ bool? isDeleted;
+
+ Orderpayment(
+ {this.iD,
+ this.orderId,
+ this.clientRequestId,
+ this.totalAmount,
+ this.paymentStatus,
+ this.order,
+ this.created,
+ this.createdBy,
+ this.modified,
+ this.modifiedBy,
+ this.isDeleted});
+
+ Orderpayment.fromJson(Map json) {
+ iD = json['ID'];
+ orderId = json['OrderId'];
+ clientRequestId = json['ClientRequestId'];
+ totalAmount = json['TotalAmount'];
+ paymentStatus = json['PaymentStatus'];
+ order = json['Order'];
+ created = json['Created'];
+ createdBy = json['CreatedBy'];
+ modified = json['Modified'];
+ modifiedBy = json['ModifiedBy'];
+ isDeleted = json['IsDeleted'];
+ }
+
+ Map toJson() {
+ final Map data = new Map();
+ data['ID'] = this.iD;
+ data['OrderId'] = this.orderId;
+ data['ClientRequestId'] = this.clientRequestId;
+ data['TotalAmount'] = this.totalAmount;
+ data['PaymentStatus'] = this.paymentStatus;
+ data['Order'] = this.order;
+ data['Created'] = this.created;
+ data['CreatedBy'] = this.createdBy;
+ data['Modified'] = this.modified;
+ data['ModifiedBy'] = this.modifiedBy;
+ data['IsDeleted'] = this.isDeleted;
+ return data;
+ }
+}
+
+class WFOrder {
+ dynamic wfButtonsDTO;
+ int? iD;
+ int? orderId;
+ int? previousStep;
+ int? nextStep;
+ int? serviceId;
+ dynamic order;
+ String? created;
+ dynamic createdBy;
+ dynamic modified;
+ dynamic modifiedBy;
+ bool? isDeleted;
+
+ WFOrder(
+ {this.wfButtonsDTO,
+ this.iD,
+ this.orderId,
+ this.previousStep,
+ this.nextStep,
+ this.serviceId,
+ this.order,
+ this.created,
+ this.createdBy,
+ this.modified,
+ this.modifiedBy,
+ this.isDeleted});
+
+ WFOrder.fromJson(Map json) {
+ wfButtonsDTO = json['wf_ButtonsDTO'];
+ iD = json['ID'];
+ orderId = json['OrderId'];
+ previousStep = json['PreviousStep'];
+ nextStep = json['NextStep'];
+ serviceId = json['ServiceId'];
+ order = json['Order'];
+ created = json['Created'];
+ createdBy = json['CreatedBy'];
+ modified = json['Modified'];
+ modifiedBy = json['ModifiedBy'];
+ isDeleted = json['IsDeleted'];
+ }
+
+ Map toJson() {
+ final Map data = new Map();
+ data['wf_ButtonsDTO'] = this.wfButtonsDTO;
+ data['ID'] = this.iD;
+ data['OrderId'] = this.orderId;
+ data['PreviousStep'] = this.previousStep;
+ data['NextStep'] = this.nextStep;
+ data['ServiceId'] = this.serviceId;
+ data['Order'] = this.order;
+ data['Created'] = this.created;
+ data['CreatedBy'] = this.createdBy;
+ data['Modified'] = this.modified;
+ data['ModifiedBy'] = this.modifiedBy;
+ data['IsDeleted'] = this.isDeleted;
+ return data;
+ }
+}
+
+
+class ServicePrice {
+ String? currency;
+ dynamic maxPrice;
+ dynamic maxTotalPrice;
+ dynamic maxVAT;
+ dynamic minPrice;
+ dynamic minTotalPrice;
+ dynamic minVAT;
+ dynamic price;
+ dynamic totalPrice;
+ dynamic vat;
+
+ ServicePrice({
+ this.currency,
+ this.maxPrice,
+ this.maxTotalPrice,
+ this.maxVAT,
+ this.minPrice,
+ this.minTotalPrice,
+ this.minVAT,
+ this.price,
+ this.totalPrice,
+ this.vat});
+
+ ServicePrice.fromJson(dynamic json) {
+ currency = json["Currency"];
+ maxPrice = json["MaxPrice"];
+ maxTotalPrice = json["MaxTotalPrice"];
+ maxVAT = json["MaxVAT"];
+ minPrice = json["MinPrice"];
+ minTotalPrice = json["MinTotalPrice"];
+ minVAT = json["MinVAT"];
+ price = json["Price"];
+ totalPrice = json["TotalPrice"];
+ vat = json["VAT"];
+ }
+
+ Map toJson() {
+ var map = {};
+ map["Currency"] = currency;
+ map["MaxPrice"] = maxPrice;
+ map["MaxTotalPrice"] = maxTotalPrice;
+ map["MaxVAT"] = maxVAT;
+ map["MinPrice"] = minPrice;
+ map["MinTotalPrice"] = minTotalPrice;
+ map["MinVAT"] = minVAT;
+ map["Price"] = price;
+ map["TotalPrice"] = totalPrice;
+ map["VAT"] = vat;
+ return map;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/features/hmg_services/hmg_services_repo.dart b/lib/features/hmg_services/hmg_services_repo.dart
new file mode 100644
index 00000000..254d3098
--- /dev/null
+++ b/lib/features/hmg_services/hmg_services_repo.dart
@@ -0,0 +1,522 @@
+import 'dart:developer';
+
+import 'package:dartz/dartz.dart';
+import 'package:hmg_patient_app_new/core/api/api_client.dart';
+import 'package:hmg_patient_app_new/core/api_consts.dart';
+import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart';
+import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart';
+import 'package:hmg_patient_app_new/features/hmg_services/models/req_models/cmc_create_new_order_req_model.dart';
+import 'package:hmg_patient_app_new/features/hmg_services/models/req_models/order_update_req_model.dart';
+import 'package:hmg_patient_app_new/features/hmg_services/models/resq_models/get_cmc_all_orders_resp_model.dart';
+import 'package:hmg_patient_app_new/features/hmg_services/models/resq_models/get_cmc_services_resp_model.dart';
+import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
+import 'package:hmg_patient_app_new/services/logger_service.dart';
+
+abstract class HmgServicesRepo {
+ Future>>> getAllComprehensiveCheckupOrders();
+
+ Future>>> getAllHomeHealthCareCheckupOrders();
+
+ Future>> updateCmcPresOrder(OrderUpdateRequestModel requestModel);
+
+ Future>> updateHhcPresOrder(OrderUpdateRequestModel requestModel);
+
+ Future>>> getAllCmcServices({required int patientID});
+
+ Future>>> getAllHhcServices({required int patientID});
+
+ Future>>> getHospitalsList();
+
+ Future>> addCmcOrder({
+ required int projectID,
+ required int orderServiceID,
+ required List services,
+ });
+
+ Future>> addHhcOrder({
+ required int projectID,
+ required int orderServiceID,
+ required List services,
+ });
+}
+
+class HmgServicesRepoImp implements HmgServicesRepo {
+ final ApiClient apiClient;
+ final LoggerService loggerService;
+
+ HmgServicesRepoImp({required this.apiClient, required this.loggerService});
+
+ @override
+ Future>>> getAllComprehensiveCheckupOrders() async {
+ Map requestBody = {};
+
+ try {
+ GenericApiModel>? apiResponse;
+ Failure? failure;
+
+ await apiClient.post(
+ ApiConsts.allCMCOrdersRc,
+ isRCService: true,
+ body: requestBody,
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ loggerService.logError("CMC Orders API Failed: $error, Status: $statusCode");
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ List cmcOrdersList = [];
+ // Log the full response for debugging
+ // Extract MessageStatus and ErrorEndUserMessage from root level
+ final apiErrorMessage = response['ErrorEndUserMessage'] as String?;
+ // Parse the response array
+ if (response['response'] != null && response['response'] is List) {
+ final ordersList = response['response'] as List;
+
+ for (var orderJson in ordersList) {
+ if (orderJson is Map) {
+ try {
+ cmcOrdersList.add(GetCMCAllOrdersResponseModel.fromJson(orderJson));
+ } catch (e) {
+ loggerService.logError("Error parsing individual order: ${e.toString()}");
+ }
+ }
+ }
+ }
+
+ apiResponse = GenericApiModel>(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: apiErrorMessage ?? errorMessage,
+ data: cmcOrdersList,
+ );
+ } catch (e) {
+ loggerService.logError("Error parsing CMC orders: ${e.toString()}");
+ failure = DataParsingFailure(e.toString());
+ }
+ },
+ );
+
+ if (failure != null) return Left(failure!);
+ if (apiResponse == null) return Left(ServerFailure("Unknown error"));
+ return Right(apiResponse!);
+ } catch (e) {
+ loggerService.logError("Unknown error in getAllCmcOrders: ${e.toString()}");
+ return Left(UnknownFailure(e.toString()));
+ }
+ }
+
+ @override
+ Future>>> getAllHomeHealthCareCheckupOrders() async {
+ Map requestBody = {};
+
+ try {
+ GenericApiModel>? apiResponse;
+ Failure? failure;
+
+ await apiClient.post(
+ ApiConsts.allHHCOrdersRc,
+ isRCService: true,
+ body: requestBody,
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ loggerService.logError("HHC Orders API Failed: $error, Status: $statusCode");
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ List cmcOrdersList = [];
+ // Log the full response for debugging
+ // Extract MessageStatus and ErrorEndUserMessage from root level
+ final apiErrorMessage = response['ErrorEndUserMessage'] as String?;
+ // Parse the response array
+ if (response['response'] != null && response['response'] is List) {
+ final ordersList = response['response'] as List;
+
+ for (var orderJson in ordersList) {
+ if (orderJson is Map) {
+ try {
+ cmcOrdersList.add(GetCMCAllOrdersResponseModel.fromJson(orderJson));
+ } catch (e) {
+ loggerService.logError("Error parsing individual order: ${e.toString()}");
+ }
+ }
+ }
+ }
+
+ apiResponse = GenericApiModel>(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: apiErrorMessage ?? errorMessage,
+ data: cmcOrdersList,
+ );
+ } catch (e) {
+ loggerService.logError("Error parsing HHC orders: ${e.toString()}");
+ failure = DataParsingFailure(e.toString());
+ }
+ },
+ );
+
+ if (failure != null) return Left(failure!);
+ if (apiResponse == null) return Left(ServerFailure("Unknown error"));
+ return Right(apiResponse!);
+ } catch (e) {
+ loggerService.logError("Unknown error in getAllHHCOrders: ${e.toString()}");
+ return Left(UnknownFailure(e.toString()));
+ }
+ }
+
+ @override
+ Future>>> getAllCmcServices({required int patientID}) async {
+ Map