diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index be08db0e..523f93bd 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -138,6 +138,7 @@ class _SideDrawerState extends State { ModulesPadding( line: 'Health Center Module', pageMover: '/health_center', + isActive: true, // activating our module OS-2 ), ModulesPadding(line: 'Leave Module'), ModulesPadding(line: 'Placement Module'), diff --git a/lib/api.dart b/lib/api.dart index 802bee2d..31865d3e 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,9 +1,10 @@ //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 @@ -29,6 +30,11 @@ const kGymkhanaMemberRecords = '/api/gymkhana/members_record'; //HealthCentre String kHealthCentreStudent = "/healthcenter/api/student"; +// -------my----- +String kHealthCenterCompunderRequest = "/healthcenter/api/compounder/request"; +String kHealthCenterCompounder = "/healthcenter/api/compounder"; +String KHealthCenterStudentRequest = "/healthcenter/api/student/request"; + //------------Screens------------ //screens/Academic/Current_Semester diff --git a/lib/screens/Healthcenter/Appointment.dart b/lib/screens/Healthcenter/Appointment.dart index dd486166..0876b2b6 100644 --- a/lib/screens/Healthcenter/Appointment.dart +++ b/lib/screens/Healthcenter/Appointment.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; import 'package:date_field/date_field.dart'; +import 'package:intl/intl.dart'; -class Appointment extends StatefulWidget { +import 'package:fusion/services/health_service.dart'; +class Appointment extends StatefulWidget { @override _AppointmentState createState() => _AppointmentState(); } @@ -10,128 +12,243 @@ class Appointment extends StatefulWidget { //int get _value=>_value; class _AppointmentState extends State { - int _value=1; + int _value = 1; + String date = '', + drname = '', + from_time = '', + to_time = '', + issues = '', + dr_id = ''; + @override Widget build(BuildContext context) { return Container( - // color: Colors.red, - width: 200, - //height: 120, - //color: Colors.blue, - alignment: Alignment.topCenter, - padding: EdgeInsets.all(30.0), - child:ListView( - children: [ - Text("Doctor",style:TextStyle(fontSize: 18,fontWeight: FontWeight.bold),textAlign: TextAlign.start,), - Padding( - padding:EdgeInsets.symmetric(horizontal:0.0), - child:Container( - height:0.5, - width:130.0, - color:Colors.black,),), - Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - DropdownButton( - dropdownColor: Colors.deepOrangeAccent, - elevation: 16, - value: _value, - isExpanded: true, - hint: Text("-SELECT-"), - items: [ - DropdownMenuItem( - child: Text("--SELECT--"), - value: 1, - ), - DropdownMenuItem( - child: Text("Dr Tony Gupta"), - value: 2, - ), - DropdownMenuItem( - child: Text("Dr Hrishi Goyal"), - value: 3, - - ), - DropdownMenuItem( - child: Text("Dr Preeti Singh"), - value: 4 - ), - ], - onChanged: (value) { - setState(() { - //_value = value; - }); - }), - Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - //SessionView, - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.event_note), - labelText: 'Date', - ), - mode: DateTimeFieldPickerMode.date, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, + // color: Colors.red, + width: 200, + //height: 120, + //color: Colors.blue, + alignment: Alignment.topCenter, + padding: EdgeInsets.all(30.0), + child: ListView( + children: [ + Text( + "Doctor", + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + textAlign: TextAlign.start, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 0.0), + child: Container( + height: 0.5, + width: 130.0, + color: Colors.black, ), - 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: 'From Time', - ), - mode: DateTimeFieldPickerMode.time, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, + ), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + DropdownButton( + dropdownColor: Colors.deepOrangeAccent, + elevation: 16, + value: _value, + isExpanded: true, + hint: Text("-SELECT-"), + items: [ + DropdownMenuItem( + child: Text("--SELECT--"), + value: 1, + ), + DropdownMenuItem( + child: Text("Dr G.S. Sandhu"), + value: 2, + ), + DropdownMenuItem( + child: Text("Dr AN Gupta"), + value: 3, + ), + DropdownMenuItem(child: Text("Dr Preeti Singh"), value: 4), + ], + onChanged: (value) { + setState(() { + // _value = (int)value; + dr_id = value.toString(); + }); + }), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + //SessionView, + DateTimeFormField( + decoration: const InputDecoration( + hintStyle: TextStyle(color: Colors.black45), + errorStyle: TextStyle(color: Colors.redAccent), + border: OutlineInputBorder(), + suffixIcon: Icon(Icons.event_note), + labelText: 'Date', ), - 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); - }, + 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, + + onDateSelected: (DateTime value) { + // print(value); + date = DateFormat('yyyy-MM-dd').format(value); + print(date); + // date =value; + }, + ), + 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: 'From Time', + ), + mode: DateTimeFieldPickerMode.time, + autovalidateMode: AutovalidateMode.always, + + // For time validation -----------> Pradeep + + validator: (e) => + (e?.day ?? 0) == 1 ? 'Please not the first day' : null, + onDateSelected: (DateTime 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', ), - Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - TextFormField( + 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); + }, + ), + Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), + TextFormField( cursorHeight: 30, decoration: new InputDecoration( labelText: "Issues/Symptoms", fillColor: Colors.white, - border: new OutlineInputBorder( - ), + 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: 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, + dr_id, + date, + from_time, + to_time, + issues, + ); + // print(user_id); + // print(start_date); + // print(end_date); + // print(reason); + // print(lodge); + + // 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"), + ), + ], + ), + ); + } + }, + + // 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), + )), + ), + ), ), - Padding(padding: EdgeInsets.symmetric(vertical: 5.0)), - Center(child:FlatButton( - child: Text('Submit', style: TextStyle(fontSize: 15.0),), - color: Colors.deepOrangeAccent, - onPressed: () {}, - ), - ), - ], - ), + ) + ], + ), ); } } diff --git a/lib/screens/Healthcenter/ambulanceRequest.dart b/lib/screens/Healthcenter/ambulanceRequest.dart index 4d90910a..e6bfd8d2 100644 --- a/lib/screens/Healthcenter/ambulanceRequest.dart +++ b/lib/screens/Healthcenter/ambulanceRequest.dart @@ -1,77 +1,194 @@ 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 = ''; + + // String? user_id = widget.ambulanceRequesterRollNo; + // String? worker_id = ""; + + TextEditingController reasonController = TextEditingController(); + @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(20.0), child: Column( - children: [ - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), - - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.event_note), - labelText: 'From', - ), - mode: DateTimeFieldPickerMode.date, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, - ), - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), - - DateTimeFormField( - decoration: const InputDecoration( - hintStyle: TextStyle(color: Colors.black45), - errorStyle: TextStyle(color: Colors.redAccent), - border: OutlineInputBorder(), - suffixIcon: Icon(Icons.event_note), - labelText: 'To', - ), - mode: DateTimeFieldPickerMode.date, - autovalidateMode: AutovalidateMode.always, - validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, - onDateSelected: (DateTime value) { - print(value); - }, - ), - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), - TextFormField( - maxLines: 4, - cursorHeight: 30, - decoration: new InputDecoration( - labelText: "Reason", - fillColor: Colors.white, - border: new OutlineInputBorder( - ), - //fillColor: Colors.green - ), - style: new TextStyle( - fontFamily: "Poppins", - ), - ), - Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), - Center(child:FlatButton( - child: Text('Submit', style: TextStyle(fontSize: 15.0),), - color: Colors.deepOrangeAccent, - onPressed: () {}, - ), + children: [ + Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + DateTimeFormField( + decoration: const InputDecoration( + hintStyle: TextStyle(color: Colors.black45), + errorStyle: TextStyle(color: Colors.redAccent), + border: OutlineInputBorder(), + suffixIcon: Icon(Icons.event_note), + labelText: 'From', + ), + 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, + onDateSelected: (DateTime value) { + // start_date = value.toString(); + start_date = DateFormat('yyyy-MM-dd').format(value); + print(start_date); + }, + ), + 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.event_note), + labelText: 'To', + ), + 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, + onDateSelected: (DateTime value) { + // end_date = value.toString(); + end_date = DateFormat('yyyy-MM-dd').format(value); + print(end_date); + }, + ), + // adding time for ambulence request + // Padding(padding: EdgeInsets.symmetric(vertical: 10.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, + border: new OutlineInputBorder(), + //fillColor: Colors.green + ), + style: new TextStyle( + fontFamily: "Poppins", + ), + ), + + Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + Center( + 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, + ); + + // print(start_date); + // print(end_date); + // print(reason); + // print(lodge); + + // 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"), + ), + ], + ), + ); + } + }, + + //end something new + + // onPressed: () { + // print('Submitted Successfully ni!'); + // // reason = Text(reasonController.text).toString(); + // var res = reasonController.text; + // print(res); + // print(reason); + // print(start_date); + // print(end_date); + // }, + 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), + )), + ), + ), + ), + ) + ], ), ); } diff --git a/lib/screens/Healthcenter/feedback.dart b/lib/screens/Healthcenter/feedback.dart index 6b34c3f9..6c191b8b 100644 --- a/lib/screens/Healthcenter/feedback.dart +++ b/lib/screens/Healthcenter/feedback.dart @@ -1,18 +1,16 @@ import 'package:flutter/material.dart'; - +import 'package:fusion/services/health_service.dart'; class FeedBack extends StatefulWidget { @override _FeedBackState createState() => _FeedBackState(); } - - class _FeedBackState extends State { - @override - + String feedback = '', date = ''; - Widget feed=Container( + @override + Widget feed = Container( padding: EdgeInsets.all(20.0), child: Column( children: [ @@ -22,25 +20,86 @@ class _FeedBackState extends State { decoration: new InputDecoration( labelText: "Feedback", fillColor: Colors.white, - border: new OutlineInputBorder( - ), + border: new OutlineInputBorder(), //fillColor: Colors.green ), style: new TextStyle( fontFamily: "Poppins", ), ), - Center(child:FlatButton( - child: Text('Submit', style: TextStyle(fontSize: 15.0),), - color: Colors.deepOrangeAccent, - onPressed: () {}, - ), - ), + Padding(padding: EdgeInsets.symmetric(vertical: 20.0)), + Center( + 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.postFeedback( + // user_id, + feedback, + ); + print(lodge); + + // 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), + )), + ), + ), + ), + ) ], ), ); - Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, @@ -50,41 +109,43 @@ class _FeedBackState extends State { ), body: Container( child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - SizedBox(height: 20.0), - DefaultTabController( - length: 1, // length of tabs - initialIndex: 0, - child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Container( - //color: Colors.deepOrangeAccent, - child: TabBar( - labelColor: Colors.deepOrange, - indicatorColor: Colors.deepOrangeAccent, - unselectedLabelColor: Colors.black, - tabs: [ - Tab( - child: Text("Feedback Form", style: TextStyle( - fontWeight: FontWeight.bold),),), - ], - ), - ), - Container( - height: 520, //height of TabBarView - decoration: BoxDecoration( - border: Border( - top: BorderSide(color: Colors.grey, width: 0.5)) + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox(height: 20.0), + DefaultTabController( + length: 1, // length of tabs + initialIndex: 0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Container( + color: Colors.deepOrangeAccent, + child: TabBar( + labelColor: Colors.deepOrange, + indicatorColor: Colors.deepOrangeAccent, + unselectedLabelColor: Colors.black, + tabs: [ + Tab( + child: Text( + "Feedback Form", + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ], + ), ), - child: TabBarView(children: [ - feed, - - ]) - ) - ]) - ), - ]), + Container( + height: 520, //height of TabBarView + decoration: BoxDecoration( + border: Border( + top: BorderSide( + color: Colors.grey, width: 0.5))), + child: TabBarView(children: [ + feed, + ])) + ])), + ]), ), ); } -} \ No newline at end of file +} diff --git a/lib/services/health_service.dart b/lib/services/health_service.dart index f90f37b0..7c29d1d0 100644 --- a/lib/services/health_service.dart +++ b/lib/services/health_service.dart @@ -1,6 +1,9 @@ import 'dart:core'; +import 'dart:convert'; import 'package:fusion/api.dart'; import 'package:fusion/constants.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; import 'package:http/http.dart' as http; class HeathService { @@ -19,4 +22,137 @@ class HeathService { return response; } } + + //---- start-here -------- + + Future getAmbulence( + String? start_date, + String? end_date, + String? reason, + ) async { + try { + Map data = { + "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? doctor_id, + String? date, + String? from_time, + String? to_time, + String? description, + ) async { + try { + // here we have to write all data point + Map data = { + "doctor_id": doctor_id!, + "date": date!, + "from_time": from_time!, + "to_time": to_time!, + "description": description, + "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 body = json.encode(data); + var response = await client.post( + Uri.http( + getLink(), + KHealthCenterStudentRequest, //constant update path + ), + headers: headers, + // body: json.encode(data), + body: body); + print("Fetched Data"); + print(response.statusCode); + print(response.body); + if (response.statusCode == 200) return true; + return false; + } catch (e) { + rethrow; + } + } + +// for feedback + + Future postFeedback(String? feedback) async { + try { + // here we have to write all data point + Map data = { + "feedback": feedback!, + // "date": date!, + "complaintadd": "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 body = json.encode(data); + var response = await client.post( + Uri.http( + getLink(), + KHealthCenterStudentRequest, //constant update path + ), + headers: headers, + body: body); + print("Fetched Data"); + print(response.statusCode); + print(response.body); + if (response.statusCode == 200) return true; + return false; + } catch (e) { + rethrow; + } + } + + // fetching health record here + }