Skip to content

Commit

Permalink
Merge pull request #2 from AsifShawon/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
AsifShawon authored Jul 27, 2024
2 parents 7353f52 + a5f8b89 commit 78427dc
Show file tree
Hide file tree
Showing 32 changed files with 1,790 additions and 1 deletion.
Binary file added Medi Care/doctor_list.ser
Binary file not shown.
Binary file added Medi Care/patient_data.ser
Binary file not shown.
Binary file added Medi Care/pending_doctor_list.ser
Binary file not shown.
Binary file added Medi Care/src/.DS_Store
Binary file not shown.
157 changes: 157 additions & 0 deletions Medi Care/src/AdminDashboard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.ImageIcon;

// edited

public class AdminDashboard extends JFrame {
private JFrame frame = new JFrame("Menu");

public AdminDashboard() {
getContentPane().setBackground(new Color(125, 173, 196));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation(800,200);
setBounds(100, 100, 967, 585);
getContentPane().setLayout(null);

JButton logOutBtn = new JButton("Log Out");
logOutBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new WelcomePage();
dispose();
}
});
logOutBtn.setFont(new Font("Tahoma", Font.BOLD, 15));
logOutBtn.setBounds(760, 43, 111, 37);
getContentPane().add(logOutBtn);

JPanel panel = new JPanel();
panel.setLayout(null);
panel.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
panel.setBackground(Color.WHITE);
panel.setBounds(65, 170, 166, 224);
getContentPane().add(panel);

JButton pendingDoctorListBtn = new JButton("See");
pendingDoctorListBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new pendingDocList();
dispose();
}
});
pendingDoctorListBtn.setFont(new Font("Tahoma", Font.BOLD, 12));
pendingDoctorListBtn.setBounds(36, 187, 89, 23);
panel.add(pendingDoctorListBtn);

JLabel lblList = new JLabel("List");
lblList.setHorizontalAlignment(SwingConstants.CENTER);
lblList.setFont(new Font("Tahoma", Font.BOLD, 14));
lblList.setBounds(10, 157, 146, 34);
panel.add(lblList);

JLabel lblPendingDoctors = new JLabel("Pending Doctor's");
lblPendingDoctors.setHorizontalAlignment(SwingConstants.CENTER);
lblPendingDoctors.setFont(new Font("Tahoma", Font.BOLD, 14));
lblPendingDoctors.setBounds(10, 135, 146, 34);
panel.add(lblPendingDoctors);

JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon("D:\\JAVA\\MediCare\\src\\components\\test.png"));
lblNewLabel.setBounds(20, 11, 146, 135);
panel.add(lblNewLabel);

JPanel panel_1 = new JPanel();
panel_1.setLayout(null);
panel_1.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
panel_1.setBackground(Color.WHITE);
panel_1.setBounds(279, 170, 166, 224);
getContentPane().add(panel_1);

JButton doctorListBtn = new JButton("See");
doctorListBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new DoctorList("admin@admin.com", null);
dispose();
}
});
doctorListBtn.setFont(new Font("Tahoma", Font.BOLD, 12));
doctorListBtn.setBounds(36, 190, 89, 23);
panel_1.add(doctorListBtn);

JLabel lblNewLabel_1 = new JLabel("Doctor's List");
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 18));
lblNewLabel_1.setBounds(10, 156, 146, 34);
panel_1.add(lblNewLabel_1);

JLabel lblNewLabel_1_1 = new JLabel("");
lblNewLabel_1_1.setIcon(new ImageIcon("D:\\JAVA\\MediCare\\src\\components\\to-do-list.png"));
lblNewLabel_1_1.setBounds(20, 11, 146, 144);
panel_1.add(lblNewLabel_1_1);

JPanel panel_2 = new JPanel();
panel_2.setLayout(null);
panel_2.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
panel_2.setBackground(Color.WHITE);
panel_2.setBounds(495, 170, 166, 224);
getContentPane().add(panel_2);

JLabel lblNewLabel_3 = new JLabel("Patient's List");
lblNewLabel_3.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 18));
lblNewLabel_3.setBounds(10, 155, 146, 34);
panel_2.add(lblNewLabel_3);

JButton patientListBtn = new JButton("See");
patientListBtn.setFont(new Font("Tahoma", Font.BOLD, 12));
patientListBtn.setBounds(36, 190, 89, 23);
panel_2.add(patientListBtn);

JLabel lblNewLabel_2 = new JLabel("");
lblNewLabel_2.setIcon(new ImageIcon("D:\\JAVA\\MediCare\\src\\components\\list.png"));
lblNewLabel_2.setBounds(20, 11, 146, 133);
panel_2.add(lblNewLabel_2);

JPanel panel_2_1 = new JPanel();
panel_2_1.setLayout(null);
panel_2_1.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
panel_2_1.setBackground(Color.WHITE);
panel_2_1.setBounds(707, 170, 166, 224);
getContentPane().add(panel_2_1);

JLabel lblHospitalAndAmbulance = new JLabel("Hospital and");
lblHospitalAndAmbulance.setHorizontalAlignment(SwingConstants.CENTER);
lblHospitalAndAmbulance.setFont(new Font("Tahoma", Font.BOLD, 14));
lblHospitalAndAmbulance.setBounds(10, 135, 146, 34);
panel_2_1.add(lblHospitalAndAmbulance);

JButton seeHosAmbBtn = new JButton("See");
seeHosAmbBtn.setFont(new Font("Tahoma", Font.BOLD, 12));
seeHosAmbBtn.setBounds(36, 190, 89, 23);
panel_2_1.add(seeHosAmbBtn);

JLabel lblAmbulanceInfo = new JLabel("Ambulance Info");
lblAmbulanceInfo.setHorizontalAlignment(SwingConstants.CENTER);
lblAmbulanceInfo.setFont(new Font("Tahoma", Font.BOLD, 14));
lblAmbulanceInfo.setBounds(10, 157, 146, 34);
panel_2_1.add(lblAmbulanceInfo);

JLabel lblNewLabel_4 = new JLabel("");
lblNewLabel_4.setIcon(new ImageIcon("D:\\JAVA\\MediCare\\src\\components\\ambulance.png"));
lblNewLabel_4.setBounds(20, 11, 146, 128);
panel_2_1.add(lblNewLabel_4);




setVisible(true);
}
}
81 changes: 81 additions & 0 deletions Medi Care/src/Doctor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Doctor implements Serializable {
private static final long serialVersionUID = 1L;

private String firstName;
private String lastName;
private String email;
private String password;
private String licenseNumber;
private List<String> hospitals;
private List<String> schedules;

public Doctor(String firstName, String lastName, String email, String password, String licenseNumber) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.password = password;
this.licenseNumber = licenseNumber;
this.hospitals = new ArrayList<>();
this.schedules = new ArrayList<>();
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getLicenseNumber() {
return licenseNumber;
}

public void setLicenseNumber(String licenseNumber) {
this.licenseNumber = licenseNumber;
}

public List<String> getHospitals() {
return hospitals;
}

public void setHospitals(List<String> hospitals) {
this.hospitals = hospitals;
}

public List<String> getSchedules() {
return schedules;
}

public void setSchedules(List<String> schedules) {
this.schedules = schedules;
}
}
136 changes: 136 additions & 0 deletions Medi Care/src/DoctorList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class DoctorList extends JFrame {
private List<Doctor> doctors;
private boolean isAdmin;

public DoctorList(String email, Patient patient) {
getContentPane().setBackground(new Color(125, 173, 196));
setTitle("Doctor List");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 800, 600);
getContentPane().setLayout(null);

JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (isAdmin) {
new AdminDashboard();
} else {
new patientHomePage(patient);
}
dispose();
}
});
btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 11));
btnNewButton.setBounds(595, 527, 179, 23);
getContentPane().add(btnNewButton);

// Check if the user is admin
isAdmin = email.equals("admin@admin.com");

// Load doctors from file
loadDoctors();

// Create a panel to hold all doctor panels
JPanel contentPanel = new JPanel();
contentPanel.setBackground(new Color(125, 173, 196));
contentPanel.setLayout(null);

// Add each doctor panel to the content panel
int y = 10; // Initial y position for the first panel
for (Doctor doctor : doctors) {
JPanel panel = createDoctorPanel(doctor);
panel.setBounds(10, y, 764, 114);
contentPanel.add(panel);
y += 120; // Increase y position for the next panel
}

// Add the content panel to a scroll pane
JScrollPane scrollPane = new JScrollPane(contentPanel);
scrollPane.setBounds(10, 10, 764, 500); // Adjust the bounds as needed
getContentPane().add(scrollPane);

setVisible(true);
}

private void loadDoctors() {
doctors = new ArrayList<>();
try (FileInputStream fileIn = new FileInputStream("doctor_list.ser");
ObjectInputStream in = new ObjectInputStream(fileIn)) {
doctors = (List<Doctor>) in.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}

private JPanel createDoctorPanel(Doctor doctor) {
JPanel panel = new JPanel();
panel.setBackground(Color.WHITE);
panel.setLayout(null);

JLabel lblName = new JLabel(doctor.getFirstName());
lblName.setFont(new Font("Tahoma", Font.BOLD, 25));
lblName.setBounds(10, 11, 315, 44);
panel.add(lblName);

JLabel lblMail = new JLabel(doctor.getEmail());
lblMail.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblMail.setBounds(10, 55, 279, 24);
panel.add(lblMail);

JButton btnContact = new JButton("Contact");
btnContact.setFont(new Font("Tahoma", Font.BOLD, 16));
btnContact.setBounds(563, 67, 168, 36);
btnContact.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Action to perform when the contact button is clicked
JOptionPane.showMessageDialog(DoctorList.this, "Contact: " + doctor.getEmail(), "Contact Doctor", JOptionPane.INFORMATION_MESSAGE);
}
});
panel.add(btnContact);

if (isAdmin) {
JButton btnDelete = new JButton("Delete");
btnDelete.setFont(new Font("Tahoma", Font.BOLD, 16));
btnDelete.setBounds(390, 67, 163, 36);
// Add action listener for delete button if user is admin
btnDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Action to perform when the delete button is clicked
// You can implement delete functionality here
int confirm = JOptionPane.showConfirmDialog(DoctorList.this, "Are you sure you want to delete " + doctor.getFirstName() + "?", "Confirm Deletion", JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION) {
doctors.remove(doctor);
saveDoctors();
panel.setVisible(false);
panel.getParent().revalidate();
panel.getParent().repaint();
}
}
});
panel.add(btnDelete);
}

return panel;
}

private void saveDoctors() {
try (FileOutputStream fileOut = new FileOutputStream("doctor_list.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut)) {
out.writeObject(doctors);
} catch (IOException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new DoctorList("admin@admin.com", null));
}
}
Loading

0 comments on commit 78427dc

Please sign in to comment.