diff --git a/lib/config/config.dart b/lib/config/config.dart index aca97ede..82254482 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -21,8 +21,8 @@ var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; // var BASE_URL = 'http://10.50.100.198:2018/'; -var BASE_URL = 'https://uat.hmgwebservices.com/'; -// var BASE_URL = 'https://hmgwebservices.com/'; +// var BASE_URL = 'https://uat.hmgwebservices.com/'; +var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'http://10.201.204.103/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; @@ -357,7 +357,7 @@ var CAN_PAY_FOR_FOR_WALKIN_APPOINTMENT = 'Services/Doctors.svc/REST/CanPayForWal var CHANNEL = 3; var GENERAL_ID = 'Cs2020@2016\$2958'; var IP_ADDRESS = '10.20.10.20'; -var VERSION_ID = 19.7; +var VERSION_ID = 20.0; var SETUP_ID = '91877'; var LANGUAGE = 2; // var PATIENT_OUT_SA = 0; diff --git a/lib/core/service/medical/labs_service.dart b/lib/core/service/medical/labs_service.dart index b0a9e874..aec1c801 100644 --- a/lib/core/service/medical/labs_service.dart +++ b/lib/core/service/medical/labs_service.dart @@ -237,9 +237,12 @@ class LabsService extends BaseService { _requestSendLabReportEmail.languageID = languageID; // await baseAppClient.post(SEND_LAB_RESULT_EMAIL, onSuccess: (dynamic response, int statusCode) { - await baseAppClient.post(isVidaPlus ? SEND_LAB_RESULT_EMAIL : SEND_LAB_RESULT_EMAIL_NEW, onSuccess: (dynamic response, int statusCode) { + // await baseAppClient.post(isVidaPlus ? SEND_LAB_RESULT_EMAIL : SEND_LAB_RESULT_EMAIL_NEW, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(SEND_LAB_RESULT_EMAIL_NEW, onSuccess: (dynamic response, int statusCode) { if (isDownload) { - labReportPDF = isVidaPlus ? response['LabReportsPDFContent'] : response['PdfContent']; + // labReportPDF = isVidaPlus ? response['LabReportsPDFContent'] : response['PdfContent']; + labReportPDF = response['PdfContent']; + hasError = false; } }, onFailure: (String error, int statusCode) { hasError = true; @@ -279,15 +282,12 @@ class LabsService extends BaseService { return copy; } - Map mapFirstItemByPriority( - List sortedResults) { + Map mapFirstItemByPriority(List sortedResults) { final Map priorityMap = {}; const priorityOrder = ['LCL', 'CL', 'L', 'N', 'H', 'CH', 'HCH']; for (final result in sortedResults) { final priority = result.calculatedResultFlag?.trim(); - if (priority != null && - priorityOrder.contains(priority) && - !priorityMap.containsKey(priority)) { + if (priority != null && priorityOrder.contains(priority) && !priorityMap.containsKey(priority)) { priorityMap[priority] = result; } @@ -307,8 +307,7 @@ class LabsService extends BaseService { print("the match iss not null"); final millis = int.tryParse(match.group(1)!); if (millis != null) { - print( - "the data and time is ${DateTime.fromMillisecondsSinceEpoch(millis)}"); + print("the data and time is ${DateTime.fromMillisecondsSinceEpoch(millis)}"); return DateTime.fromMillisecondsSinceEpoch(millis); } } @@ -335,14 +334,9 @@ class LabsService extends BaseService { return mapResultToThreshold(topResults, mapOfPriority); } - List mapResultToThreshold( - List results, Map mapOfPriority) { + List mapResultToThreshold(List results, Map mapOfPriority) { // Extract valid numeric results - List actualValues = results - .map((e) => double.tryParse(e.resultValue ?? '')) - .where((v) => v != null) - .cast() - .toList(); + List actualValues = results.map((e) => double.tryParse(e.resultValue ?? '')).where((v) => v != null).cast().toList(); if (actualValues.isEmpty) return []; @@ -376,14 +370,10 @@ class LabsService extends BaseService { var mapOfValues = inferThresholds(mapOfPriority); var item = results.first; - String? realCriticalLow = - (item.criticalLow == "0") ? null : item.criticalLow; - String? realReferenceHigh = - (item.referenceHigh == "0") ? null : item.referenceHigh; - String? realCriticalHigh = - (item.criticalHigh == "0") ? null : item.criticalHigh; - String? realReferenceLow = - (item.referenceLow == "0") ? null : item.referenceLow; + String? realCriticalLow = (item.criticalLow == "0") ? null : item.criticalLow; + String? realReferenceHigh = (item.referenceHigh == "0") ? null : item.referenceHigh; + String? realCriticalHigh = (item.criticalHigh == "0") ? null : item.criticalHigh; + String? realReferenceLow = (item.referenceLow == "0") ? null : item.referenceLow; final adjustedValues = adjustValues( criticalLow: mapOfValues['criticalLow'], low: mapOfValues['low'], @@ -393,53 +383,26 @@ class LabsService extends BaseService { ); return [ - ThresholdRange( - label: 'Critical Low', - value: adjustedValues["criticalLow"]!, - color: Color(0xffffffff), - lineColor: Color(0xFFe9a2a4), - actualValue: realCriticalLow), - ThresholdRange( - label: 'Low', - value: adjustedValues['low']!, - color: Color(0xFFf2fbf5), - lineColor: Color(0xFFefc481), - actualValue: realReferenceLow), - ThresholdRange( - label: 'Normal', - value: adjustedValues['normal']!, - color: Color(0xFFf2fbf5), - lineColor: Color(0xFF5dc36b)), - ThresholdRange( - label: 'High', - value: adjustedValues['high']!, - color: Color(0xffffffff), - lineColor: Color(0xFFefc481), - actualValue: realReferenceHigh), - ThresholdRange( - label: 'Critical High', - value: adjustedValues['criticalHigh']!, - color: Color(0xffffffff), - lineColor: Color(0xFFe9a2a4), - actualValue: realCriticalHigh), + ThresholdRange(label: 'Critical Low', value: adjustedValues["criticalLow"]!, color: Color(0xffffffff), lineColor: Color(0xFFe9a2a4), actualValue: realCriticalLow), + ThresholdRange(label: 'Low', value: adjustedValues['low']!, color: Color(0xFFf2fbf5), lineColor: Color(0xFFefc481), actualValue: realReferenceLow), + ThresholdRange(label: 'Normal', value: adjustedValues['normal']!, color: Color(0xFFf2fbf5), lineColor: Color(0xFF5dc36b)), + ThresholdRange(label: 'High', value: adjustedValues['high']!, color: Color(0xffffffff), lineColor: Color(0xFFefc481), actualValue: realReferenceHigh), + ThresholdRange(label: 'Critical High', value: adjustedValues['criticalHigh']!, color: Color(0xffffffff), lineColor: Color(0xFFe9a2a4), actualValue: realCriticalHigh), ]; } - Map inferThresholds( - Map mapOfPriority) { + Map inferThresholds(Map mapOfPriority) { double? parse(String? v) { final parsed = double.tryParse(v ?? ''); return (parsed == null || parsed < 0) ? null : parsed; } // Parse inputs - double? criticalLow = parse( - mapOfPriority['LCL']?.resultValue ?? mapOfPriority['CL']?.resultValue); + double? criticalLow = parse(mapOfPriority['LCL']?.resultValue ?? mapOfPriority['CL']?.resultValue); double? low = parse(mapOfPriority['L']?.resultValue); double? normal = parse(mapOfPriority['N']?.resultValue); double? high = parse(mapOfPriority['H']?.resultValue); - double? criticalHigh = parse( - mapOfPriority['CH']?.resultValue ?? mapOfPriority['HCH']?.resultValue); + double? criticalHigh = parse(mapOfPriority['CH']?.resultValue ?? mapOfPriority['HCH']?.resultValue); const step = 5.0; List values = [criticalLow, low, normal, high, criticalHigh]; @@ -453,11 +416,11 @@ class LabsService extends BaseService { return v < 0 ? 0 : v; }); var mapresult = { - 'criticalLow': values[0]??-1, - 'low': values[1]??-1, - 'normal': values[2]??-1, - 'high': values[3]??-1, - 'criticalHigh': values[4]??-1, + 'criticalLow': values[0] ?? -1, + 'low': values[1] ?? -1, + 'normal': values[2] ?? -1, + 'high': values[3] ?? -1, + 'criticalHigh': values[4] ?? -1, }; print("the result is $mapresult"); @@ -480,20 +443,23 @@ class LabsService extends BaseService { if (criticalLow == null || criticalLow == -1) criticalLowHasValue = false; if (low == null || low == -1) lowHasValue = false; - if (normal == null ||normal ==-1) normaHasValue = false; - if (high == null ||high ==-1) highHasValue = false; - if (criticalHigh == null ||criticalHigh ==-1) criticalHighHasValue = false; + if (normal == null || normal == -1) normaHasValue = false; + if (high == null || high == -1) highHasValue = false; + if (criticalHigh == null || criticalHigh == -1) criticalHighHasValue = false; print("the values arre $criticalLowHasValue $lowHasValue $normaHasValue $highHasValue $criticalHighHasValue"); if (!criticalLowHasValue) { criticalLow = 0; if (lowHasValue) { low = low! - step; - } if (normaHasValue && (criticalLow!= 0 || criticalLow != -1)) { + } + if (normaHasValue && (criticalLow != 0 || criticalLow != -1)) { low = normal! - step * 2; - } if (highHasValue && (criticalLow!= 0 || criticalLow != -1)) { + } + if (highHasValue && (criticalLow != 0 || criticalLow != -1)) { low = high! - step * 3; - } if (criticalHighHasValue && (criticalLow!= 0 || criticalLow != -1)) { + } + if (criticalHighHasValue && (criticalLow != 0 || criticalLow != -1)) { low = criticalHigh! - step * 4; } } @@ -503,25 +469,30 @@ class LabsService extends BaseService { if (criticalLowHasValue && (low != 0 || low != -1)) { low = criticalLow! + step; - } if (normaHasValue && (low != 0 || low != -1)) { + } + if (normaHasValue && (low != 0 || low != -1)) { low = normal! - step; - } if (highHasValue && (low != 0 || low != -1)) { + } + if (highHasValue && (low != 0 || low != -1)) { low = high! - step * 2; - } if (criticalHighHasValue && (low != 0 || low != -1)) { + } + if (criticalHighHasValue && (low != 0 || low != -1)) { low = criticalHigh! - step * 3; } - } if (!normaHasValue) { normal = 0; if (criticalLowHasValue && (normal != 0 || normal != -1)) { normal = criticalLow! + step * 2; - } if (lowHasValue) { + } + if (lowHasValue) { normal = low! + step; - } if (highHasValue) { + } + if (highHasValue) { normal = high! - step; - } if (criticalHighHasValue) { + } + if (criticalHighHasValue) { normal = criticalHigh! - step * 2; } } @@ -530,59 +501,62 @@ class LabsService extends BaseService { if (criticalLowHasValue) { high = criticalLow! + step * 3; - } if (lowHasValue) { + } + if (lowHasValue) { high = low! + step * 2; - } if (normaHasValue) { + } + if (normaHasValue) { high = normal! + step; - } if (criticalHighHasValue) { + } + if (criticalHighHasValue) { high = criticalHigh! - step; } } if (!criticalHighHasValue) { - criticalHigh = 0; if (criticalLowHasValue) { criticalHigh = criticalLow! + step * 4; - } if (lowHasValue) { + } + if (lowHasValue) { criticalHigh = low! + step * 3; - } if (normaHasValue) { + } + if (normaHasValue) { criticalHigh = normal! + step * 2; - } if (highHasValue) { + } + if (highHasValue) { criticalHigh = high! + step; } } - if(((criticalLow??0)<0) == true){ - var mod = ((low ?? 0) + (normal??0) )/2; + if (((criticalLow ?? 0) < 0) == true) { + var mod = ((low ?? 0) + (normal ?? 0)) / 2; criticalLow = mod; } - if(((low??0)<0) == true){ - var mod = ((criticalLow ?? 0) + (normal??0) )/2; + if (((low ?? 0) < 0) == true) { + var mod = ((criticalLow ?? 0) + (normal ?? 0)) / 2; low = mod; } - if(((normal??0)<0) == true){ - var mod = ((low ?? 0) + (high??0) )/2; + if (((normal ?? 0) < 0) == true) { + var mod = ((low ?? 0) + (high ?? 0)) / 2; normal = mod; } - if(((high??0)<0) == true){ - var mod = ((normal ?? 0) + (criticalHigh??0) )/2; + if (((high ?? 0) < 0) == true) { + var mod = ((normal ?? 0) + (criticalHigh ?? 0)) / 2; high = mod; } - if(((criticalHigh??0)<0) == true){ - criticalHigh = (high??0)+step; + if (((criticalHigh ?? 0) < 0) == true) { + criticalHigh = (high ?? 0) + step; } - - Map values = { - 'criticalLow':criticalLow , + 'criticalLow': criticalLow, 'low': low, - 'normal': normal , - 'high': high , - 'criticalHigh': criticalHigh, + 'normal': normal, + 'high': high, + 'criticalHigh': criticalHigh, }; print("thee adjusted values `are $values"); @@ -628,9 +602,7 @@ class LabsService extends BaseService { const priorityOrder = ['LCL', 'CL', 'L', 'N', 'H', 'CH', 'HCH']; // Sort results by priority order - results.sort((a, b) => priorityOrder - .indexOf(a.calculatedResultFlag ?? '') - .compareTo(priorityOrder.indexOf(b.calculatedResultFlag ?? ''))); + results.sort((a, b) => priorityOrder.indexOf(a.calculatedResultFlag ?? '').compareTo(priorityOrder.indexOf(b.calculatedResultFlag ?? ''))); // Extract values List values = results.map((r) { @@ -716,54 +688,15 @@ class LabsService extends BaseService { return transformedValue; } - - List getThresholdValue() { return [ - ThresholdRange( - label: 'LCL', - value: 0, - color: Color(0xffffffff), - lineColor: Color(0xFFe9a2a4)), ThresholdRange( - label: 'CL', - value: 0, - color: Color(0xffffffff), - lineColor: Color(0xFFe9a2a4)), - ThresholdRange( - label: 'L', - value: 20, - color: Color(0xFFf2fbf5), - lineColor: Color(0xFFeecd94)), - ThresholdRange( - label: 'N', - value: 40, - color: Color(0xFFf2fbf5), - lineColor: Color(0xFF5dc36b)), - ThresholdRange( - label: 'H', - value: 60, - color: Color(0xffffffff), - lineColor: Color(0xFFeecd94)), - ThresholdRange( - label: 'CH', - value: 80, - color: Color(0xffffffff), - lineColor: Color(0xFFe9a2a4)), ThresholdRange( - label: 'HCH', - value: 80, - color: Color(0xffffffff), - lineColor: Color(0xFFe9a2a4)), + ThresholdRange(label: 'LCL', value: 0, color: Color(0xffffffff), lineColor: Color(0xFFe9a2a4)), + ThresholdRange(label: 'CL', value: 0, color: Color(0xffffffff), lineColor: Color(0xFFe9a2a4)), + ThresholdRange(label: 'L', value: 20, color: Color(0xFFf2fbf5), lineColor: Color(0xFFeecd94)), + ThresholdRange(label: 'N', value: 40, color: Color(0xFFf2fbf5), lineColor: Color(0xFF5dc36b)), + ThresholdRange(label: 'H', value: 60, color: Color(0xffffffff), lineColor: Color(0xFFeecd94)), + ThresholdRange(label: 'CH', value: 80, color: Color(0xffffffff), lineColor: Color(0xFFe9a2a4)), + ThresholdRange(label: 'HCH', value: 80, color: Color(0xffffffff), lineColor: Color(0xFFe9a2a4)), ]; } - - } - - - - - - - - -