generated from DSCKGEC/project-template
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Mehul-Kumar-27/Medicine-Information
Issue #21 Feature to see the details of medicines, like prices, how to use, side effects etc.
- Loading branch information
Showing
14 changed files
with
2,452 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
823 changes: 823 additions & 0 deletions
823
...d/app/intermediates/assets/debug/mergeDebugAssets/flutter_assets/assets/data/medicine.csv
Large diffs are not rendered by default.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
lib/bloc/lab_investigation_information_bloc/lab_investigation_list/lab_test_list_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'dart:async'; | ||
import 'package:bloc/bloc.dart'; | ||
|
||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:medi_app/network/medicines_api.dart'; | ||
part 'lab_test_list_event.dart'; | ||
part 'lab_test_list_state.dart'; | ||
|
||
class MedicineListBloc extends Bloc<MedicineListEvent, MedicineListState> { | ||
MedicineInformation medicineInformation; | ||
MedicineListBloc(this.medicineInformation) | ||
: super(LoadingMedicineDataState()); | ||
|
||
late List<List<dynamic>> medicineData; | ||
late List<List<dynamic>> filterMedicineData; | ||
|
||
@override | ||
Stream<MedicineListState> mapEventToState( | ||
MedicineListEvent event, | ||
) async* { | ||
if (event is GetMedicineData) { | ||
yield LoadingMedicineDataState(); | ||
|
||
try { | ||
medicineData = await medicineInformation.getListOfMedicines(); | ||
filterMedicineData = medicineData; | ||
yield LoadedListState(medicineData); | ||
} catch (e) { | ||
yield ShowSnackBar(e.toString()); | ||
yield ErrorState(e.toString()); | ||
} | ||
} else if (event is SearchTestData) { | ||
try { | ||
List<List<dynamic>> copyList = medicineData; | ||
|
||
// hospitalCompareData = copyList; | ||
filterMedicineData = []; | ||
|
||
for (var element in copyList) { | ||
if (element[0].toLowerCase().contains(event.query)) { | ||
filterMedicineData.add(element); | ||
} | ||
} | ||
|
||
if (filterMedicineData.isEmpty) { | ||
yield ErrorState('No Result Found'); | ||
} else { | ||
yield LoadedListState(filterMedicineData); | ||
} | ||
} catch (e) { | ||
yield ErrorState('something wrong'); | ||
} | ||
} | ||
} | ||
} | ||
|
||
class MedicineInformation { | ||
Future getListOfMedicines() async { | ||
MedicineAPIClient medicineAPIClient = MedicineAPIClient(); | ||
|
||
return medicineAPIClient.fetchMedicinesFromAssets(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
lib/bloc/lab_investigation_information_bloc/lab_investigation_list/lab_test_list_event.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
part of 'lab_test_list_bloc.dart'; | ||
|
||
abstract class MedicineListEvent extends Equatable { | ||
const MedicineListEvent(); | ||
} | ||
|
||
class GetMedicineData extends MedicineListEvent { | ||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
class SearchTestData extends MedicineListEvent { | ||
final String query; | ||
|
||
SearchTestData(this.query); | ||
@override | ||
List<Object> get props => [query]; | ||
} | ||
|
||
// class UpdateTestToGetInformation extends LabTestListEvent { | ||
// final int index; | ||
// // final bool filteredlist; | ||
// UpdateTestToGetInformation(this.index); | ||
// @override | ||
// List<Object> get props => [index]; | ||
// } | ||
|
||
// class SelectedTheTestToGetInformation extends LabTestListEvent { | ||
// final LabInformationScreenBloc labInformationScreenBloc; | ||
// final int index; | ||
// SelectedTheTestToGetInformation(this.labInformationScreenBloc, this.index); | ||
// @override | ||
// List<Object> get props => [labInformationScreenBloc, index]; | ||
// } |
37 changes: 37 additions & 0 deletions
37
lib/bloc/lab_investigation_information_bloc/lab_investigation_list/lab_test_list_state.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
part of 'lab_test_list_bloc.dart'; | ||
|
||
abstract class MedicineListState extends Equatable { | ||
const MedicineListState(); | ||
} | ||
|
||
class LoadingMedicineDataState extends MedicineListState { | ||
@override | ||
// TODO: implement props | ||
List<Object> get props => []; | ||
} | ||
|
||
class ErrorState extends MedicineListState { | ||
final String message; | ||
@override | ||
// TODO: implement props | ||
List<Object> get props => [message]; | ||
|
||
ErrorState(this.message); | ||
} | ||
|
||
class ShowSnackBar extends MedicineListState { | ||
final String message; | ||
ShowSnackBar(this.message); | ||
@override | ||
// TODO: implement props | ||
List<Object> get props => []; | ||
} | ||
|
||
class LoadedListState extends MedicineListState { | ||
final List<List<dynamic>> labTestListData; | ||
|
||
LoadedListState(this.labTestListData); | ||
|
||
@override | ||
List<Object> get props => [labTestListData]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:flutter/services.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
class MedicineAPIClient { | ||
Future fetchMedicinesFromAssets() async { | ||
final myData = await rootBundle.loadString("assets/data/medicine.csv"); | ||
List<dynamic> myDataList = myData.split("\n"); | ||
List<List<dynamic>> rowsAsListOfValues = []; | ||
myDataList.forEach((element) { | ||
List<dynamic> values = []; | ||
element.split(",").forEach((elementValue) { | ||
values.add(elementValue); | ||
}); | ||
|
||
if (values.length > 2 && | ||
values[0] != null && | ||
values[0] != '''"''' && | ||
values[0].toString().length <= 35 && | ||
"${values[0]}".isNotEmpty) { | ||
rowsAsListOfValues.add(values); | ||
} | ||
}); | ||
rowsAsListOfValues.sort((a, b) { | ||
return a[0].toLowerCase().compareTo(b[0].toLowerCase()); | ||
}); | ||
|
||
return rowsAsListOfValues; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.