0% found this document useful (0 votes)
549 views138 pages

Java Mini Project - Report (E - Health Care System)

Basic implementation E- health system including features of appoinment , Bed availability, To heck the medicine availability

Uploaded by

Hemalatha R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
549 views138 pages

Java Mini Project - Report (E - Health Care System)

Basic implementation E- health system including features of appoinment , Bed availability, To heck the medicine availability

Uploaded by

Hemalatha R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UCS2313-Object Oriented Programming Lab

e-Health Care Management System

Team Members:

Harine Cellam N S - 3122225001034


Harinishree K - 3122225001035
Hemalatha R - 3122225001039

Problem Statement:

In the current healthcare scenario, patients face challenges in efficiently


managing their healthcare needs. This includes booking appointments with doctors,
locating nearby hospitals, checking ward availability, and finding out about medicine
availability in pharmacies. The lack of a centralized, user-friendly system that integrates
all these services results in a time-consuming and often frustrating experience for
patients. Therefore, there is a need for an integrated e-Health Care Management System
that allows patients to seamlessly manage their healthcare needs from a single
platform.

Motivation for the problem:

The motivation for developing an e-Health Care Management System that integrates
various healthcare services into a single platform is driven by several factors:

1. Efficiency: Currently, patients have to navigate through multiple platforms or


physically visit healthcare facilities to book appointments, locate hospitals, check
ward availability, and find out about medicine availability. An integrated system
would streamline these processes, saving time and effort for the patients.
2. Accessibility: With the advent of the internet and digital technologies, healthcare
services can be made more accessible. Patients from remote areas can access
healthcare services without the need for physical travel.
3. Patient Empowerment: By providing patients with the ability to manage their
healthcare needs, we empower them to take charge of their health. They can
make informed decisions and actively participate in their healthcare journey.
4. Improved Healthcare: An integrated system would lead to better coordination
among healthcare providers, improved patient monitoring, and hence, improved
quality of healthcare services.
5. Cost-Effective: By digitizing and integrating healthcare services, we can reduce
the administrative and operational costs associated with healthcare delivery.

The goal is to leverage technology to make healthcare more patient-centric, efficient,


and accessible.

Scope:

1. Appointment Booking: The system will allow patients to book appointments with
doctors based on their availability.
2. Hospital Locator: The system will provide a feature to locate nearby hospitals by
entering the district.
3. Ward Availability: The system will provide real-time information about the
availability of wards in hospitals.
4. Medicine Availability: The system will provide information about the availability
of medicines in pharmacies.

Limitations:

1. Data Accuracy: Data accuracy is a major concern where the data is not verified
and verifying data can be a tedious process.
2. Updating Data: Updating data needs to be done manually and requires physical
labor.
3. Appointment Status: Once the doctor confirms or rejects an appointment, he/she
can’t modify the appointment if necessary.
Design of the Solution:

Patient

-name:String
-dob:String
-age:int
-bloodGroup:String
-height:String
-weight:String
-contact:String
-aadhar:String
-password:String

+viewMyProfile():void
+bookAppointment():void
+viewDoctor():void
+searchHospital():void
+checkWardAvailability():void
+checkMedicineAvailability():void

Doctor

-name:String
-dob:String
-degree:String
-specialization:String
-experience:int
-hospital:String
-contact:String
-password:String

+viewMyProfile():void
+checkAppointments():void
+viewAppointments():void
Admin

-name:String
-password:String

+hospitalDetails():void
+wardDetails():void
+medicineDetails():void

Hospital

-name:String
-district:String
-generalWards:int
-maleWards:int
-femaleWards:int
-mixedWards:int
-paediatricWards:int
-maternityWards:int
-ICUs:int
-emergencyWards:int
-isolationWards:int
-psychiatricWards:int

+storeHospitalData():void
+updateHospitalData():void
+viewHospitalData():void

Pharmacy

-name:String
-district:String
-medicine:String
-availableStatus:String

+storeData():void
+updataData():void
+viewData():void
Appointment

-doctor:String
-patient:String
-date:String
-time:String
-note:String

+bookAppointment():void
+updateStatus():void
+viewStatus():void

Modules split-up:

1. User Registration and Authentication Module: This module will handle user
registration, login, and authentication. It will ensure that only registered users can
access the system.
2. Appointment Booking Module: This module will allow patients to book
appointments with doctors. It will display the available slots and confirm the
booking.
3. Hospital Locator Module: This module will help patients locate nearby hospitals.
The user can enter district name to locate the hospitals in the district.
4. Ward Availability Module: This module will provide information about the
availability of wards in different hospitals. It will require real-time data from the
hospitals.
5. Medicine Availability Module: This module will allow patients to check the
availability of medicines in different pharmacies. It will require real-time data
from the pharmacies.
6. Doctor Profile Module: Here, the patient can view the doctor’s details by just
entering his/her name.
7. Appointment Checking Module: The doctor can check and either confirm or
reject the booked appointment and can also view the appointment details in the
appointment status module within this module.
8. Hospital Details Module: The administrator can enter the details of the hospital
with ward details in this module. The administrator can also update the
information in this module.
9. Ward Details Module: The administrator can check the ward details of a
particular hospital in this module by entering the hospital name.
10. Medicine Details Module: The administrator can enter the pharmacy details with
the medicine availability status and can also update the status of medicine
availability in this module.

Implementation Specifics:

Frontend:

● Technology: JavaFX is used for the GUI. JavaFX is a set of graphics and media
packages that enables developers to design, create, test, debug, and deploy rich
client applications that operate consistently across diverse platforms.
● Design: The design is user-friendly and intuitive. JavaFX provides a powerful
framework for developing rich client applications.

Backend:

● Technology: Java is used for the backend. Java is a popular programming


language known for its “write once, run anywhere” capability.
● IDE: IntelliJ IDEA is used as the IDE. It’s a popular IDE for Java development that
provides features like code completion, debugging, and testing tools.

Database:

● Technology: MySQL is used for data storage. MySQL is a popular open-source


relational database management system.
● Integration with Java: JDBC (Java Database Connectivity) API is used to connect
and execute queries with the MySQL database. JDBC provides methods to query
and update data in a database, and is oriented towards relational databases.

Testing:

● Unit tests should be written to test individual components of the system. JUnit is
a simple framework to write repeatable tests in Java and can be used for this
purpose.

Deployment:

● The system could be deployed on a server. You’ll need to package your


application into a JAR (Java ARchive) file. This file is platform-independent and
can be run on any machine that has the Java Runtime Environment installed.
Implementation:

Main.java
package com.example.healthcare;

import javafx.application.Application;

import javafx.fxml.FXMLLoader;

import javafx.scene.Scene;

import javafx.stage.Stage;

import java.io.IOException;

public class Main extends Application {

@Override

public void start(Stage stage) throws IOException {

FXMLLoader fxmlLoader = new


FXMLLoader(Main.class.getResource("main.fxml"));

Scene scene = new Scene(fxmlLoader.load());

stage.setTitle("e-Health Care Management System!");

stage.setScene(scene);

stage.show();

public static void main(String[] args) {

launch();

MainController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;
import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.stage.Stage;

import java.io.IOException;

import javafx.event.ActionEvent;

public class MainController {

@FXML

private Button doctor;

@FXML

private Button patient;

@FXML

private Button admin;

@FXML

public void switchToDoctorLogin(ActionEvent event) {

try {

Parent root =
FXMLLoader.load(getClass().getResource("doctorLogin.fxml"));

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Doctor - Log In!");

stage.setScene(new Scene(root, 600, 400));

stage.show();

} catch (IOException ex) {

System.err.println(ex);

}
@FXML

public void switchToPatientLogin(ActionEvent event) {

try {

Parent root =
FXMLLoader.load(getClass().getResource("patientLogin.fxml"));

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Patient - Log In!");

stage.setScene(new Scene(root, 600, 400));

stage.show();

} catch (IOException ex) {

System.err.println(ex);

@FXML

public void switchToAdminLogin(ActionEvent event) {

try {

Parent root =
FXMLLoader.load(getClass().getResource("adminLogin.fxml"));

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Admin - Log In!");

stage.setScene(new Scene(root, 600, 400));

stage.show();

} catch (IOException ex) {

System.err.println(ex);

}
Functions.java
package com.example.healthcare;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Alert;

import javafx.stage.Stage;

public class Functions {

public static Connection getConnection() throws SQLException,


ClassNotFoundException {

Class.forName("com.mysql.cj.jdbc.Driver");

return
DriverManager.getConnection("jdbc:mysql://localhost:3306/hospitalrecord",
"admin","password");

public static void signUpUser(ActionEvent event, String username, String


password, String fxmlFile){

try (Connection connection = getConnection();

PreparedStatement psCheckUserExists =
connection.prepareStatement("SELECT * FROM doctors_password_credentials WHERE
`User Name` = ?");
PreparedStatement psInsert = connection.prepareStatement("INSERT
INTO doctors_password_credentials (`User Name`, `Password`) VALUES (?,?)")) {

psCheckUserExists.setString(1, username);

ResultSet resultSet = psCheckUserExists.executeQuery();

if(resultSet.isBeforeFirst()){

System.out.println("User Already Exists!");

Alert alert = new Alert(Alert.AlertType.ERROR);

alert.setContentText("You cannot use this username!");

alert.show();

else{

psInsert.setString(1,username);

psInsert.setString(2, password);

psInsert.executeUpdate();

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource(fxmlFile));

Parent root = loader.load();

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome!");

stage.setScene(new Scene(root, 600, 400));

stage.show();

} catch (Exception e) {

e.printStackTrace();

} catch (SQLException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {
e.printStackTrace();

} catch (NullPointerException e) {

e.printStackTrace();

public static void logInUser(ActionEvent event, String username, String


password, String fxmlFile){

try (Connection connection = getConnection();

PreparedStatement preparedStatement =
connection.prepareStatement("SELECT `Password` FROM
doctors_password_credentials WHERE `User Name` = ?")) {

preparedStatement.setString(1, username);

ResultSet resultSet = preparedStatement.executeQuery();

if(!resultSet.next()){

System.out.println("User not found in the database!");

Alert alert = new Alert(Alert.AlertType.ERROR);

alert.setContentText("Provided Credentials are Incorrect!");

alert.show();

else{

do {

String retrievedPassword = resultSet.getString("Password");

if(retrievedPassword.equals(password)){

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource(fxmlFile));

Parent root = loader.load();

DoctorDashboardController controller =
loader.getController();
controller.setUsername(username);

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome, " + username);

stage.setScene(new Scene(root, 600, 400));

stage.show();

} catch (Exception e) {

e.printStackTrace();

else{

System.out.println("Password did not match!");

Alert alert = new Alert(Alert.AlertType.ERROR);

alert.setContentText("The Provided Credentials are


Incorrect!");

alert.show();

} while(resultSet.next());

} catch (SQLException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

} catch (NullPointerException e) {

e.printStackTrace();

}
PatientSignupController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.scene.Node;

import javafx.scene.control.Alert;

import javafx.scene.control.Button;

import javafx.scene.control.PasswordField;

import javafx.scene.control.TextField;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.*;

public class PatientSignupController {

@FXML

private TextField username;

@FXML

private PasswordField password;

@FXML

private Button signup;


@FXML

private Button login;

public static Connection getConnection() throws SQLException,


ClassNotFoundException {

Class.forName("com.mysql.cj.jdbc.Driver");

return
DriverManager.getConnection("jdbc:mysql://localhost:3306/hospitalrecord",
"admin","password");

public static void signUpUser(ActionEvent event, String username, String


password, String fxmlFile){

try (Connection connection = getConnection();

PreparedStatement psCheckUserExists =
connection.prepareStatement("SELECT * FROM patients_password_credentials WHERE
`User Name` = ?");

PreparedStatement psInsert = connection.prepareStatement("INSERT


INTO patients_password_credentials (`User Name`, `Password`) VALUES (?,?)")) {

psCheckUserExists.setString(1, username);

ResultSet resultSet = psCheckUserExists.executeQuery();

if(resultSet.isBeforeFirst()){

System.out.println("User Already Exists!");

Alert alert = new Alert(Alert.AlertType.ERROR);

alert.setContentText("You cannot use this username!");

alert.show();

else{

psInsert.setString(1,username);

psInsert.setString(2, password);

psInsert.executeUpdate();
FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource(fxmlFile));

Parent root = loader.load();

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome!");

stage.setScene(new Scene(root, 600, 400));

stage.show();

} catch (Exception e) {

e.printStackTrace();

} catch (SQLException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

} catch (NullPointerException e) {

e.printStackTrace();

@FXML

public void initialize() {

signup.setOnAction(event -> {

String user = username.getText();

String pass = password.getText();

signUpUser(event, user, pass, "patientProfile.fxml");

});
login.setOnAction(event -> {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("patientLogin.fxml"));

Parent root = loader.load();

Stage stage = (Stage) login.getScene().getWindow();

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

});

PatientProfileController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.stage.Stage;

import javafx.event.ActionEvent;
import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.SQLException;

import java.io.IOException;

public class PatientProfileController {

@FXML

private TextField name;

@FXML

private TextField dob;

@FXML

private TextField age;

@FXML

private TextField bloodGroup;

@FXML

private TextField height;

@FXML

private TextField weight;

@FXML

private TextField contact;

@FXML
private TextField aadhar;

@FXML

private Button save;

@FXML

public void initialize() {

save.setOnAction(event -> {

String patientName = name.getText();

String patientDOB = dob.getText();

int patientAge = Integer.parseInt(age.getText());

String patientBloodGroup = bloodGroup.getText();

String patientHeight = height.getText();

String patientWeight = weight.getText();

String patientAadhar = aadhar.getText();

String patientContact = contact.getText();

try (Connection connection = Functions.getConnection();

PreparedStatement preparedStatement =
connection.prepareStatement("INSERT INTO patients_details (Name, DOB, Age,
`Blood Group`, Height, Weight, Aadhar, Contact) VALUES (?,?,?,?,?,?,?,?)")) {

preparedStatement.setString(1, patientName);

preparedStatement.setString(2, patientDOB);

preparedStatement.setInt(3, patientAge);

preparedStatement.setString(4, patientBloodGroup);

preparedStatement.setString(5, patientHeight);

preparedStatement.setString(6, patientWeight);

preparedStatement.setString(7, patientAadhar);

preparedStatement.setString(8, patientContact);
preparedStatement.executeUpdate();

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("patientDashboard.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (SQLException | ClassNotFoundException | IOException e) {

e.printStackTrace();

});

PatientLoginController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.scene.Node;

import javafx.scene.control.Alert;

import javafx.scene.control.Button;

import javafx.scene.control.PasswordField;

import javafx.scene.control.TextField;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.scene.Parent;

import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

import java.sql.*;

public class PatientLoginController {

@FXML

private TextField username;

@FXML

private PasswordField password;

@FXML

private Button login;

@FXML

private Button signup;

public static Connection getConnection() throws SQLException,


ClassNotFoundException {

Class.forName("com.mysql.cj.jdbc.Driver");

return
DriverManager.getConnection("jdbc:mysql://localhost:3306/hospitalrecord",
"admin","password");

public static void logInUser(ActionEvent event, String username, String


password, String fxmlFile){

try (Connection connection = getConnection();


PreparedStatement preparedStatement =
connection.prepareStatement("SELECT `Password` FROM
patients_password_credentials WHERE `User Name` = ?")) {

preparedStatement.setString(1, username);

ResultSet resultSet = preparedStatement.executeQuery();

if(!resultSet.next()){

System.out.println("User not found in the database!");

Alert alert = new Alert(Alert.AlertType.ERROR);

alert.setContentText("Provided Credentials are Incorrect!");

alert.show();

else{

do {

String retrievedPassword = resultSet.getString("Password");

if(retrievedPassword.equals(password)){

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource(fxmlFile));

Parent root = loader.load();

PatientDashboardController controller =
loader.getController();

controller.setUsername(username);

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome, " + username);

stage.setScene(new Scene(root, 600, 400));

stage.show();
} catch (Exception e) {

e.printStackTrace();

else{

System.out.println("Password did not match!");

Alert alert = new Alert(Alert.AlertType.ERROR);

alert.setContentText("The Provided Credentials are


Incorrect!");

alert.show();

} while(resultSet.next());

} catch (SQLException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

} catch (NullPointerException e) {

e.printStackTrace();

@FXML

public void initialize() {

login.setOnAction(event -> {

String user = username.getText();

String pass = password.getText();

logInUser(event, user, pass, "patientDashboard.fxml");

});
signup.setOnAction(event -> {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("patientSignup.fxml"));

Parent root = loader.load();

Stage stage = (Stage) signup.getScene().getWindow();

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

});

PatientDashboardController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.scene.Node;

import javafx.scene.control.Button;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.stage.Stage;
import java.io.IOException;

public class PatientDashboardController {

@FXML

private Button patientProfile;

@FXML

private Button doctorProfile;

@FXML

private Button findNearbyHospitals;

@FXML

private Button bookAppointment;

@FXML

private Button checkWardAvailability;

@FXML

private Button checkMedicineAvailability;

private static String username;

public void setUsername(String username) {

PatientDashboardController.username = username;

}
public static String getUsername() {

return username;

@FXML

public void openPatientProfile(ActionEvent event) {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("patientProfileDisplay.fxml"));

Parent patientProfile = loader.load();

Scene scene = new Scene(patientProfile);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Patient Profile");

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

@FXML

public void openFindNearbyHospitals(ActionEvent event){

Parent root = null;

try {

root = FXMLLoader.load(getClass().getResource("hospitals.fxml"));

Stage stage = new Stage();

stage.setTitle("Find Nearby Hospitals");

stage.setScene(new Scene(root));

stage.show();
} catch (IOException e) {

throw new RuntimeException(e);

@FXML

public void openBookAppointment(ActionEvent event){

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource("appointmentBooking.fxml"));

Parent root = loader.load();

Stage stage = new Stage();

stage.setTitle("Book Appointment");

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

throw new RuntimeException(e);

@FXML

public void openCheckWardAvailability(ActionEvent event){

Parent root = null;

try {

root =
FXMLLoader.load(getClass().getResource("checkWardAvailability.fxml"));

Stage stage = new Stage();

stage.setTitle("Check Ward Availability");


stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

throw new RuntimeException(e);

@FXML

public void openCheckMedicineAvailability(ActionEvent event){

Parent root = null;

try {

root =
FXMLLoader.load(getClass().getResource("medicineSuggest.fxml"));

Stage stage = new Stage();

stage.setTitle("Check Medicine Availability");

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

throw new RuntimeException(e);

@FXML

public void openDoctorProfile(ActionEvent event) {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("doctorProfileView.fxml"));

Parent patientProfile = loader.load();

Scene scene = new Scene(patientProfile);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();
stage.setTitle("Doctor Profile");

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

PatientProfileDisplayController.java
package com.example.healthcare;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;
public class PatientProfileDisplayController {

@FXML

private Label name;

@FXML

private Label dob;

@FXML

private Label age;

@FXML

private Label bloodGroup;

@FXML

private Label height;

@FXML

private Label weight;

@FXML

private Label contact;

@FXML

private Label aadhar;

@FXML

private Button back;


private final String username = PatientDashboardController.getUsername();

@FXML

public void initialize() {

try (Connection connection = Functions.getConnection();

PreparedStatement preparedStatement =
connection.prepareStatement("SELECT * FROM patients_details WHERE Name = ?")) {

preparedStatement.setString(1, username);

ResultSet resultSet = preparedStatement.executeQuery();

if (resultSet.next()) {

name.setText(resultSet.getString("Name"));

dob.setText(resultSet.getString("DOB"));

age.setText(String.valueOf(resultSet.getInt("Age")));

bloodGroup.setText(resultSet.getString("Blood Group"));

height.setText(resultSet.getString("Height"));

weight.setText(resultSet.getString("Weight"));

aadhar.setText(resultSet.getString("Aadhar"));

contact.setText(resultSet.getString("Contact"));

} catch (SQLException | ClassNotFoundException e) {

e.printStackTrace();

@FXML

public void goBack(ActionEvent event) {


try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("patientDashboard.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

AppointmentBookingController.java
package com.example.healthcare;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.*;

import javafx.collections.FXCollections;

import javafx.collections.ObservableList;

import javafx.stage.Stage;

import java.io.IOException;
import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.time.LocalDate;

public class AppointmentBookingController {

@FXML

private ComboBox<String> doctor;

@FXML

private ComboBox<String> timeSlot;

@FXML

private DatePicker date;

@FXML

private TextField time;

@FXML

private TextField notes;

@FXML

private Button book;

@FXML

private Button booked;


@FXML

private Button back;

private static String username = PatientDashboardController.getUsername();

public void setUsername(String username) {

AppointmentBookingController.username = username;

public static String getUsername() {

return username;

@FXML

public void initialize() {

populateDoctorComboBox();

limitDatePicker();

createTimeSlotComboBox();

book.setOnAction(this::bookAppointment);

public void bookAppointment(ActionEvent event) {

String selectedDoctor = doctor.getValue();

String patient = username;

String selectedDate = date.getValue().toString();

String selectedTime = timeSlot.getValue();

String enteredNotes = notes.getText();

try (Connection connection = Functions.getConnection()) {


PreparedStatement preparedStatement =
connection.prepareStatement("INSERT INTO appointments (Doctor, Patient, Date,
Time, Notes) VALUES (?,?,?,?,?)");

String[] doctorArray = selectedDoctor.split(",");

String doctorName = doctorArray[0];

preparedStatement.setString(1, doctorName);

preparedStatement.setString(2, patient);

preparedStatement.setString(3, selectedDate);

preparedStatement.setString(4, selectedTime);

preparedStatement.setString(5, enteredNotes);

preparedStatement.executeUpdate();

} catch (SQLException | ClassNotFoundException e) {

throw new RuntimeException(e);

public void populateDoctorComboBox() {

try (Connection connection = Functions.getConnection();

PreparedStatement preparedStatement =
connection.prepareStatement("SELECT Name, Specialization FROM
doctors_details")) {

ResultSet resultSet = preparedStatement.executeQuery();

ObservableList<String> doctorList =
FXCollections.observableArrayList();

while (resultSet.next()) {

String name = resultSet.getString("Name");


String specialization = resultSet.getString("Specialization");

doctorList.add(name + ", " + specialization);

doctor.setItems(doctorList);

} catch (SQLException | ClassNotFoundException e) {

e.printStackTrace();

public void limitDatePicker() {

LocalDate today = LocalDate.now();

LocalDate nextWeek = today.plusDays(7);

date.setDayCellFactory(d -> new DateCell() {

@Override

public void updateItem(LocalDate item, boolean empty) {

super.updateItem(item, empty);

setDisable(item.isAfter(nextWeek) || item.isBefore(today));

});

public void createTimeSlotComboBox() {

ObservableList<String> timeSlotList =
FXCollections.observableArrayList();
for (int hour = 8; hour <= 17; hour++) {

for (int minute = 0; minute <= 45; minute += 15) {

String hourString = String.format("%02d", hour);

String minuteString = String.format("%02d", minute);

timeSlotList.add(hourString + ":" + minuteString);

timeSlot.setItems(timeSlotList);

@FXML

public void bookedAppointment(ActionEvent event) {

try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("bookedAppointment.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

@FXML

public void goBack(ActionEvent event) {


try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("patientDashboard.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

BookedAppointmentController.java
package com.example.healthcare;

import javafx.event.ActionEvent;

import javafx.fxml.*;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.scene.control.TableColumn;

import javafx.scene.control.TableView;

import javafx.scene.control.cell.PropertyValueFactory;

import javafx.scene.layout.GridPane;

import javafx.stage.Stage;
import java.io.IOException;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;

public class BookedAppointmentController{

@FXML

private Label usernameLabel;

@FXML

private Label titleLabel;

@FXML

private Button back;

@FXML

private TableView<Appointment> appointmentTableView;

@FXML

private TableColumn<Appointment, Integer> idColumn;

@FXML

private TableColumn<Appointment, String> doctorColumn;

@FXML

private TableColumn<Appointment, String> patientColumn;


@FXML

private TableColumn<Appointment, String> dateColumn;

@FXML

private TableColumn<Appointment, String> timeColumn;

@FXML

private TableColumn<Appointment, String> notesColumn;

@FXML

private TableColumn<Appointment, String> statusColumn;

private final String username = PatientDashboardController.getUsername();

public void initialize() {

// Set the username and title labels

usernameLabel.setText("Welcome, " + username);

titleLabel.setText("Booked Appointments");

// Set the cell value factories for each column

idColumn.setCellValueFactory(new PropertyValueFactory<>("id"));

doctorColumn.setCellValueFactory(new PropertyValueFactory<>("doctor"));

patientColumn.setCellValueFactory(new
PropertyValueFactory<>("patient"));

dateColumn.setCellValueFactory(new PropertyValueFactory<>("date"));

timeColumn.setCellValueFactory(new PropertyValueFactory<>("time"));

notesColumn.setCellValueFactory(new PropertyValueFactory<>("notes"));

statusColumn.setCellValueFactory(new PropertyValueFactory<>("status"));
try (Connection connection = Functions.getConnection()) {

PreparedStatement preparedStatement =
connection.prepareStatement("SELECT * FROM appointments WHERE Patient = ?");

preparedStatement.setString(1, username);

try (ResultSet resultSet = preparedStatement.executeQuery()) {

while(resultSet.next()) {

int id = resultSet.getInt("ID");

String doctor = resultSet.getString("Doctor");

String patient = resultSet.getString("Patient");

String date = resultSet.getString("Date");

String time = resultSet.getString("Time");

String notes = resultSet.getString("Notes");

String status = resultSet.getString("Status");

Appointment appointment = new Appointment(id, doctor,


patient, date, time, notes, status);

appointmentTableView.getItems().add(appointment);

} catch (SQLException | ClassNotFoundException e) {

e.printStackTrace();

@FXML
public void goBack(ActionEvent event) {

try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("appointmentBooking.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

CheckWardAvailabilityController.java
package com.example.healthcare;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.scene.control.TextField;

import javafx.stage.Stage;

import java.io.IOException;
import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

public class CheckWardAvailabilityController {

@FXML

private TextField hospitalTextField;

@FXML

private Button checkButton;

@FXML

private Label wardDetailsLabel;

@FXML

private void checkAvailability(ActionEvent event) {

String hospitalName = hospitalTextField.getText();

try (Connection connection = Functions.getConnection()) {

PreparedStatement statement = connection

.prepareStatement("SELECT `General Wards`, `Male Wards`,


`Female Wards`, `Mixed Wards`, `Paediatric Wards`, " +

"`Maternity Wards`, ICUs, `Emergency Wards`,


`Isolation Wards`, `Psychiatric Wards` " +

"FROM hospital WHERE Name = ?");

statement.setString(1, hospitalName);

ResultSet resultSet = statement.executeQuery();


if (resultSet.next()) {

int generalWards = resultSet.getInt("General Wards");

int maleWards = resultSet.getInt("Male Wards");

int femaleWards = resultSet.getInt("Female Wards");

int mixedWards = resultSet.getInt("Mixed Wards");

int paediatricWards = resultSet.getInt("Paediatric Wards");

int maternityWards = resultSet.getInt("Maternity Wards");

int icus = resultSet.getInt("ICUs");

int emergencyWards = resultSet.getInt("Emergency Wards");

int isolationWards = resultSet.getInt("Isolation Wards");

int psychiatricWards = resultSet.getInt("Psychiatric Wards");

String resultText = "General Wards: " + generalWards + "\n" +

"Male Wards: " + maleWards + "\n" +

"Female Wards: " + femaleWards + "\n" +

"Mixed Wards: " + mixedWards + "\n" +

"Paediatric Wards: " + paediatricWards + "\n" +

"Maternity Wards: " + maternityWards + "\n" +

"ICUs: " + icus + "\n" +

"Emergency Wards: " + emergencyWards + "\n" +

"Isolation Wards: " + isolationWards + "\n" +

"Psychiatric Wards: " + psychiatricWards;

wardDetailsLabel.setText(resultText);

} else {

wardDetailsLabel.setText("No such hospital found.");

} catch (Exception e) {

e.printStackTrace();
}

@FXML

private Button back;

@FXML

public void goBack(ActionEvent event) {

try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("patientDashboard.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

HospitalsController.java
package com.example.healthcare;

import javafx.application.Application;

import javafx.collections.FXCollections;

import javafx.collections.ObservableList;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.fxml.Initializable;
import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.TableColumn;

import javafx.scene.control.TableView;

import javafx.scene.control.TextField;

import javafx.scene.control.cell.PropertyValueFactory;

import javafx.stage.Stage;

import javafx.fxml.FXML;

import java.io.IOException;

import java.net.URL;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.ArrayList;

import java.util.List;

import java.util.ResourceBundle;

public class HospitalsController implements Initializable {

public static class Hospital {

private String name;

private String district;

private int generalWards;

private int maleWards;

private int femaleWards;

private int mixedWards;


private int paediatricWards;

private int maternityWards;

private int icus;

private int emergencyWards;

private int isolationWards;

private int psychiatricWards;

public Hospital(String name, String district, int generalWards, int


maleWards, int femaleWards, int mixedWards, int paediatricWards, int
maternityWards, int icus, int emergencyWards, int isolationWards, int
psychiatricWards) {

this.name = name;

this.district = district;

this.generalWards = generalWards;

this.maleWards = maleWards;

this.femaleWards = femaleWards;

this.mixedWards = mixedWards;

this.paediatricWards = paediatricWards;

this.maternityWards = maternityWards;

this.icus = icus;

this.emergencyWards = emergencyWards;

this.isolationWards = isolationWards;

this.psychiatricWards = psychiatricWards;

public String getName() {

return name;

public String getDistrict() {

return district;
}

public int getGeneralWards() {

return generalWards;

public int getMaleWards() {

return maleWards;

public int getFemaleWards() {

return femaleWards;

public int getMixedWards() {

return mixedWards;

public int getPaediatricWards() {

return paediatricWards;

public int getMaternityWards() {

return maternityWards;

public int getIcus() {

return icus;

}
public int getEmergencyWards() {

return emergencyWards;

public int getIsolationWards() {

return isolationWards;

public int getPsychiatricWards() {

return psychiatricWards;

@FXML

private TextField districtField;

@FXML

private Button searchButton;

@FXML

private TableView<Hospital> hospitalTable = new TableView<>();

@FXML

private TableColumn<Hospital, String> nameColumn = new


TableColumn<>("Hospital Name");

@FXML

private TableColumn<Hospital, String> districtColumn = new


TableColumn<>("District");

@FXML

private TableColumn<Hospital, Integer> generalWardsColumn = new


TableColumn<>("General Wards");

@FXML
private TableColumn<Hospital, Integer> maleWardsColumn = new
TableColumn<>("Male Wards");

@FXML

private TableColumn<Hospital, Integer> femaleWardsColumn = new


TableColumn<>("Female Wards");

@FXML

private TableColumn<Hospital, Integer> mixedWardsColumn = new


TableColumn<>("Mixed Wards");

@FXML

private TableColumn<Hospital, Integer> paediatricWardsColumn = new


TableColumn<>("Paediatric Wards");

@FXML

private TableColumn<Hospital, Integer> maternityWardsColumn = new


TableColumn<>("Maternity Wards");

@FXML

private TableColumn<Hospital, Integer> icusColumn = new


TableColumn<>("ICUs");

@FXML

private TableColumn<Hospital, Integer> emergencyWardsColumn = new


TableColumn<>("Emergency Wards");

@FXML

private TableColumn<Hospital, Integer> isolationWardsColumn = new


TableColumn<>("Isolation Wards");

@FXML

private TableColumn<Hospital, Integer> psychiatricWardsColumn = new


TableColumn<>("Psychiatric Wards");

@Override

public void initialize(URL url, ResourceBundle rb) {

hospitalTable.getColumns().clear();

hospitalTable.getColumns().addAll(nameColumn, districtColumn,
generalWardsColumn, maleWardsColumn, femaleWardsColumn, mixedWardsColumn,
paediatricWardsColumn, maternityWardsColumn, icusColumn, emergencyWardsColumn,
isolationWardsColumn, psychiatricWardsColumn);

nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));

districtColumn.setCellValueFactory(new
PropertyValueFactory<>("district"));

generalWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("generalWards"));

maleWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("maleWards"));

femaleWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("femaleWards"));

mixedWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("mixedWards"));

paediatricWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("paediatricWards"));

maternityWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("maternityWards"));

icusColumn.setCellValueFactory(new PropertyValueFactory<>("icus"));

emergencyWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("emergencyWards"));

isolationWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("isolationWards"));

psychiatricWardsColumn.setCellValueFactory(new
PropertyValueFactory<>("psychiatricWards"));

@FXML

private void searchHospitals() {

String district = districtField.getText();

List<Hospital> hospitals = new ArrayList<>();

try (Connection connection = Functions.getConnection()) {


PreparedStatement statement = connection.prepareStatement("SELECT *
FROM hospital WHERE District = ?");

statement.setString(1, district);

ResultSet resultSet = statement.executeQuery();

while (resultSet.next()) {

String name = resultSet.getString("Name");

String districtName = resultSet.getString("District");

int generalWards = resultSet.getInt("General Wards");

int maleWards = resultSet.getInt("Male Wards");

int femaleWards = resultSet.getInt("Female Wards");

int mixedWards = resultSet.getInt("Mixed Wards");

int paediatricWards = resultSet.getInt("Paediatric Wards");

int maternityWards = resultSet.getInt("Maternity Wards");

int icus = resultSet.getInt("ICUs");

int emergencyWards = resultSet.getInt("Emergency Wards");

int isolationWards = resultSet.getInt("Isolation Wards");

int psychiatricWards = resultSet.getInt("Psychiatric Wards");

Hospital hospital = new Hospital(name, districtName,


generalWards, maleWards, femaleWards, mixedWards, paediatricWards,
maternityWards, icus, emergencyWards, isolationWards, psychiatricWards);

hospitals.add(hospital);

} catch (Exception e) {

e.printStackTrace();

ObservableList<Hospital> data =
FXCollections.observableArrayList(hospitals);
hospitalTable.setItems(data);

@FXML

private Button back;

@FXML

public void goBack(ActionEvent event) {

try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("patientDashboard.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

MedicineSuggestController.java
package com.example.healthcare;

import javafx.collections.FXCollections;

import javafx.collections.ObservableList;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;
import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.TableColumn;

import javafx.scene.control.TableView;

import javafx.scene.control.TextField;

import javafx.scene.control.cell.PropertyValueFactory;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

public class MedicineSuggestController {

public static class Medicine {

private String pharmacy;

private String district;

private String medicine;

private String available;

public Medicine(String pharmacy, String district, String medicine,


String available) {

this.pharmacy = pharmacy;

this.district = district;

this.medicine = medicine;

this.available = available;

}
public String getPharmacy() {

return pharmacy;

public String getDistrict() {

return district;

public String getMedicine() {

return medicine;

public String getAvailable() {

return available;

public void setPharmacy(String pharmacy) {

this.pharmacy = pharmacy;

public void setDistrict(String district) {

this.district = district;

public void setMedicine(String medicine) {

this.medicine = medicine;

}
public void setAvailable(String available) {

this.available = available;

@FXML

private TextField pharmacyTextField;

@FXML

private TextField medicineTextField;

@FXML

private Button searchButton;

@FXML

private TableView<Medicine> searchResultsTable;

@FXML

private TableColumn<Medicine, String> pharmacyColumn;

@FXML

private TableColumn<Medicine, String> districtColumn;

@FXML

private TableColumn<Medicine, String> medicineColumn;

@FXML

private TableColumn<Medicine, String> availableColumn;

@FXML

private void initialize() {

pharmacyColumn.setCellValueFactory(new
PropertyValueFactory<>("pharmacy"));

districtColumn.setCellValueFactory(new
PropertyValueFactory<>("district"));

medicineColumn.setCellValueFactory(new
PropertyValueFactory<>("medicine"));
availableColumn.setCellValueFactory(new
PropertyValueFactory<>("available"));

@FXML

private void searchData(ActionEvent event) {

String pharmacy = pharmacyTextField.getText();

String medicine = medicineTextField.getText();

ObservableList<Medicine> medicines = searchMedicineDetails(pharmacy,


medicine);

searchResultsTable.setItems(medicines);

public ObservableList<Medicine> searchMedicineDetails(String pharmacy,


String medicine) {

ObservableList<Medicine> medicines =
FXCollections.observableArrayList();

try (Connection connection = Functions.getConnection()) {

PreparedStatement statement = connection

.prepareStatement("SELECT * FROM medicine WHERE Pharmacy = ?


OR Medicine = ?");

statement.setString(1, pharmacy);

statement.setString(2, medicine);

ResultSet resultSet = statement.executeQuery();

while (resultSet.next()) {
Medicine medicineRecord = new Medicine(

resultSet.getString("Pharmacy"),

resultSet.getString("District"),

resultSet.getString("Medicine"),

resultSet.getString("Available")

);

medicines.add(medicineRecord);

} catch (Exception e) {

e.printStackTrace();

return medicines;

@FXML

private Button back;

@FXML

public void goBack(ActionEvent event) {

try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("patientDashboard.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

}
}

DoctorProfileViewController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.scene.control.TextField;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

public class DoctorProfileViewController{

@FXML

private TextField doctorNameField;

@FXML

private Button confirmButton;

@FXML

private Label doctorDetails;

@FXML

public void handleConfirmButtonAction() throws SQLException,


ClassNotFoundException {
String doctorName = doctorNameField.getText();

displayDoctorDetails(doctorName);

public void displayDoctorDetails(String doctorName) throws SQLException,


ClassNotFoundException {

String details = getDoctorDetails(doctorName);

doctorDetails.setText(details);

public String getDoctorDetails(String doctorName) throws SQLException,


ClassNotFoundException {

String details = "";

String sql = "SELECT * FROM doctors_details WHERE Name = ?";

Connection conn = Functions.getConnection();

try (PreparedStatement pstmt = conn.prepareStatement(sql)) {

pstmt.setString(1, doctorName);

ResultSet rs = pstmt.executeQuery();

if (rs.next()) {

details = "Name: " + rs.getString("Name") + "\n" +

"DOB: " + rs.getString("DOB") + "\n" +

"Degree: " + rs.getString("Degree") + "\n" +

"Specialization: " + rs.getString("Specialization") +


"\n" +

"Experience: " + rs.getString("Experience") + "\n" +

"Hospital: " + rs.getString("Hospital") + "\n" +

"Contact: " + rs.getString("Contact");

}
} catch (SQLException e) {

System.out.println(e.getMessage());

return details;

DoctorSignupController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.PasswordField;

import javafx.scene.control.TextField;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.stage.Stage;

import java.io.IOException;

public class DoctorSignupController {

@FXML

private TextField username;

@FXML
private PasswordField password;

@FXML

private Button signup;

@FXML

private Button login;

@FXML

public void initialize() {

signup.setOnAction(event -> {

String user = username.getText();

String pass = password.getText();

Functions.signUpUser(event, user, pass, "doctorProfile.fxml");

});

login.setOnAction(event -> {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("doctorLogin.fxml"));

Parent root = loader.load();

Stage stage = (Stage) login.getScene().getWindow();

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

});

}
DoctorProfileController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.stage.Stage;

import javafx.event.ActionEvent;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.SQLException;

import java.io.IOException;

public class DoctorProfileController {

@FXML

private TextField name;

@FXML

private TextField dob;

@FXML

private TextField degree;


@FXML

private TextField specialization;

@FXML

private TextField yearofexperience;

@FXML

private TextField hospital;

@FXML

private TextField contact;

@FXML

private Button save;

@FXML

public void initialize() {

save.setOnAction(event -> {

String doctorName = name.getText();

String doctorDOB = dob.getText();

String doctorDegree = degree.getText();

String doctorSpecialization = specialization.getText();

String doctorExperience = yearofexperience.getText();

String doctorHospital = hospital.getText();

String doctorContact = contact.getText();

try (Connection connection = Functions.getConnection();


PreparedStatement preparedStatement =
connection.prepareStatement("INSERT INTO doctors_details (Name, DOB, Degree,
Specialization, Experience, Hospital, Contact) VALUES (?,?,?,?,?,?,?)")) {

preparedStatement.setString(1, doctorName);

preparedStatement.setString(2, doctorDOB);

preparedStatement.setString(3, doctorDegree);

preparedStatement.setString(4, doctorSpecialization);

preparedStatement.setString(5, doctorExperience);

preparedStatement.setString(6, doctorHospital);

preparedStatement.setString(7, doctorContact);

preparedStatement.executeUpdate();

Parent doctorDashboard =
FXMLLoader.load(getClass().getResource("doctorDashboard.fxml"));

Scene scene = new Scene(doctorDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (SQLException | ClassNotFoundException | IOException e) {

e.printStackTrace();

});

DoctorLoginController.java
package com.example.healthcare;
import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.PasswordField;

import javafx.scene.control.TextField;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.stage.Stage;

import java.io.IOException;

public class DoctorLoginController {

@FXML

private TextField username;

@FXML

private PasswordField password;

@FXML

private Button login;

@FXML

private Button signup;

@FXML

public void initialize() {


login.setOnAction(event -> {

String user = username.getText();

String pass = password.getText();

Functions.logInUser(event, user, pass, "doctorDashboard.fxml");

});

signup.setOnAction(event -> {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("doctorSignup.fxml"));

Parent root = loader.load();

Stage stage = (Stage) signup.getScene().getWindow();

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

});

DoctorDashboardController.java
package com.example.healthcare;

import javafx.application.Application;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;
import javafx.scene.Scene;

import javafx.stage.Stage;

import java.io.IOException;

public class DoctorDashboardController{

private static String username;

public void setUsername(String username) {

DoctorDashboardController.username = username;

public static String getUsername(){

return username;

public void openDoctorProfile(ActionEvent event) {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("doctorProfileDisplay.fxml"));

Parent doctorProfile = loader.load();

Scene scene = new Scene(doctorProfile);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

}
}

public void openAppointments(ActionEvent event) {

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource("appointmentChecking.fxml"));

Parent root = loader.load();

AppointmentCheckingController controller = loader.getController();

controller.setUsername(username);

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome, " + username);

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

DoctorProfileDisplayController.java
package com.example.healthcare;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;
import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

public class DoctorProfileDisplayController {

@FXML

private Label name;

@FXML

private Label dob;

@FXML

private Label degree;

@FXML

private Label specialization;

@FXML

private Label yearofexperience;

@FXML

private Label hospital;


@FXML

private Label contact;

@FXML

private Button back;

private final String username = DoctorDashboardController.getUsername();

@FXML

public void initialize() {

try (Connection connection = Functions.getConnection();

PreparedStatement preparedStatement =
connection.prepareStatement("SELECT * FROM doctors_details WHERE Name = ?")) {

preparedStatement.setString(1, username);

ResultSet resultSet = preparedStatement.executeQuery();

if (resultSet.next()) {

name.setText(resultSet.getString("Name"));

dob.setText(resultSet.getString("DOB"));

degree.setText(resultSet.getString("Degree"));

specialization.setText(resultSet.getString("Specialization"));

yearofexperience.setText(resultSet.getString("Experience"));

hospital.setText(resultSet.getString("Hospital"));

contact.setText(resultSet.getString("Contact"));

} catch (SQLException | ClassNotFoundException e) {


e.printStackTrace();

@FXML

public void goBack(ActionEvent event) {

try {

Parent doctorDashboard =
FXMLLoader.load(getClass().getResource("doctorDashboard.fxml"));

Scene scene = new Scene(doctorDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

AppointmentCheckingController.java
package com.example.healthcare;

import javafx.collections.FXCollections;

import javafx.collections.ObservableList;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;
import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.ListView;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

public class AppointmentCheckingController {

@FXML

private ListView<String> appointmentList;

@FXML

private ObservableList<String> data = FXCollections.observableArrayList();

@FXML

private Button confirmButton;

@FXML

private Button rejectButton;

@FXML

private Button confirmAllButton;

@FXML
private Button rejectAllButton;

@FXML

private Button back;

private static String username;

public void setUsername(String username) {

AppointmentCheckingController.username = username;

@FXML

public void initialize() throws SQLException {

String name = DoctorDashboardController.getUsername();

setUsername(name);

try (Connection connection = Functions.getConnection()) {

PreparedStatement preparedStatement =
connection.prepareStatement("SELECT * FROM appointments WHERE Doctor = ?");

preparedStatement.setString(1, username);

try (ResultSet resultSet = preparedStatement.executeQuery()) {

while(resultSet.next()) {

String details = "ID: " + resultSet.getInt("ID") +

", Doctor: " + resultSet.getString("Doctor") +

", Patient: " + resultSet.getString("Patient") +

", Date: " + resultSet.getString("Date") +

", Time: " + resultSet.getString("Time") +

", Notes: " + resultSet.getString("Notes") +


", Status: " + resultSet.getString("Status");

String status = resultSet.getString("Status");

if (status.equals("Pending")) {

data.add(details);

System.out.println(details);

appointmentList.setItems(data);

appointmentList.refresh();

} catch (SQLException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

throw new RuntimeException(e);

@FXML

public void confirmAppointment() {

String appointmentDetails =
appointmentList.getSelectionModel().getSelectedItem();

String patientName = extractPatientName(appointmentDetails);

updateStatus(patientName, "Confirmed");

@FXML

public void rejectAppointment() {


String appointmentDetails =
appointmentList.getSelectionModel().getSelectedItem();

String patientName = extractPatientName(appointmentDetails);

updateStatus(patientName, "Rejected");

private String extractPatientName(String appointmentDetails) {

int startIndex = appointmentDetails.indexOf("Patient: ") + "Patient:


".length();

int endIndex = appointmentDetails.indexOf(",", startIndex);

return appointmentDetails.substring(startIndex, endIndex);

@FXML

public void confirmAllAppointments() {

updateAllStatus("Confirmed");

@FXML

public void rejectAllAppointments() {

updateAllStatus("Rejected");

private void updateStatus(String patientName, String status) {

try (Connection connection = Functions.getConnection();

PreparedStatement preparedStatement =
connection.prepareStatement("UPDATE appointments SET Status = ? WHERE Doctor =
? AND Patient = ?")) {
preparedStatement.setString(1, status);

preparedStatement.setString(2, username);

preparedStatement.setString(3, patientName);

preparedStatement.executeUpdate();

} catch (SQLException | ClassNotFoundException e) {

e.printStackTrace();

private void updateAllStatus(String status) {

try (Connection connection = Functions.getConnection();

PreparedStatement preparedStatement =
connection.prepareStatement("UPDATE appointments SET Status = ? WHERE Doctor =
?")) {

preparedStatement.setString(1, status);

preparedStatement.setString(2, username);

preparedStatement.executeUpdate();

} catch (SQLException | ClassNotFoundException e) {

e.printStackTrace();

@FXML

public void goBack(ActionEvent event) {

try {
Parent doctorDashboard =
FXMLLoader.load(getClass().getResource("doctorDashboard.fxml"));

Scene scene = new Scene(doctorDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

@FXML

public void gotoAppointments(ActionEvent event) {

try {

FXMLLoader loader = new FXMLLoader();

loader.setLocation(getClass().getResource("appointmentStatus.fxml"));

Parent doctorDashboard = loader.load();

Scene scene = new Scene(doctorDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

}
Appointment.java
package com.example.healthcare;

import javafx.application.Application;

import javafx.stage.Stage;

public class Appointment{

private int id;

private String doctor;

private String patient;

private String date;

private String time;

private String notes;

private String status;

public Appointment(int id, String doctor, String patient, String date,


String time, String notes, String status) {

this.id = id;

this.doctor = doctor;

this.patient = patient;

this.date = date;

this.time = time;

this.notes = notes;

this.status = status;

public Appointment() {

}
public int getId() {

return id;

public void setId(int id) {

this.id = id;

public String getDoctor() {

return doctor;

public void setDoctor(String doctor) {

this.doctor = doctor;

public String getPatient() {

return patient;

public void setPatient(String patient) {

this.patient = patient;

public String getDate() {

return date;

public void setDate(String date) {


this.date = date;

public String getTime() {

return time;

public void setTime(String time) {

this.time = time;

public String getNotes() {

return notes;

public void setNotes(String notes) {

this.notes = notes;

public String getStatus() {

return status;

public void setStatus(String status) {

this.status = status;

}
AppointmentStatusController.java
package com.example.healthcare;

import javafx.fxml.FXML;

import javafx.scene.control.TableColumn;

import javafx.scene.control.TableView;

import javafx.scene.control.TextArea;

import javafx.scene.control.cell.PropertyValueFactory;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;

public class AppointmentStatusController {

private static String username = DoctorDashboardController.getUsername();

public void setUsername(String username) {

AppointmentStatusController.username = username;

@FXML

private TableView<Appointment> appointmentTable;

@FXML

private TableColumn<Appointment, String> doctorColumn;

@FXML

private TableColumn<Appointment, String> patientColumn;


@FXML

private TableColumn<Appointment, String> dateColumn;

@FXML

private TableColumn<Appointment, String> timeColumn;

@FXML

private TableColumn<Appointment, String> notesColumn;

@FXML

private TableColumn<Appointment, String> statusColumn;

public void initialize() throws SQLException, ClassNotFoundException {

doctorColumn.setCellValueFactory(new PropertyValueFactory<>("Doctor"));

patientColumn.setCellValueFactory(new
PropertyValueFactory<>("Patient"));

dateColumn.setCellValueFactory(new PropertyValueFactory<>("Date"));

timeColumn.setCellValueFactory(new PropertyValueFactory<>("Time"));

notesColumn.setCellValueFactory(new PropertyValueFactory<>("Notes"));

statusColumn.setCellValueFactory(new PropertyValueFactory<>("Status"));

List<Appointment> appointments = getAllAppointments(username);

appointmentTable.getItems().setAll(appointments);

public List<Appointment> getAllAppointments(String username) throws


SQLException, ClassNotFoundException {

List<Appointment> appointments = new ArrayList<>();

String sql = "SELECT * FROM appointments WHERE Doctor = ?";

Connection conn = Functions.getConnection();

try (PreparedStatement pstmt = conn.prepareStatement(sql)) {


pstmt.setString(1, username);

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

Appointment appointment = new Appointment();

appointment.setId(rs.getInt("ID"));

appointment.setDoctor(rs.getString("Doctor"));

appointment.setPatient(rs.getString("Patient"));

appointment.setDate(rs.getString("Date"));

appointment.setTime(rs.getString("Time"));

appointment.setNotes(rs.getString("Notes"));

appointment.setStatus(rs.getString("Status"));

appointments.add(appointment);

} catch (SQLException e) {

System.out.println(e.getMessage());

return appointments;

AdminSignupController.java
package com.example.healthcare;

import javafx.application.Application;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Alert;

import javafx.scene.control.Button;

import javafx.scene.control.PasswordField;

import javafx.scene.control.TextField;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.*;

public class AdminSignupController{

@FXML

private TextField username;

@FXML

private PasswordField password;

@FXML

private Button signup;

@FXML

private Button login;

public static Connection getConnection() throws SQLException,


ClassNotFoundException {

Class.forName("com.mysql.cj.jdbc.Driver");
return
DriverManager.getConnection("jdbc:mysql://localhost:3306/hospitalrecord",
"admin","password");

public static void signUpUser(ActionEvent event, String username, String


password, String fxmlFile){

try (Connection connection = getConnection();

PreparedStatement psCheckUserExists =
connection.prepareStatement("SELECT * FROM admins_password_credentials WHERE
`User Name` = ?");

PreparedStatement psInsert = connection.prepareStatement("INSERT


INTO admins_password_credentials (`User Name`, `Password`) VALUES (?,?)")) {

psCheckUserExists.setString(1, username);

ResultSet resultSet = psCheckUserExists.executeQuery();

if(resultSet.isBeforeFirst()){

System.out.println("User Already Exists!");

Alert alert = new Alert(Alert.AlertType.ERROR);

alert.setContentText("You cannot use this username!");

alert.show();

else{

psInsert.setString(1,username);

psInsert.setString(2, password);

psInsert.executeUpdate();

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource(fxmlFile));

Parent root = loader.load();

AdminDashboardController controller =
loader.getController();

controller.setUsername(username);
Stage stage = (Stage)((Node)
event.getSource()).getScene().getWindow();

stage.setTitle("Welcome!");

stage.setScene(new Scene(root, 600, 400));

stage.show();

} catch (Exception e) {

e.printStackTrace();

} catch (SQLException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

} catch (NullPointerException e) {

e.printStackTrace();

@FXML

public void initialize() {

signup.setOnAction(event -> {

String user = username.getText();

String pass = password.getText();

signUpUser(event, user, pass, "adminDashboard.fxml");

});

login.setOnAction(event -> {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("adminLogin.fxml"));
Parent root = loader.load();

Stage stage = (Stage) login.getScene().getWindow();

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

});

AdminLoginController.java
package com.example.healthcare;

import javafx.application.Application;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Alert;

import javafx.scene.control.Button;

import javafx.scene.control.PasswordField;

import javafx.scene.control.TextField;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.*;
public class AdminLoginController{

@FXML

private TextField username;

@FXML

private PasswordField password;

@FXML

private Button login;

@FXML

private Button signup;

public static Connection getConnection() throws SQLException,


ClassNotFoundException {

Class.forName("com.mysql.cj.jdbc.Driver");

return
DriverManager.getConnection("jdbc:mysql://localhost:3306/hospitalrecord",
"admin","password");

public static void logInUser(ActionEvent event, String username, String


password, String fxmlFile){

try (Connection connection = getConnection();

PreparedStatement preparedStatement =
connection.prepareStatement("SELECT `Password` FROM admins_password_credentials
WHERE `User Name` = ?")) {

preparedStatement.setString(1, username);

ResultSet resultSet = preparedStatement.executeQuery();

if(!resultSet.next()){

System.out.println("User not found in the database!");


Alert alert = new Alert(Alert.AlertType.ERROR);

alert.setContentText("Provided Credentials are Incorrect!");

alert.show();

else{

do {

String retrievedPassword = resultSet.getString("Password");

if(retrievedPassword.equals(password)){

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource(fxmlFile));

Parent root = loader.load();

AdminDashboardController controller =
loader.getController();

controller.setUsername(username);

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome, " + username);

stage.setScene(new Scene(root, 600, 400));

stage.show();

} catch (Exception e) {

e.printStackTrace();

else{

System.out.println("Password did not match!");

Alert alert = new Alert(Alert.AlertType.ERROR);


alert.setContentText("The Provided Credentials are
Incorrect!");

alert.show();

} while(resultSet.next());

} catch (SQLException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

} catch (NullPointerException e) {

e.printStackTrace();

@FXML

public void initialize() {

login.setOnAction(event -> {

String user = username.getText();

String pass = password.getText();

logInUser(event, user, pass, "adminDashboard.fxml");

});

signup.setOnAction(event -> {

try {

FXMLLoader loader = new


FXMLLoader(getClass().getResource("adminSignup.fxml"));

Parent root = loader.load();

Stage stage = (Stage) signup.getScene().getWindow();


stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

});

AdminDashboardController.java
package com.example.healthcare;

import javafx.application.Application;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.stage.Stage;

import java.io.IOException;

public class AdminDashboardController{

@FXML

private Button hospital;


@FXML

private Button ward;

@FXML

private Button medicine;

private static String username;

public void setUsername(String username) {

AdminDashboardController.username = username;

public void openHospitalDetails(ActionEvent event) {

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource("hospitalDetails.fxml"));

Parent root = loader.load();

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome, " + username);

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

public void openWardDetails(ActionEvent event) {

FXMLLoader loader;
try {

loader = new
FXMLLoader(Functions.class.getResource("wardDetails.fxml"));

Parent root = loader.load();

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome, " + username);

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

public void openMedicineDetails(ActionEvent event) {

FXMLLoader loader;

try {

loader = new
FXMLLoader(Functions.class.getResource("medicineDetails.fxml"));

Parent root = loader.load();

Stage stage = (Stage)((Node)


event.getSource()).getScene().getWindow();

stage.setTitle("Welcome, " + username);

stage.setScene(new Scene(root));

stage.show();

} catch (IOException e) {

e.printStackTrace();

HospitalDetailsController.java
package com.example.healthcare;

import javafx.event.ActionEvent;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.*;

import javafx.fxml.FXML;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.*;

import java.util.ArrayList;

import java.util.List;

public class HospitalDetailsController{

private String name;

private String district;

private int generalWards;

private int maleWards;

private int femaleWards;

private int mixedWards;

private int paediatricWards;

private int maternityWards;

private int icus;

private int emergencyWards;

private int isolationWards;

private int psychiatricWards;


@FXML

private TextField nameField;

@FXML

private TextField districtField;

@FXML

private TextField generalWardsField;

@FXML

private TextField maleWardsField;

@FXML

private TextField femaleWardsField;

@FXML

private TextField mixedWardsField;

@FXML

private TextField paediatricWardsField;

@FXML

private TextField maternityWardsField;

@FXML

private TextField icusField;

@FXML

private TextField emergencyWardsField;

@FXML

private TextField isolationWardsField;

@FXML

private TextField psychiatricWardsField;

public HospitalDetailsController() {

public HospitalDetailsController(String name, String district, int


generalWards, int maleWards, int femaleWards, int mixedWards, int
paediatricWards, int maternityWards, int icus, int emergencyWards, int
isolationWards, int psychiatricWards) {

this.name = name;

this.district = district;

this.generalWards = generalWards;

this.maleWards = maleWards;

this.femaleWards = femaleWards;

this.mixedWards = mixedWards;

this.paediatricWards = paediatricWards;

this.maternityWards = maternityWards;

this.icus = icus;

this.emergencyWards = emergencyWards;

this.isolationWards = isolationWards;

this.psychiatricWards = psychiatricWards;

public String getName() {

return name;

public String getDistrict() {

return district;

public int getGeneralWards() {

return generalWards;

public int getMaleWards() {

return maleWards;
}

public int getFemaleWards() {

return femaleWards;

public int getMixedWards() {

return mixedWards;

public int getPaediatricWards() {

return paediatricWards;

public int getMaternityWards() {

return maternityWards;

public int getICUs() {

return icus;

public int getEmergencyWards() {

return emergencyWards;

public int getIsolationWards() {

return isolationWards;

}
public int getPsychiatricWards() {

return psychiatricWards;

@FXML

private Button storeButton;

@FXML

private TableView<HospitalDetailsController> hospitalTable;

@FXML

private TableColumn<HospitalDetailsController, String> nameColumn;

@FXML

private TableColumn<HospitalDetailsController, String> districtColumn;

@FXML

private TableColumn<HospitalDetailsController, Number> generalWardsColumn;

@FXML

private TableColumn<HospitalDetailsController, Number> maleWardsColumn;

@FXML

private TableColumn<HospitalDetailsController, Number> femaleWardsColumn;

@FXML

private TableColumn<HospitalDetailsController, Number> mixedWardsColumn;

@FXML

private TableColumn<HospitalDetailsController, Number>


paediatricWardsColumn;

@FXML

private TableColumn<HospitalDetailsController, Number> maternityWardsColumn;

@FXML

private TableColumn<HospitalDetailsController, Number> icusColumn;

@FXML

private TableColumn<HospitalDetailsController, Number> emergencyWardsColumn;


@FXML

private TableColumn<HospitalDetailsController, Number> isolationWardsColumn;

@FXML

private TableColumn<HospitalDetailsController, Number>


psychiatricWardsColumn;

private List<HospitalDetailsController> hospitals = new ArrayList<>();

@FXML

private void storeData(ActionEvent event) {

String name = nameField.getText();

String district = districtField.getText();

int generalWards = Integer.parseInt(generalWardsField.getText());

int maleWards = Integer.parseInt(maleWardsField.getText());

int femaleWards = Integer.parseInt(femaleWardsField.getText());

int mixedWards = Integer.parseInt(mixedWardsField.getText());

int paediatricWards = Integer.parseInt(paediatricWardsField.getText());

int maternityWards = Integer.parseInt(maternityWardsField.getText());

int icus = Integer.parseInt(icusField.getText());

int emergencyWards = Integer.parseInt(emergencyWardsField.getText());

int isolationWards = Integer.parseInt(isolationWardsField.getText());

int psychiatricWards =
Integer.parseInt(psychiatricWardsField.getText());

HospitalDetailsController hospital = new HospitalDetailsController(name,


district, generalWards, maleWards, femaleWards, mixedWards, paediatricWards,
maternityWards, icus, emergencyWards, isolationWards, psychiatricWards);

hospitals.add(hospital);

if (hospitals != null && !hospitals.isEmpty()) {


try (Connection connection = getConnection()) {

PreparedStatement statement = connection

.prepareStatement("INSERT INTO hospital (Name, District,


`General Wards`, `Male Wards`, `Female Wards`, `Mixed Wards`, `Paediatric
Wards`, `Maternity Wards`, ICUs, `Emergency Wards`, `Isolation Wards`,
`Psychiatric Wards`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

for (HospitalDetailsController hospitalDetailsController :


hospitals) {

statement.setString(1, hospital.getName());

statement.setString(2, hospital.getDistrict());

statement.setInt(3, hospital.getGeneralWards());

statement.setInt(4, hospital.getMaleWards());

statement.setInt(5, hospital.getFemaleWards());

statement.setInt(6, hospital.getMixedWards());

statement.setInt(7, hospital.getPaediatricWards());

statement.setInt(8, hospital.getMaternityWards());

statement.setInt(9, hospital.getICUs());

statement.setInt(10, hospital.getEmergencyWards());

statement.setInt(11, hospital.getIsolationWards());

statement.setInt(12, hospital.getPsychiatricWards());

statement.executeUpdate();

} catch (Exception e) {

e.printStackTrace();

}
public static Connection getConnection() throws SQLException,
ClassNotFoundException {

Class.forName("com.mysql.cj.jdbc.Driver");

return
DriverManager.getConnection("jdbc:mysql://localhost:3306/hospitalrecord",
"admin","password");

@FXML

private TextField hospital;

@FXML

private TextField updateGeneralWardsField;

@FXML

private TextField updateMaleWardsField;

@FXML

private TextField updateFemaleWardsField;

@FXML

private TextField updateMixedWardsField;

@FXML

private TextField updatePaediatricWardsField;

@FXML

private TextField updateMaternityWardsField;

@FXML

private TextField updateIcusField;

@FXML

private TextField updateEmergencyWardsField;

@FXML

private TextField updateIsolationWardsField;

@FXML

private TextField updatePsychiatricWardsField;


@FXML

private Button updateButton;

@FXML

private void updateData(ActionEvent event) {

String hospitalName = hospital.getText();

int generalWards = updateGeneralWardsField.getText().isEmpty() ? 0 :


Integer.parseInt(updateGeneralWardsField.getText());

int maleWards = updateMaleWardsField.getText().isEmpty() ? 0 :


Integer.parseInt(updateMaleWardsField.getText());

int femaleWards = updateFemaleWardsField.getText().isEmpty() ? 0 :


Integer.parseInt(updateFemaleWardsField.getText());

int mixedWards = updateMixedWardsField.getText().isEmpty() ? 0 :


Integer.parseInt(updateMixedWardsField.getText());

int paediatricWards = updatePaediatricWardsField.getText().isEmpty() ? 0


: Integer.parseInt(updatePaediatricWardsField.getText());

int maternityWards = updateMaternityWardsField.getText().isEmpty() ? 0 :


Integer.parseInt(updateMaternityWardsField.getText());

int icus = updateIcusField.getText().isEmpty() ? 0 :


Integer.parseInt(updateIcusField.getText());

int emergencyWards = updateEmergencyWardsField.getText().isEmpty() ? 0 :


Integer.parseInt(updateEmergencyWardsField.getText());

int isolationWards = updateIsolationWardsField.getText().isEmpty() ? 0 :


Integer.parseInt(updateIsolationWardsField.getText());

int psychiatricWards = updatePsychiatricWardsField.getText().isEmpty() ?


0 : Integer.parseInt(updatePsychiatricWardsField.getText());

updateWardNumbers(hospitalName, generalWards, maleWards, femaleWards,


mixedWards, paediatricWards, maternityWards, icus, emergencyWards,
isolationWards, psychiatricWards);

public void updateWardNumbers(String hospitalName, int generalWards, int


maleWards, int femaleWards, int mixedWards, int paediatricWards, int
maternityWards, int icus, int emergencyWards, int isolationWards, int
psychiatricWards) {

try (Connection connection = getConnection()) {


PreparedStatement statement = connection

.prepareStatement("UPDATE hospital SET `General Wards` = ?,


`Male Wards` = ?, `Female Wards` = ?, `Mixed Wards` = ?, `Paediatric Wards` =
?, `Maternity Wards` = ?, ICUs = ?, `Emergency Wards` = ?, `Isolation Wards` =
?, `Psychiatric Wards` = ? WHERE Name = ?");

statement.setInt(1, generalWards);

statement.setInt(2, maleWards);

statement.setInt(3, femaleWards);

statement.setInt(4, mixedWards);

statement.setInt(5, paediatricWards);

statement.setInt(6, maternityWards);

statement.setInt(7, icus);

statement.setInt(8, emergencyWards);

statement.setInt(9, isolationWards);

statement.setInt(10, psychiatricWards);

statement.setString(11, hospitalName);

statement.executeUpdate();

} catch (Exception e) {

e.printStackTrace();

@FXML

private Button back;

@FXML

public void goBack(ActionEvent event) {

try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("adminDashboard.fxml"));

Scene scene = new Scene(patientDashboard);


Stage stage = (Stage) ((Node)
event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

WardDetailsController.java
package com.example.healthcare;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;

import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.scene.control.TextField;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;
public class WardDetailsController{

@FXML

private TextField hospital;

@FXML

private Label hospitalNameLabel;

@FXML

private Label districtLabel;

@FXML

private Label generalWardsLabel;

@FXML

private Label maleWardsLabel;

@FXML

private Label femaleWardsLabel;

@FXML

private Label mixedWardsLabel;

@FXML

private Label paediatricWardsLabel;

@FXML

private Label maternityWardsLabel;

@FXML

private Label icusLabel;

@FXML

private Label emergencyWardsLabel;

@FXML

private Label isolationWardsLabel;

@FXML

private Label psychiatricWardsLabel;

public void displayWardDetails(ActionEvent event) throws Exception{


String hospitalName = hospital.getText();

String query = "SELECT * FROM hospital WHERE Name = ?";

try (Connection connection = Functions.getConnection()) {

PreparedStatement statement = connection.prepareStatement(query);

statement.setString(1, hospitalName);

ResultSet resultSet = statement.executeQuery();

while (resultSet.next()) {

hospitalNameLabel.setText(resultSet.getString("Name"));

districtLabel.setText(resultSet.getString("District"));

generalWardsLabel.setText(String.valueOf(resultSet.getInt("General Wards")));

maleWardsLabel.setText(String.valueOf(resultSet.getInt("Male
Wards")));

femaleWardsLabel.setText(String.valueOf(resultSet.getInt("Female
Wards")));

mixedWardsLabel.setText(String.valueOf(resultSet.getInt("Mixed
Wards")));

paediatricWardsLabel.setText(String.valueOf(resultSet.getInt("Paediatric
Wards")));

maternityWardsLabel.setText(String.valueOf(resultSet.getInt("Maternity
Wards")));

icusLabel.setText(String.valueOf(resultSet.getInt("ICUs")));

emergencyWardsLabel.setText(String.valueOf(resultSet.getInt("Emergency
Wards")));

isolationWardsLabel.setText(String.valueOf(resultSet.getInt("Isolation
Wards")));

psychiatricWardsLabel.setText(String.valueOf(resultSet.getInt("Psychiatric
Wards")));
}

} catch (Exception e) {

e.printStackTrace();

@FXML

private Button back;

@FXML

public void goBack(ActionEvent event) {

try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("adminDashboard.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

MedicineDetailsController.java
package com.example.healthcare;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.FXMLLoader;
import javafx.scene.Node;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;

import javafx.stage.Stage;

import java.io.IOException;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.SQLException;

public class MedicineDetailsController {

@FXML

private TextField pharmacyTextField;

@FXML

private TextField districtTextField;

@FXML

private TextField medicineTextField;

@FXML

private TextField availableTextField;

@FXML

private Button insertButton;

@FXML

private void insertData(ActionEvent event) {

String pharmacy = pharmacyTextField.getText();

String district = districtTextField.getText();


String medicine = medicineTextField.getText();

String available = availableTextField.getText();

try (Connection connection = getConnection()) {

PreparedStatement statement = connection

.prepareStatement("INSERT INTO medicine (Pharmacy, District,


Medicine, Available) VALUES (?, ?, ?, ?)");

statement.setString(1, pharmacy);

statement.setString(2, district);

statement.setString(3, medicine);

statement.setString(4, available);

statement.executeUpdate();

} catch (Exception e) {

e.printStackTrace();

public static Connection getConnection() throws SQLException,


ClassNotFoundException {

Class.forName("com.mysql.cj.jdbc.Driver");

return
DriverManager.getConnection("jdbc:mysql://localhost:3306/hospitalrecord",
"admin", "password");

@FXML

private TextField updatePharmacyTextField;

@FXML

private TextField updateDistrictTextField;

@FXML
private TextField updateMedicineTextField;

@FXML

private TextField updateAvailableTextField;

@FXML

private Button updateButton;

@FXML

private void updateData(ActionEvent event) {

String pharmacy = updatePharmacyTextField.getText();

String district = updateDistrictTextField.getText();

String medicine = updateMedicineTextField.getText();

String available = updateAvailableTextField.getText();

updateMedicineDetails(pharmacy, district, medicine, available);

public void updateMedicineDetails(String pharmacy, String district, String


medicine, String available) {

try (Connection connection = getConnection()) {

PreparedStatement statement = connection

.prepareStatement("UPDATE medicine SET Available = ? WHERE


Pharmacy = ? AND District = ? AND Medicine = ?");

statement.setString(1, available);

statement.setString(2, pharmacy);

statement.setString(3, district);

statement.setString(4, medicine);

statement.executeUpdate();
} catch (Exception e) {

e.printStackTrace();

@FXML

private Button back;

@FXML

public void goBack(ActionEvent event) {

try {

Parent patientDashboard =
FXMLLoader.load(getClass().getResource("adminDashboard.fxml"));

Scene scene = new Scene(patientDashboard);

Stage stage = (Stage) ((Node)


event.getSource()).getScene().getWindow();

stage.setScene(scene);

stage.show();

} catch (IOException e) {

e.printStackTrace();

Output Screenshots:

Main Screen:
Patient Login:

Patient Dashboard:
Patient Profile:
Appointment Booking Module:
Booked Appointments with Status:
Ward Availability Checking Module:
Find Nearby Hospital Module:
Search Medicine By Pharmacy:
Search Medicine by Name:

Doctor Profile Module:


Doctor Login:

Doctor Dashboard:
Doctor Profile:

Check Appointments:

The appointments booked with status pending will appear here.


Booked Appointments:
Admin Login:

Admin Dashboard:
Hospital Table:

Storing data:
Updating the data:
Displaying ward details:
Medicine Details Module:

Storing the medicine:


Updating the medicine availability status:
Object Oriented Features used:

In the e-Health Care Management System, several Object-Oriented Programming (OOP)


features are used:

1. Classes and Objects: The system is modeled using classes such as Patient,
Doctor, Hospital, Pharmacy, and Appointment and
ControllerClasses for each fxml file. Each of these classes have objects
representing individual instances.
2. Encapsulation: Each class encapsulate (hide) its data (attributes) from the
outside world. For example, the Patient class can have private attributes like
patientID, name, address, and contactNumber.
3. Inheritance: If there are common attributes or methods among classes, you can
create a parent class and have other classes inherit from it. For example, both
Doctor and Patient classes could inherit from a User class that contains
common attributes like userID, name, address, and contactNumber.
4. Polymorphism: Polymorphism allows a child class to inherit the methods of its
parent class and to override them as needed. For example, if there is a User
class with a method displayDetails(), the Doctor and Patient classes
inheriting from User can override this method to display their specific details.
5. Abstraction: Abstraction can be used to hide complex implementations from the
user. For example, the process of booking an appointment can be abstracted
behind a method like bookAppointment().

Inference:
Upon completion, the e-Health Care Management System is expected to
significantly improve the healthcare experience for patients. By integrating various
healthcare services into a single platform, the system should make it easier and more
efficient for patients to manage their healthcare needs. This includes booking
appointments with doctors, locating nearby hospitals, checking ward availability, and
finding out about medicine availability in pharmacies.
In addition, the system should also provide benefits to healthcare providers by
automating administrative tasks, improving patient communication, and potentially
increasing patient engagement and satisfaction. The successful implementation of this
system could serve as a model for future digital healthcare solutions.

Future extension:

1. Telemedicine: Integrate a telemedicine feature that allows patients to consult


with doctors virtually. This could include video consultations and online
prescriptions.
2. Health Records: Expand the system to include a comprehensive electronic health
record for each patient. This could include medical history, test results, and
prescribed medications.
3. Payment Integration: Incorporate a secure online payment system for patients to
pay for healthcare services directly through the platform.

You might also like