diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 1e747906..475d23a0 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -17,32 +17,32 @@ class PatientsProvider with ChangeNotifier { final response = await http.post(url, headers: requestHeaders, body: json.encode({ - "ProjectID": 12, - "ClinicID": 17, - "DoctorID": 98129, - "FirstName": "0", - "MiddleName": "0", - "LastName": "0", - "PatientMobileNumber": "0", - "PatientIdentificationID": "0", - "PatientID": 0, - "From": "0", - "To": "0", - "LanguageID": 2, - "stamp": "2020-03-02T13:56:39.170Z", - "IPAdress": "11.11.11.11", - "VersionID": 1.2, - "Channel": 9, - "TokenID": "2Fi7HoIHB0eDyekVa6tCJg==", - "SessionID": "5G0yXn0Jnq", - "IsLoginForDoctorApp": true, - "PatientOutSA": false + "ProjectID": patient.PatientID, + "ClinicID": patient.ClinicID, + "DoctorID": patient.DoctorID, + "FirstName": patient.FirstName, + "MiddleName": patient.MiddleName, + "LastName": patient.LastName, + "PatientMobileNumber": patient.PatientMobileNumber, + "PatientIdentificationID": patient.PatientIdentificationID, + "PatientID": patient.PatientID, + "From": patient.From, + "To": patient.To, + "LanguageID": patient.LanguageID, + "stamp": patient.stamp, + "IPAdress":patient.IPAdress, + "VersionID": patient.VersionID, + "Channel": patient.Channel, + "TokenID": patient.TokenID, + "SessionID": patient.SessionID, + "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, + "PatientOutSA": patient.PatientOutSA })); // var response = await http.post(url, body: {'name': 'doodle', 'color': 'blue'}); print('Response status: ${response.statusCode}'); print('Response body: ${response.body}'); + // notifyListeners(); return Future.value(json.decode(response.body)); - notifyListeners(); } catch (error) { print(error.toString()); print('error'); diff --git a/lib/screens/patients/patients_list_screen.dart b/lib/screens/patients/patients_list_screen.dart index 168f41bd..0f1a9390 100644 --- a/lib/screens/patients/patients_list_screen.dart +++ b/lib/screens/patients/patients_list_screen.dart @@ -1,40 +1,60 @@ -import 'package:doctor_app_flutter/models/patient_model.dart'; -import 'package:doctor_app_flutter/providers/patients_provider.dart'; +import '../../models/patient_model.dart'; +import '../../providers/patients_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; + class PatientsList extends StatefulWidget { @override _PatientsListState createState() => _PatientsListState(); } class _PatientsListState extends State { - var _isInit =true; - @override + var _isInit = true; + var _isLoading = true; + var _hasError; + @override void didChangeDependencies() { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatientModel patient = routeArgs['patientSearchForm']; - String patientType = routeArgs['selectedType']; + String patientType = routeArgs['selectedType']; print(patientType); - if(_isInit) { - setState(() { - + if (_isInit) { + // setState(() {}); + PatientsProvider patientsProv = Provider.of(context); + patientsProv.getPatientList(patient, patientType).then((res) { + setState(() { + _isLoading = false; + _hasError = res['ErrorEndUserMessage']; + + }); + }).catchError((error) { + print(error); }); - PatientsProvider patientsProv = Provider.of(context); - patientsProv.getPatientList(patient, patientType).then((res){ - print('Response EEEEEEEE: ${res}'); - print(res['ServiceName']); - }); } _isInit = false; super.didChangeDependencies(); - } + @override Widget build(BuildContext context) { - - return Scaffold( - appBar: AppBar(title: Text('PatientsList'),), + appBar: AppBar( + title: Text('PatientsList'), + ), + body: _isLoading + ? Center( + child: CircularProgressIndicator(), + ) + : Container( + child: _hasError != null + ? Center( + child: Text( + _hasError, + style: TextStyle(color: Theme.of(context).errorColor), + ), + ) + : Text('EEEEEEEEEEEEEE'), + ), ); } -} \ No newline at end of file +}