0% found this document useful (0 votes)
33 views42 pages

Ajpr MP

The document is a micro project report for a Web Medical Management System developed by students of Y. B. Patil Polytechnic, Akurdi, Pune, as part of their Diploma in Computer Engineering. The project aims to automate patient record management, user authentication, and appointment scheduling to improve efficiency and accuracy in healthcare settings. The report includes acknowledgments, objectives, key features, advantages, and code snippets related to the system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views42 pages

Ajpr MP

The document is a micro project report for a Web Medical Management System developed by students of Y. B. Patil Polytechnic, Akurdi, Pune, as part of their Diploma in Computer Engineering. The project aims to automate patient record management, user authentication, and appointment scheduling to improve efficiency and accuracy in healthcare settings. The report includes acknowledgments, objectives, key features, advantages, and code snippets related to the system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 42

MICRO PROJECT REPORT

Name of institute: Y. B. Patil Polytechnic, Akurdi, Pune

Name of Program: Diploma in Computer Engineering

Name of Course: Advanced Java Programming

Course Code: 22517 Academic Year: 2024-25

Sr. No. Roll no Name of the Student Enrollment No.

1. Y-A3317 Priya Karnawat 2201340087

2. Y-A3318 Shital Biradar 2201340088

3. Y-A3319 Swadha Lonkar 2201340089

4. Y-A3320 Neha Sharma 2201340091

Class: TYCO-A Semester: 5 Scheme: I

Title of Project: Web Medical Management System

Name of teacher: Mrs. Archana Bansod

CERTIFICATE

1
This is to certify that the Project Report entitled Web Medical Management System

Under the course: Advanced Java Programming

Is a Bonafide Work Carried Out By

Sr. No. Roll no Name of the Student Enrollment No.

1. Y-A3317 Priya Karnawat 2201340087

2. Y-A3318 Shital Biradar 2201340088

3. Y-A3319 Swadha Lonkar 2201340089

4. Y-A3320 Neha Sharma 2201340091

In Partial Fulfillment of the Requirement for the Diploma in

Computer Engineering

During the Academic Year 2024-2025

Mrs. Archana Bansod Mrs. Pooja Ahuja Dr. A.S Kondekar

(Project Guide) (H.O.D) (Principal)

2
ACKNOWLEDGEMENT

Firstly, we would like to express our special thanks of gratitude to our subject teacher Mrs.
Archana Bansod and principal Dr. A.S. Kondekar of Y.B Patil Polytechnic, Akurdi, Pune,
who gave us the golden opportunity to do this wonderful project of Advanced Java
Programming on ‘Web Medical Management System’ due to which we came to know
about so many new things in the field of Billing systems and we are really thankful to them
for the same.

We also thank them for their able guidance and support in completing our project.

Secondly, we would also like to extent our gratitude to the Y.B. Patil Polytechnic, Akurdi,
Pune for providing us the facility required.

Thirdly, we would like to thank our friends who helped us a lot in finalizing this project
within the limited time frame.

Lastly, thanks to our group members for co-operating and doing the team work together.

Date:

Place:Akurdi

3
INDEX

Sr. No Content Page No

1. Introduction 5

2. Problem Statement 6

3. Objectives 7

4. Key Features of the System 8

5. Advantages 9

6. Code 10

7. Output 21

8. References

9. Conclusion

4
Introduction

In today's rapidly evolving healthcare landscape, the ability to manage patient records,
appointments, and user authentication efficiently is crucial for ensuring smooth operations and
quality care. Healthcare providers, whether they are hospitals, clinics, or private practices, rely
heavily on managing vast amounts of patient data, tracking appointments, and ensuring secure
access to sensitive medical information. As the demand for medical services grows, it becomes
increasingly important to have systems in place that can streamline these processes and reduce
human error.

For any healthcare institution, managing patient data, scheduling appointments, and ensuring that
only authorized users have access to critical information is of paramount importance. Manual
processes for handling patient records, authentication, and appointment scheduling are not only
time-consuming but also prone to errors, which can impact patient care and operational
efficiency. Ensuring that patient details are accurately stored, and appointments are properly
scheduled, can be a daunting task without automation.

The Web Medical Management System was developed to automate and streamline the core
processes in medical organizations, including user authentication, patient management, and
appointment scheduling (with future plans for implementation). This system leverages modern
software technologies to provide a seamless and efficient interface for managing patient
information, securing user logins, and storing data in an easily accessible format.

This project aims to simplify the complex and critical tasks of managing medical records by
utilizing a powerful combination of Java, Swing (for the user interface), and SQLite (for local
database management). The system offers intuitive interfaces for users to input patient details,
securely log into the platform, and manage patient records, including essential information like
contact details, gender, age, and medical history. It also includes functionality for adding new
patients to the database, with records stored for future access and modifications.

The Web Medical Management System is an ideal solution for small to medium-sized healthcare
organizations that require an efficient, user-friendly system for managing patient data and user
authentication. By automating these essential tasks, the system not only reduces the potential for
errors but also helps healthcare providers focus on what matters most—delivering excellent
patient care. With the flexibility of future feature expansion, such as appointment management,
this system is designed to evolve alongside the needs of modern healthcare practices.

5
Problem statement

In the healthcare industry, medical practices, clinics, and hospitals face significant challenges in
managing patient records, appointments, and ensuring secure access to sensitive medical data.
While large healthcare facilities may have sophisticated software infrastructure, smaller practices
and individual healthcare providers often lack access to such advanced systems. This disparity
results in inefficiencies in handling patient information, scheduling appointments, and ensuring
secure, authorized access to medical data.

Manual handling of patient records is prone to errors such as incorrect data entry, missed
appointments, or improper access control. These errors not only impact patient care but also
expose healthcare organizations to potential regulatory and compliance risks.

Recognizing these challenges, the Web Medical Management System is designed to address
the following critical issues:

1. Manual Data Entry Errors: Manual record-keeping is prone to inaccuracies, which can
compromise patient care. By automating the process, the system ensures that patient records
are accurate, reducing the risk of medical errors
2. Inefficient Record Management: Without a structured system for storing patient data, it
becomes difficult to organize and access medical records quickly. The system utilizes a
centralized database to securely store and retrieve patient details, improving efficiency and
accessibility.
3. Security and Privacy Concerns: Sensitive patient data must be protected from unauthorized
access. The system incorporates user authentication and data encryption to ensure that only
authorized personnel can access medical records, ensuring compliance with privacy
regulations like HIPAA.
4. Appointment Scheduling Challenges: Without a streamlined appointment management
system, healthcare providers face difficulties in tracking patient appointments, leading to
scheduling conflicts or missed appointments.

Through the Web Medical Management System, healthcare providers can simplify
administrative tasks, improve the accuracy and security of patient data, and enhance overall
patient care. This project aims to provide a user-friendly, cost-effective, and scalable solution for
managing medical records and appointments, reducing errors and improving operational
efficiency.

6
Objectives

1. Patient Record Management:To provide a seamless and efficient way to store, manage,
and retrieve patient records. The system will ensure that all patient details, such as
personal information, age, gender, contact, and address, are accurately recorded and
easily accessible for healthcare providers.

2. User Authentication and Access Control:The system will incorporate secure user
authentication to manage access to patient records. Admin users will have full access to
the system’s features, including record management and report generation, while other
users (e.g., medical staff) will only have access to relevant data based on their roles

3. Centralized Data Storage and Accessibility:To centralize patient information in a


secure, easily accessible database. This will improve operational efficiency by reducing
the need for paper records and enabling medical staff to access up-to-date information
quickly when required.

4. Patient Data Security and Privacy:To implement robust security features to protect
sensitive patient data. The system will enforce user authentication and authorization to
ensure that only authorized personnel can access patient information, in compliance with
privacy laws and regulations like HIPAA.

5. Error-Free Patient Data Entry:To minimize human errors in patient data entry by
automating the process and using validation checks. The system will ensure that
information such as patient age, gender, and contact details are entered accurately,
reducing the risk of incorrect diagnoses or treatments.

6. User-Friendly Interface:To provide an intuitive and easy-to-navigate interface for


medical staff, reducing the learning curve and enhancing usability. The design will focus
on simplicity while ensuring all necessary functions are easily accessible.

7
Key Features of the system

1. Patient Record Management: The system allows healthcare providers to maintain


detailed patient records, including personal details, medical history, age, gender, contact
information, and address. It helps streamline patient registration and data retrieval
processes.

2. Patient Data Entry and Update: The system provides an interface for healthcare
professionals to enter and update patient information, including name, age, contact
details, gender, and medical history, ensuring accurate and up-to-date patient profiles.

3. Automated Patient Addition: The system allows healthcare administrators or staff to


add new patients to the database with ease. This feature enables efficient patient
onboarding, reducing manual effort and increasing data accuracy.

4. User-Friendly Interface: The system is designed with a simple and intuitive graphical
user interface (GUI), allowing users, including healthcare staff and patients, to interact
with the system without requiring advanced technical knowledge.

5. Database Management: The system uses an SQLite database to store and retrieve
patient information. It ensures that all records are securely saved and easily accessible for
future reference, providing efficient data storage and retrieval.

6. Secure Login and Authentication: The system features user authentication for secure
access, with different roles (such as admin, doctor, patient) having distinct access levels
to ensure data privacy and security.

7. Expandable and Customizable: The system is designed to be scalable and flexible,


allowing for the future addition of more advanced features like appointment reminders,
patient billing, or integration with other healthcare systems (e.g., Electronic Health
Records or EHR systems).

8
Advantages

1. Efficiency: The system automates key tasks such as patient record management and user
authentication, drastically reducing time spent on manual processes. This enables
healthcare providers to streamline workflows and spend more time on patient care.

2. Accuracy: The system minimizes human errors by automating data entry and
management, ensuring that patient information is consistently accurate. With accurate
records, the risk of mistakes in treatment or medication is reduced.

3. Cost-Effective: By reducing the need for paper-based record-keeping and minimizing


administrative overhead, the system helps healthcare organizations cut costs. Automation
frees up staff from tedious manual tasks, leading to savings in labor and time.

4. Transparency: The system offers clear and easily accessible records for healthcare
providers, making it easy to track patient information. This improves trust and clarity in
healthcare operations.

5. Easy Record Keeping: Patient data is stored in a centralized database, making it simple
to retrieve and update records as necessary. This eliminates the need for physical
paperwork, reducing clutter and the risk of losing important information.

6. Scalability and Flexibility: The system is designed to grow alongside the needs of the
healthcare facility, allowing for the addition of new features such as appointment
scheduling.

7. User-Friendly Interface: Built with a simple and intuitive GUI, the system is easy for
medical staff to navigate with minimal training. Users can quickly input and access
patient information, reducing the time spent on learning the system.

8. Improved Data Security: With user authentication in place, the system ensures that
sensitive patient data is accessed only by authorized personnel. This protects patient
privacy and helps meet healthcare data protection regulations like HIPAA.

9
Codes

package MyPackage;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

import javax.swing.table.DefaultTableModel;

public class HospitalManagementSystem {

private static final String DATABASE_URL = "jdbc:sqlite:medical.db";

private static final String ADMIN_USERNAME = "admin";

private static final String ADMIN_PASSWORD = "admin";

public static void main(String[] args) {

initializeDatabase();

JFrame mainFrame = new JFrame("Hospital Management System");

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mainFrame.setSize(800, 600);

mainFrame.setLayout(new CardLayout());

10
JPanel registrationPanel = createPatientRegistrationPanel();

JPanel doctorRegistrationPanel = createDoctorRegistrationPanel();

JPanel medicineRegistrationPanel = createMedicineRegistrationPanel();

JPanel adminLoginPanel = createAdminLoginPanel(mainFrame);

JTabbedPane mainTabs = new JTabbedPane();

mainTabs.addTab("Patient Registration", registrationPanel);

mainTabs.addTab("Doctor Registration", doctorRegistrationPanel);

mainTabs.addTab("Medicine Registration", medicineRegistrationPanel);

mainTabs.addTab("Admin Login", adminLoginPanel);

mainFrame.add(mainTabs);

mainFrame.setVisible(true);

private static JPanel createAdminLoginPanel(JFrame mainFrame) {

JPanel adminLoginPanel = new JPanel();

adminLoginPanel.setLayout(null);

JLabel adminTitle = new JLabel("Admin Login");

adminTitle.setFont(new Font("Arial", Font.BOLD, 20));

11
adminTitle.setBounds(300, 20, 300, 30);

adminLoginPanel.add(adminTitle);

JLabel usernameLabel = new JLabel("Username:");

usernameLabel.setBounds(100, 80, 120, 25);

adminLoginPanel.add(usernameLabel);

JTextField usernameField = new JTextField();

usernameField.setBounds(200, 80, 200, 25);

adminLoginPanel.add(usernameField);

JLabel passwordLabel = new JLabel("Password:");

passwordLabel.setBounds(100, 120, 120, 25);

adminLoginPanel.add(passwordLabel);

JPasswordField passwordField = new JPasswordField();

passwordField.setBounds(200, 120, 200, 25);

adminLoginPanel.add(passwordField);

JButton loginButton = new JButton("Login");

loginButton.setBounds(200, 180, 100, 30);

adminLoginPanel.add(loginButton);

12
JLabel loginMessage = new JLabel("");

loginMessage.setBounds(200, 220, 400, 25);

adminLoginPanel.add(loginMessage);

loginButton.addActionListener(e -> {

String username = usernameField.getText();

String password = new String(passwordField.getPassword());

if (username.equals(ADMIN_USERNAME) &&
password.equals(ADMIN_PASSWORD)) {

loginMessage.setText("Login successful!");

JOptionPane.showMessageDialog(mainFrame, "Welcome, Admin!");

showAdminPanel(mainFrame);

} else {

loginMessage.setText("Invalid username or password.");

});

return adminLoginPanel;

13
private static void showAdminPanel(JFrame mainFrame) {

JTabbedPane adminTabs = new JTabbedPane();

// Tab for Patients

JPanel patientsPanel = new JPanel(new BorderLayout());

JTable patientsTable = createPatientsTable();

JScrollPane patientsScrollPane = new JScrollPane(patientsTable);

patientsPanel.add(patientsScrollPane, BorderLayout.CENTER);

adminTabs.addTab("Patients", patientsPanel);

// Tab for Doctors

JPanel doctorsPanel = new JPanel(new BorderLayout());

JTable doctorsTable = createDoctorsTable();

JScrollPane doctorsScrollPane = new JScrollPane(doctorsTable);

doctorsPanel.add(doctorsScrollPane, BorderLayout.CENTER);

adminTabs.addTab("Doctors", doctorsPanel);

// Tab for Medicines

JPanel medicinesPanel = new JPanel(new BorderLayout());

JTable medicinesTable = createMedicinesTable();

JScrollPane medicinesScrollPane = new JScrollPane(medicinesTable);

medicinesPanel.add(medicinesScrollPane, BorderLayout.CENTER);

14
adminTabs.addTab("Medicines", medicinesPanel);

// Add the Admin Tabs to the Main Frame

mainFrame.getContentPane().removeAll();

mainFrame.add(adminTabs);

mainFrame.revalidate();

mainFrame.repaint();

private static JTable createPatientsTable() {

String[] columns = {"ID", "Name", "Age", "Gender", "Contact",


"Disease"};

DefaultTableModel model = new DefaultTableModel(columns, 0);

try (Connection connection =


DriverManager.getConnection(DATABASE_URL);

Statement stmt = connection.createStatement();

ResultSet rs = stmt.executeQuery("SELECT * FROM patients")) {

while (rs.next()) {

model.addRow(new Object[]{

rs.getInt("id"),

rs.getString("name"),

rs.getInt("age"),

15
rs.getString("gender"),

rs.getString("contact"),

rs.getString("disease")

});

} catch (SQLException e) {

e.printStackTrace();

return new JTable(model);

private static JTable createDoctorsTable() {

String[] columns = {"ID", "Name", "Specialty", "Contact"};

DefaultTableModel model = new DefaultTableModel(columns, 0);

try (Connection connection =


DriverManager.getConnection(DATABASE_URL);

Statement stmt = connection.createStatement();

ResultSet rs = stmt.executeQuery("SELECT * FROM doctors")) {

while (rs.next()) {

model.addRow(new Object[]{

rs.getInt("id"),

16
rs.getString("name"),

rs.getString("specialty"),

rs.getString("contact")

});

} catch (SQLException e) {

e.printStackTrace();

return new JTable(model);

private static JTable createMedicinesTable() {

String[] columns = {"ID", "Name", "Price", "Stock"};

DefaultTableModel model = new DefaultTableModel(columns, 0);

try (Connection connection =


DriverManager.getConnection(DATABASE_URL);

Statement stmt = connection.createStatement();

ResultSet rs = stmt.executeQuery("SELECT * FROM medicines")) {

while (rs.next()) {

model.addRow(new Object[]{

rs.getInt("id"),

17
rs.getString("name"),

rs.getDouble("price"),

rs.getInt("stock")

});

} catch (SQLException e) {

e.printStackTrace();

return new JTable(model);

private static void initializeDatabase() {

try (Connection connection =


DriverManager.getConnection(DATABASE_URL);

Statement statement = connection.createStatement()) {

18
String createPatientsTable = "CREATE TABLE IF NOT EXISTS
patients (" +

"id INTEGER PRIMARY KEY AUTOINCREMENT, " +

"name TEXT, " +

"age INTEGER, " +

"gender TEXT, " +

"contact TEXT, " +

"disease TEXT)";

statement.execute(createPatientsTable);

String createDoctorsTable = "CREATE TABLE IF NOT EXISTS


doctors (" +

"id INTEGER PRIMARY KEY AUTOINCREMENT, " +

"name TEXT, " +

"specialty TEXT, " +

"contact TEXT)";

statement.execute(createDoctorsTable);

String createMedicinesTable = "CREATE TABLE IF NOT EXISTS


medicines (" +

"id INTEGER PRIMARY KEY AUTOINCREMENT, " +

"name TEXT, " +

"price REAL, " +

"stock INTEGER)";

19
statement.execute(createMedicinesTable);

} catch (SQLException e) {

e.printStackTrace();

// Patient Registration Panel

private static JPanel createPatientRegistrationPanel() {

JPanel panel = new JPanel();

panel.setLayout(null);

JLabel nameLabel = new JLabel("Name:");

nameLabel.setBounds(100, 40, 120, 25);

JTextField nameField = new JTextField();

nameField.setBounds(200, 40, 200, 25);

JLabel ageLabel = new JLabel("Age:");

ageLabel.setBounds(100, 80, 120, 25);

JTextField ageField = new JTextField();

ageField.setBounds(200, 80, 200, 25);

JLabel genderLabel = new JLabel("Gender:");

genderLabel.setBounds(100, 120, 120, 25);

JTextField genderField = new JTextField();

genderField.setBounds(200, 120, 200, 25);

20
JLabel contactLabel = new JLabel("Contact:");

contactLabel.setBounds(100, 160, 120, 25);

JTextField contactField = new JTextField();

contactField.setBounds(200, 160, 200, 25);

JLabel diseaseLabel = new JLabel("Disease:");

diseaseLabel.setBounds(100, 200, 120, 25);

JTextField diseaseField = new JTextField();

diseaseField.setBounds(200, 200, 200, 25);

JButton registerButton = new JButton("Register");

registerButton.setBounds(200, 240, 100, 30);

panel.add(nameLabel);

panel.add(nameField);

panel.add(ageLabel);

panel.add(ageField);

panel.add(genderLabel);

panel.add(genderField);

panel.add(contactLabel);

panel.add(contactField);

panel.add(diseaseLabel);

21
panel.add(diseaseField);

panel.add(registerButton);

registerButton.addActionListener(e -> {

String name = nameField.getText();

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

String gender = genderField.getText();

String contact = contactField.getText();

String disease = diseaseField.getText();

try (Connection connection =


DriverManager.getConnection(DATABASE_URL);

PreparedStatement stmt = connection.prepareStatement(

"INSERT INTO patients (name, age, gender, contact, disease)


VALUES (?, ?, ?, ?, ?)")) {

stmt.setString(1, name);

stmt.setInt(2, age);

stmt.setString(3, gender);

stmt.setString(4, contact);

stmt.setString(5, disease);

stmt.executeUpdate();

JOptionPane.showMessageDialog(panel, "Patient Registered


Successfully!");

} catch (SQLException ex) {

22
ex.printStackTrace();

});

return panel;

// Doctor Registration Panel

private static JPanel createDoctorRegistrationPanel() {

JPanel doctorPanel = new JPanel();

doctorPanel.setLayout(null); // Using null layout for absolute positioning

JLabel title = new JLabel("Doctor Registration");

title.setFont(new Font("Arial", Font.BOLD, 20));

title.setBounds(300, 20, 300, 30); // Positioning the title

doctorPanel.add(title);

JLabel nameLabel = new JLabel("Name:");

nameLabel.setBounds(100, 80, 120, 25);

doctorPanel.add(nameLabel);

JTextField nameField = new JTextField();

23
nameField.setBounds(200, 80, 200, 25);

doctorPanel.add(nameField);

JLabel specialtyLabel = new JLabel("Specialty:");

specialtyLabel.setBounds(100, 120, 120, 25);

doctorPanel.add(specialtyLabel);

JTextField specialtyField = new JTextField();

specialtyField.setBounds(200, 120, 200, 25);

doctorPanel.add(specialtyField);

JLabel contactLabel = new JLabel("Contact:");

contactLabel.setBounds(100, 160, 120, 25);

doctorPanel.add(contactLabel);

JTextField contactField = new JTextField();

contactField.setBounds(200, 160, 200, 25);

doctorPanel.add(contactField);

JButton registerButton = new JButton("Register");

registerButton.setBounds(200, 220, 100, 30);

doctorPanel.add(registerButton);

24
JLabel registrationMessage = new JLabel("");

registrationMessage.setBounds(200, 260, 400, 25);

doctorPanel.add(registrationMessage);

registerButton.addActionListener(e -> {

String name = nameField.getText();

String specialty = specialtyField.getText();

String contact = contactField.getText();

if (name.isEmpty() || specialty.isEmpty() || contact.isEmpty()) {

registrationMessage.setText("Please fill all fields!");

return;

try (Connection connection =


DriverManager.getConnection(DATABASE_URL);

PreparedStatement stmt = connection.prepareStatement(

"INSERT INTO doctors (name, specialty, contact) VALUES (?,


?, ?)")) {

stmt.setString(1, name);

stmt.setString(2, specialty);

stmt.setString(3, contact);

stmt.executeUpdate();

registrationMessage.setText("Doctor registered successfully!");

25
nameField.setText("");

specialtyField.setText("");

contactField.setText("");

} catch (SQLException ex) {

ex.printStackTrace();

});

return doctorPanel;

// Medicine Registration Panel

private static JPanel createMedicineRegistrationPanel() {

JPanel medicinePanel = new JPanel();

medicinePanel.setLayout(null);

JLabel title = new JLabel("Medicine Registration");

title.setFont(new Font("Arial", Font.BOLD, 20));

title.setBounds(300, 20, 300, 30);

medicinePanel.add(title);

26
JLabel nameLabel = new JLabel("Name:");

nameLabel.setBounds(100, 80, 120, 25);

medicinePanel.add(nameLabel);

JTextField nameField = new JTextField();

nameField.setBounds(200, 80, 200, 25);

medicinePanel.add(nameField);

JLabel priceLabel = new JLabel("Price:");

priceLabel.setBounds(100, 120, 120, 25);

medicinePanel.add(priceLabel);

JTextField priceField = new JTextField();

priceField.setBounds(200, 120, 200, 25);

medicinePanel.add(priceField);

JLabel stockLabel = new JLabel("Stock:");

stockLabel.setBounds(100, 160, 120, 25);

medicinePanel.add(stockLabel);

JTextField stockField = new JTextField();

stockField.setBounds(200, 160, 200, 25);

medicinePanel.add(stockField);

27
JButton registerButton = new JButton("Register");

registerButton.setBounds(200, 220, 100, 30);

medicinePanel.add(registerButton);

JLabel registrationMessage = new JLabel("");

registrationMessage.setBounds(200, 260, 400, 25);

medicinePanel.add(registrationMessage);

registerButton.addActionListener(e -> {

String name = nameField.getText();

String priceText = priceField.getText();

String stockText = stockField.getText();

if (name.isEmpty() || priceText.isEmpty() || stockText.isEmpty()) {

registrationMessage.setText("Please fill all fields!");

return;

try {

double price = Double.parseDouble(priceText);

int stock = Integer.parseInt(stockText);

28
try (Connection connection =
DriverManager.getConnection(DATABASE_URL);

PreparedStatement stmt = connection.prepareStatement(

"INSERT INTO medicines (name, price, stock) VALUES


(?, ?, ?)")) {

stmt.setString(1, name);

stmt.setDouble(2, price);

stmt.setInt(3, stock);

stmt.executeUpdate();

registrationMessage.setText("Medicine registered successfully!");

nameField.setText("");

priceField.setText("");

stockField.setText("");

} catch (NumberFormatException ex) {

registrationMessage.setText("Invalid price or stock value!");

} catch (SQLException ex) {

ex.printStackTrace();

});

return medicinePanel;

29
Database
package MyPackage;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

public class SQLiteJDBCExample {

private static final String DATABASE_URL = "jdbc:sqlite:medical.db";

public static void main(String[] args) {

try {

Connection connection =
DriverManager.getConnection(DATABASE_URL);

System.out.println("Connected to SQLite database!");

String createPatientsTableSQL = "CREATE TABLE IF NOT EXISTS


Patients ("

+ "id INTEGER PRIMARY KEY AUTOINCREMENT, "

+ "name TEXT NOT NULL, "

+ "age INTEGER NOT NULL, "

30
+ "gender TEXT NOT NULL, "

+ "contact TEXT NOT NULL, "

+ "disease TEXT NOT NULL"

+ ");";

connection.createStatement().execute(createPatientsTableSQL);

System.out.println("Patients table created successfully!");

String createDoctorsTableSQL = "CREATE TABLE IF NOT EXISTS


Doctors ("

+ "id INTEGER PRIMARY KEY AUTOINCREMENT, "

+ "name TEXT NOT NULL, "

+ "specialty TEXT NOT NULL, "

+ "contact TEXT NOT NULL"

+ ");";

connection.createStatement().execute(createDoctorsTableSQL);

System.out.println("Doctors table created successfully!");

String createMedicinesTableSQL = "CREATE TABLE IF NOT


EXISTS Medicines ("

+ "id INTEGER PRIMARY KEY AUTOINCREMENT, "

+ "name TEXT NOT NULL, "

+ "price REAL NOT NULL, "

+ "stock INTEGER NOT NULL"

31
+ ");";

connection.createStatement().execute(createMedicinesTableSQL);

System.out.println("Medicines table created successfully!");

String insertPatientSQL = "INSERT INTO Patients (name, age, gender,


contact, disease) VALUES (?, ?, ?, ?, ?)";

PreparedStatement patientStatement =
connection.prepareStatement(insertPatientSQL);

patientStatement.setString(1, "ABC");

patientStatement.setInt(2, 30);

patientStatement.setString(3, "Male");

patientStatement.setString(4, "1234567890");

patientStatement.setString(5, "Flu");

patientStatement.executeUpdate();

System.out.println("Patient data inserted successfully!");

String insertDoctorSQL = "INSERT INTO Doctors (name, specialty,


contact) VALUES (?, ?, ?)";

PreparedStatement doctorStatement =
connection.prepareStatement(insertDoctorSQL);

doctorStatement.setString(1, "Dr. XYZ");

doctorStatement.setString(2, "Cardiology");

doctorStatement.setString(3, "9876543210");

doctorStatement.executeUpdate();

32
System.out.println("Doctor data inserted successfully!");

String insertMedicineSQL = "INSERT INTO Medicines (name, price,


stock) VALUES (?, ?, ?)";

PreparedStatement medicineStatement =
connection.prepareStatement(insertMedicineSQL);

medicineStatement.setString(1, "Paracetamol");

medicineStatement.setDouble(2, 50.0);

medicineStatement.setInt(3, 100);

medicineStatement.executeUpdate();

System.out.println("Medicine data inserted successfully!");

String selectPatientsSQL = "SELECT * FROM Patients";

ResultSet patientsResultSet =
connection.createStatement().executeQuery(selectPatientsSQL);

System.out.println("Patient Records:");

while (patientsResultSet.next()) {

System.out.println("ID: " + patientsResultSet.getInt("id"));

System.out.println("Name: " + patientsResultSet.getString("name"));

System.out.println("Age: " + patientsResultSet.getInt("age"));

System.out.println("Gender: " +
patientsResultSet.getString("gender"));

System.out.println("Contact: " +
patientsResultSet.getString("contact"));

33
System.out.println("Disease: " +
patientsResultSet.getString("disease"));

System.out.println("-------------------");

String selectDoctorsSQL = "SELECT * FROM Doctors";

ResultSet doctorsResultSet =
connection.createStatement().executeQuery(selectDoctorsSQL);

System.out.println("Doctor Records:");

while (doctorsResultSet.next()) {

System.out.println("ID: " + doctorsResultSet.getInt("id"));

System.out.println("Name: " + doctorsResultSet.getString("name"));

System.out.println("Specialty: " +
doctorsResultSet.getString("specialty"));

System.out.println("Contact: " +
doctorsResultSet.getString("contact"));

System.out.println("-------------------");

String selectMedicinesSQL = "SELECT * FROM Medicines";

ResultSet medicinesResultSet =
connection.createStatement().executeQuery(selectMedicinesSQL);

System.out.println("Medicine Records:");

while (medicinesResultSet.next()) {

34
System.out.println("ID: " + medicinesResultSet.getInt("id"));

System.out.println("Name: " +
medicinesResultSet.getString("name"));

System.out.println("Price: " +
medicinesResultSet.getDouble("price"));

System.out.println("Stock: " + medicinesResultSet.getInt("stock"));

System.out.println("-------------------");

connection.close();

System.out.println("Connection closed.");

} catch (Exception e) {

e.printStackTrace();

35
Output

36
37
38
39
Database

40
References

1. www.codewithc.com
2. www.codebun.com
3. www.javatpoint.com
4. www.1000projects.org

41
Conclusion

The Web Medical Management System, as outlined in the provided code, presents a
comprehensive solution for managing patient information, appointments, and user
authentication within healthcare environments. By streamlining the process of patient
record management, appointment scheduling, and data storage, the system significantly
improves the efficiency of healthcare service delivery. It eliminates the challenges of
manual record-keeping and offers an intuitive platform for both healthcare staff and
patients.

Through features like secure login, real-time data entry, and automated patient
management, the system ensures the accuracy and integrity of medical records, ultimately
enhancing the quality of care provided. The use of SQLite for database management allows
for seamless data storage and retrieval, making it both cost-effective and easy to maintain.

While the system currently provides basic functionality, it can be expanded to include more
advanced features such as automated billing, patient reminders, and integration with other
healthcare software. This scalability ensures that the system can grow along with the
healthcare provider's needs, making it a valuable tool for small to medium-sized healthcare
practices.

In conclusion, this Web Medical Management System serves as a foundation for improving
operational efficiency and patient care within the healthcare industry, offering a simple yet
effective solution to common administrative challenges. With its user-friendly interface,
secure data management, and potential for future enhancements, it offers a promising
approach to modernizing healthcare administration.

42

You might also like