Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working on appoinment functionality #131

Open
wants to merge 4 commits into
base: os-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Components/side_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class _SideDrawerState extends State<SideDrawer> {
ModulesPadding(
line: 'Health Center Module',
pageMover: '/health_center',
isActive: true, // activating our module OS-2
),
ModulesPadding(line: 'Leave Module'),
ModulesPadding(line: 'Placement Module'),
Expand Down
10 changes: 8 additions & 2 deletions lib/api.dart
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
331 changes: 224 additions & 107 deletions lib/screens/Healthcenter/Appointment.dart
Original file line number Diff line number Diff line change
@@ -1,137 +1,254 @@
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();
}

//int get _value=>_value;

class _AppointmentState extends State<Appointment> {
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: <Widget>[
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: <Widget>[
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>(
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: () {},
),
),
],
),
)
],
),
);
}
}
Loading