Fix get test result inputs changes

This commit is contained in:
hanie.khodkari
2025-05-08 22:00:41 +03:30
parent 75cd8e5c78
commit 12758968c9
4 changed files with 31 additions and 23 deletions
+22 -5
View File
@@ -19,7 +19,9 @@ class TestResultAddScreen extends StatefulWidget {
class _TestResultAddScreenState extends State<TestResultAddScreen> {
TextEditingController testTypeCTRL = new TextEditingController();
final List<String> testTypeVals = [];
List<Map<String, String>> testTypeMap = [];
List<String> testTypeVals = [];
TextEditingController testCodeCTRL = new TextEditingController();
bool isInit = true;
@@ -31,10 +33,16 @@ class _TestResultAddScreenState extends State<TestResultAddScreen> {
Provider.of<TestResultsProvider>(context, listen: false);
testResultProviderObject.resetTests();
testResultProviderObject.getFilterItems().then((result) {
for (var testType in result[1].keys) {
// testTypeVals = result[1] as List<Map<String, String>>;
// testTypeCTRL.text = testTypeVals[0].keys as String;
testTypeMap = Provider.of<TestResultsProvider>(
context,
listen: false,
).testTypeMap;
for (var testType in testTypeMap[1].keys) {
testTypeVals.add(testType);
}
testTypeCTRL.text = testTypeVals[0];
setState(() {
isInit = false;
});
@@ -246,14 +254,23 @@ class _TestResultAddScreenState extends State<TestResultAddScreen> {
arguments: testCodeCTRL.text,
);
} else if (testTypeCTRL.text != '') {
String? testTypeId = '';
for (var map in testTypeMap) {
if (map.containsKey(
testTypeCTRL.text)) {
testTypeId =
map[testTypeCTRL.text];
break;
}
}
Provider.of<TestResultsProvider>(
context,
listen: false,
).testType = testTypeCTRL.text;
).testTypeId = testTypeId!;
Navigator.pushReplacementNamed(
context,
Routes.formTestResultScreen,
arguments: testTypeCTRL.text,
arguments: testTypeId,
);
}
// print(testCode);
+2 -5
View File
@@ -74,15 +74,12 @@ class _FormPageState extends State<FormPage> {
_isLoading = true;
});
var providerObject = Provider.of<TestResultsProvider>(context);
String testTypeName = Provider.of<TestResultsProvider>(context).testType;
String testCode = Provider.of<TestResultsProvider>(context).testCode;
String testTypeId = Provider.of<TestResultsProvider>(context).testTypeId;
providerObject.catchImages.clear();
Provider.of<Inputs>(context, listen: false)
.getInputs(
testResultId: '',
name: testTypeName,
uniqueCode: testCode,
testTypeId: '',
testTypeId: testTypeId,
)
.then((_) {
setState(() {
+2 -10
View File
@@ -11,18 +11,10 @@ class Inputs with ChangeNotifier {
Future<bool> getInputs({
required String testResultId,
required String name,
required String uniqueCode,
required String testTypeId,
}) async {
var response = await http.post(
Uri.parse(Url.getInputs),
body: {
'test_type_id': testTypeId,
'test_result_id': testResultId,
'name': name,
'unique_code': uniqueCode,
},
var response = await http.get(
Uri.parse("${Url.getInputs}/$testTypeId"),
headers: {
'Authorization': User.token,
'X-Requested-With': 'XMLHttpRequest',
+5 -3
View File
@@ -15,12 +15,13 @@ import 'package:random_string/random_string.dart';
class TestResultsProvider with ChangeNotifier {
List<PlatformFile> catchImages = [];
List<Uint8List> images = [];
String testType = '';
String testTypeId = '';
String testCode = '';
List<Map<String, String>> testTypeMap = [];
resetTests() {
testCode = '';
testType = '';
testTypeId = '';
}
setImages() async {
@@ -208,9 +209,10 @@ class TestResultsProvider with ChangeNotifier {
result.add(hospitals);
for (var testType in filterDatas['data']['TestTypes']) {
testTypes.addAll({testType['name']: testType['id'].toString()});
testTypeMap.add(testTypes);
}
result.add(testTypes);
print("test type : ${testTypeMap}");
return result;
}