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

OS -2 API Integration Added , added ambulance and appointment request functionality , view of doctor details functionality #136

Open
wants to merge 2 commits into
base: test
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
3 changes: 2 additions & 1 deletion lib/Components/side_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ class _SideDrawerState extends State<SideDrawer> {
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'),
Expand Down
7 changes: 4 additions & 3 deletions lib/api.dart
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions lib/models/complaints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
34 changes: 34 additions & 0 deletions lib/models/health.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> json) {
return Doctor(
id: json['id'],
doctorName: json['doctor_name'],
doctorPhone: json['doctor_phone'],
specialization: json['specialization'],
active: json['active'],
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ComplainHistory extends StatefulWidget {
_ComplainHistoryState createState() => _ComplainHistoryState();
}

class _ComplainHistoryState extends State<ComplainHistory> {
class _ComplainHistoryState extends State<ComplainHistory>{
bool _loading1 = true;
//integrating_api
late StreamController _complaintController;
Expand Down
216 changes: 169 additions & 47 deletions lib/screens/Healthcenter/Appointment.dart
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,6 +13,8 @@ class Appointment extends StatefulWidget {

class _AppointmentState extends State<Appointment> {
int _value = 1;
String select_date = '', drname = '', from_time = '', to_time = '', issues = '';


@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -45,21 +50,20 @@ class _AppointmentState extends State<Appointment> {
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)),
Expand All @@ -74,10 +78,20 @@ class _AppointmentState extends State<Appointment> {
),
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)),
Expand All @@ -91,55 +105,163 @@ class _AppointmentState extends State<Appointment> {
),
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: <Widget>[
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: <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 appointment 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),
)),
),
),
// color: Colors.deepOrangeAccent,
onPressed: () {},
),
),
)

],
),
);
}
}
}
Loading