diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index be08db0e..86904cec 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -132,12 +132,13 @@ class _SideDrawerState extends State { pageMover: '/library_homepage'), ModulesPadding(line: 'Awards & Scholarship Module'), ModulesPadding( - line: 'Complaint Module', pageMover: '/complaint'), + line: 'Complaint Module', pageMover: '/complaint',isActive: true,), ModulesPadding(line: 'Central Mess Module'), ModulesPadding(line: 'Feeds Module'), ModulesPadding( line: 'Health Center Module', pageMover: '/health_center', + isActive: true, ), ModulesPadding(line: 'Leave Module'), ModulesPadding(line: 'Placement Module'), diff --git a/lib/api.dart b/lib/api.dart index 802bee2d..1dcfa167 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,9 +1,9 @@ //Server and local links String klocalLink = "127.0.0.1:8000"; -String kserverLink = "172.27.16.215:80"; +String kserverLink = "172.27.16.214:80"; //Login Service -String kAuthUrl = "172.27.16.215:80"; +String kAuthUrl = "172.27.16.214:80"; String kAuthLogin = "/api/auth/login/"; //Profile Service @@ -28,7 +28,8 @@ const kGymkhanaMemberRecords = '/api/gymkhana/members_record'; //HealthCentre String kHealthCentreStudent = "/healthcenter/api/student"; - +String kcompounder = "/healthcenter/api/student/request"; +String KHealthCenterStudentRequest = "/healthcenter/api/student/request"; //------------Screens------------ //screens/Academic/Current_Semester diff --git a/lib/models/complaints.dart b/lib/models/complaints.dart index 16b50bbf..d35d980c 100644 --- a/lib/models/complaints.dart +++ b/lib/models/complaints.dart @@ -26,9 +26,7 @@ class ComplaintData { class ComplaintDataUserStudent { List? student_complain; - ComplaintDataUserStudent({this.student_complain}); - factory ComplaintDataUserStudent.fromJson(Map json) { return ComplaintDataUserStudent( student_complain: json["student_complain"], diff --git a/lib/models/health.dart b/lib/models/health.dart index ed9c53c7..db72b002 100644 --- a/lib/models/health.dart +++ b/lib/models/health.dart @@ -50,3 +50,37 @@ class HealthData { }; } } +class StudentMedicalHistory { + List? medical_history; + StudentMedicalHistory({this.medical_history}); + factory StudentMedicalHistory.fromJson(Map json) { + return StudentMedicalHistory( + medical_history: json["student_complain"], + ); + } +} +class Doctor { + final int id; + final String doctorName; + final String doctorPhone; + final String specialization; + final bool active; + + Doctor({ + required this.id, + required this.doctorName, + required this.doctorPhone, + required this.specialization, + required this.active, + }); + + factory Doctor.fromJson(Map json) { + return Doctor( + id: json['id'], + doctorName: json['doctor_name'], + doctorPhone: json['doctor_phone'], + specialization: json['specialization'], + active: json['active'], + ); + } +} \ No newline at end of file diff --git a/lib/screens/Complaint/ComplaintHistory/complain_history.dart b/lib/screens/Complaint/ComplaintHistory/complain_history.dart index a187ad1a..1f5547ab 100644 --- a/lib/screens/Complaint/ComplaintHistory/complain_history.dart +++ b/lib/screens/Complaint/ComplaintHistory/complain_history.dart @@ -15,7 +15,7 @@ class ComplainHistory extends StatefulWidget { _ComplainHistoryState createState() => _ComplainHistoryState(); } -class _ComplainHistoryState extends State { +class _ComplainHistoryState extends State{ bool _loading1 = true; //integrating_api late StreamController _complaintController; diff --git a/lib/screens/Healthcenter/Appointment.dart b/lib/screens/Healthcenter/Appointment.dart index 8188e9d5..4064d7d8 100644 --- a/lib/screens/Healthcenter/Appointment.dart +++ b/lib/screens/Healthcenter/Appointment.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; import 'package:date_field/date_field.dart'; +import 'package:intl/intl.dart'; + +import 'package:fusion/services/health_service.dart'; class Appointment extends StatefulWidget { @override @@ -10,6 +13,8 @@ class Appointment extends StatefulWidget { class _AppointmentState extends State { int _value = 1; + String select_date = '', drname = '', from_time = '', to_time = '', issues = ''; + @override Widget build(BuildContext context) { @@ -45,21 +50,20 @@ class _AppointmentState extends State { items: [ DropdownMenuItem( child: Text("--SELECT--"), - value: 1, - ), - DropdownMenuItem( - child: Text("Dr Tony Gupta"), - value: 2, + value: 1, ), DropdownMenuItem( - child: Text("Dr Hrishi Goyal"), + child: Text("Dr. John Doe"), value: 3, ), - DropdownMenuItem(child: Text("Dr Preeti Singh"), value: 4), + DropdownMenuItem(child: Text("Dr. Jyoti"), value: 4), ], onChanged: (value) { setState(() { - //_value = value; + _value = value as int ; + if(_value==2) drname= "Dr G.S. Sandhu"; + else if(_value==3) drname="Dr Preeti Singh"; + }); }), Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), @@ -74,10 +78,20 @@ class _AppointmentState extends State { ), mode: DateTimeFieldPickerMode.date, autovalidateMode: AutovalidateMode.always, + + // Adding first date (for this we can't select past date) + + // initialValue or controller.text can be null, empty or a DateTime string otherwise it will throw an error. + initialValue: DateTime.now(), + firstDate: DateTime.now(), + validator: (e) => - (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + onDateSelected: (DateTime value) { - print(value); + // print(value); + select_date = DateFormat('yyyy-MM-dd').format(value); + }, ), Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), @@ -91,55 +105,163 @@ class _AppointmentState extends State { ), mode: DateTimeFieldPickerMode.time, autovalidateMode: AutovalidateMode.always, + validator: (e) => - (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, onDateSelected: (DateTime value) { - print(value); + // print(value); + from_time = DateFormat('HH:mm:ss').format(value); + // print(from_time); }, ), Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.access_time_rounded), - labelText: 'To Time', - ), - mode: DateTimeFieldPickerMode.time, - autovalidateMode: AutovalidateMode.always, - validator: (e) => - (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, + DateTimeFormField( + decoration: const InputDecoration( + hintStyle: TextStyle(color: Colors.black45), + errorStyle: TextStyle(color: Colors.redAccent), + border: OutlineInputBorder(), + suffixIcon: Icon(Icons.access_time_rounded), + labelText: 'To Time', ), + mode: DateTimeFieldPickerMode.time, + autovalidateMode: AutovalidateMode.always, + validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + onDateSelected: (DateTime value) { + print(value); + to_time = DateFormat('HH:mm:ss').format(value); + DateTime fromTime = DateFormat('HH:mm:ss').parse(from_time); + DateTime toTime = DateFormat('HH:mm:ss').parse(to_time); + if (toTime.isBefore(fromTime)) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Invalid Time'), + content: Text( + 'The from time cannot be greater than or equal to the to time.', + ), + actions: [ + TextButton( + child: Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + }, + ), Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), TextFormField( - cursorHeight: 30, - decoration: new InputDecoration( - labelText: "Issues/Symptoms", - fillColor: Colors.white, - border: new OutlineInputBorder(), - //fillColor: Colors.green - ), - style: new TextStyle( - fontFamily: "Poppins", - ), - ), - Padding(padding: EdgeInsets.symmetric(vertical: 5.0)), + cursorHeight: 30, + decoration: new InputDecoration( + labelText: "Issues/Symptoms", + fillColor: Colors.white, + border: new OutlineInputBorder(), + //fillColor: Colors.green + ), + style: new TextStyle( + fontFamily: "Poppins", + ), + onChanged: (value) { + setState(() { + issues = value; + }); + }), + Padding( + padding: EdgeInsets.symmetric( + vertical: 5.0)), //FlatButton not found in healthcenter + Center( - child: TextButton( - child: Text( - 'Submit', - style: TextStyle(fontSize: 15.0), + child: SizedBox( + width: 100, + height: 40, + child: TextButton( + child: Text( + "Submit", + style: TextStyle(fontSize: 20), + ), + + // try something new here + + onPressed: () async { + HeathService auth = HeathService(); + bool lodge = await auth.doctorAppoinment( + _value, + // drname, + select_date, + from_time, + to_time, + issues, + ); + print(select_date); + print(drname); + print(to_time); + // print(reason); + print(lodge); + // TextInput.finishAutofillContext(); + if (lodge == true) { + return showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text("Success"), + content: Text("appointment Request Added Successfully"), + actions: [ + ElevatedButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text("okay"), + ), + ], + ), + ); + } else { + return showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text("Failed"), + content: Text("Cannot add appointment Request"), + actions: [ + ElevatedButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text("okay"), + ), + ], + ), + ); + } + }, + + // end something new here + + // onPressed: () { + // print(date); + // print(to_time); + // print(from_time); + // print(issues); + // print('Submitted Successfully!'); + // }, + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.red), + backgroundColor: MaterialStateProperty.all(Colors.white), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + side: BorderSide(color: Colors.red), + )), + ), ), - // color: Colors.deepOrangeAccent, - onPressed: () {}, ), - ), + ) + ], ), ); } -} +} \ No newline at end of file diff --git a/lib/screens/Healthcenter/ambulanceRequest.dart b/lib/screens/Healthcenter/ambulanceRequest.dart index 41e92bc1..1f7a17f1 100644 --- a/lib/screens/Healthcenter/ambulanceRequest.dart +++ b/lib/screens/Healthcenter/ambulanceRequest.dart @@ -1,12 +1,28 @@ import 'package:flutter/material.dart'; import 'package:date_field/date_field.dart'; +import 'package:fusion/services/storage_service.dart'; + +import 'package:fusion/services/health_service.dart'; +import 'package:intl/intl.dart'; class AmbulanceRequest extends StatefulWidget { + // here is changes for user_id + // final String? ambulanceRequesterRollNo; + // AmbulanceRequest(this.ambulanceRequesterRollNo); + @override _AmbulanceRequestState createState() => _AmbulanceRequestState(); } class _AmbulanceRequestState extends State { + int _value = 1; + String start_date = '', end_date = '', reason = '', user_id = "20BCS046"; + + // String? user_id = widget.ambulanceRequesterRollNo; + // String? worker_id = ""; + + TextEditingController reasonController = TextEditingController(); + @override Widget build(BuildContext context) { return Container( @@ -24,13 +40,21 @@ class _AmbulanceRequestState extends State { ), mode: DateTimeFieldPickerMode.date, autovalidateMode: AutovalidateMode.always, + + // initialValue or controller.text can be null, empty or a DateTime string otherwise it will throw an error. + initialValue: DateTime.now(), + firstDate: DateTime.now(), + validator: (e) => - (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, onDateSelected: (DateTime value) { - print(value); + // start_date = value.toString(); + start_date = DateFormat('yyyy-MM-dd').format(value); + print(start_date); }, ), - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + DateTimeFormField( decoration: const InputDecoration( hintStyle: TextStyle(color: Colors.black45), @@ -41,16 +65,32 @@ class _AmbulanceRequestState extends State { ), mode: DateTimeFieldPickerMode.date, autovalidateMode: AutovalidateMode.always, + + + // initialValue or controller.text can be null, empty or a DateTime string otherwise it will throw an error. + initialValue: DateTime.now(), + firstDate: DateTime.now(), + validator: (e) => - (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, onDateSelected: (DateTime value) { - print(value); + // end_date = value.toString(); + end_date = DateFormat('yyyy-MM-dd').format(value); + print(end_date); }, ), - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), TextFormField( maxLines: 4, cursorHeight: 30, + controller: reasonController, + // onChanged: (value) => reasonController.text = value, + onChanged: (value) { + setState(() { + reason = value.toString(); + }); + }, decoration: new InputDecoration( labelText: "Reason", fillColor: Colors.white, @@ -61,19 +101,82 @@ class _AmbulanceRequestState extends State { fontFamily: "Poppins", ), ), + Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), Center( - child: TextButton( - child: Text( - 'Submit', - style: TextStyle(fontSize: 15.0), + child: SizedBox( + width: 100, + height: 40, + child: TextButton( + child: Text( + "Submit", + style: TextStyle(fontSize: 20), + ), + + // try something new + + onPressed: () async { + HeathService auth = HeathService(); + bool lodge = await auth.getAmbulence( + // user_id, + start_date, + end_date, + reason, + ); + + + // TextInput.finishAutofillContext(); + if (lodge == true) { + return showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text("Success"), + content: Text("Ambulance Request Added Successfully"), + actions: [ + ElevatedButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text("okay"), + ), + ], + ), + ); + } else { + return showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text("Failed"), + content: Text("Cannot add Ambulance Request"), + actions: [ + ElevatedButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text("okay"), + ), + ], + ), + ); + } + }, + + + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.red), + backgroundColor: MaterialStateProperty.all(Colors.white), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + side: BorderSide(color: Colors.red), + )), + ), ), - // color: Colors.deepOrangeAccent, - onPressed: () {}, ), - ), + ) + ], ), ); } -} +} \ No newline at end of file diff --git a/lib/screens/Healthcenter/feedback.dart b/lib/screens/Healthcenter/feedback.dart index 86fe408c..b12e728a 100644 --- a/lib/screens/Healthcenter/feedback.dart +++ b/lib/screens/Healthcenter/feedback.dart @@ -1,12 +1,16 @@ import 'package:flutter/material.dart'; + class FeedBack extends StatefulWidget { @override _FeedBackState createState() => _FeedBackState(); } class _FeedBackState extends State { + gender? _genderEnum; + Rating? _treatment,_waiting,_maintenance; @override + Widget feed = Container( padding: EdgeInsets.all(20.0), child: Column( @@ -39,6 +43,8 @@ class _FeedBackState extends State { ); Widget build(BuildContext context) { + int _value=1; + double iconSize = 40; return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( @@ -72,6 +78,7 @@ class _FeedBackState extends State { ], ), ), + Container( height: 520, //height of TabBarView decoration: BoxDecoration( diff --git a/lib/screens/Healthcenter/healthcentermodule.dart b/lib/screens/Healthcenter/healthcentermodule.dart index a785697d..2df30675 100644 --- a/lib/screens/Healthcenter/healthcentermodule.dart +++ b/lib/screens/Healthcenter/healthcentermodule.dart @@ -43,7 +43,7 @@ class _HealthCenterModState extends State { getData() async { //print('token-'+widget.token!); try { - Response response = await healthService.getHealth(widget.token!); + Response response = await healthService.getHealth(); setState(() { // print(response); data = HealthData.fromJson(jsonDecode(response.body)); diff --git a/lib/screens/Healthcenter/history.dart b/lib/screens/Healthcenter/history.dart index 42b01fe0..8db52a33 100644 --- a/lib/screens/Healthcenter/history.dart +++ b/lib/screens/Healthcenter/history.dart @@ -11,7 +11,7 @@ class _HistoryState extends State { @override Widget build(BuildContext context) { final HealthData data = - ModalRoute.of(context)!.settings.arguments as HealthData; + ModalRoute.of(context)!.settings.arguments as HealthData; return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( @@ -101,18 +101,18 @@ class _HistoryState extends State { ]), data.complaints != null && data.complaints!.isNotEmpty ? TableRow(children: [ - for (var complaints in data.complaints!) - tableCell2("\n" + complaints["feedback"].toString() + "\n"), - for (var complaints in data.complaints!) - tableCell2("\n" + complaints["complaint"].toString() + "\n"), - for (var complaints in data.complaints!) - tableCell2("\n" + complaints["date"].toString() + "\n"), - ]) + for (var complaints in data.complaints!) + tableCell2("\n" + complaints["feedback"].toString() + "\n"), + for (var complaints in data.complaints!) + tableCell2("\n" + complaints["complaint"].toString() + "\n"), + for (var complaints in data.complaints!) + tableCell2("\n" + complaints["date"].toString() + "\n"), + ]) : TableRow(children: [ - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - ]), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + ]), ]), ); } @@ -127,20 +127,11 @@ class _HistoryState extends State { tableCell("\nDescription\n"), tableCell("\nDate\n"), ]), - data.appointments != null && data.appointments!.isNotEmpty - ? TableRow(children: [ - tableCell2("\n" + "Name not available" + "\n"), - for (var appointments in data.appointments!) - tableCell2( - "\n" + appointments!["description"].toString() + "\n"), - for (var appointments in data.appointments!) - tableCell2("\n" + appointments!["date"].toString() + "\n"), - ]) - : TableRow(children: [ - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - ]), + TableRow(children: [ + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + ]), ]), ); } @@ -155,35 +146,35 @@ class _HistoryState extends State { tableCell("\nHospital\n"), Center( child: Column( - children: [ - tableCell("\nAdmit"), - tableCell("Date\n"), - ], - )), + children: [ + tableCell("\nAdmit"), + tableCell("Date\n"), + ], + )), Center( child: Column( - children: [ - tableCell("\nDischarge"), - tableCell("Date\n"), - ], - )), + children: [ + tableCell("\nDischarge"), + tableCell("Date\n"), + ], + )), tableCell("\nReason\n"), ]), data.hospitals != null && data.hospitals!.isNotEmpty ? TableRow(children: [ - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - ]) + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + ]) : TableRow(children: [ - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - ]), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + ]), ]), ); } @@ -208,17 +199,17 @@ class _HistoryState extends State { ]), data.ambulances != null && data.ambulances!.isNotEmpty ? TableRow(children: [ - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - ]) + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + ]) : TableRow(children: [ - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - tableCell2("\n" + "NA" + "\n"), - ]) + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + ]) ]), ); } @@ -229,60 +220,66 @@ class _HistoryState extends State { padding: EdgeInsets.symmetric(vertical: 15, horizontal: 5), child: Table(border: TableBorder.all(color: Colors.black), children: [ TableRow(children: [ - tableCell("\nTreated By\n"), - if (data.prescription != null && data.prescription!.isNotEmpty) - for (var prescription in data.prescription!) - tableCell2("\n" + "Name Not available" + "\n") - else - tableCell2("\n" + "NA" + "\n"), - ]), - TableRow(children: [ - tableCell("\nDate\n"), - if (data.prescription != null && data.prescription!.isNotEmpty) - for (var prescription in data.prescription!) - tableCell2("\n" + prescription!['date'].toString() + "\n") - else - tableCell2("\n" + "NA" + "\n"), - ]), - TableRow(children: [ - tableCell("\nDetail\n"), - if (data.prescription != null && data.prescription!.isNotEmpty) - for (var prescription in data.prescription!) - tableCell2("\n" + prescription!["details"].toString() + "\n") - else - tableCell2("\n" + "NA" + "\n"), - ]), - TableRow(children: [ - tableCell("\nTest\n"), - if (data.prescription != null && data.prescription!.isNotEmpty) - for (var prescription in data.prescription!) - tableCell2("\n" + prescription!["test"].toString() + "\n") - else - tableCell2("\n" + "NA" + "\n"), - ]), - TableRow(children: [ - tableCell("\nMedicine\n"), - if (data.medicines != null && data.medicines!.isNotEmpty) - for (var medicines in data.medicines!) - tableCell2("\n" + medicines!["medicine_id"].toString() + "\n") - else - tableCell2("\n" + "NA" + "\n"), - ]), - TableRow(children: [ - tableCell("\nNo of Days\n"), - if (data.medicines != null && data.medicines!.isNotEmpty) - for (var medicines in data.medicines!) - tableCell2("\n" + medicines!["days"].toString() + "\n") - else - tableCell2("\n" + "NA" + "\n"), + Center( + child: Column( + children: [ + tableCell("\n Treated By"), + // tableCell("Date\n"), + ], + )), + Center( + child: Column( + children: [ + tableCell("\n Date\n"), + ], + )), + Center( + child: Column( + children: [ + tableCell("\nDetail"), + // tableCell("Date\n"), + ], + )), + Center( + child: Column( + children: [ + tableCell("\n Test"), + ], + )), + Center( + child: Column( + children: [ + tableCell("\nMedicine"), + // tableCell("Date\n"), + ], + )), + Center( + child: Column( + children: [ + tableCell("\n No of Days"), + // tableCell("Date\n"), + ], + )), + tableCell("\n No of Times/day\n"), ]), - TableRow(children: [ - tableCell("\nNo of Times/day\n"), - if (data.medicines != null && data.medicines!.isNotEmpty) - for (var medicines in data.medicines!) - tableCell2("\n" + medicines!["times"].toString() + "\n") - else - tableCell2("\n" + "NA" + "\n"), + data.prescription != null && data.prescription!.isNotEmpty + ? TableRow(children: [ + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + ]) + : TableRow(children: [ + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), + tableCell2("\n" + "NA" + "\n"), ]), ]), ); @@ -304,4 +301,4 @@ class _HistoryState extends State { ), ); } -} +} \ No newline at end of file diff --git a/lib/screens/Healthcenter/viewschedule.dart b/lib/screens/Healthcenter/viewschedule.dart index 1361ff56..168f41bf 100644 --- a/lib/screens/Healthcenter/viewschedule.dart +++ b/lib/screens/Healthcenter/viewschedule.dart @@ -1,34 +1,53 @@ import 'package:flutter/material.dart'; - +import 'package:fusion/models/health.dart'; +import 'package:http/http.dart' as http; +import 'package:fusion/api.dart'; +import 'dart:convert'; +import 'package:fusion/constants.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; class ViewSchedule extends StatefulWidget { @override _ViewScheduleState createState() => _ViewScheduleState(); } class _ViewScheduleState extends State { + List doctors = []; @override + void initState() { + super.initState(); + fetchDoctors(); + } + Future fetchDoctors() async { + var storage_service = locator(); -//////////////////// - Widget doctorinfo=new Container( - color: Colors.white, - padding: EdgeInsets.symmetric(vertical: 15,horizontal: 5), - child: Table( - border: TableBorder.all(color: Colors.black), - children: [ - TableRow(children: [ - Center(child: Text("\nDoctor Name\n",style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),), - Center(child: Text("\nSpecialization\n",style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),), - Center(child: Text("\nPhone\n",style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),), - ]), - TableRow(children: [ - Center(child: Text("\nNA\n",style: TextStyle(fontSize: 16,)),), - Center(child:Text("\nNA\n",style: TextStyle(fontSize: 16)),), - Center(child:Text("\nNA\n",style: TextStyle(fontSize: 16,)),), - ]), - ]), - ); - /////////// + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + print("fetching details"); + var client = http.Client(); + http.Response response = await client.get( + Uri.http( + getLink(), + kHealthCentreStudent, //constant api + ), + headers: headers, + ); + if (response.statusCode == 200) { + setState(() { + Map data = json.decode(response.body); + Listdoctorsdata = data['doctors']; + doctors = (doctorsdata as List).map((data) => Doctor.fromJson(data)).toList(); + // print(doctors); + }); + } else { + throw Exception('Failed to load doctors'); + } + print(doctors); + } ///////////DOCTOR info Widget viewschedule=new Container( @@ -110,7 +129,7 @@ class _ViewScheduleState extends State { ), child: TabBarView(children: [ viewschedule, - doctorinfo, + doctorinfo(doctors), ]) ) ]) @@ -120,3 +139,36 @@ class _ViewScheduleState extends State { ); } } +Container doctorinfo(List doctors) { + return new Container( + color: Colors.white, + padding: EdgeInsets.symmetric(vertical: 15, horizontal: 5), + child: Table( + border: TableBorder.all(color: Colors.black), + children: [ + TableRow(children: [ + Center(child: Text("\nDoctor Name\n", + style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),), + Center(child: Text("\nSpecialization\n", + style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),), + Center(child: Text("\nPhone\n", + style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),), + ]), + ...doctors.map((doctor) => + TableRow(children: [ + Center( + child: Text("\n${doctor.doctorName}\n", + style: TextStyle(fontSize: 16)), + ), + Center( + child: Text("\n${doctor.specialization}\n", + style: TextStyle(fontSize: 16)), + ), + Center( + child: Text("\n${doctor.doctorPhone}\n", + style: TextStyle(fontSize: 16)), + ), + ])).toList(), + ]), + ); +} diff --git a/lib/services/complaint_service.dart b/lib/services/complaint_service.dart index 849bb608..c1669bcc 100644 --- a/lib/services/complaint_service.dart +++ b/lib/services/complaint_service.dart @@ -22,7 +22,11 @@ class ComplaintService { http.Response response = await client.get( Uri.http( getLink(), + // kHealthCentreStudent, + // kProfile, + // kcompounder, kComplaintService, //constant api path + // kHealthCentreStudent, ), headers: headers, ); diff --git a/lib/services/health_service.dart b/lib/services/health_service.dart index f90f37b0..5f9d74ae 100644 --- a/lib/services/health_service.dart +++ b/lib/services/health_service.dart @@ -1,11 +1,176 @@ import 'dart:core'; +import 'dart:convert'; import 'package:fusion/api.dart'; import 'package:fusion/constants.dart'; +import 'package:fusion/models/health.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; import 'package:http/http.dart' as http; class HeathService { - getHealth(String token) async { - Map headers = {'Authorization': 'Token ' + token}; + Future getHealth() async { + try { + var storage_service = locator(); + + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + print("fetching complaints"); + var client = http.Client(); + http.Response response = await client.get( + Uri.http( + getLink(), + kHealthCentreStudent, //constant api + ), + headers: headers, + ); + if (response.statusCode == 200) { + print("successfully fetched profile"); + return response; + } + throw Exception('Can\'t load'); + } + catch (e) { + rethrow; + } + } + + //---- start-here -------- + + Future getAmbulence( + // here we have to all data point + // String? user_id, + // String? date_request, + String? start_date, + String? end_date, + String? reason, + ) async { + try { + Map data = { + // we have to write all point here + // "user_id": user_id!, + // "date_request": date_request! + "start_date": start_date!, + "end_date": end_date!, + "reason": reason, + "ambulancerequest": "true" + }; + var storage_service = locator(); + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? ""), + 'Content-type': 'application/json', + }; + var body = json.encode(data); + var client = http.Client(); + var response = await client.post( + Uri.http( + getLink(), + KHealthCenterStudentRequest, //constant update path + ), + headers:headers , + body: body,); + print("Fetched Data"); + print(response.statusCode); + // print(jsonDecode(response.body)); + if (response.statusCode == 201) return true; + else return false; + } catch (e) { + rethrow; + } + } + + Future doctorAppoinment( + // String user_id, + int? doctor_id, + String? date, + String? from_time, + String? to_time, + String? issue, + ) async { + try { + // here we have to write all data point + Map data = { + "doctor_id": doctor_id!, + "date": date!, + "description": issue, + "appointmentadd": "true" + }; + print(json.encode(data)); + var storage_service = locator(); + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? ""), + 'Content-type': 'application/json', + }; + + var client = http.Client(); + var response = await client.post( + Uri.http( + getLink(), + KHealthCenterStudentRequest, //constant update path + ), + headers: headers, + body: json.encode(data)); + print("Fetched Data"); + print(response.statusCode); + print(response.body); + print("Fetched Dated"); + if (response.statusCode == 201) return true; + return false; + } catch (e) { + rethrow; + } + } + + Future Student_history( + // yaha parameters dalna hai form ke + ) async { + try { + Map data = { + // yaha par key value pair banana hai param se + }; + var storage_service = locator(); + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + + var client = http.Client(); + var response = await client.put( + Uri.http( + getLink(), + kHealthCentreStudent, //change karna hai endpoint ko + ), + headers: headers, + body: data); + print("Fetched Data"); + if (response.statusCode == 200) return true; + return false; + } catch (e) { + rethrow; + } + } + Future> fetchDoctors() async { + List doctors = []; + var storage_service = locator(); + + if (storage_service.userInDB?.token == null) + throw Exception('Token Error'); + + Map headers = { + 'Authorization': 'Token ' + (storage_service.userInDB?.token ?? "") + }; + print("fetching complaints"); var client = http.Client(); http.Response response = await client.get( Uri.http( @@ -15,8 +180,11 @@ class HeathService { headers: headers, ); if (response.statusCode == 200) { - print("successfully fetched profile"); - return response; + doctors = (json.decode(response.body) as List).map((data) => Doctor.fromJson(data)).toList(); + } else { + throw Exception('Failed to load doctors'); } + return(doctors); + print(doctors); } -} +} \ No newline at end of file