|
|
|
|
@ -71,6 +71,9 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
List<TestDetails> uniqueTestsList = [];
|
|
|
|
|
List<String> indexedCharacterForUniqueTest = [];
|
|
|
|
|
|
|
|
|
|
List<TestDetails> filteredUniqueTestsList = [];
|
|
|
|
|
List<String> filteredIndexedCharacterForUniqueTest = [];
|
|
|
|
|
|
|
|
|
|
double maxY = 0.0;
|
|
|
|
|
double minY = double.infinity;
|
|
|
|
|
double maxX = double.infinity;
|
|
|
|
|
@ -218,7 +221,8 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
final clinicMap = <String, List<PatientLabOrdersResponseModel>>{};
|
|
|
|
|
final hospitalMap = <String, List<PatientLabOrdersResponseModel>>{};
|
|
|
|
|
if (query.isEmpty) {
|
|
|
|
|
// filteredLabOrders = List.from(patientLabOrders); // reset
|
|
|
|
|
filteredLabOrders = List.from(patientLabOrders); // reset
|
|
|
|
|
filteredUniqueTestsList = List.from(uniqueTestsList);
|
|
|
|
|
for (var order in patientLabOrders) {
|
|
|
|
|
final clinicKey = (order.clinicDescription ?? 'Unknown').trim();
|
|
|
|
|
clinicMap.putIfAbsent(clinicKey, () => []).add(order);
|
|
|
|
|
@ -234,7 +238,10 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
final descriptions = order.testDetails?.map((d) => d.description?.toLowerCase()).toList() ?? [];
|
|
|
|
|
return descriptions.any((desc) => desc != null && desc.contains(query.toLowerCase()));
|
|
|
|
|
}).toList();
|
|
|
|
|
// patientLabOrders = filteredLabOrders;
|
|
|
|
|
filteredUniqueTestsList = uniqueTestsList.where((test) {
|
|
|
|
|
final desc = test.description?.toLowerCase() ?? '';
|
|
|
|
|
return desc.contains(query.toLowerCase());
|
|
|
|
|
}).toList();
|
|
|
|
|
for (var order in filteredLabOrders) {
|
|
|
|
|
final clinicKey = (order.clinicDescription ?? 'Unknown').trim();
|
|
|
|
|
clinicMap.putIfAbsent(clinicKey, () => []).add(order);
|
|
|
|
|
@ -246,6 +253,14 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
patientLabOrdersByHospital = hospitalMap.values.toList();
|
|
|
|
|
patientLabOrdersViewList = isSortByClinic ? patientLabOrdersByClinic : patientLabOrdersByHospital;
|
|
|
|
|
}
|
|
|
|
|
// Rebuild filtered indexed characters
|
|
|
|
|
filteredIndexedCharacterForUniqueTest = [];
|
|
|
|
|
for (var test in filteredUniqueTestsList) {
|
|
|
|
|
String label = test.description ?? "";
|
|
|
|
|
if (label.isEmpty) continue;
|
|
|
|
|
if (filteredIndexedCharacterForUniqueTest.contains(label[0].toLowerCase())) continue;
|
|
|
|
|
filteredIndexedCharacterForUniqueTest.add(label[0].toLowerCase());
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -280,6 +295,10 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
for (var element in uniqueTests) {
|
|
|
|
|
labOrderTests.add(element.description ?? "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize filtered lists with full data
|
|
|
|
|
filteredUniqueTestsList = List.from(uniqueTestsList);
|
|
|
|
|
filteredIndexedCharacterForUniqueTest = List.from(indexedCharacterForUniqueTest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getLabResultsByAppointmentNo(
|
|
|
|
|
@ -396,7 +415,7 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
double lowRefenceValue = double.infinity;
|
|
|
|
|
String? flagForLowReferenceRange;
|
|
|
|
|
|
|
|
|
|
sortedResult.take(3).toList().reversed.forEach((element) {
|
|
|
|
|
sortedResult.toList().reversed.forEach((element) {
|
|
|
|
|
try {
|
|
|
|
|
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
|
|
|
|
|
var resultValue = double.parse(element.resultValue!);
|
|
|
|
|
|