diff --git a/assets/images/svg/ai_overview.svg b/assets/images/svg/ai_overview.svg
new file mode 100644
index 0000000..95c29aa
--- /dev/null
+++ b/assets/images/svg/ai_overview.svg
@@ -0,0 +1,19 @@
+
diff --git a/assets/images/svg/calculator_icon.svg b/assets/images/svg/calculator_icon.svg
new file mode 100644
index 0000000..989a4db
--- /dev/null
+++ b/assets/images/svg/calculator_icon.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/images/svg/guard_icon.svg b/assets/images/svg/guard_icon.svg
new file mode 100644
index 0000000..e3a68d9
--- /dev/null
+++ b/assets/images/svg/guard_icon.svg
@@ -0,0 +1,5 @@
+
diff --git a/assets/images/svg/high_caution.svg b/assets/images/svg/high_caution.svg
new file mode 100644
index 0000000..d268468
--- /dev/null
+++ b/assets/images/svg/high_caution.svg
@@ -0,0 +1,5 @@
+
diff --git a/assets/images/svg/information-circle.svg b/assets/images/svg/information-circle.svg
new file mode 100644
index 0000000..f1a850e
--- /dev/null
+++ b/assets/images/svg/information-circle.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json
index 178b4c0..3df6041 100644
--- a/assets/langs/ar-SA.json
+++ b/assets/langs/ar-SA.json
@@ -1526,8 +1526,48 @@
"trackerAndOthers": "المتتبع وأخرى",
"bmi": "مؤشر كتلة الجسم",
"yesPleaseINeedHelp": "نعم، من فضلك أريد المساعدة",
- "noThanksIKnowTheClinic": "لا شكراً، أعرف العيادة"
- "unableToSendOTP": "تعذر إرسال رمز التحقق لمرة واحدة"
+ "noThanksIKnowTheClinic": "لا شكراً، أعرف العيادة",
+ "unableToSendOTP": "تعذر إرسال رمز التحقق لمرة واحدة",
+ "aiOverView": "AI ملخص",
+ "generateAiAnalysis": "قم بإجراء تحليل لهذا الطلب AI",
+ "aiAnalysis": "AI تحليل",
+ "prediction": "تنبؤ",
+ "prevention": "وقاية",
+ "disclaimer": "تنصل",
+ "thisAboveInfo": "المعلومات المذكورة أعلاه تم إنشاؤها بواسطة AI",
+ "aiDisclaimer": "سيتم مشاركة بيانات نتائج تحاليلك المخبرية بشكل آمن مع خدمة الذكاء الاصطناعي لدينا لتحليلها. يساعد هذا في تقديم رؤى صحية مُخصصة. هل ترغب في المتابعة؟",
+ "consent": "موافقة",
+ "bmiNormalDescription": "مؤشر كتلة جسمك ضمن المعدل الصحي. استمر في اتباع نظام غذائي متوازن، وممارسة النشاط البدني بانتظام، وإجراء الفحوصات الدورية للحفاظ على صحة جيدة. راقب أي تغييرات ملحوظة مع مرور الوقت.",
+ "bmiUnderweightDescription": "يشير مؤشر كتلة الجسم إلى أنك تعاني من نقص الوزن. لذا، يُنصح بزيادة السعرات الحرارية المتناولة من خلال تناول الأطعمة الغنية بالعناصر الغذائية، وممارسة تمارين المقاومة لبناء العضلات، واستشارة أخصائي رعاية صحية للتحقق من وجود أسباب كامنة.",
+ "bmiOverweightDescription": "يشير مؤشر كتلة الجسم إلى زيادة الوزن. لذا، يُنصح بالسعي إلى إنقاص الوزن تدريجياً وبشكل مستدام من خلال تقليل السعرات الحرارية بشكل معتدل، وممارسة النشاط البدني بانتظام، واختيار الأطعمة الصحية. استشر طبيبك قبل إجراء أي تغييرات جذرية في نمط حياتك.",
+ "caloriesMaintenanceDescription": "السعرات الحرارية اليومية المُقدَّرة للحفاظ على وزنك الحالي بناءً على مستوى نشاطك ومعدل الأيض لديك. استخدم هذه الكمية كخط أساس: زدها قليلاً لزيادة الكتلة العضلية، أو قللها قليلاً لإنقاص الوزن تدريجياً. تابع تقدمك وعدّل الخطة كل أسبوعين إلى أربعة أسابيع.",
+ "caloriesModerateDeficitDescription": "نظام غذائي معتدل لتقليل السعرات الحرارية مصمم لإنقاص الوزن بشكل ثابت ومستدام (عادةً من 0.25 إلى 0.5 كيلوغرام أسبوعيًا). يُنصح بدمجه مع تمارين المقاومة وتناول كمية كافية من البروتين للحفاظ على الكتلة العضلية. تجنب التخفيضات الحادة في السعرات الحرارية واستشر طبيبًا مختصًا إذا كنت تعاني من أي حالة صحية.",
+ "caloriesAggressiveDeficitDescription": "يؤدي خفض السعرات الحرارية بشكل كبير إلى فقدان الوزن بشكل أسرع، ولكنه قد يصعب الاستمرار عليه ويزيد من خطر نقص العناصر الغذائية والإرهاق وفقدان الكتلة العضلية. لا يُنصح باتباعه على المدى الطويل؛ استشر طبيبًا أو أخصائي تغذية قبل الاستمرار.",
+ "bodyFatEssentialDescription": "نسبة الدهون في جسمك ضمن النطاق الأساسي/الرياضي. هذا المستوى شائع لدى الرياضيين ويشير إلى انخفاض نسبة الدهون في الجسم. مع أن هذا قد يكون مثاليًا للأداء، تأكد من الحفاظ على تغذية سليمة ووظائف هرمونية متوازنة. استشر طبيبًا إذا شعرت بالتعب، أو واجهت مشاكل هرمونية، أو أي مخاوف صحية أخرى.",
+ "bodyFatFitnessDescription": "نسبة الدهون في جسمك ضمن النطاق الصحي. وهذا يدل على مستوى صحي من الدهون في الجسم يرتبط بلياقة بدنية جيدة. حافظ على نمط حياتك الحالي، بما في ذلك ممارسة الرياضة بانتظام واتباع نظام غذائي متوازن، للحفاظ على هذا المستوى الصحي.",
+ "bodyFatAverageDescription": "نسبة الدهون في جسمك ضمن المعدل الطبيعي/المقبول، وهي نسبة تُعتبر صحية لعموم الناس. لتحسين تكوين جسمك، يُنصح بممارسة تمارين القوة، وتمارين القلب والأوعية الدموية، واتباع نظام غذائي متوازن. ركّز على التغييرات التدريجية والمستدامة للحفاظ على صحتك على المدى الطويل.",
+ "bodyFatObeseDescription": "نسبة الدهون في جسمك أعلى من المعدل الصحي الموصى به. قد يزيد هذا من المخاطر الصحية، بما في ذلك أمراض القلب والأوعية الدموية، والسكري، ومشاكل المفاصل. يُنصح باستشارة طبيب أو أخصائي تغذية معتمد لوضع خطة علاجية شخصية تشمل التغذية المتوازنة، والنشاط البدني المنتظم، وتعديلات نمط الحياة لتحقيق إدارة مستدامة للوزن.",
+ "bmrNormalDescription": "معدل الأيض الأساسي لديك ضمن النطاق المتوقع لحالتك. معدل الأيض الأساسي هو الطاقة التي يحتاجها جسمك في حالة الراحة للحفاظ على وظائفه الحيوية (التنفس، الدورة الدموية، درجة الحرارة). استخدم هذه القيمة كأساس لتقدير إجمالي احتياجاتك اليومية من الطاقة من خلال تطبيق مُعامل النشاط. حافظ على نظام غذائي متوازن وممارسة النشاط البدني بانتظام لدعم صحة التمثيل الغذائي.",
+ "bmrLowDescription": "معدل الأيض الأساسي لديك أقل من المعدل الطبيعي لحالتك. تشمل الأسباب المحتملة انخفاض كتلة العضلات، أو تراجع التمثيل الغذائي المرتبط بالتقدم في السن، أو التكيف الأيضي الناتج عن تقييد السعرات الحرارية لفترة طويلة. يُنصح بالتركيز على تمارين المقاومة لبناء العضلات والحفاظ عليها، والتأكد من تناول كميات كافية من البروتين والمغذيات الدقيقة، واستشارة أخصائي رعاية صحية إذا كان هذا الأمر غير متوقع.",
+ "bmrHighDescription": "معدل الأيض الأساسي لديك أعلى من المتوسط \u200B\u200Bبالنسبة لحالتك. قد يعكس هذا زيادة في كتلة العضلات، أو صغر السن، أو ارتفاع معدل الأيض لديك بشكل طبيعي، مما يعني أنك تحرق طاقة أكبر أثناء الراحة. استخدم هذه المعلومات لتحديد احتياجاتك من السعرات الحرارية: احتياجات أعلى للحفاظ على الوزن أو بناء العضلات، ونقص معتدل في السعرات الحرارية لإنقاص الوزن. استشر طبيبك إذا لاحظت أي تغيرات سريعة غير مبررة.",
+ "ibwAtTargetDescription": "Your weight is at the ideal target. Maintain your current habits — balanced diet and regular activity — to keep this.",
+ "ibwBelowTargetDescription": "You are below the ideal weight by {kg} kg. Aim to gradually increase weight with a modest calorie surplus, nutrient-dense foods, and resistance training.",
+ "ibwAboveTargetDescription": "You are above the ideal weight by {kg} kg. Aim for a gradual, sustainable weight reduction through a moderate calorie deficit, increased activity, and balanced nutrition.",
+ "ibwCloseToRangeDescription": "Your weight is close to the ideal range. Maintain a balanced diet and regular activity; follow personalized advice from a healthcare professional if needed.",
+ "ibwUnderweightDescription": "You are below the ideal weight by {kg} kg. Focus on increasing calorie intake with nutrient-dense foods, prioritize protein and resistance training to build healthy mass, and consider consulting a healthcare professional.",
+ "ibwUnderweightGenericDescription": "You appear underweight compared to the ideal. Consider increasing calorie intake with nutrient-dense foods and resistance training; seek professional guidance if needed.",
+ "ibwOverweightDescription": "You are above the ideal weight by {kg} kg. Aim for a gradual, sustainable weight loss strategy — moderate calorie deficit, regular physical activity, and balanced nutrition. Consult a professional before major changes.",
+ "ibwOverweightGenericDescription": "You appear above the ideal weight. Consider a gradual, sustainable calorie deficit combined with activity and balanced nutrition; consult a professional if needed.",
+ "dietVeryLowCarbsDescription": "Very low‑carb (ketogenic) approach: minimal carbohydrates, higher fat and moderate protein. May support rapid weight loss and improved blood sugar control for some, but can be hard to sustain and may cause nutrient gaps. Monitor hydration/electrolytes and consult a professional for long‑term use.",
+ "dietLowCarbsDescription": "Low‑carb, higher‑protein plan: reduced carbohydrates with increased protein to support satiety and muscle maintenance. Helpful for weight management and glycemic control when balanced with vegetables and healthy fats. Ensure adequate fiber and micronutrients.",
+ "dietModerateCarbsDescription": "Moderate carbohydrate intake with balanced protein and fats: provides steady energy for daily activity and exercise while allowing flexibility. Suitable for many people aiming for sustainable weight management and performance.",
+ "dietUSDAGuidelinesDescription": "USDA‑based balanced pattern: emphasizes fruits, vegetables, whole grains, lean proteins, and limited added sugars and saturated fats. Evidence‑based framework for general health, nutrient adequacy, and chronic disease prevention.",
+ "dietZoneDietDescription": "Zone Diet (~40% carbs / 30% protein / 30% fat): emphasizes hormonal balance and portion control. May improve body composition and energy for some, but requires planning; personalize with a nutrition professional.",
+ "contextDependent": "يعتمد السياق",
+ "calculatedValue": "القيمة المحسوبة",
+ "calculationFormula": "صيغة الحساب"
+
+
}
diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json
index d6f5228..7799807 100644
--- a/assets/langs/en-US.json
+++ b/assets/langs/en-US.json
@@ -1517,8 +1517,46 @@
"trackerAndOthers": "Tracker & Others",
"bmi": "BMI",
"yesPleaseINeedHelp": "Yes, Please I need help",
- "noThanksIKnowTheClinic": "No, Thanks. I Know the clinic"
- "unableToSendOTP": "Unable to send Verification OTP"
+ "noThanksIKnowTheClinic": "No, Thanks. I Know the clinic",
+ "unableToSendOTP": "Unable to send Verification OTP",
+ "aiOverView": "AI Overview",
+ "generateAiAnalysis": "Generate AI analysis for this order",
+ "aiAnalysis": "AI Analysis",
+ "prediction": "Prediction",
+ "prevention": "Prevention",
+ "disclaimer": "Disclaimer",
+ "thisAboveInfo": "The above information is generated by",
+ "aiDisclaimer": "Your lab result data will be securely shared with our AI service for analysis. This helps provide personalized health insights. Do you want to proceed?",
+ "consent": "Consent",
+ "bmiNormalDescription": "Your BMI is within the healthy range. Continue a balanced diet, regular physical activity, and routine checkups to maintain good health. Monitor any significant changes over time.",
+ "bmiUnderweightDescription": "BMI suggests you are underweight. Consider increasing calorie intake with nutrient-dense foods, include resistance training to build muscle, and consult a healthcare professional to check for underlying causes.",
+ "bmiOverweightDescription": "BMI indicates overweight. Aim for gradual, sustainable weight loss through a modest calorie deficit, regular physical activity, and healthier food choices. Seek medical advice before major lifestyle changes.",
+ "caloriesMaintenanceDescription": "Estimated daily calories to maintain your current weight given your activity level and metabolism. Use this as a baseline: increase slightly for muscle gain, or create a small deficit for gradual weight loss. Track progress and adjust every 2–4 weeks.",
+ "caloriesModerateDeficitDescription": "A moderate calorie reduction designed for steady, sustainable weight loss (typically 0.25–0.5 kg per week). Combine with resistance training and adequate protein to preserve muscle. Avoid extreme cuts and consult a professional if you have medical conditions.",
+ "caloriesAggressiveDeficitDescription": "A large calorie reduction that may produce faster weight loss but can be hard to sustain and increase risk of nutrient deficiencies, fatigue, or muscle loss. Not recommended long-term; seek guidance from a healthcare or nutrition professional before continuing.",
+ "bodyFatEssentialDescription": "Your body fat percentage is in the essential/athletic range. This level is typical for athletes and indicates very low body fat. While this may be optimal for performance, ensure you maintain adequate nutrition and hormone function. Consult a healthcare professional if you experience fatigue, hormonal issues, or other health concerns.",
+ "bodyFatFitnessDescription": "Your body fat percentage is in the fitness range. This indicates a healthy level of body fat associated with good physical conditioning. Maintain your current lifestyle habits including regular exercise and balanced nutrition to sustain this healthy range.",
+ "bodyFatAverageDescription": "Your body fat percentage is in the average/acceptable range. This is considered a healthy range for general population. To improve body composition, consider incorporating strength training, cardiovascular exercise, and a balanced diet. Focus on gradual, sustainable changes for long-term health.",
+ "bodyFatObeseDescription": "Your body fat percentage is above the recommended healthy range. This may increase health risks including cardiovascular disease, diabetes, and joint problems. Consider consulting a healthcare provider or registered dietitian to develop a personalized plan that includes balanced nutrition, regular physical activity, and lifestyle modifications for sustainable weight management.",
+ "bmrNormalDescription": "Your Basal Metabolic Rate (BMR) is within the expected range for your profile. BMR is the energy your body needs at rest to maintain vital functions (breathing, circulation, temperature). Use this value as the baseline for estimating total daily energy needs by applying an activity multiplier. Maintain a balanced diet and regular physical activity to support metabolic health.",
+ "bmrLowDescription": "Your BMR is lower than typical for your profile. Possible causes include lower lean muscle mass, age-related metabolic decline, or metabolic adaptation from prolonged calorie restriction. Consider focusing on resistance training to build/maintain muscle, ensure adequate protein and micronutrient intake, and consult a healthcare professional if this is unexpected.",
+ "bmrHighDescription": "Your BMR is higher than average for your profile. This can reflect greater lean mass, younger age, or a naturally higher metabolic rate, meaning you burn more energy at rest. Use this information to tailor calorie targets: higher needs for maintenance or muscle gain, moderate deficit for weight loss. Seek medical advice if you notice rapid unexplained changes.",
+ "ibwAtTargetDescription": "Your weight is at the ideal target. Maintain your current habits — balanced diet and regular activity — to keep this.",
+ "ibwBelowTargetDescription": "You are below the ideal weight by {kg} kg. Aim to gradually increase weight with a modest calorie surplus, nutrient-dense foods, and resistance training.",
+ "ibwAboveTargetDescription": "You are above the ideal weight by {kg} kg. Aim for a gradual, sustainable weight reduction through a moderate calorie deficit, increased activity, and balanced nutrition.",
+ "ibwCloseToRangeDescription": "Your weight is close to the ideal range. Maintain a balanced diet and regular activity; follow personalized advice from a healthcare professional if needed.",
+ "ibwUnderweightDescription": "You are below the ideal weight by {kg} kg. Focus on increasing calorie intake with nutrient-dense foods, prioritize protein and resistance training to build healthy mass, and consider consulting a healthcare professional.",
+ "ibwUnderweightGenericDescription": "You appear underweight compared to the ideal. Consider increasing calorie intake with nutrient-dense foods and resistance training; seek professional guidance if needed.",
+ "ibwOverweightDescription": "You are above the ideal weight by {kg} kg. Aim for a gradual, sustainable weight loss strategy — moderate calorie deficit, regular physical activity, and balanced nutrition. Consult a professional before major changes.",
+ "ibwOverweightGenericDescription": "You appear above the ideal weight. Consider a gradual, sustainable calorie deficit combined with activity and balanced nutrition; consult a professional if needed.",
+ "dietVeryLowCarbsDescription": "Very low‑carb (ketogenic) approach: minimal carbohydrates, higher fat and moderate protein. May support rapid weight loss and improved blood sugar control for some, but can be hard to sustain and may cause nutrient gaps. Monitor hydration/electrolytes and consult a professional for long‑term use.",
+ "dietLowCarbsDescription": "Low‑carb, higher‑protein plan: reduced carbohydrates with increased protein to support satiety and muscle maintenance. Helpful for weight management and glycemic control when balanced with vegetables and healthy fats. Ensure adequate fiber and micronutrients.",
+ "dietModerateCarbsDescription": "Moderate carbohydrate intake with balanced protein and fats: provides steady energy for daily activity and exercise while allowing flexibility. Suitable for many people aiming for sustainable weight management and performance.",
+ "dietUSDAGuidelinesDescription": "USDA‑based balanced pattern: emphasizes fruits, vegetables, whole grains, lean proteins, and limited added sugars and saturated fats. Evidence‑based framework for general health, nutrient adequacy, and chronic disease prevention.",
+ "dietZoneDietDescription": "Zone Diet (~40% carbs / 30% protein / 30% fat): emphasizes hormonal balance and portion control. May improve body composition and energy for some, but requires planning; personalize with a nutrition professional.",
+ "contextDependent": "Context Dependent",
+ "calculatedValue": "Calculated Value",
+ "calculationFormula": "Calculation Formula"
diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart
index 8319c9d..e71629d 100644
--- a/lib/core/api_consts.dart
+++ b/lib/core/api_consts.dart
@@ -901,6 +901,8 @@ class ApiConsts {
static String getPatientBloodGroup = "services/PatientVarification.svc/REST/BloodDonation_GetBloodGroupDetails";
static String getPatientBloodAgreement = "Services/PatientVarification.svc/REST/CheckUserAgreementForBloodDonation";
+ static String getAiOverViewLabOrders = "Services/Patients.svc/REST/HMGAI_Lab_Analyze_Orders_API";
+ static String getAiOverViewLabOrder = "Services/Patients.svc/REST/HMGAI_Lab_Analyzer_API";
// ************ static values for Api ****************
static final double appVersionID = 50.3;
diff --git a/lib/core/app_assets.dart b/lib/core/app_assets.dart
index 5b8d2ed..d9d7120 100644
--- a/lib/core/app_assets.dart
+++ b/lib/core/app_assets.dart
@@ -251,6 +251,10 @@ class AppAssets {
static const String alertSquare = '$svgBasePath/alert-square.svg';
static const String arrowRight = '$svgBasePath/arrow-right.svg';
static const String tickIcon = '$svgBasePath/tick.svg';
+ static const String guradIcon = '$svgBasePath/guard_icon.svg';
+ static const String calculatorIcon = '$svgBasePath/calculator_icon.svg';
+ static const String informationIcon = '$svgBasePath/information-circle.svg';
+ static const String highCautionIcon = '$svgBasePath/high_caution.svg';
// Symptoms Checker
static const String calendarGrey = '$svgBasePath/calendar-grey.svg';
@@ -322,6 +326,7 @@ class AppAssets {
static const String doctorResponseIcon = '$svgBasePath/doctor_response_icon.svg';
static const String changeLanguageHomePageIcon = '$svgBasePath/change_language_home_page.svg';
+ static const String aiOverView = '$svgBasePath/ai_overview.svg';
// PNGS //
static const String hmgLogo = '$pngBasePath/hmg_logo.png';
diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart
index 8206160..e93c246 100644
--- a/lib/features/authentication/authentication_view_model.dart
+++ b/lib/features/authentication/authentication_view_model.dart
@@ -279,9 +279,10 @@ class AuthenticationViewModel extends ChangeNotifier {
loginTypeEnum = otpTypeEnum == OTPTypeEnum.sms ? LoginTypeEnum.sms : LoginTypeEnum.whatsapp;
- if (phoneNumberController.text.isEmpty) {
- phoneNumberController.text = "504278212";
- }
+ // if (phoneNumberController.text.isEmpty) {
+ // phoneNumberController.text = "504278212";
+ // }
+
bool isValidated = ValidationUtils.isValidatePhoneAndId(phoneNumber: phoneNumberController.text, nationalId: nationalIdController.text);
if (!isValidated) {
@@ -404,7 +405,6 @@ class AuthenticationViewModel extends ChangeNotifier {
return;
}
patientShareRequestID = apiResponse.data['PatientShareRequestID'];
- print("PatientShareRequestID ==============: $patientShareRequestID");
_appState.setFamilyFileTokenID = apiResponse.data['LogInTokenID'];
}
if (apiResponse.messageStatus == 2) {
@@ -581,7 +581,8 @@ class AuthenticationViewModel extends ChangeNotifier {
if (!_appState.getIsChildLoggedIn) {
await medicalVm.getFamilyFiles(status: 0);
// await medicalVm.getAllPendingRecordsByResponseId();
- _navigationService.replaceAllRoutesAndNavigateToLanding();
+ _navigationService.popUntilNamed(AppRoutes.landingScreen);
+ // _navigationService.replaceAllRoutesAndNavigateToLanding();
}
} else {
if (activation.list != null && activation.list!.isNotEmpty) {
diff --git a/lib/features/lab/lab_repo.dart b/lib/features/lab/lab_repo.dart
index e661157..a4cdcf1 100644
--- a/lib/features/lab/lab_repo.dart
+++ b/lib/features/lab/lab_repo.dart
@@ -5,6 +5,8 @@ import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart';
import 'package:dartz/dartz.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
+import 'package:hmg_patient_app_new/features/lab/models/resp_models/ai_overview_labresults_by_ai_model.dart';
+import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_order_response_by_ai_model.dart';
import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_orders_response_model.dart';
import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_special_result.dart';
import 'package:hmg_patient_app_new/services/logger_service.dart';
@@ -13,6 +15,7 @@ import 'models/resp_models/lab_result.dart' show LabResult;
abstract class LabRepo {
Future>>> getPatientLabOrders();
+
Future>>> getPatientLabResults(PatientLabOrdersResponseModel laborder, bool isVidaPlus, String procedureName);
Future>>> getPatientLabResultsByHospitals(PatientLabOrdersResponseModel laborder, bool isVidaPlus);
@@ -22,6 +25,10 @@ abstract class LabRepo {
Future>> getLabResultReportPDF({required PatientLabOrdersResponseModel labOrder});
Future>> getLabResultsByAppointmentNo({required num appointmentNo, required num projectID, required num clinicID});
+
+ Future>> getPatientAiOverViewLabOrders(var payload);
+
+ Future>> getPatientAiOverViewLabOrder(var payload);
}
class LabRepoImp implements LabRepo {
@@ -71,10 +78,7 @@ class LabRepoImp implements LabRepo {
}
@override
- Future>>> getPatientLabResults(
- PatientLabOrdersResponseModel laborder, bool isVidaPlus, String procedureName
- ) async {
-
+ Future>>> getPatientLabResults(PatientLabOrdersResponseModel laborder, bool isVidaPlus, String procedureName) async {
Map request = Map();
request['InvoiceNo_VP'] = isVidaPlus ? laborder!.invoiceNo : "0";
request['InvoiceNo'] = isVidaPlus ? "0" : laborder!.invoiceNo;
@@ -100,10 +104,7 @@ class LabRepoImp implements LabRepo {
throw Exception("lab list is empty");
}
- final labOrders = list
- .map((item) => LabResult.fromJson(item as Map))
- .toList()
- .cast();
+ final labOrders = list.map((item) => LabResult.fromJson(item as Map)).toList().cast();
apiResponse = GenericApiModel>(
messageStatus: messageStatus,
@@ -125,9 +126,7 @@ class LabRepoImp implements LabRepo {
}
@override
- Future>>>
- getPatientLabResultsByHospitals(
- PatientLabOrdersResponseModel laborder, bool isVidaPlus) async {
+ Future>>> getPatientLabResultsByHospitals(PatientLabOrdersResponseModel laborder, bool isVidaPlus) async {
Map request = Map();
request['InvoiceNo_VP'] = isVidaPlus ? laborder!.invoiceNo : "0";
request['InvoiceNo'] = isVidaPlus ? "0" : laborder!.invoiceNo;
@@ -175,9 +174,7 @@ class LabRepoImp implements LabRepo {
}
@override
- Future>>>
- getSpecialLabResult(
- PatientLabOrdersResponseModel laborder, bool isVidaPlus) async {
+ Future>>> getSpecialLabResult(PatientLabOrdersResponseModel laborder, bool isVidaPlus) async {
Map request = Map();
request['InvoiceNo_VP'] = isVidaPlus ? laborder!.invoiceNo : "0";
request['InvoiceNo'] = isVidaPlus ? "0" : laborder!.invoiceNo;
@@ -203,11 +200,7 @@ class LabRepoImp implements LabRepo {
throw Exception("lab list is empty");
}
- final labOrders = list
- .map((item) => PatientLabSpecialResult.fromJson(
- item as Map))
- .toList()
- .cast();
+ final labOrders = list.map((item) => PatientLabSpecialResult.fromJson(item as Map)).toList().cast();
apiResponse = GenericApiModel>(
messageStatus: messageStatus,
@@ -318,4 +311,76 @@ class LabRepoImp implements LabRepo {
return Left(UnknownFailure(e.toString()));
}
}
+
+ @override
+ Future>> getPatientAiOverViewLabOrder(var labOrder) async {
+ try {
+ GenericApiModel? apiResponse;
+ Failure? failure;
+ await apiClient.post(
+ ApiConsts.getAiOverViewLabOrder,
+ body: labOrder,
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ var res;
+ if (response["analysis_result"] != null) {
+ res = response["analysis_result"];
+ }
+ apiResponse = GenericApiModel(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: null,
+ data: LabOrderResponseByAi.fromJson(res),
+ );
+ } 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>> getPatientAiOverViewLabOrders(var labOrder) async {
+ try {
+ GenericApiModel? apiResponse;
+ Failure? failure;
+ await apiClient.post(
+ ApiConsts.getAiOverViewLabOrders,
+ body: {"lab_results": labOrder},
+ onFailure: (error, statusCode, {messageStatus, failureType}) {
+ failure = failureType;
+ },
+ onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
+ try {
+ var res;
+ if (response["lab_analysis_result"] != null) {
+ res = response["lab_analysis_result"];
+ }
+ apiResponse = GenericApiModel(
+ messageStatus: messageStatus,
+ statusCode: statusCode,
+ errorMessage: null,
+ data: LabOrdersResponseByAi.fromJson(res),
+ );
+ } 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/lab/lab_view_model.dart b/lib/features/lab/lab_view_model.dart
index 118c54a0..9b4e941 100644
--- a/lib/features/lab/lab_view_model.dart
+++ b/lib/features/lab/lab_view_model.dart
@@ -1,16 +1,24 @@
import 'dart:collection';
+import 'dart:convert';
import 'dart:core';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/common_models/data_points.dart';
+import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
+import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart' show Utils;
import 'package:hmg_patient_app_new/features/lab/lab_repo.dart';
+import 'package:hmg_patient_app_new/features/lab/models/ai_overview_labresult_model_payload.dart';
+import 'package:hmg_patient_app_new/features/lab/models/resp_models/ai_overview_labresults_by_ai_model.dart';
import 'package:hmg_patient_app_new/features/lab/models/resp_models/lab_result.dart';
+import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_order_response_by_ai_model.dart';
import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_orders_response_model.dart';
import 'package:hmg_patient_app_new/presentation/lab/lab_result_via_clinic/LabResultByClinic.dart';
import 'package:hmg_patient_app_new/presentation/lab/lab_results/lab_result_details.dart';
+import 'package:hmg_patient_app_new/presentation/labAiAnalysis/lab_ai_analysis_detailed_page.dart';
+import 'package:hmg_patient_app_new/services/cache_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';
@@ -53,20 +61,7 @@ class LabViewModel extends ChangeNotifier {
List mainLabResults = [];
List mainGraphPoints = [];
List filteredGraphValues = [];
- List months = [
- 'Jan',
- 'Feb',
- 'Mar',
- 'April',
- 'May',
- 'Jun',
- 'July',
- 'Aug',
- 'Sep',
- 'Oct',
- 'Nov',
- 'Dec'
- ];
+ List months = ['Jan', 'Feb', 'Mar', 'April', 'May', 'Jun', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
late List _labSuggestionsList = [];
@@ -86,22 +81,22 @@ class LabViewModel extends ChangeNotifier {
List> patientLabOrdersByHospital = [];
List> patientLabOrdersViewList = [];
- LabViewModel(
- {required this.labRepo,
- required this.errorHandlerService,
- required this.navigationService});
+ LabOrderResponseByAi? labOrderResponseByAi;
+ LabOrdersResponseByAi? labOrdersResponseByAi;
+
+ LabViewModel({required this.labRepo, required this.errorHandlerService, required this.navigationService});
initLabProvider() {
// if (isLabNeedToLoad) {
- patientLabOrders.clear();
- filteredLabOrders.clear();
- labOrderTests.clear();
- isLabOrdersLoading = true;
- isLabResultsLoading = true;
- patientLabOrdersByClinic.clear();
- patientLabOrdersByHospital.clear();
- patientLabOrdersViewList.clear();
- getPatientLabOrders();
+ patientLabOrders.clear();
+ filteredLabOrders.clear();
+ labOrderTests.clear();
+ isLabOrdersLoading = true;
+ isLabResultsLoading = true;
+ patientLabOrdersByClinic.clear();
+ patientLabOrdersByHospital.clear();
+ patientLabOrdersViewList.clear();
+ getPatientLabOrders();
// }
notifyListeners();
}
@@ -133,13 +128,13 @@ class LabViewModel extends ChangeNotifier {
final result = await labRepo.getPatientLabOrders();
result.fold(
- (failure) async {
- isLabOrdersLoading = false;
- isLabResultsLoading = false;
- notifyListeners();
- },
- // => await errorHandler_service.handleError(failure: failure),
- (apiResponse) {
+ (failure) async {
+ isLabOrdersLoading = false;
+ isLabResultsLoading = false;
+ notifyListeners();
+ },
+ // => await errorHandler_service.handleError(failure: failure),
+ (apiResponse) {
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
@@ -203,11 +198,7 @@ class LabViewModel extends ChangeNotifier {
}
filterSuggestions() {
- final List labels = patientLabOrders
- .expand((order) => order.testDetails ?? [])
- .map((detail) => detail.description)
- .whereType()
- .toList();
+ final List labels = patientLabOrders.expand((order) => order.testDetails ?? []).map((detail) => detail.description).whereType().toList();
_labSuggestionsList = labels.toSet().toList();
notifyListeners();
@@ -319,14 +310,12 @@ class LabViewModel extends ChangeNotifier {
);
}
- Future getPatientLabResultByHospital(
- PatientLabOrdersResponseModel laborder) async {
+ Future getPatientLabResultByHospital(PatientLabOrdersResponseModel laborder) async {
isLabResultByHospitalLoading = true;
notifyListeners();
mainLabResultsByHospitals.clear();
- final result = await labRepo.getPatientLabResultsByHospitals(laborder,
- Utils.isVidaPlusProject(int.parse(laborder.projectID ?? "0")));
+ final result = await labRepo.getPatientLabResultsByHospitals(laborder, Utils.isVidaPlusProject(int.parse(laborder.projectID ?? "0")));
result.fold(
(failure) async {
@@ -350,12 +339,9 @@ class LabViewModel extends ChangeNotifier {
mainLabResults.clear();
filteredGraphValues.clear();
maxY = double.negativeInfinity;
- minY = double.infinity;
- maxX = double.infinity;
- final result = await labRepo.getPatientLabResults(
- laborder,
- Utils.isVidaPlusProject(int.parse(laborder.projectID ?? "0")),
- procedureName);
+ minY = double.infinity;
+ maxX = double.infinity;
+ final result = await labRepo.getPatientLabResults(laborder, Utils.isVidaPlusProject(int.parse(laborder.projectID ?? "0")), procedureName);
result.fold(
(failure) async {
@@ -369,7 +355,6 @@ class LabViewModel extends ChangeNotifier {
var recentThree = sort(apiResponse.data!);
mainLabResults = recentThree;
-
double highRefrenceValue = double.negativeInfinity;
String? flagForHighReferenceRange;
double lowRefenceValue = double.infinity;
@@ -377,11 +362,10 @@ class LabViewModel extends ChangeNotifier {
recentThree.reversed.forEach((element) {
try {
- var dateTime =
- DateUtil.convertStringToDate(element.verifiedOnDateTime!);
+ var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
var resultValue = double.parse(element.resultValue!);
- var transformedValue = transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??"");
- if (resultValue>maxY) {
+ var transformedValue = transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag ?? "");
+ if (resultValue > maxY) {
maxY = resultValue;
maxX = maxY;
}
@@ -398,14 +382,13 @@ class LabViewModel extends ChangeNotifier {
}
filteredGraphValues.add(DataPoint(
- value: transformedValue,
- actualValue:element.resultValue!,
- label: formatDateAsMMYY(dateTime),
- unitOfMeasurement: element.uOM,
- displayTime: resultDate(dateTime),
- time: DateUtil.convertStringToDate(element.verifiedOnDateTime),
- referenceValue: element.calculatedResultFlag ?? "",
-
+ value: transformedValue,
+ actualValue: element.resultValue!,
+ label: formatDateAsMMYY(dateTime),
+ unitOfMeasurement: element.uOM,
+ displayTime: resultDate(dateTime),
+ time: DateUtil.convertStringToDate(element.verifiedOnDateTime),
+ referenceValue: element.calculatedResultFlag ?? "",
));
} catch (e) {}
});
@@ -421,7 +404,7 @@ class LabViewModel extends ChangeNotifier {
this.highRefrenceValue = double.parse(highRefrenceValue.toStringAsFixed(1));
this.lowRefenceValue = double.parse(lowRefenceValue.toStringAsFixed(1));
- if(maxY< highRefrenceValue) {
+ if (maxY < highRefrenceValue) {
maxY = highRefrenceValue;
}
maxY += 25;
@@ -431,7 +414,9 @@ class LabViewModel extends ChangeNotifier {
checkIfGraphShouldBeDisplayed(recentResult);
recentResult.verifiedOn = resultDate(DateUtil.convertStringToDate(recentResult.verifiedOnDateTime!));
// filteredGraphValues = [filteredGraphValues.first];
- navigationService.push(MaterialPageRoute(
+ labOrderResponseByAi = null;
+ navigationService.push(
+ MaterialPageRoute(
builder: (_) => LabResultDetails(recentLabResult: recentResult, testDescription: testDescription),
),
);
@@ -441,14 +426,13 @@ class LabViewModel extends ChangeNotifier {
);
}
- void checkIfGraphShouldBeDisplayed(LabResult recentResult){
+ void checkIfGraphShouldBeDisplayed(LabResult recentResult) {
shouldShowGraph = recentResult.checkIfGraphShouldBeDisplayed();
isGraphVisible = shouldShowGraph;
notifyListeners();
}
- Future getPatientSpecialResult(
- PatientLabOrdersResponseModel laborder) async {
+ Future getPatientSpecialResult(PatientLabOrdersResponseModel laborder) async {
isSpecialResultsLoading = true;
labSpecialResult = "";
notifyListeners();
@@ -470,8 +454,7 @@ class LabViewModel extends ChangeNotifier {
StringBuffer htmlbuffer = StringBuffer("");
apiResponse.data?.forEach((element) {
- if(element.resultDataHTML != null && element.resultDataHTML?.isNotEmpty == true)
- htmlbuffer.write("${element.resultDataHTML}