From 5ce178e8e9836f4bb4c7bd22d51062947645d5e2 Mon Sep 17 00:00:00 2001 From: PragatiChandra6 <130374779+PragatiChandra6@users.noreply.github.com> Date: Sun, 30 Apr 2023 18:40:17 +0530 Subject: [PATCH] Add files via upload Team Members -Pragati Chandra -Kritika Dubey -Gauri Joshi -Akanksha Kale Domain-Healthcare Project Description- Users: Patient Hospital staff Functions: -Maintaining medical records(upload, search ,view) -Maintaining medical reports -Displaying customized health trends and tips -Booking appointment and display of appointment list -Diagnose me taking symptoms -Finding Ambulance Route -Disease Outbreak -Hospital Connectivity Data Structures and Algorithms used: -LinkedList -Dijkstra's Algorithm -Graphs -Prim's Algorithm -Decision Tree -Arrays -Priority Queue Link of Project Drive: https://drive.google.com/drive/folders/1lnhJAgWUA34AYc9vasHN_4zxcJaKExMa --- AddRecord.java | 96 ++++++++ AddReport.java | 143 +++++++++++ Adddate.java | 88 +++++++ Adddiagnosis.java | 85 +++++++ Addname.java | 84 +++++++ AmbulanceGUI.java | 261 ++++++++++++++++++++ AppointmentB.java | 54 +++++ AppointmentView.java | 51 ++++ BodyPartsGui.java | 51 ++++ Book.java | 165 +++++++++++++ DiseaseSpread.java | 392 ++++++++++++++++++++++++++++++ ENT.java | 171 ++++++++++++++ Eyes.java | 164 +++++++++++++ GraphGUI.java | 416 ++++++++++++++++++++++++++++++++ H.java | 152 ++++++++++++ HelloAppliaction.java | 126 ++++++++++ HelloController.java | 56 +++++ Hospitalgui.java | 89 +++++++ Login.java | 63 +++++ MedicalRecordSystem.java | 485 ++++++++++++++++++++++++++++++++++++++ PatientGUI.java | 136 +++++++++++ PrimsGUI.java | 274 +++++++++++++++++++++ Report1.java | 59 +++++ ReportGUI.java | 92 ++++++++ SearchRecord.java | 67 ++++++ Skin.java | 164 +++++++++++++ ViewRecord.java | 49 ++++ checkHealthtrendsGUI.java | 134 +++++++++++ 28 files changed, 4167 insertions(+) create mode 100644 AddRecord.java create mode 100644 AddReport.java create mode 100644 Adddate.java create mode 100644 Adddiagnosis.java create mode 100644 Addname.java create mode 100644 AmbulanceGUI.java create mode 100644 AppointmentB.java create mode 100644 AppointmentView.java create mode 100644 BodyPartsGui.java create mode 100644 Book.java create mode 100644 DiseaseSpread.java create mode 100644 ENT.java create mode 100644 Eyes.java create mode 100644 GraphGUI.java create mode 100644 H.java create mode 100644 HelloAppliaction.java create mode 100644 HelloController.java create mode 100644 Hospitalgui.java create mode 100644 Login.java create mode 100644 MedicalRecordSystem.java create mode 100644 PatientGUI.java create mode 100644 PrimsGUI.java create mode 100644 Report1.java create mode 100644 ReportGUI.java create mode 100644 SearchRecord.java create mode 100644 Skin.java create mode 100644 ViewRecord.java create mode 100644 checkHealthtrendsGUI.java diff --git a/AddRecord.java b/AddRecord.java new file mode 100644 index 0000000..829d230 --- /dev/null +++ b/AddRecord.java @@ -0,0 +1,96 @@ + +package com.example.demo2; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +public class AddRecord extends JFrame implements ActionListener { + + private ArrayList medicalRecords; + private JTextField nameField, idField, diagnosisField, passwordField, dateField; + private JButton submitButton; + + public AddRecord(ArrayList medicalRecords) { + this.medicalRecords = medicalRecords; + + // Initialize JFrame components + setTitle("Add Medical Record"); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setPreferredSize(new Dimension(400, 250)); + + // Initialize JTextFields + nameField = new JTextField(20); + nameField.setBounds(182, 42, 107, 19); + idField = new JTextField(20); + idField.setBounds(182, 71, 107, 19); + diagnosisField = new JTextField(20); + diagnosisField.setBounds(182, 97, 107, 19); + passwordField = new JTextField(20); + passwordField.setBounds(182, 120, 107, 19); + dateField = new JTextField(20); + dateField.setBounds(182, 149, 107, 19); + + // Initialize JButton + submitButton = new JButton("Submit"); + submitButton.setBounds(106, 182, 146, 21); + + // Add components to JFrame + JPanel panel = new JPanel(); + panel.setLayout(null); + + JLabel label = new JLabel("Patient Name:"); + label.setBounds(10, 42, 162, 16); + panel.add(label); + + panel.add(nameField); + + JLabel label_1 = new JLabel("Patient ID:"); + label_1.setBounds(10, 74, 154, 13); + panel.add(label_1); + + panel.add(idField); + + JLabel label_2 = new JLabel("Diagnosis:"); + label_2.setBounds(10, 100, 154, 13); + panel.add(label_2); + + panel.add(diagnosisField); + + JLabel label_3 = new JLabel("Password:"); + label_3.setBounds(10, 123, 154, 13); + panel.add(label_3); + + panel.add(passwordField ); + + JLabel label_4 = new JLabel("Date of Diagnosis (DD/MM/YYYY):"); + label_4.setBounds(10, 146, 154, 13); + panel.add(label_4); + + panel.add(dateField); + + panel.add(submitButton); + getContentPane().add(panel); + + // Add ActionListener to button + submitButton.addActionListener(this); + + pack(); + setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + String patientName = nameField.getText(); + int patientId = Integer.parseInt(idField.getText()); + String diagnosis = diagnosisField.getText(); + String password = passwordField.getText(); + String dateOfDiagnosis = dateField.getText(); + + Patient medicalRecord = new Patient(patientName, password,patientId, diagnosis, dateOfDiagnosis); + medicalRecords.add(medicalRecord); + JOptionPane.showMessageDialog(this, "New medical record added successfully!"); + dispose(); + } +} diff --git a/AddReport.java b/AddReport.java new file mode 100644 index 0000000..60bf5e9 --- /dev/null +++ b/AddReport.java @@ -0,0 +1,143 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; + +public class AddReport extends JFrame { + private JLabel patientIdLabel; + private JTextField patientIdField; + private JLabel dateLabel; + private JTextField dateField; + private JLabel weightLabel; + private JTextField weightField; + private JLabel heightLabel; + private JTextField heightField; + private JLabel bpHLabel; + private JTextField bpHField; + private JLabel bpLLabel; + private JTextField bpLField; + private JLabel haemoglobinLabel; + private JTextField haemoglobinField; + private JLabel cholesterolLabel; + private JTextField cholesterolField; + private JLabel sugarLabel; + private JTextField sugarField; + private JButton addButton; + + private ArrayList medicalRecords; + + public AddReport(ArrayList medicalRecords) { + this.medicalRecords = medicalRecords; + setTitle("Add Report to Patient"); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setResizable(false); + getContentPane().setLayout(null); + + patientIdLabel = new JLabel("Patient ID:"); + patientIdLabel.setBounds(20, 20, 100, 20); + getContentPane().add(patientIdLabel); + + patientIdField = new JTextField(); + patientIdField.setBounds(130, 20, 200, 20); + getContentPane().add(patientIdField); + + dateLabel = new JLabel("Date (dd/mm/yyyy):"); + dateLabel.setBounds(20, 50, 100, 20); + getContentPane().add(dateLabel); + + dateField = new JTextField(); + dateField.setBounds(130, 50, 200, 20); + getContentPane().add(dateField); + + weightLabel = new JLabel("Weight (in kg):"); + weightLabel.setBounds(20, 80, 100, 20); + getContentPane().add(weightLabel); + + weightField = new JTextField(); + weightField.setBounds(130, 80, 200, 20); + getContentPane().add(weightField); + + heightLabel = new JLabel("Height (in cm):"); + heightLabel.setBounds(20, 110, 100, 20); + getContentPane().add(heightLabel); + + heightField = new JTextField(); + heightField.setBounds(130, 110, 200, 20); + getContentPane().add(heightField); + + bpHLabel = new JLabel("High Blood Pressure:"); + bpHLabel.setBounds(20, 140, 100, 20); + getContentPane().add(bpHLabel); + + bpHField = new JTextField(); + bpHField.setBounds(130, 140, 200, 20); + getContentPane().add(bpHField); + + bpLLabel = new JLabel("Low Blood Pressure:"); + bpLLabel.setBounds(20, 170, 100, 20); + getContentPane().add(bpLLabel); + + bpLField = new JTextField(); + bpLField.setBounds(130, 170, 200, 20); + getContentPane().add(bpLField); + + haemoglobinLabel = new JLabel("Haemoglobin:"); + haemoglobinLabel.setBounds(20, 200, 100, 20); + getContentPane().add(haemoglobinLabel); + + haemoglobinField = new JTextField(); + haemoglobinField.setBounds(130, 200, 200, 20); + getContentPane().add(haemoglobinField); + + cholesterolLabel = new JLabel("Cholesterol:"); + cholesterolLabel.setBounds(20, 230, 100, 20); + getContentPane().add(cholesterolLabel); + + cholesterolField = new JTextField(); + cholesterolField.setBounds(130, 230, 200, 20); + getContentPane().add(cholesterolField); + + sugarLabel = new JLabel("Sugar:"); + sugarLabel.setBounds(20, 260, 100, 20); + getContentPane().add(sugarLabel); + + sugarField = new JTextField(); + sugarField.setBounds(130, 260, 200, 20); + getContentPane().add(sugarField); + + addButton = new JButton("Add Report"); + addButton.setBounds(130, 290, 100, 30); + addButton.addActionListener(e -> addReportToPatient()); + getContentPane().add(addButton); + + setSize(370, 370); + setVisible(true); + } + + private void addReportToPatient() { + int pid = Integer.parseInt(patientIdField.getText()); + for (Patient p : medicalRecords) { + if (p.getPatientId() == pid) { + String date = dateField.getText(); + double weight = Double.parseDouble(weightField.getText()); + double height = Double.parseDouble(heightField.getText()); + int bpH = Integer.parseInt(bpHField.getText()); + int bpL = Integer.parseInt(bpLField.getText()); + double haemoglobin = Double.parseDouble(haemoglobinField.getText()); + double cholesterol = Double.parseDouble(cholesterolField.getText()); + double sugar = Double.parseDouble(sugarField.getText()); + + Report r = new Report(date, bpH, bpL, haemoglobin, weight, height, cholesterol, sugar); + p.addReport(r); + + JOptionPane.showMessageDialog(this, "Report added successfully."); + dispose(); + return; + } + } + + JOptionPane.showMessageDialog(this, "Patient not found."); + } +} + diff --git a/Adddate.java b/Adddate.java new file mode 100644 index 0000000..b86dfae --- /dev/null +++ b/Adddate.java @@ -0,0 +1,88 @@ +package com.example.demo2; + +//package tryframe; + + + +import javax.swing.*; + +import java.awt.*; + +import java.awt.event.*; + +import static com.example.demo2.MedicalRecordSystem.patient1; + + +public class Adddate extends JFrame implements ActionListener { + + private JTextField diagnosisField; + + private JButton submitButton; + + private Patient patient; + + + + public Adddate(Patient patient) { + + this.patient = patient; + + + + // Initialize JFrame components + + setTitle("Add/Edit Diagnosis Date"); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + setPreferredSize(new Dimension(300, 100)); + + + + diagnosisField = new JTextField(20); + + submitButton = new JButton("Submit"); + + + + // Add components to JFrame + + JPanel panel = new JPanel(new FlowLayout()); + + panel.add(new JLabel("Diagnosis:")); + + panel.add(diagnosisField); + + panel.add(submitButton); + + add(panel); + + + + // Add ActionListener to button + + submitButton.addActionListener(this); + + + + pack(); + + setVisible(true); + + } + + + + @Override + + public void actionPerformed(ActionEvent e) { + + String diagnosis = diagnosisField.getText(); + + patient1.setDateOfDiagnosis(diagnosis); + + dispose(); + + } + +} \ No newline at end of file diff --git a/Adddiagnosis.java b/Adddiagnosis.java new file mode 100644 index 0000000..dc86cb8 --- /dev/null +++ b/Adddiagnosis.java @@ -0,0 +1,85 @@ +package com.example.demo2; + +import javax.swing.*; + +import java.awt.*; + +import java.awt.event.*; + +import static com.example.demo2.MedicalRecordSystem.patient1; + + +public class Adddiagnosis extends JFrame implements ActionListener { + + private JTextField diagnosisField; + + private JButton submitButton; + + private Patient patient; + + + + public Adddiagnosis(Patient patient) { + + this.patient = patient; + + + + // Initialize JFrame components + + setTitle("Add/Edit Diagnosis"); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + setPreferredSize(new Dimension(300, 100)); + + + + diagnosisField = new JTextField(20); + + submitButton = new JButton("Submit"); + + + + // Add components to JFrame + + JPanel panel = new JPanel(new FlowLayout()); + + panel.add(new JLabel("Diagnosis:")); + + panel.add(diagnosisField); + + panel.add(submitButton); + + add(panel); + + + + // Add ActionListener to button + + submitButton.addActionListener(this); + + + + pack(); + + setVisible(true); + + } + + + + @Override + + public void actionPerformed(ActionEvent e) { + + String diagnosis = diagnosisField.getText(); + + patient1.setDiagnosis(diagnosis); + + dispose(); + + } + +} + diff --git a/Addname.java b/Addname.java new file mode 100644 index 0000000..c55387b --- /dev/null +++ b/Addname.java @@ -0,0 +1,84 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static com.example.demo2.MedicalRecordSystem.patient1; + +public class Addname extends JFrame implements ActionListener { + + private JTextField nameField; + + private JButton submitButton; + + private Patient patient; + + + + public Addname(Patient patient) { + + this.patient = patient; + + + + // Initialize JFrame components + + setTitle("Add/Edit Name"); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + setPreferredSize(new Dimension(300, 100)); + + + + nameField = new JTextField(20); + + submitButton = new JButton("Submit"); + + + + // Add components to JFrame + + JPanel panel = new JPanel(new FlowLayout()); + + panel.add(new JLabel("Name:")); + + panel.add(nameField); + + panel.add(submitButton); + + add(panel); + + + + // Add ActionListener to button + + submitButton.addActionListener(this); + + + + pack(); + + setVisible(true); + + } + + + + @Override + + public void actionPerformed(ActionEvent e) { + + String name = nameField.getText(); + + patient1.setPatientName(name); + + dispose(); + + } + + + +} \ No newline at end of file diff --git a/AmbulanceGUI.java b/AmbulanceGUI.java new file mode 100644 index 0000000..9e6a644 --- /dev/null +++ b/AmbulanceGUI.java @@ -0,0 +1,261 @@ +package com.example.demo2; + +//package tryframe; + +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JLabel; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; +import java.util.PriorityQueue; +import java.awt.event.ActionEvent; +import java.awt.Font; + +public class AmbulanceGUI { + private JFrame frame; + private final ButtonGroup buttonGroup = new ButtonGroup(); + private int patient; + private static final int MAX_NODES = 100; + private static final int INF = Integer.MAX_VALUE; //setting all unavailable edges to infinity + private int[] shortestdistance; + private boolean[] visited; + private List[] adjecent; + private JTextField textField; + private JTextField textField_1; + + public AmbulanceGUI(int numNodes) { + shortestdistance = new int[numNodes]; + visited = new boolean[numNodes]; + adjecent = new ArrayList[numNodes]; + + for (int i = 0; i < numNodes; i++) { + adjecent[i] = new ArrayList<>(); + } + } + + public void addEdge(int u, int v, int weight) { + adjecent[u].add(new Edge(v, weight)); + adjecent[v].add(new Edge(u, weight)); + } + + public int shortestPath(int source, int destination) { + for (int i = 0; i < shortestdistance.length; i++) { + shortestdistance[i] = INF; + } + + for (int i = 0; i < visited.length; i++) { + visited[i] = false; + } + + PriorityQueue pq = new PriorityQueue<>(); + pq.offer(new Node(source, 0)); + shortestdistance[source] = 0; + + while (pq.isEmpty()!=true) { + Node curr = pq.poll(); + int current = curr.node; + + if (visited[current]) { + continue; + } + + visited[current] = true; + + for (Edge e : adjecent[current]) { + int v = e.node; + int weight = e.weight; + + if (visited[v]!=true && shortestdistance[current] + weight < shortestdistance[v]) { + shortestdistance[v] = shortestdistance[current] + weight; + pq.offer(new Node(v, shortestdistance[v])); + } + } + } + + + + return shortestdistance[destination]; + } + + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + AmbulanceGUI window = new AmbulanceGUI(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public AmbulanceGUI() { + initialize(); + } + + private void initialize() { + frame = new JFrame(); + frame.setBounds(100, 100, 635, 458); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().setLayout(null); + + textField = new JTextField(); + textField.setFont(new Font("Times New Roman", Font.PLAIN, 16)); + textField.setBounds(49, 297, 525, 45); + frame.getContentPane().add(textField); + textField.setColumns(10); + + JRadioButton rdbtnHospital = new JRadioButton("Sunshine Hospital"); + rdbtnHospital.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + rdbtnHospital.setBounds(70, 85, 167, 23); + frame.getContentPane().add(rdbtnHospital); + buttonGroup.add(rdbtnHospital); + + JRadioButton rdbtnHospital_1 = new JRadioButton("Wellfare Hospital"); + rdbtnHospital_1.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + rdbtnHospital_1.setBounds(402, 130, 172, 23); + frame.getContentPane().add(rdbtnHospital_1); + buttonGroup.add(rdbtnHospital_1); + + JRadioButton rdbtnHospital_2 = new JRadioButton("Amity Hospital"); + rdbtnHospital_2.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + rdbtnHospital_2.setBounds(239, 173, 167, 23); + frame.getContentPane().add(rdbtnHospital_2); + buttonGroup.add(rdbtnHospital_2); + + JRadioButton rdbtnHospital_3 = new JRadioButton("Viman Nagar"); + rdbtnHospital_3.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + rdbtnHospital_3.setBounds(239, 85, 143, 23); + frame.getContentPane().add(rdbtnHospital_3); + buttonGroup.add(rdbtnHospital_3); + + JRadioButton rdbtnHospital_4 = new JRadioButton("Shivaji Nagar"); + rdbtnHospital_4.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + rdbtnHospital_4.setBounds(239, 130, 130, 23); + frame.getContentPane().add(rdbtnHospital_4); + buttonGroup.add(rdbtnHospital_4); + + JRadioButton rdbtnHospital_5 = new JRadioButton("Karve Nagar"); + rdbtnHospital_5.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + rdbtnHospital_5.setBounds(70, 130, 167, 23); + frame.getContentPane().add(rdbtnHospital_5); + buttonGroup.add(rdbtnHospital_5); + + JRadioButton rdbtnHospital_6 = new JRadioButton("Jaber Nagar"); + rdbtnHospital_6.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + rdbtnHospital_6.setBounds(402, 85, 130, 23); + frame.getContentPane().add(rdbtnHospital_6); + buttonGroup.add(rdbtnHospital_6); + + JButton btnNewButton_1 = new JButton("Closest hospital"); + btnNewButton_1.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + btnNewButton_1.setBounds(224, 243, 172, 28); + frame.getContentPane().add(btnNewButton_1); + + JLabel lblNewLabel = new JLabel("CLOSEST HOSPITAL"); + lblNewLabel.setFont(new Font("Times New Roman", Font.PLAIN, 20)); + lblNewLabel.setBounds(224, 20, 234, 23); + frame.getContentPane().add(lblNewLabel); + + textField_1 = new JTextField(); + textField_1.setFont(new Font("Times New Roman", Font.PLAIN, 16)); + textField_1.setColumns(10); + textField_1.setBounds(49, 340, 525, 45); + frame.getContentPane().add(textField_1); + btnNewButton_1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + + AmbulanceGUI graph = new AmbulanceGUI(7); + graph.addEdge(0, 1, 5); + graph.addEdge(0, 2, 10); + graph.addEdge(1, 2, 3); + graph.addEdge(1, 3, 9); + graph.addEdge(2, 4, 12); + graph.addEdge(3, 4, 4); + graph.addEdge(3, 5, 7); + graph.addEdge(4, 5, 2); + graph.addEdge(3, 6, 8); + graph.addEdge(0, 6, 14); + graph.addEdge(4, 0, 11); + if (rdbtnHospital.isSelected()) { + patient = 0; + } else if (rdbtnHospital_1.isSelected()) { + patient = 1; + } else if (rdbtnHospital_2.isSelected()) { + patient = 6; + } else if (rdbtnHospital_3.isSelected()) { + patient = 2; + } else if (rdbtnHospital_4.isSelected()) { + patient = 3; + } else if (rdbtnHospital_5.isSelected()) { + patient = 4; + } else if (rdbtnHospital_6.isSelected()) { + patient = 5; + } + + int minDist = INF; + int nearestHospital = -1; + for (int hospital : new int[] {0, 1, 6}) { + int dist = graph.shortestPath(hospital, patient); + if (dist < minDist) { + minDist = dist; + nearestHospital = hospital; + } + } + + int distToHospital = graph.shortestPath(nearestHospital, patient); + String hos=""; + if(nearestHospital==0) + { + hos="Sunshine Hospital"; + } + else if(nearestHospital==1) + { + hos="Wellfare Hospital"; + } + else if(nearestHospital==6) + { + hos="Amity Hospital"; + } + textField.setText("The nearest hospital to the patient is:-"+hos); + textField_1.setText("The distance to be travelled is:-"+distToHospital+"km"); + + } + + }); + + + } + private static class Node implements Comparable { + int node; + int distance; + + public Node(int node, int distance) { + this.node = node; + this.distance = distance; + } + + @Override + public int compareTo(Node o) { + return Integer.compare(distance, o.distance); + } + } + + private static class Edge { + int node; + int weight; + + public Edge(int node, int weight) { + this.node = node; + this.weight = weight; + } + } +} diff --git a/AppointmentB.java b/AppointmentB.java new file mode 100644 index 0000000..72fa7bf --- /dev/null +++ b/AppointmentB.java @@ -0,0 +1,54 @@ +package com.example.demo2; + +//package com.example.demo2; + +import java.util.LinkedList; +import java.util.Queue; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import java.awt.BorderLayout; + +import static com.example.demo2.MedicalRecordSystem.doctor_b; + +public class AppointmentB extends JFrame { + private JTextArea appointmentTextArea; + + public AppointmentB() { + super("Appointment Viewer"); + + // create the main panel + JPanel mainPanel = new JPanel(new BorderLayout()); + + // create the appointment text area + appointmentTextArea = new JTextArea(20, 40); + JScrollPane scrollPane = new JScrollPane(appointmentTextArea); + + // add the appointment text area to the main panel + mainPanel.add(scrollPane, BorderLayout.CENTER); + + // add the main panel to the frame + add(mainPanel); + + // set the size and visibility of the frame + setSize(500, 400); + setVisible(true); + } + + public void updateAppointmentText(String appointmentText) { + appointmentTextArea.setText(appointmentText); + } + + public static void main(String args[]) { + AppointmentView appointmentView = new AppointmentView(); + String appointmentText = doctor_b.viewappointment(new StringBuilder()); + appointmentView.updateAppointmentText(appointmentText); + } +} + + +//String doctorname; + + diff --git a/AppointmentView.java b/AppointmentView.java new file mode 100644 index 0000000..6df1a36 --- /dev/null +++ b/AppointmentView.java @@ -0,0 +1,51 @@ +package com.example.demo2; + +import java.util.LinkedList; +import java.util.Queue; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import java.awt.BorderLayout; + +import static com.example.demo2.MedicalRecordSystem.doctor_a; + +public class AppointmentView extends JFrame { + private JTextArea appointmentTextArea; + + public AppointmentView() { + super("Appointment Viewer"); + + // create the main panel + JPanel mainPanel = new JPanel(new BorderLayout()); + + // create the appointment text area + appointmentTextArea = new JTextArea(20, 40); + JScrollPane scrollPane = new JScrollPane(appointmentTextArea); + + // add the appointment text area to the main panel + mainPanel.add(scrollPane, BorderLayout.CENTER); + + // add the main panel to the frame + add(mainPanel); + + // set the size and visibility of the frame + setSize(500, 400); + setVisible(true); + } + + public void updateAppointmentText(String appointmentText) { + appointmentTextArea.setText(appointmentText); + } + + public static void main(String args[]) { + AppointmentView appointmentView = new AppointmentView(); + String appointmentText = doctor_a.viewappointment(new StringBuilder()); + appointmentView.updateAppointmentText(appointmentText); + } +} + + + //String doctorname; + diff --git a/BodyPartsGui.java b/BodyPartsGui.java new file mode 100644 index 0000000..14f7ed3 --- /dev/null +++ b/BodyPartsGui.java @@ -0,0 +1,51 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class BodyPartsGui { + public static void main(String[] args) { + JFrame frame = new JFrame("Body Parts"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(400, 200); + + JPanel panel = new JPanel(); + panel.setLayout(new GridLayout(3, 1, 10, 10)); // Set grid layout for buttons + + // Create buttons + JButton button1 = new JButton("Eyes"); + JButton button2 = new JButton("Skin"); + JButton button3 = new JButton("Ent"); + + // Add action listeners to buttons + button1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Eyes.main(new String[0]); + // Replace with desired action + } + }); + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Skin.main(new String[0]); // Replace with desired action + } + }); + button3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ENT.main(new String[0]); + } + }); + + // Add buttons to panel + panel.add(button1); + panel.add(button2); + panel.add(button3); + + // Set panel to be the content pane of the frame + frame.setContentPane(panel); + + // Show the GUI + frame.setVisible(true); + } +} diff --git a/Book.java b/Book.java new file mode 100644 index 0000000..a19b668 --- /dev/null +++ b/Book.java @@ -0,0 +1,165 @@ +package com.example.demo2; + +import java.awt.EventQueue; + + +import javax.swing.*; + +import java.awt.Font; + +import java.awt.event.ActionEvent; + +import java.awt.event.ActionListener; + + +import static com.example.demo2.MedicalRecordSystem.*; + + +public class Book { + + + + private JFrame frame; + + + + /** + + * Launch the application. + + */ + + public static void main(String[] args) { + + EventQueue.invokeLater(new Runnable() { + + public void run() { + + try { + + Book window = new Book(); + + window.frame.setVisible(true); + + } catch (Exception e) { + + e.printStackTrace(); + + } + + } + + }); + + } + + + + /** + + * Create the application. + + */ + + public Book() { + + initialize(); + + } + + + + /** + + * Initialize the contents of the frame. + + */ + + private void initialize() { + + frame = new JFrame(); + + frame.setBounds(100, 100, 645, 442); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + frame.getContentPane().setLayout(null); + + + + JLabel lblNewLabel = new JLabel("Book an Appointment"); + + lblNewLabel.setFont(new Font("Times New Roman", Font.BOLD, 22)); + + lblNewLabel.setBounds(199, 38, 286, 38); + + frame.getContentPane().add(lblNewLabel); + + + + JButton btnNewButton = new JButton("Dr Ajay Joshi"); + + btnNewButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + patient1.bookappointment(doctor_a, patient1); + + JOptionPane.showMessageDialog(null, "Appointment booked successfully with Dr Ajay Joshi"); + + } + + }); + + btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 15)); + + btnNewButton.setBounds(93, 191, 150, 63); + + frame.getContentPane().add(btnNewButton); + + + + JButton btnNewButton_1 = new JButton("Dr Meenal Kumar"); + + btnNewButton_1.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + patient1.bookappointment(doctor_b, patient1); + + JOptionPane.showMessageDialog(null, "Appointment booked successfully with Dr Meenal Kumar"); + + + } + + }); + + btnNewButton_1.setFont(new Font("Times New Roman", Font.PLAIN, 15)); + + btnNewButton_1.setBounds(355, 191, 155, 63); + + frame.getContentPane().add(btnNewButton_1); + + + + + + + + + + + + JLabel lblNewLabel_1 = new JLabel("Choose your Doctor"); + + lblNewLabel_1.setFont(new Font("Times New Roman", Font.PLAIN, 20)); + + lblNewLabel_1.setBounds(222, 106, 180, 21); + + frame.getContentPane().add(lblNewLabel_1); + + } + + + +} \ No newline at end of file diff --git a/DiseaseSpread.java b/DiseaseSpread.java new file mode 100644 index 0000000..231ba4b --- /dev/null +++ b/DiseaseSpread.java @@ -0,0 +1,392 @@ +package com.example.demo2; + +import javax.swing.*; + +import java.awt.*; + +import java.awt.event.*; + +import java.util.*; + + + +public class DiseaseSpread extends JFrame implements ActionListener { + + + + private static final long serialVersionUID = 1L; + + private JComboBox locality1, locality2; + + private JButton btnDiseaseSpread, btnNumPatients, btnHotspot, btnExit; + + private static JTextArea outputArea; + + private JPanel controlPanel; + + + + public DiseaseSpread() { + + setTitle("Disease Spread"); + + setSize(600, 400); + + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + + + controlPanel = new JPanel(new GridLayout(5, 2)); + + + + String[] localities = { "Karvenagar", "M.N.P", "Kothrud", "Aundh", "PCMC" }; + + locality1 = new JComboBox<>(localities); + + locality2 = new JComboBox<>(localities); + + controlPanel.add(new JLabel("Locality 1:")); + + controlPanel.add(locality1); + + controlPanel.add(new JLabel("Locality 2:")); + + controlPanel.add(locality2); + + + + btnDiseaseSpread = new JButton("See Disease Spread"); + + btnDiseaseSpread.addActionListener(this); + + controlPanel.add(btnDiseaseSpread); + + + + btnNumPatients = new JButton("See Number of Patients Travelling"); + + btnNumPatients.addActionListener(this); + + controlPanel.add(btnNumPatients); + + + + btnHotspot = new JButton("See the Hotspot"); + + btnHotspot.addActionListener(this); + + controlPanel.add(btnHotspot); + + + + btnExit = new JButton("Exit"); + + btnExit.addActionListener(this); + + controlPanel.add(btnExit); + + + + outputArea = new JTextArea(10, 50); + + outputArea.setEditable(false); + + JScrollPane scrollPane = new JScrollPane(outputArea); + + add(controlPanel, BorderLayout.NORTH); + + add(scrollPane, BorderLayout.CENTER); + + setVisible(true); + + } + + + + public static void main(String[] args) { + + new DiseaseSpread(); + + } + + + + @Override + + public void actionPerformed(ActionEvent e) { + + if (e.getSource() == btnDiseaseSpread) { + + outputArea.setText(""); + + outputArea.append("Disease transmission has been done as follows:\n"); + + BFS(); + + } else if (e.getSource() == btnNumPatients) { + + outputArea.setText(""); + + outputArea.append("Total patients travelling from " + + + locality1.getSelectedItem() + " to " + + + locality2.getSelectedItem() + " are " + + + diseaseoutbreak(getNode((String) locality1.getSelectedItem()), + + getNode((String) locality2.getSelectedItem())) + "\n"); + + } else if (e.getSource() == btnHotspot) { + + outputArea.setText(""); + + outputArea.append("The hotspot locality is: " + hotspot() + "\n"); + + } else if (e.getSource() == btnExit) { + + System.exit(0); + + } + + } + + + + static Node getNode(String s) { + + Node n = new Node(); + + switch (s) { + + case "Karvenagar": + + n = Graph.a; + + break; + + case "M.N.P": + + n = Graph.b; + + break; + + case "Kothrud": + + n = Graph.c; + + break; + + case "Aundh": + + n = Graph.d; + + break; + + case "PCMC": + + n = Graph.e; + + break; + + } + + return n; + + } + + + + // Breadth First Search Algorithm + + static void BFS() { + + Queue queue = new LinkedList<>(); + + queue.add(Graph.a); + + Graph.a.visited = true; + + while (!queue.isEmpty()) { + + Node element = queue.remove(); + + outputArea.append(element.name + " -> "); + + ArrayList neighbours = element.neighbours; + + for (int i = 0; i < neighbours.size(); i++) { + + Node n = neighbours.get(i); + + if (n != null && !n.visited) { + + queue.add(n); + + n.visited = true; + + } + + } + + } + + resetNodes(); + + } + + + + static int diseaseoutbreak(Node source, Node destination) { + + int patients = 0; + + Queue queue = new LinkedList<>(); + + queue.add(source); + + source.visited = true; + + while (!queue.isEmpty()) { + + Node element = queue.remove(); + + ArrayList neighbours = element.neighbours; + + for (int i = 0; i < neighbours.size(); i++) { + + Node n = neighbours.get(i); + + if (n == destination) { + + patients++; + + } + + if (n != null && !n.visited) { + + queue.add(n); + + n.visited = true; + + } + + } + + } + + resetNodes(); + + return patients; + + } + + + + static String hotspot() { + + int maxCount = 0; + + String hotspot = ""; + + for (Node node : Graph.nodes) { + + int count = 0; + + for (Node neighbour : node.neighbours) { + + if (neighbour != null) { + + count++; + + } + + } + + if (count > maxCount) { + + maxCount = count; + + hotspot = node.name; + + } + + } + + return hotspot; + + } + + + + static void resetNodes() { + + for (Node node : Graph.nodes) { + + node.visited = false; + + } + + } + +} + +class Node { + + String name; + + boolean visited; + + ArrayList neighbours; + + Node() { + + neighbours = new ArrayList<>(); + + } + +} + +class Graph { + + static Node a = new Node(); + + static Node b = new Node(); + + static Node c = new Node(); + + static Node d = new Node(); + + static Node e = new Node(); + + static ArrayList nodes; + + static { + + a.name = "Karvenagar"; + + b.name = "M.N.P"; + + c.name = "Kothrud"; + + d.name = "Aundh"; + + e.name = "PCMC"; + + + a.neighbours.addAll(Arrays.asList(b, c, d)); + + b.neighbours.addAll(Arrays.asList(a, c, d, e)); + + c.neighbours.addAll(Arrays.asList(a, b, d)); + + d.neighbours.addAll(Arrays.asList(a, b, c, e)); + + e.neighbours.addAll(Arrays.asList(b, d)); + + + nodes = new ArrayList<>(Arrays.asList(a, b, c, d, e)); + + } +} diff --git a/ENT.java b/ENT.java new file mode 100644 index 0000000..0585add --- /dev/null +++ b/ENT.java @@ -0,0 +1,171 @@ +package com.example.demo2; + +//package tryframe; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.LinkedList; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JTextField; + +public class ENT { + + private JFrame frame; + private JTextField txtDiagnoseMeeyes; + private JTextField txtDiagnoseMeeyes_1; + + private static class Node { + String symptom; + Node yes; + Node no; + + public Node(String symptom) { + this.symptom = symptom; + this.yes = null; + this.no = null; + } + } + + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + ENT window = new ENT(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public ENT() { + initialize(); + } + + private void initialize() { + frame = new JFrame(); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.setBounds(100, 100, 718, 482); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().setLayout(null); + + JCheckBox chckbxNewCheckBox = new JCheckBox("cough"); + chckbxNewCheckBox.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox.setBounds(84, 95, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox); + + JCheckBox chckbxNewCheckBox_1 = new JCheckBox("fever"); + chckbxNewCheckBox_1.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_1.setBounds(274, 95, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox_1); + + JCheckBox chckbxNewCheckBox_2 = new JCheckBox("headache"); + chckbxNewCheckBox_2.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_2.setBounds(84, 166, 113, 21); + frame.getContentPane().add(chckbxNewCheckBox_2); + + JCheckBox chckbxNewCheckBox_3 = new JCheckBox("sore throat"); + chckbxNewCheckBox_3.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_3.setBounds(274, 166, 113, 21); + frame.getContentPane().add(chckbxNewCheckBox_3); + + JCheckBox chckbxNewCheckBox_4 = new JCheckBox("runny nose"); + chckbxNewCheckBox_4.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_4.setBounds(476, 166, 113, 21); + frame.getContentPane().add(chckbxNewCheckBox_4); + + JCheckBox chckbxNewCheckBox_5 = new JCheckBox("itchiness"); + chckbxNewCheckBox_5.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_5.setBounds(274, 237, 176, 21); + frame.getContentPane().add(chckbxNewCheckBox_5); + + JCheckBox chckbxNewCheckBox_6 = new JCheckBox("joint pain"); + chckbxNewCheckBox_6.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_6.setBounds(476, 95, 138, 21); + frame.getContentPane().add(chckbxNewCheckBox_6); + + JButton btnNewButton = new JButton("Diagnose Me"); + btnNewButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + LinkedList listofSymptoms=new LinkedList(); + if(chckbxNewCheckBox.isSelected()) { + listofSymptoms.add("cough"); + } + if(chckbxNewCheckBox_1.isSelected()) { + listofSymptoms.add("fever"); + } + if(chckbxNewCheckBox_2.isSelected()) { + listofSymptoms.add("headache"); + } + if(chckbxNewCheckBox_3.isSelected()) { + listofSymptoms.add("sore throat"); + } + if(chckbxNewCheckBox_4.isSelected()) { + listofSymptoms.add("runny nose"); + } + if(chckbxNewCheckBox_5.isSelected()) { + listofSymptoms.add("itchiness"); + } + if(chckbxNewCheckBox_6.isSelected()) { + listofSymptoms.add("joint pain"); + } + + Node root = new Node("cough"); + root.yes = new Node("fever"); + root.no = new Node("headache"); + root.yes.yes = new Node("sore throat"); + root.yes.no = new Node("runny nose"); + root.no.yes = new Node("sore throat"); + root.no.no = new Node("runny nose"); + root.no.no.yes = new Node("itchiness"); + root.no.no.no = new Node("joint pain"); + root.yes.yes.yes = new Node("You may have the flu"); + root.no.yes.no = new Node("You may have a migraine"); + root.yes.yes.no = new Node("You may have a respiratory infection"); + root.yes.no.yes = new Node("You may have the common cold"); + root.yes.no.no = new Node("You may have a throat infection"); + root.no.yes.yes = new Node("You may have strep throat"); + root.no.no.yes.yes = new Node("You may have allergies"); + root.no.no.no.yes = new Node("You may have the flu"); + root.no.no.no.no = new Node("You may have nothing"); + root.no.no.yes.no = new Node("You may have the viral infection"); + + Node current = root; + while(current.yes != null || current.no != null) { + if(listofSymptoms.contains(current.symptom)) { + current = current.yes; + } else { + current = current.no; + } + } + txtDiagnoseMeeyes.setText(current.symptom); + } + }); + btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + btnNewButton.setBounds(264, 305, 169, 42); + frame.getContentPane().add(btnNewButton); + + txtDiagnoseMeeyes = new JTextField(""); + txtDiagnoseMeeyes.setEditable(false); + txtDiagnoseMeeyes.setFont(new Font("Times New Roman", Font.BOLD, 18)); + txtDiagnoseMeeyes.setBounds(49, 371, 626, 50); + frame.getContentPane().add(txtDiagnoseMeeyes); + txtDiagnoseMeeyes.setColumns(10); + + txtDiagnoseMeeyes_1 = new JTextField(); + txtDiagnoseMeeyes_1.setText(" DIAGNOSE ME-ENT"); + txtDiagnoseMeeyes_1.setFont(new Font("Times New Roman", Font.PLAIN, 24)); + txtDiagnoseMeeyes_1.setBounds(223, 31, 246, 30); + frame.getContentPane().add(txtDiagnoseMeeyes_1); + txtDiagnoseMeeyes_1.setColumns(10); + + } +} + + diff --git a/Eyes.java b/Eyes.java new file mode 100644 index 0000000..397fc51 --- /dev/null +++ b/Eyes.java @@ -0,0 +1,164 @@ +package com.example.demo2; + +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.LinkedList; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JTextField; + +public class Eyes { + + private JFrame frame; + private JTextField txtDiagnoseMeeyes; + private JTextField txtDiagnoseMeeyes_1; + + private static class Node { + String symptom; + Node yes; + Node no; + + public Node(String symptom) { + this.symptom = symptom; + this.yes = null; + this.no = null; + } + } + + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + Eyes window = new Eyes(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public Eyes() { + initialize(); + } + + private void initialize() { + frame = new JFrame(); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.setBounds(100, 100, 718, 482); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().setLayout(null); + + JCheckBox chckbxNewCheckBox = new JCheckBox("redness"); + chckbxNewCheckBox.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox.setBounds(84, 95, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox); + + JCheckBox chckbxNewCheckBox_1 = new JCheckBox("itchiness"); + chckbxNewCheckBox_1.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_1.setBounds(274, 95, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox_1); + + JCheckBox chckbxNewCheckBox_2 = new JCheckBox("pain"); + chckbxNewCheckBox_2.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_2.setBounds(84, 166, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox_2); + + JCheckBox chckbxNewCheckBox_3 = new JCheckBox("discharge"); + chckbxNewCheckBox_3.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_3.setBounds(274, 166, 113, 21); + frame.getContentPane().add(chckbxNewCheckBox_3); + + JCheckBox chckbxNewCheckBox_4 = new JCheckBox("dryness"); + chckbxNewCheckBox_4.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_4.setBounds(476, 166, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox_4); + + JCheckBox chckbxNewCheckBox_5 = new JCheckBox("sensitivity to light"); + chckbxNewCheckBox_5.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_5.setBounds(274, 237, 176, 21); + frame.getContentPane().add(chckbxNewCheckBox_5); + + JCheckBox chckbxNewCheckBox_6 = new JCheckBox("blurred vision"); + chckbxNewCheckBox_6.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_6.setBounds(476, 95, 138, 21); + frame.getContentPane().add(chckbxNewCheckBox_6); + + JButton btnNewButton = new JButton("Diagnose Me"); + btnNewButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + LinkedList listofSymptoms=new LinkedList(); + if(chckbxNewCheckBox.isSelected()) { + listofSymptoms.add("redness"); + } + if(chckbxNewCheckBox_1.isSelected()) { + listofSymptoms.add("itchiness"); + } + if(chckbxNewCheckBox_2.isSelected()) { + listofSymptoms.add("pain"); + } + if(chckbxNewCheckBox_3.isSelected()) { + listofSymptoms.add("discharge"); + } + if(chckbxNewCheckBox_4.isSelected()) { + listofSymptoms.add("dryness"); + } + if(chckbxNewCheckBox_5.isSelected()) { + listofSymptoms.add("sensitivity to light"); + } + if(chckbxNewCheckBox_6.isSelected()) { + listofSymptoms.add("blurred vision"); + } + + Node root = new Node("redness"); + root.yes = new Node("pain"); + root.no = new Node("itchiness"); + root.yes.yes = new Node("blurred vision"); + root.yes.no = new Node("sensitivity to light"); + root.no.yes = new Node("discharge"); + root.no.no = new Node("dryness"); + root.yes.yes.yes=new Node("You may have uveitis"); + root.yes.yes.no=new Node("You may have glaucoma"); + root.yes.no.yes=new Node("You may have retinal detachment"); + root.yes.no.no=new Node("You may have vitreous detachment"); + root.no.yes.yes=new Node("You may have conjunctivitis"); + root.no.yes.no=new Node("You may have keratitis"); + root.no.no.yes=new Node("You may have allergic conjunctivitis"); + root.no.no.no=new Node("You may have nothing"); + root.no.no.yes.yes=new Node("You may have pink eye"); + + Node current = root; + while(current.yes != null || current.no != null) { + if(listofSymptoms.contains(current.symptom)) { + current = current.yes; + } else { + current = current.no; + } + } + txtDiagnoseMeeyes.setText(current.symptom); + } + }); + btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + btnNewButton.setBounds(264, 305, 169, 42); + frame.getContentPane().add(btnNewButton); + + txtDiagnoseMeeyes = new JTextField(""); + txtDiagnoseMeeyes.setEditable(false); + txtDiagnoseMeeyes.setFont(new Font("Times New Roman", Font.BOLD, 18)); + txtDiagnoseMeeyes.setBounds(49, 371, 626, 50); + frame.getContentPane().add(txtDiagnoseMeeyes); + txtDiagnoseMeeyes.setColumns(10); + + txtDiagnoseMeeyes_1 = new JTextField(); + txtDiagnoseMeeyes_1.setText(" DIAGNOSE ME-EYES"); + txtDiagnoseMeeyes_1.setFont(new Font("Times New Roman", Font.PLAIN, 24)); + txtDiagnoseMeeyes_1.setBounds(223, 31, 246, 30); + frame.getContentPane().add(txtDiagnoseMeeyes_1); + txtDiagnoseMeeyes_1.setColumns(10); + } +} diff --git a/GraphGUI.java b/GraphGUI.java new file mode 100644 index 0000000..88b43ba --- /dev/null +++ b/GraphGUI.java @@ -0,0 +1,416 @@ +package com.example.demo2; + +import javafx.application.Application; +import javafx.application.Platform; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; +import javafx.stage.Stage; +import javafx.scene.control.Label; +import javafx.scene.layout.Pane; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.Scanner; + +import static java.lang.Integer.valueOf; + +//import javafx.util.Pair; + +import java.util.ArrayList; +import java.util.LinkedList; + +public class GraphGUI { + + private static ArrayList>> adj; + private static Node a = new Node("Karvenagar", 1); + private static Node b = new Node("M.N.P", 2); + private static Node c = new Node("Kothrud", 3); + private static Node d = new Node("Aundh", 4); + private static Node e = new Node("PCMC", 5); + static StringBuilder sb = new StringBuilder(); + + + static class Node { + String s; + int p; + + public Node(String s, int p) { + this.s = s; + this.p = p; + } + + public Node() { + + } + } + + + public static void main(String args[]) { + // Creating a graph with 5 vertices + //Platform.startup(); + int V = 6; + adj = new ArrayList<>(V); + + for (int i = 0; i < V; i++) adj.add(new ArrayList<>()); + + // Adding edges one by one + addEdge(adj, a, b, 5); + addEdge(adj, a, c, 4); + addEdge(adj, b, c, 3); + addEdge(adj, b, d, 5); + addEdge(adj, c, d, 6); + addEdge(adj, a, e, 8); + addEdge(adj, b, e, 8); + addEdge(adj, c, e, 7); + addEdge(adj, d, e, 3); + Pane root = new Pane(); + root.setPrefSize(600, 400); + + // Creating nodes and edges + + + // Create a GridPane for the GUI layout + GridPane gridPane = new GridPane(); + gridPane.setPadding(new Insets(10, 10, 10, 10)); + gridPane.setVgap(10); + gridPane.setHgap(10); + + // Add a label for the disease spread + Label diseaseLabel = new Label("Disease Trend:"); + gridPane.add(diseaseLabel, 0, 0); + + // Add a text area to display the disease spread + TextArea diseaseTextArea = new TextArea(); + diseaseTextArea.setEditable(false); + diseaseTextArea.setPrefSize(400, 200); + gridPane.add(diseaseTextArea, 0, 1, 2, 1); + + // Add a button to show the disease spread + Button diseaseButton = new Button("Show Disease Spread"); + Button patientsButton = new Button("Enter locality name"); + diseaseButton.setOnAction(event -> { + + //sb.append("The disease transmission has been done as follows:\n"); + BFS(adj, V, sb); + diseaseTextArea.setText(sb.toString()); + }); + gridPane.add(diseaseButton, 0, 2); + + + TextArea patientsTextArea = new TextArea(); + patientsTextArea.setEditable(false); + patientsTextArea.setPrefSize(400, 200); + gridPane.add(patientsTextArea, 0, 4, 2, 1); + // Add a button to show the number of patients + + TextField localityTextField = new TextField(); + + patientsButton.setOnAction(event -> + { + StringBuilder bc = new StringBuilder(); + String input = localityTextField.getText().trim(); + if (input.equalsIgnoreCase("Karvenagar")) { + + //int locality = Integer.parseInt(input); + // int patients = diseaseoutbreak(adj, V, locality); + diseaseoutbreak(a, adj, bc); + patientsTextArea.setText(bc.toString()); + //patientsTextArea.setText("The number of patients travelling from Locality " + locality + " is " + patients + "."); + } else if (input.equalsIgnoreCase("MNP")) { + diseaseoutbreak(b, adj, bc); + patientsTextArea.setText(bc.toString()); + + } else if (input.equalsIgnoreCase("Kothrud")) { + diseaseoutbreak(c, adj, bc); + patientsTextArea.setText(bc.toString()); + } else if (input.equalsIgnoreCase("Aundh")) { + diseaseoutbreak(d, adj, bc); + patientsTextArea.setText(bc.toString()); + } else if (input.equalsIgnoreCase("PCMC")) { + diseaseoutbreak(e, adj, bc); + patientsTextArea.setText(bc.toString()); + + } else { + patientsTextArea.setText("Please enter a valid locality name."); + } + }); + // Add a text area to display the number of patients travelling + + + gridPane.add(patientsButton, 0, 3); + gridPane.add(localityTextField, 1, 3); + + Stage stage = new Stage(); + // Create a new Scene with the GridPane as the root node + Scene scene = new Scene(gridPane); + + // Set the scene to the stage + stage.setScene(scene); + + // Set the title of the window + stage.setTitle("Graph GUI"); + + // Show the stage + stage.show(); + } + + // Function to add an edge to the graph + private static void addEdge(ArrayList>> adj, Node u, Node v, int weight) { + adj.get(u.p).add(new Pair1<>(v, weight)); + adj.get(v.p).add(new Pair1<>(u, weight)); + } + + // Function to perform BFS traversal of the graph + // private static void BFS(ArrayList>> adj, int V, StringBuilder sb) { + static void BFS(ArrayList>> adj, int V, StringBuilder sb) { + + boolean visited[] = new boolean[V + 1]; + + // Mark all vertices not-visited initially + for (int i = 0; i <= V; i++) + visited[i] = false; + + LinkedList queue = new LinkedList(); + + // The start vertex or source vertex is 1 + Node s = new Node("Karvenagar", 1); + + + visited[s.p] = true; + queue.add(s); + sb.append("\nThe disease transmission has been done as follows:"); + while (queue.size() != 0) { + + s = queue.poll(); + + + sb.append("\n " + s.s); + sb.append("\n | "); + + + for (int i = 0; i < adj.get(s.p).size(); i++) { + + + Node newNode = adj.get(s.p).get(i).getKey(); + + // Check if it is not visited + if (visited[newNode.p] == false) { + // Mark it visited + visited[newNode.p] = true; + + // Add it to queue + queue.add(newNode); + } + } + } + } + + + static int diseaseoutbreak(Node r, ArrayList>> adj, StringBuilder sb) { + int c = 0; + for (int j = 0; j < adj.get(r.p).size(); j++) { + c = c + adj.get(r.p).get(j).getValue(); + sb.append("\n Patients travelling between " + r.s + " and " + adj.get(r.p).get(j).getKey().s + " are " + adj.get(r.p).get(j).getValue()); + + } + sb.append("\nTotal patients travelling from " + r.s + " are " + c); + return c; + } + + int hotspot() { + int arr[] = new int[5]; + int q = diseaseoutbreak(a, adj, sb); + int w = diseaseoutbreak(b, adj, sb); + int o = diseaseoutbreak(c, adj, sb); + int r = diseaseoutbreak(d, adj, sb); + int t = diseaseoutbreak(e, adj, sb); + + int max = arr[0]; // Assume first element is the maximum + for (int i = 1; i < arr.length; i++) { + if (arr[i] > max) { // If a larger element is found, update max + max = arr[i]; + } + } + return max; // Return the maximum element + + } + + + // Pair class to store the node and the edge weight + static class Pair1 { + private final K key; + private final V value; + + public Pair1(K key, V value) { + this.key = key; + this.value = value; + } + + public K getKey() { + return key; + } + + public V getValue() { + return value; + } + } + + +} + + + /*let a,b,c,d be then localitites and 1,2,3,4,5 be their numbers*/ + +/* + class Graph { + static Node a = new Node("Karvenagar", 1); + static Node b = new Node("M.N.P", 2); + static Node c = new Node("Kothrud", 3); + static Node d = new Node("Aundh", 4); + static Node e = new Node("PCMC", 5); + // A utility function to add an edge in an + + // undirected graph + static class Node { + String s; + int p; + + + public Node(String s, int p) { + this.s = s; + this.p = p; + + } + + public Node() { + + } + + + } + + + static void addEdge(ArrayList>> adj, + Node a, Node b, int weight) { + + adj.get(a.p).add(new Pair<>(b, valueOf(weight))); + + adj.get(b.p).add(new Pair<>(a, valueOf(weight))); + + } + + // A utility function to print the adjacency list + // representation of graph + static void + printGraph(ArrayList>> adj) { + for (int i = 1; i < adj.size(); i++) { + System.out.println("\nconnectivity list of locality number " + i); + System.out.print("head "); + for (int j = 0; j < adj.get(i).size(); j++) { + System.out.print(" -> " + "---" + adj.get(i).get(j).getValue() + "----" + + adj.get(i).get(j).getKey().s); + } + System.out.println(); + } + } + + static void BFS(ArrayList>> adj, int V) { + + boolean visited[] = new boolean[V + 1]; + + // Mark all vertices not-visited initially + for (int i = 0; i <= V; i++) + visited[i] = false; + + LinkedList queue = new LinkedList(); + + // The start vertex or source vertex is 1 + Node s = new Node("Karvenagar", 1); + + + visited[s.p] = true; + queue.add(s); + System.out.println("The disease transmission has been done as follows:"); + while (queue.size() != 0) { + + s = queue.poll(); + + + System.out.println(" " + s.s); + System.out.println(" | "); + + + for (int i = 0; i < adj.get(s.p).size(); i++) { + + + Node newNode = adj.get(s.p).get(i).getKey(); + + // Check if it is not visited + if (visited[newNode.p] == false) { + // Mark it visited + visited[newNode.p] = true; + + // Add it to queue + queue.add(newNode); + } + } + } + } + + static int diseaseoutbreak(Node r, ArrayList>> adj) { + int c = 0; + for (int j = 0; j < adj.get(r.p).size(); j++) { + c = c + adj.get(r.p).get(j).getValue(); + System.out.println(" Patients travelling between " + r.s + " and " + adj.get(r.p).get(j).getKey().s + " are " + adj.get(r.p).get(j).getValue()); + + } + System.out.println("Total patients travelling from " + r.s + " are " + c); + return c; + } + + static int comparison(int[] k) { + int temp = 0; + for (int i = 0; i < k.length; i++) { + temp = k[i]; + for (int j = i + 1; j < k.length; j++) { + if (k[i] <= k[j]) { + temp = k[j]; + + } + } + + } + return temp; + } + + + // Driver Code + public static void main(String[] args) { + // Creating a graph with 5 vertices + int V = 6; + int h; + ArrayList>> adj + = new ArrayList>>(V); + + for (int i = 0; i < V; i++) adj.add(new ArrayList<>()); + + + // Adding edges one by one + addEdge(adj, a, b, 5); + addEdge(adj, a, c, 4); + addEdge(adj, b, c, 3); + addEdge(adj, b, d, 5); + addEdge(adj, c, d, 6); + addEdge(adj, a, e, 8); + addEdge(adj, b, e, 8); + addEdge(adj, c, e, 7); + addEdge(adj, d, e, 3); + } + } +} +*/ diff --git a/H.java b/H.java new file mode 100644 index 0000000..b0ff1d9 --- /dev/null +++ b/H.java @@ -0,0 +1,152 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static com.example.demo2.Hospital.medicalRecords; +import static com.example.demo2.MedicalRecordSystem.doctor_a; +import static com.example.demo2.MedicalRecordSystem.doctor_b; + +public class H extends JFrame implements ActionListener { + + private JLabel titleLabel; + private JButton addRecordButton; + private JButton searchRecordButton; + private JButton viewAllRecordsButton; + private JButton addReportButton; + private JButton doctorAppointmentsButton; + private JButton logoutButton; + private JPanel mainPanel; + private JPanel buttonPanel; + private JPanel doctorPanel; + private JLabel doctorLabel; + private JButton doctor1Button; + private JButton doctor2Button; + + private Hospital hospital; + private Doctor doctorA; + private Doctor doctorB; + + public H() { + super("Hospital Staff"); + setSize(500, 300); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + hospital = new Hospital(); + doctorA = new Doctor("Dr. Ajay Joshi"); + doctorB = new Doctor("Dr. Meenal Kumar"); + + titleLabel = new JLabel("Please select an option:"); + titleLabel.setFont(new Font("Arial", Font.BOLD, 16)); + + addRecordButton = new JButton("Add a new medical record"); + addRecordButton.addActionListener(this); + + searchRecordButton = new JButton("Search for a medical record"); + searchRecordButton.addActionListener(this); + + viewAllRecordsButton = new JButton("View all medical records"); + viewAllRecordsButton.addActionListener(this); + + addReportButton = new JButton("Add report to patient"); + addReportButton.addActionListener(this); + + doctorAppointmentsButton = new JButton("(For doctors) See your appointments for today"); + doctorAppointmentsButton.addActionListener(this); + + logoutButton = new JButton("Hospital Staff Logout"); + logoutButton.addActionListener(this); + + buttonPanel = new JPanel(); + buttonPanel.setLayout(new GridLayout(3, 2)); + buttonPanel.add(addRecordButton); + buttonPanel.add(searchRecordButton); + buttonPanel.add(viewAllRecordsButton); + buttonPanel.add(addReportButton); + buttonPanel.add(doctorAppointmentsButton); + buttonPanel.add(logoutButton); + + doctorLabel = new JLabel("Welcome Doctor, What is your name?"); + doctorLabel.setFont(new Font("Arial", Font.BOLD, 16)); + + doctor1Button = new JButton("Dr. Ajay Joshi"); + doctor1Button.addActionListener(this); + + doctor2Button = new JButton("Dr. Meenal Kumar"); + doctor2Button.addActionListener(this); + + doctorPanel = new JPanel(); + doctorPanel.setLayout(new GridLayout(3, 1)); + doctorPanel.add(doctorLabel); + doctorPanel.add(doctor1Button); + doctorPanel.add(doctor2Button); + doctorPanel.setVisible(false); + + mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout()); + mainPanel.add(titleLabel, BorderLayout.NORTH); + mainPanel.add(buttonPanel, BorderLayout.CENTER); + mainPanel.add(doctorPanel, BorderLayout.SOUTH); + + add(mainPanel); + setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == addRecordButton) { + AddRecord f = new AddRecord(medicalRecords ); + } else if (e.getSource() == searchRecordButton) { + SearchRecord s = new SearchRecord(medicalRecords); + } else if (e.getSource() == viewAllRecordsButton) { + ViewRecord v= new ViewRecord(medicalRecords); + } else if (e.getSource() == addReportButton) { + AddReport g = new AddReport(medicalRecords); + } else if (e.getSource() == doctorAppointmentsButton) { + buttonPanel.setVisible(false); + doctorPanel.setVisible(true); + } else if (e.getSource() == doctor1Button) { + boolean m = true; + while (m) { + int x = JOptionPane.showOptionDialog(null,"Please select an option:", "Dr. Ajay Joshi", + JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, + null, new String[]{"See today's appointments", "Deque appointment queue and Go Back"}, null); + if (x == 0) { + AppointmentView.main(new String[0]); + } else if(x==1) { + JOptionPane.showMessageDialog(null,"dequed appointment successfully!"); + doctor_a.dequeAppointment(doctor_a); + doctorPanel.setVisible(false); + buttonPanel.setVisible(true); + m = false; + } + } + } else if (e.getSource() == doctor2Button) { + boolean m = true; + while (m) { + int x = JOptionPane.showOptionDialog(null, + "Please select an option:", "Dr. Meenal Kumar", + JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, + null, new String[]{"See today's appointments", "Deque appointment queue and Go Back"}, null); + if (x == 0) { + AppointmentB.main(new String[0]); + } else if(x==1){ + JOptionPane.showMessageDialog(null,"dequed appointment successfully!"); + doctor_b.dequeAppointment(doctor_b); + doctorPanel.setVisible(false); + buttonPanel.setVisible(true); + m = false; + } + } + } else if (e.getSource() == logoutButton) { + System.exit(0); + } + } + public static void main(String[] args) { + H frame = new H(); + } +} + +// End of code. diff --git a/HelloAppliaction.java b/HelloAppliaction.java new file mode 100644 index 0000000..40e438b --- /dev/null +++ b/HelloAppliaction.java @@ -0,0 +1,126 @@ +package com.example.demo2; + +import javafx.stage.Stage; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +class HelloApplication { + + public static void main(String[] args) { + // Set look and feel for the GUI + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { + e.printStackTrace(); + } + + JFrame frame = new JFrame("Medical GUI"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(800, 300); + final boolean[] exit = {false}; + JPanel panel = new JPanel(); + panel.setBackground(new Color(240, 240, 240)); // Set background color of the panel + panel.setLayout(new GridLayout(2, 3, 10, 10)); // Set grid layout for buttons + + // Create buttons with custom styling + JButton button1 = new JButton("
Medical Records,
Hospital,Appointment
"); + // button1.setBackground(new Color(52, 152, 219)); + button1.setForeground(Color.black); + button1.setFont(new Font("Arial", Font.PLAIN, 18)); + button1.setPreferredSize(new Dimension(200, 100)); + + + JButton button2 = new JButton("
Disease Outbreak
"); + //button2.setBackground(new Color(155, 89, 182)); + button2.setForeground(Color.black); + button2.setFont(new Font("Arial", Font.PLAIN, 18)); + button2.setPreferredSize(new Dimension(200, 100)); + + + JButton button3 = new JButton("
Hospital Connectivity
"); + // button3.setBackground(new Color(26, 188, 156)); + button3.setForeground(Color.black); + button3.setFont(new Font("Arial", Font.PLAIN, 18)); + button3.setPreferredSize(new Dimension(200, 100)); + + + JButton button4 = new JButton("
Diagnose Me
"); + // button4.setBackground(new Color(241, 196, 15)); + button4.setForeground(Color.black); + button4.setFont(new Font("Arial", Font.PLAIN, 18)); + button4.setPreferredSize(new Dimension(200, 100)); + + + JButton button5 = new JButton("
Ambulance Route
"); + // button5.setBackground(new Color(231, 76, 60)); + button5.setForeground(Color.black); + button5.setFont(new Font("Arial", Font.PLAIN, 18)); + button5.setPreferredSize(new Dimension(200, 100)); + + + JButton button6 = new JButton("Exit"); + button6.setBackground(new Color(189, 195, 199)); + button6.setFont(new Font("Arial", Font.PLAIN, 18)); + button1.setBackground(new Color(51, 153, 255)); // blue + button2.setBackground(new Color(51, 153, 255)); // blue + button3.setBackground(new Color(51, 153, 255)); // blue + button4.setBackground(new Color(51, 153, 255)); // blue + button5.setBackground(new Color(51, 153, 255)); // blue + button6.setBackground(new Color(51, 153, 255)); // blue + + + // Add action listeners to buttons + button1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + HelloController.main(new String[0]); + } + }); + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + + DiseaseSpread.main(new String[0]); + } + }); + button3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + PrimsGUI.main(new String[0]); + } + }); + button4.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + BodyPartsGui.main(new String[0]); + } + }); + button5.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + AmbulanceGUI.main(new String[0]); + } + }); + button6.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.exit(0); // Exit the program + } + }); + + // Add buttons to panel + panel.add(button1); + panel.add(button2); + panel.add(button3); + panel.add(button4); + panel.add(button5); + panel.add(button6); + + // ImageIcon imageIcon = new ImageIcon("background.jpg"); + //Image image = imageIcon.getImage().getScaledInstance(frame.getWidth(), frame.getHeight(), Image.SCALE; + // Set panel to be the content pane of the frame + frame.setContentPane(panel); + + // Show the GUI + frame.setVisible(true); + } + + + } \ No newline at end of file diff --git a/HelloController.java b/HelloController.java new file mode 100644 index 0000000..9817740 --- /dev/null +++ b/HelloController.java @@ -0,0 +1,56 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +//import com.example.demo2.HelloAppliaction; +public class HelloController { + public static void main(String[] args) { + JFrame frame = new JFrame("Home Page"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(600, 300); + + JPanel panel = new JPanel(); + panel.setLayout(new GridLayout(3, 1, 10, 10)); // Set grid layout for buttons + + // Create buttons + JButton button1 = new JButton("Patient"); + JButton button2 = new JButton("Hospital Staff"); + JButton button3 = new JButton("Exit"); + + // Add action listeners to buttons + button1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Login.main( new String[0]); + } + }); + button2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Hospitalgui.main(new String[0]); + + } + }); + button3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + HelloApplication.main(new String[0]); + + } + }); + + // Add buttons to panel + panel.add(button1); + panel.add(button2); + panel.add(button3); + + // Set panel to be the content pane of the frame + frame.setContentPane(panel); + + // Show the GUI + frame.setVisible(true); + } +} diff --git a/Hospitalgui.java b/Hospitalgui.java new file mode 100644 index 0000000..6a6bc1f --- /dev/null +++ b/Hospitalgui.java @@ -0,0 +1,89 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class Hospitalgui extends JFrame implements ActionListener { + + private Container c; + private JLabel title; + private JLabel userLabel; + private JTextField userText; + private JLabel passwordLabel; + private JPasswordField passwordText; + private JButton loginButton; + private JLabel loginStatus; + + public Hospitalgui() { + setTitle("Hospital Login"); + setBounds(300, 90, 600, 400); + setDefaultCloseOperation(EXIT_ON_CLOSE); + setResizable(false); + + c = getContentPane(); + c.setLayout(null); + + title = new JLabel("Hospital Login"); + title.setFont(new Font("Arial", Font.PLAIN, 30)); + title.setSize(300, 30); + title.setLocation(150, 30); + c.add(title); + + userLabel = new JLabel("Username"); + userLabel.setFont(new Font("Arial", Font.PLAIN, 20)); + userLabel.setSize(100, 20); + userLabel.setLocation(100, 100); + c.add(userLabel); + + userText = new JTextField(); + userText.setFont(new Font("Arial", Font.PLAIN, 15)); + userText.setSize(190, 20); + userText.setLocation(200, 100); + c.add(userText); + + passwordLabel = new JLabel("Password"); + passwordLabel.setFont(new Font("Arial", Font.PLAIN, 20)); + passwordLabel.setSize(100, 20); + passwordLabel.setLocation(100, 150); + c.add(passwordLabel); + + passwordText = new JPasswordField(); + passwordText.setFont(new Font("Arial", Font.PLAIN, 15)); + passwordText.setSize(190, 20); + passwordText.setLocation(200, 150); + c.add(passwordText); + + loginButton = new JButton("Login"); + loginButton.setFont(new Font("Arial", Font.PLAIN, 15)); + loginButton.setSize(100, 20); + loginButton.setLocation(250, 200); + loginButton.addActionListener(this); + c.add(loginButton); + + loginStatus = new JLabel(""); + loginStatus.setFont(new Font("Arial", Font.PLAIN, 15)); + loginStatus.setSize(200, 20); + loginStatus.setLocation(200, 250); + c.add(loginStatus); + + setVisible(true); + } + + public void actionPerformed(ActionEvent e) { + String user = userText.getText(); + String password = new String(passwordText.getPassword()); + + if (user.equals("Hospital1234") && password.equals("1234")) { + loginStatus.setText("Login successful"); + H.main(new String[]{}); + + } else { + loginStatus.setText("Login unsuccessful"); + } + } + + public static void main(String[] args) { + Hospitalgui frame = new Hospitalgui(); + } +} diff --git a/Login.java b/Login.java new file mode 100644 index 0000000..3ed96ec --- /dev/null +++ b/Login.java @@ -0,0 +1,63 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class Login { + public static void main(String[] args) { + // Set up the GUI + JFrame frame = new JFrame("Login"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(400, 200); + + JPanel panel = new JPanel(); + panel.setLayout(new GridLayout(3, 2, 10, 10)); + + JLabel loginLabel = new JLabel("Login:"); + JTextField loginField = new JTextField(); + + JLabel passwordLabel = new JLabel("Password:"); + JPasswordField passwordField = new JPasswordField(); + + JButton loginButton = new JButton("Login"); + JLabel errorLabel = new JLabel(""); + + // Add action listener to the login button + loginButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String login = loginField.getText(); + String password = new String(passwordField.getPassword()); + + // Compare login and password to hardcoded values + if (login.equals("Patient1234") && password.equals("1234")) { + JOptionPane.showMessageDialog(null, "Login successful."); + PatientGUI.main(new String[0]); + // MedicalRecordSystem.patientfunctions(); + //Patient1 P=new Patient1(); + //PatientGUI.create(P); + + + } else { + errorLabel.setText("Invalid login or password."); + } + } + }); + + // Add components to the panel + panel.add(loginLabel); + panel.add(loginField); + panel.add(passwordLabel); + panel.add(passwordField); + panel.add(loginButton); + panel.add(errorLabel); + + // Set panel to be the content pane of the frame + frame.setContentPane(panel); + + // Show the GUI + frame.setVisible(true); + } +} + diff --git a/MedicalRecordSystem.java b/MedicalRecordSystem.java new file mode 100644 index 0000000..4e108c8 --- /dev/null +++ b/MedicalRecordSystem.java @@ -0,0 +1,485 @@ +package com.example.demo2; + +import java.util.*; + +class Patient { + + //attributes of patient + String patientName; + String password; + private int patientId; + private String diagnosis; + private String dateOfDiagnosis; + public static ArrayList reports =new ArrayList(); + + public Patient(String patientName,String password, int patientId, String diagnosis, String dateOfDiagnosis) { + this.patientName = patientName; + this.password=password; + this.patientId = patientId; + this.diagnosis = diagnosis; + this.dateOfDiagnosis = dateOfDiagnosis; + } + + public Patient() { + + } + + public String getPatientName() { + return patientName; + } + + public int getPatientId() { + return patientId; + } + + public String getDiagnosis() { + return diagnosis; + } + + public String getDateOfDiagnosis() { + return dateOfDiagnosis; + } + + public void setPatientName(String patientName) { + this.patientName = patientName; + } + + public void setPatientId(int patientId) { + this.patientId = patientId; + } + + public void setDiagnosis(String diagnosis) { + this.diagnosis = diagnosis; + } + + public void setDateOfDiagnosis(String dateOfDiagnosis) { + this.dateOfDiagnosis = dateOfDiagnosis; + } + static void bookappointment(Doctor doctor1, Patient patient){ + MedicalRecordSystem.slot newslot=new MedicalRecordSystem.slot(patient); + doctor1.appointments.add(newslot); + } + + public String displayDetails(StringBuilder sb) { + sb.append("Patient id: "+patientId+"\nPatient name: "+patientName+"\nDiagnosis: "+diagnosis+"\nDate of diagnosis: "+dateOfDiagnosis); + viewAllReports(sb); + return sb.toString(); + } + //to add new report + public void addReport() { + Scanner sc=new Scanner(System.in); + System.out.println("Enter details of report: \n"); + System.out.println("Date(dd/mm/yyyy): "); + String date=sc.nextLine(); + System.out.println("Weight (in kg): "); + double weight=sc.nextInt(); + System.out.println("Height (in cm): "); + double height=sc.nextInt(); + System.out.println("High Blood pressure: "); + int bpH=sc.nextInt(); + System.out.println("Low Blood pressure: "); + int bpL=sc.nextInt(); + System.out.println("Haemoglobin: "); + double haemoglobin=sc.nextInt(); + System.out.println("Cholesterol: "); + double cholesterol=sc.nextInt(); + System.out.println("Sugar: "); + double sugar=sc.nextInt(); + Report r=new Report(date,bpH,bpL,haemoglobin,weight,height,cholesterol,sugar); + reports.add(r); + } + public void addReport(Report r) { + reports.add(r); + } + public StringBuilder viewAllReports(StringBuilder sb) { + for(Report r:reports) { + r.display(sb); + sb.append("\n"); + } + return sb; + } + public void checkHealthTrends() { + int bpH=0,bpL=0,bh=0,bl=0; + double haemo=0,sugar=0,weight=0,choles=0,h=0,s=0,w=0,c=0; + //to check increase or decrease in factors of report + for(int i=1;i125 || bl >85) { + System.out.println("You have high Blood Pressure. (TIP: Reduce intake of salt in your diet.)"); + } + else if(bh<115 || bl <75) { + System.out.println("You have low Blood Pressure. (TIP: You should start doing breathing excercises.)"); + } + else { + System.out.println("You have normal blood pressure. (Keeping yourself fit!)"); + } + + System.out.println("\n***HAEMOGLOBIN***"); + if(h>14) { + System.out.println("You have high Haemoglobin."); + } + else if(h<9) { + System.out.println("You have low Haemoglobin. (TIP: You should start eating more red fruits!)"); + } + else { + System.out.println("You have normal haemoglobin. (Doing great!)"); + } + if(haemo<0 ) { + System.out.println("Your haemoglobin is getting lower. (Be cautious.)"); + } + if(haemo>0 ) { + System.out.println("Your haemoglobin is getting higher. (Good!)"); + } + + System.out.println("\n***SUGAR***"); + if(s>110) { + System.out.println("You have high Sugar. (TIP: Reduce intake od sweets in your diet."); + } + else if(s<100) { + System.out.println("You have low Sugar. (TIP: Have some desserrt twice a week!)"); + } + else { + System.out.println("You have normal sugar. (Doing great!)"); + } + if(sugar<0 ) { + System.out.println("Your blood sugar level is getting lower."); + } + if(sugar>0 ) { + System.out.println("Your blood sugar level is getting higher."); + } + + System.out.println("\n***WEIGHT***"); + if(w>80) { + System.out.println("You have high weight. (TIP: Start excercising more."); + } + else if(w<50) { + System.out.println("You have low weight. (TIP: Increace intake of proteins.)"); + } + else { + System.out.println("You have normal weight. (Doing great!)"); + } + if(weight<0 ) { + System.out.println("Your weight is decreasing."); + } + if(weight>0 ) { + System.out.println("Your weight is increasing."); + } + + System.out.println("\n***CHOLESTEROL***"); + if(c>180) { + System.out.println("You have high cholesterol. (TIP: Stop eating oily foods."); + } + else { + System.out.println("You have normal cholesterol. (Doing great!)"); + } + if(choles<0 ) { + System.out.println("Your cholesterol level is decreasing."); + } + if(choles>0 ) { + System.out.println("Your cholesterol level is increasing."); + } + + } + +} + + + +class Doctor { + String doctorname; + static Queue appointments=new LinkedList<>(); + Doctor(String doctorname){ + this.doctorname=doctorname; + } + static String viewappointment(StringBuilder sb){ + int i=1; + + for (MedicalRecordSystem.slot item: appointments) { + sb.append("\nAppointment no "+i++); + sb.append("\nPatient Name: "+ MedicalRecordSystem.slot.patient.getPatientName()); + sb.append("\nPatient ID: "+ MedicalRecordSystem.slot.patient.getPatientId()); + + } +return sb.toString(); + } + void dequeAppointment(Doctor doctor){ + doctor.appointments.remove(); + } +} + + + +class Hospital { + static ArrayList medicalRecords = new ArrayList<>(); + static Scanner scanner=new Scanner(System.in); + public static void addMedicalRecord() { + System.out.println("Please enter the patient name:"); + String patientName = scanner.nextLine(); + + System.out.println("Please enter the patient ID:"); + int patientId = scanner.nextInt(); + scanner.nextLine(); // Consume newline left-over + + System.out.println("Please enter the patient's diagnosis:"); + String diagnosis = scanner.nextLine(); + + System.out.println("Please enter the patient's password:"); + String password = scanner.nextLine(); + + System.out.println("Please enter the date of diagnosis (in the format of DD/MM/YYYY):"); + String dateOfDiagnosis = scanner.nextLine(); + + Patient medicalRecord = new Patient(patientName, password,patientId, diagnosis, dateOfDiagnosis); + medicalRecords.add(medicalRecord); + System.out.println("New medical record added successfully!"); + } + + + + + public static void addReportToPatient() { + System.out.println("Enter patient id: "); + int pid=scanner.nextInt(); + for(Patient p: medicalRecords) { + if(p.getPatientId()==pid) { + p.addReport(); + } + } + } + + +} + + +class Report{ + + //attributes of report + private String date; + private int bpH; //high bp + private int bpL; //low bp + private double haemoglobin; + private double weight; + private double height; + private double cholesterol; + private double sugar; + + public Report(String date,int bpH, int bpL, double haemoglobin, double weight, double height, double cholesterol, + double sugar) { + super(); + this.date=date; + this.bpH = bpH; + this.bpL = bpL; + this.haemoglobin = haemoglobin; + this.weight = weight; + this.height = height; + this.cholesterol = cholesterol; + this.sugar = sugar; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public int getBpH() { + return bpH; + } + public void setBpH(int bpH) { + this.bpH = bpH; + } + public int getBpL() { + return bpL; + } + public void setBpL(int bpL) { + this.bpL = bpL; + } + public double getHaemoglobin() { + return haemoglobin; + } + public void setHaemoglobin(double haemoglobin) { + this.haemoglobin = haemoglobin; + } + public double getWeight() { + return weight; + } + public void setWeight(double weight) { + this.weight = weight; + } + public double getHeight() { + return height; + } + public void setHeight(double height) { + this.height = height; + } + public double getCholesterol() { + return cholesterol; + } + public void setCholesterol(double cholesterol) { + this.cholesterol = cholesterol; + } + public double getSugar() { + return sugar; + } + public void setSugar(double sugar) { + this.sugar = sugar; + } + public String display(StringBuilder sb) { + sb.append("Date: "+date+"\nWeight: "+weight+" kg\nHeight: "+height+" cm\nBlood pressure: "+bpH+"-"+bpL+"\nHaemoglobin: "+haemoglobin+"\nCholesterol: "+cholesterol+"\nSugar: "+sugar); + return sb.toString(); + } +} + + + + +class MedicalRecordSystem { + static class slot { + static Patient patient; + + slot(Patient patient) { + this.patient = patient; + } + + } + + + /* System has arraylist of Patients + * each patient has name,id,disease to be diagnosed, date of diagnosis and + * an arraylist storing all the reports of that patient. + */ + /* Username, password + Patient1234,1234 + * Hospital1234, Hospital1234 + * "Patient1234","1234" + "Patient5678", "5678" + "Patient9101", "9101" + "Patient1121", "1121" + "Patient3141", "3141" + * + */ + Scanner scanner = new Scanner(System.in); + static HashMap patientTable = new HashMap<>(); + static Hospital hospital1 = new Hospital(); + static Doctor doctor_a = new Doctor("Dr Ajay Joshi"); + static Doctor doctor_b = new Doctor("Dr Meenal Kumar"); + static Patient patient1 = new Patient("Patient1234", "1234", 1234, "Cancer", "12-12-2022"); + static Patient patient2 = new Patient("Patient5678", "5678", 5678, "Diabetes", "05-05-2023"); + static Patient patient3 = new Patient("Patient9101", "9101", 9101, "Heart Disease", "08-08-2024"); + static Patient patient4 = new Patient("Patient1121", "1121", 1121, "Arthritis", "01-01-2025"); + static Patient patient5 = new Patient("Patient3141", "3141", 3141, "Migraine", "06-06-2026"); + + static void mdr() { + + patientTable.put("1234", patient1); + patientTable.put("5678", patient2); + patientTable.put("9101", patient3); + patientTable.put("1121", patient4); + patientTable.put("3141", patient5); + + + } + + static void patientfunctions() { + Scanner scanner = new Scanner(System.in); + int choice; + do { + + System.out.println("\nPatients, Please select an option:"); + System.out.println("1. Add/Edit name"); + System.out.println("2. Add/Edit Diagnosis"); + System.out.println("3. Add/Edit diagnosis date"); + System.out.println("4. Add report"); + System.out.println("5. View all details"); + System.out.println("6. Check your health trends."); + System.out.println("7. Book an appointment"); + System.out.println("8. Patient Logout"); + + choice = scanner.nextInt(); + scanner.nextLine(); // Consume newline left-over + + switch (choice) { + case 1: + System.out.println("Enter name: "); + String n = scanner.nextLine(); + patient1.setPatientName(n); + break; + case 2: + System.out.println("Enter diagnosis: "); + String diagnosis = scanner.nextLine(); + patient1.setDiagnosis(diagnosis); + break; + case 3: + System.out.println("Enter diagnosis date: "); + String date = scanner.nextLine(); + patient1.setDateOfDiagnosis(date); + break; + case 4: + patient1.addReport(); + break; + case 5: + //patient1.displayDetails(); + break; + case 6: + patient1.checkHealthTrends(); + break; + case 7: + System.out.println("Welcome to appointment booking system!"); + System.out.println("Which doctor would you like to consult?"); + System.out.println("1. Dr Ajay Joshi"); + System.out.println("2. Dr Meenal Kumar"); + int doc_choice = scanner.nextInt(); + System.out.println("Appointment booked successfully"); + switch (doc_choice) { + case 1: + patient1.bookappointment(doctor_a, patient1); + break; + case 2: + patient1.bookappointment(doctor_b, patient1); + break; + default: + System.out.println("invalid response"); + break; + } + break; + + + case 8: + //running = false; + break; + default: + System.out.println("Invalid option, please try again."); + break; + + + } + + + } while (choice!=8); + + } + + + + } + + + + + diff --git a/PatientGUI.java b/PatientGUI.java new file mode 100644 index 0000000..09c544c --- /dev/null +++ b/PatientGUI.java @@ -0,0 +1,136 @@ +package com.example.demo2;//package tryframe; + +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JButton; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.Color; + +public class PatientGUI { + Patient P = new Patient(); + private JFrame frame; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + PatientGUI window = new PatientGUI(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public PatientGUI() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + + frame = new JFrame(); + frame.setBounds(100, 100, 620, 435); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().setLayout(null); + + JLabel lblNewLabel = new JLabel("PATIENT"); + lblNewLabel.setFont(new Font("Times New Roman", Font.PLAIN, 20)); + lblNewLabel.setBounds(229, 31, 111, 24); + frame.getContentPane().add(lblNewLabel); + + JButton btnNewButton = new JButton("Add/Edit name"); + btnNewButton.setBounds(82, 103, 137, 32); + frame.getContentPane().add(btnNewButton); + btnNewButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Addname A = new Addname(P); + } + }); + + + JButton btnNewButton_1 = new JButton("2. Add/Edit Diagnosis"); + btnNewButton_1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Adddiagnosis d = new Adddiagnosis(P); + } + }); + btnNewButton_1.setBounds(229, 103, 142, 32); + frame.getContentPane().add(btnNewButton_1); + + JButton btnNewButton_2 = new JButton("3. Add/Edit diagnosis date"); + btnNewButton_2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Adddate d = new Adddate(P); + } + }); + btnNewButton_2.setBounds(381, 103, 151, 32); + frame.getContentPane().add(btnNewButton_2); + + JButton btnNewButton_3 = new JButton("4. Add report"); + btnNewButton_3.setBounds(82, 258, 138, 32); + frame.getContentPane().add(btnNewButton_3); + btnNewButton_3.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ReportGUI.main(new String[0]); + } + }); + + + JButton btnNewButton_4 = new JButton("5. View all details"); + btnNewButton_4.setBounds(229, 258, 137, 32); + frame.getContentPane().add(btnNewButton_4); + btnNewButton_4.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Report1.main(new String[0]); + } + }); + + JButton btnNewButton_5 = new JButton("6. Check your health trends"); + btnNewButton_5.setBounds(116, 174, 161, 32); + frame.getContentPane().add(btnNewButton_5); + btnNewButton_5.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkHealthtrendsGUI.main(new String[0]); + } + }); + + JButton btnNewButton_6 = new JButton("7. Book an appointment"); + btnNewButton_6.setBounds(302, 174, 142, 32); + frame.getContentPane().add(btnNewButton_6); + btnNewButton_6.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Book.main(new String[0]); + } + }); + + JButton btnNewButton_7 = new JButton("Patient Logout"); + btnNewButton_7.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + } + }); + btnNewButton_7.setBackground(new Color(0, 0, 0)); + btnNewButton_7.setForeground(new Color(0, 0, 0)); + btnNewButton_7.setBounds(381, 258, 151, 32); + frame.getContentPane().add(btnNewButton_7); + } + + } \ No newline at end of file diff --git a/PrimsGUI.java b/PrimsGUI.java new file mode 100644 index 0000000..ade4d74 --- /dev/null +++ b/PrimsGUI.java @@ -0,0 +1,274 @@ +package com.example.demo2; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableModel; + +//package tryframe; + + + +import java.awt.Dimension; + + + +import javax.swing.JFrame; + +import javax.swing.JPanel; + +import javax.swing.JScrollPane; + +import javax.swing.JTable; + +import javax.swing.SwingUtilities; + +import javax.swing.table.DefaultTableModel; + + + +public class PrimsGUI { + + + + // Number of vertices in the graph + + static final int V = 5; + + + + // Array to store constructed MST + + static int[] parent = new int[V]; + + + + // Key values used to pick minimum weight edge in cut + + static int[] key = new int[V]; + + + + // A utility function to find the vertex with minimum key + + // value, from the set of vertices not yet included in MST + + static int minKey(int key[], Boolean mstSet[]) { + + // Initialize min value + + int min = Integer.MAX_VALUE, min_index = -1; + + + + for (int v = 0; v < V; v++) + + if (mstSet[v] == false && key[v] < min) { + + min = key[v]; + + min_index = v; + + } + + + + return min_index; + + } + + + + // Function to construct and print MST for a graph represented + + // using adjacency matrix representation + + static void primMST(int graph[][]) { + + // To represent set of vertices not yet included in MST + + Boolean mstSet[] = new Boolean[V]; + + + + // Initialize all keys as INFINITE + + for (int i = 0; i < V; i++) { + + key[i] = Integer.MAX_VALUE; + + mstSet[i] = false; + + } + + + + // Always include first 1st vertex in MST. + + key[0] = 0; // Make key 0 so that this vertex is + + // picked as first vertex + + parent[0] = -1; // First node is always root of MST + + + + // The MST will have V vertices + + for (int count = 0; count < V - 1; count++) { + + // Pick thd minimum key vertex from the set of vertices + + // not yet included in MST + + int u = minKey(key, mstSet); + + + + // Add the picked vertex to the MST Set + + mstSet[u] = true; + + + + for (int v = 0; v < V; v++) + + + + if (graph[u][v] != 0 && mstSet[v] == false && graph[u][v] < key[v]) { + + parent[v] = u; + + key[v] = graph[u][v]; + + } + + } + + } + + + + public static void main(String[] args) { + + // Create a graph with the distances between hospitals + + int[][] graph = new int[][]{{0, 2, 0, 6, 0}, {2, 0, 3, 8, 5}, {0, 3, 0, 0, 7}, {6, 8, 0, 0, 9}, + + {0, 5, 7, 9, 0}}; + + + + // Find the minimum spanning tree using Prim's algorithm + + primMST(graph); + +// Create a table with the model + + // DefaultTableModel model = null; + + + + + + // Create a scroll pane with the table + + + + // Create a table model with the headers + + DefaultTableModel model = new DefaultTableModel(new Object[][]{}, new String[]{"Hospital", "Distance", "Message"}) { + + @Override + + public Class getColumnClass(int column) { + + switch (column) { + + case 0: + + return String.class; // "Hospital" column is a String + + case 1: + + return Integer.class; // "Distance" column is an Integer + + case 2: + + return String.class; // "Message" column is a String + + default: + + return Object.class; + + } + + } + + }; + + + + for (int i = 1; i < V; i++) { + + String message = ""; + + if (graph[i][parent[i]] < 4) { + + message = "These hospitals are connected enough to share resources, recommend patients, and transfer doctors"; + + } else { + + message = "These hospitals are not close enough to share resources, recommend patients, or transfer doctors"; + + } + + + + + + model.addRow(new Object[]{"Hospital " + (parent[i] + 1) + " - Hospital " + (i + 1), + + graph[i][parent[i]], message}); + + } + + JTable table = new JTable(model); + + JScrollPane scrollPane = new JScrollPane(table); + + + + // Create a panel with the scroll pane + + JPanel panel = new JPanel(); + + panel.add(scrollPane); + + + + // Create a frame with the panel + + JFrame frame = new JFrame("Minimum Spanning Tree of Hospitals"); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + frame.getContentPane().add(panel); + + frame.setSize(new Dimension(800, frame.getHeight())); + + frame.pack(); + + frame.setVisible(true); + + + + + + + + } + +} \ No newline at end of file diff --git a/Report1.java b/Report1.java new file mode 100644 index 0000000..36de019 --- /dev/null +++ b/Report1.java @@ -0,0 +1,59 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; + +public class Report1 extends JFrame { + + ArrayList reports; + private JTextArea reportDisplay; + + public Report1(ArrayList reports) { + this.reports = reports; + + // Create the text area to display the reports + reportDisplay = new JTextArea(20, 50); + reportDisplay.setEditable(false); + + // Add the text area to a scroll pane so it can scroll if there are many reports + JScrollPane scrollPane = new JScrollPane(reportDisplay); + + // Add the scroll pane to the frame + getContentPane().add(scrollPane, BorderLayout.CENTER); + + // Set the title and size of the frame + setTitle("All Reports"); + setSize(600, 400); + + // Display all reports + displayReports(); + } + + private void displayReports() { + // Clear the text area + reportDisplay.setText(""); + + // Display each report + for (Report r : reports) { + reportDisplay.append("Date: " + r.getDate() + "\n"); + reportDisplay.append("Weight: " + r.getWeight() + " kg\n"); + reportDisplay.append("Height: " + r.getHeight() + " cm\n"); + reportDisplay.append("Blood pressure: " + r.getBpH() + "-" + r.getBpL() + "\n"); + reportDisplay.append("Haemoglobin: " + r.getHaemoglobin() + "\n"); + reportDisplay.append("Cholesterol: " + r.getCholesterol() + "\n"); + reportDisplay.append("Sugar: " + r.getSugar() + "\n\n"); + } + } + + public static void main(String[] args) { + // Create some example reports + //ArrayList reports = new ArrayList<>(); + // reports.add(new Report("01/01/2023", 120, 80, 12.5, 75.0, 180.0, 5.0, 100.0)); + // reports.add(new Report("02/01/2023", 130, 90, 13.0, 77.0, 182.0, 5.5, 105.0)); + + // Create the GUI and display it + Report1 reportGUI = new Report1(Patient.reports); + reportGUI.setVisible(true); + } +} diff --git a/ReportGUI.java b/ReportGUI.java new file mode 100644 index 0000000..471ca4c --- /dev/null +++ b/ReportGUI.java @@ -0,0 +1,92 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +public class ReportGUI extends JFrame implements ActionListener { + + private JLabel dateLabel, weightLabel, heightLabel, bpHLabel, bpLLabel, haemoLabel, cholLabel, sugarLabel; + private JTextField dateField, weightField, heightField, bpHField, bpLField, haemoField, cholField, sugarField; + private JButton addButton; + private JPanel mainPanel, inputPanel; + //private ArrayList reports = new ArrayList<>(); + + public ReportGUI() { + setTitle("Report GUI"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setSize(400, 300); + + mainPanel = new JPanel(new BorderLayout()); + inputPanel = new JPanel(new GridLayout(8, 2)); + + dateLabel = new JLabel("Date (dd/mm/yyyy): "); + weightLabel = new JLabel("Weight (in kg): "); + heightLabel = new JLabel("Height (in cm): "); + bpHLabel = new JLabel("High Blood pressure: "); + bpLLabel = new JLabel("Low Blood pressure: "); + haemoLabel = new JLabel("Haemoglobin: "); + cholLabel = new JLabel("Cholesterol: "); + sugarLabel = new JLabel("Sugar: "); + + dateField = new JTextField(); + weightField = new JTextField(); + heightField = new JTextField(); + bpHField = new JTextField(); + bpLField = new JTextField(); + haemoField = new JTextField(); + cholField = new JTextField(); + sugarField = new JTextField(); + + addButton = new JButton("Add Report"); + addButton.addActionListener(this); + + inputPanel.add(dateLabel); + inputPanel.add(dateField); + inputPanel.add(weightLabel); + inputPanel.add(weightField); + inputPanel.add(heightLabel); + inputPanel.add(heightField); + inputPanel.add(bpHLabel); + inputPanel.add(bpHField); + inputPanel.add(bpLLabel); + inputPanel.add(bpLField); + inputPanel.add(haemoLabel); + inputPanel.add(haemoField); + inputPanel.add(cholLabel); + inputPanel.add(cholField); + inputPanel.add(sugarLabel); + inputPanel.add(sugarField); + + mainPanel.add(inputPanel, BorderLayout.CENTER); + mainPanel.add(addButton, BorderLayout.SOUTH); + + add(mainPanel); + + setVisible(true); + } + + public static void main(String[] args) { + new ReportGUI(); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == addButton) { + String date = dateField.getText(); + double weight = Double.parseDouble(weightField.getText()); + double height = Double.parseDouble(heightField.getText()); + int bpH = Integer.parseInt(bpHField.getText()); + int bpL = Integer.parseInt(bpLField.getText()); + double haemo = Double.parseDouble(haemoField.getText()); + double chol = Double.parseDouble(cholField.getText()); + double sugar = Double.parseDouble(sugarField.getText()); + Report report = new Report(date, bpH, bpL, haemo, weight, height, chol, sugar); + Patient.reports.add(report); + JOptionPane.showMessageDialog(mainPanel, "Report added successfully!"); + } + } +} + diff --git a/SearchRecord.java b/SearchRecord.java new file mode 100644 index 0000000..42c42a8 --- /dev/null +++ b/SearchRecord.java @@ -0,0 +1,67 @@ +package com.example.demo2; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +import static com.example.demo2.Hospital.medicalRecords; + +public class SearchRecord extends JFrame implements ActionListener { + private JLabel patientIdLabel; + private JTextField patientIdField; + private JButton searchButton; + private JTextArea resultArea; + + + public SearchRecord(ArrayList medicalRecords) { + //this.medicalRecords = medicalRecords; + setTitle("Search Medical Record"); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + getContentPane().setLayout(new GridLayout(12, 12)); + + patientIdLabel = new JLabel("Patient ID:"); + getContentPane().add(patientIdLabel); + + patientIdField = new JTextField(); + getContentPane().add(patientIdField); + + searchButton = new JButton("Search"); + getContentPane().add(searchButton); + searchButton.addActionListener(this); + + resultArea = new JTextArea(); + resultArea.setTabSize(100); + resultArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(resultArea); + scrollPane.setPreferredSize(new Dimension(400, 600)); // set new size here + getContentPane().add(scrollPane); + + pack(); + setLocationRelativeTo(null); + setSize(400,400); + setVisible(true); + } + + public void actionPerformed(ActionEvent e) { + StringBuilder sb = new StringBuilder(); + if (e.getSource() == searchButton) { + int patientId = Integer.parseInt(patientIdField.getText()); + + boolean found = false; + for (Patient medicalRecord : medicalRecords) { + if (medicalRecord.getPatientId() == patientId) { + resultArea.setText(medicalRecord.displayDetails(sb)); + found = true; + break; + } + } + + if (!found) { + resultArea.setText("No medical record found for the given patient ID."); + } + } + } +} + diff --git a/Skin.java b/Skin.java new file mode 100644 index 0000000..1410e55 --- /dev/null +++ b/Skin.java @@ -0,0 +1,164 @@ +package com.example.demo2; + +//package tryframe; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.LinkedList; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JTextField; + +public class Skin { + + private JFrame frame; + private JTextField txtDiagnoseMeeyes; + private JTextField txtDiagnoseMeeyes_1; + + private static class Node { + String symptom; + Node yes; + Node no; + + public Node(String symptom) { + this.symptom = symptom; + this.yes = null; + this.no = null; + } + } + + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + Skin window = new Skin(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public Skin() { + initialize(); + } + + private void initialize() { + frame = new JFrame(); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.setBounds(100, 100, 718, 482); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().setLayout(null); + + JCheckBox chckbxNewCheckBox = new JCheckBox("itchiness"); + chckbxNewCheckBox.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox.setBounds(84, 95, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox); + + JCheckBox chckbxNewCheckBox_1 = new JCheckBox("rash"); + chckbxNewCheckBox_1.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_1.setBounds(274, 95, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox_1); + + JCheckBox chckbxNewCheckBox_2 = new JCheckBox("redness"); + chckbxNewCheckBox_2.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_2.setBounds(84, 166, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox_2); + + JCheckBox chckbxNewCheckBox_3 = new JCheckBox("blisters"); + chckbxNewCheckBox_3.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_3.setBounds(274, 166, 113, 21); + frame.getContentPane().add(chckbxNewCheckBox_3); + + JCheckBox chckbxNewCheckBox_4 = new JCheckBox("dryness"); + chckbxNewCheckBox_4.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_4.setBounds(476, 166, 93, 21); + frame.getContentPane().add(chckbxNewCheckBox_4); + + JCheckBox chckbxNewCheckBox_5 = new JCheckBox("pain"); + chckbxNewCheckBox_5.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_5.setBounds(274, 237, 176, 21); + frame.getContentPane().add(chckbxNewCheckBox_5); + + JCheckBox chckbxNewCheckBox_6 = new JCheckBox("flaking"); + chckbxNewCheckBox_6.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + chckbxNewCheckBox_6.setBounds(476, 95, 138, 21); + frame.getContentPane().add(chckbxNewCheckBox_6); + + JButton btnNewButton = new JButton("Diagnose Me"); + btnNewButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + LinkedList listofSymptoms=new LinkedList(); + if(chckbxNewCheckBox.isSelected()) { + listofSymptoms.add("itchiness"); + } + if(chckbxNewCheckBox_1.isSelected()) { + listofSymptoms.add("rash"); + } + if(chckbxNewCheckBox_2.isSelected()) { + listofSymptoms.add("redness"); + } + if(chckbxNewCheckBox_3.isSelected()) { + listofSymptoms.add("blisters"); + } + if(chckbxNewCheckBox_4.isSelected()) { + listofSymptoms.add("dryness"); + } + if(chckbxNewCheckBox_5.isSelected()) { + listofSymptoms.add("pain"); + } + if(chckbxNewCheckBox_6.isSelected()) { + listofSymptoms.add("flaking"); + } + + Node root = new Node("itchiness"); + root.yes = new Node("rash"); + root.no = new Node("redness"); + root.yes.yes = new Node("blisters"); + root.yes.no = new Node("dryness"); + root.no.yes = new Node("pain"); + root.no.no = new Node("flaking"); + root.yes.yes.yes = new Node("You may have chickenpox"); + root.yes.yes.no = new Node("You may have shingles"); + root.yes.no.yes = new Node("You may have eczema"); + root.yes.no.no = new Node("You may have psoriasis"); + root.no.yes.yes = new Node("You may have an infection"); + root.no.yes.no = new Node("You may have cellulitis"); + root.no.no.yes = new Node("You may have rosacea"); + root.no.no.no = new Node("You may have dry skin"); + + Node current = root; + while(current.yes != null || current.no != null) { + if(listofSymptoms.contains(current.symptom)) { + current = current.yes; + } else { + current = current.no; + } + } + txtDiagnoseMeeyes.setText(current.symptom); + } + }); + btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 18)); + btnNewButton.setBounds(264, 305, 169, 42); + frame.getContentPane().add(btnNewButton); + + txtDiagnoseMeeyes = new JTextField(""); + txtDiagnoseMeeyes.setEditable(false); + txtDiagnoseMeeyes.setFont(new Font("Times New Roman", Font.BOLD, 18)); + txtDiagnoseMeeyes.setBounds(49, 371, 626, 50); + frame.getContentPane().add(txtDiagnoseMeeyes); + txtDiagnoseMeeyes.setColumns(10); + + txtDiagnoseMeeyes_1 = new JTextField(); + txtDiagnoseMeeyes_1.setText(" DIAGNOSE ME-SKIN"); + txtDiagnoseMeeyes_1.setFont(new Font("Times New Roman", Font.PLAIN, 24)); + txtDiagnoseMeeyes_1.setBounds(223, 31, 246, 30); + frame.getContentPane().add(txtDiagnoseMeeyes_1); + txtDiagnoseMeeyes_1.setColumns(10); + } +} diff --git a/ViewRecord.java b/ViewRecord.java new file mode 100644 index 0000000..b10b35d --- /dev/null +++ b/ViewRecord.java @@ -0,0 +1,49 @@ +package com.example.demo2; +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; + +public class ViewRecord extends JFrame { + + + public ViewRecord(ArrayList medicalRecords) { + + + setTitle("View All Medical Records"); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setSize(789, 452); // Set the size of the frame to 800x600 pixels + getContentPane().setLayout(null); + + JTextArea resultArea = new JTextArea(); + resultArea.setEditable(false); + resultArea.setLineWrap(true); + resultArea.setWrapStyleWord(true); + + JScrollPane scrollPane = new JScrollPane(resultArea); + scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.setBounds(50, 50, 700, 450); // Set the size of the scroll pane to 700x450 pixels + getContentPane().add(scrollPane); + + JButton closeButton = new JButton("Close"); + closeButton.addActionListener(e -> dispose()); + closeButton.setBounds(325, 520, 150, 30); // Set the size and position of the close button + getContentPane().add(closeButton); + + StringBuilder sb = new StringBuilder(); + if (medicalRecords.isEmpty()) { + sb.append("No medical records found."); + } else { + sb.append("All medical records:\n"); + for (Patient p : medicalRecords) { + for (Report r: Patient.reports) { + sb.append(p.getPatientName()).append(":\n"); + sb.append(r.display(sb)).append("\n\n"); + } + } + } + resultArea.setText(sb.toString()); + + setVisible(true); + } +} \ No newline at end of file diff --git a/checkHealthtrendsGUI.java b/checkHealthtrendsGUI.java new file mode 100644 index 0000000..268d99e --- /dev/null +++ b/checkHealthtrendsGUI.java @@ -0,0 +1,134 @@ +package com.example.demo2; + +import java.awt.*; +import javax.swing.*; + +public class checkHealthtrendsGUI extends JFrame { + + private JTextArea outputTextArea; + + public checkHealthtrendsGUI() { + super("Health Trends"); + + // Set layout + setLayout(new BorderLayout()); + + // Create text area to display output + outputTextArea = new JTextArea(); + outputTextArea.setEditable(false); + outputTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); + + // Create scroll pane for output text area + JScrollPane scrollPane = new JScrollPane(outputTextArea); + + // Add scroll pane to center of frame + add(scrollPane, BorderLayout.CENTER); + + // Create button to check health trends + JButton checkButton = new JButton("Check Health Trends"); + + // Add action listener to button + checkButton.addActionListener(e -> { + // Call checkHealthTrends method and display results in output text area + checkHealthTrends(); + }); + + // Add button to south of frame + add(checkButton, BorderLayout.SOUTH); + + // Set frame properties + setSize(800, 600); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + } + + public void checkHealthTrends() { + + + int bpH = 0, bpL = 0, bh = 0, bl = 0; + double haemo = 0, sugar = 0, weight = 0, choles = 0, h = 0, s = 0, w = 0, c = 0; + //to check increase or decrease in factors of report + for (int i = 1; i < Patient.reports.size(); i++) { + bpH = Patient.reports.get(i).getBpH() - Patient.reports.get(i - 1).getBpH(); + bpL = bpL + Patient.reports.get(i).getBpL() - Patient.reports.get(i - 1).getBpL(); + haemo = haemo + Patient.reports.get(i).getHaemoglobin() - Patient.reports.get(i - 1).getHaemoglobin(); + sugar = sugar + Patient.reports.get(i).getSugar() - Patient.reports.get(i - 1).getSugar(); + weight = weight + Patient.reports.get(i).getWeight() - Patient.reports.get(i - 1).getWeight(); + choles = choles + Patient.reports.get(i).getCholesterol() - Patient.reports.get(i - 1).getCholesterol(); + System.out.println(Patient.reports.get(i).getBpH()); + } + for(int i=1;i 125 || bl > 85) { + outputTextArea.append("You have high Blood Pressure. \n(TIP: Reduce intake of salt in your diet.)\n"); + } else if (bh < 115 || bl < 75) { + outputTextArea.append("You have low Blood Pressure. \n(TIP: You should start doing breathing excercises.)\n"); + } else { + outputTextArea.append("You have normal blood pressure. \n(Keeping yourself fit!)\n"); + } + + outputTextArea.append("\n***HAEMOGLOBIN***\n"); + if (h > 14) { + outputTextArea.append("You have high Haemoglobin.\n"); + } else if (h < 9) { + outputTextArea.append("You have low Haemoglobin. \n(TIP: You should start eating more iron - rich foods like spinach, lentils, and red meat.\n"); + + } else { + outputTextArea.append("You have normal Haemoglobin. (Good job!)\n"); + } + outputTextArea.append("\n***BLOOD SUGAR LEVEL***\n"); + if (s > 7.8) { + outputTextArea.append("You have high Blood Sugar Level. \n(TIP: Reduce intake of sugary foods and drinks.)\n"); + } else if (s < 4) { + outputTextArea.append("You have low Blood Sugar Level. \n(TIP: Eat small, frequent meals throughout the day.)\n"); + } else { + outputTextArea.append("You have normal Blood Sugar Level. (Good job!)\n"); + } + + outputTextArea.append("\n***WEIGHT***\n"); + if (w > 75) { + outputTextArea.append("You are overweight. \n(TIP: Exercise regularly and eat a balanced diet.)\n"); + } else if (w < 55) { + outputTextArea.append("You are underweight. \n(TIP: Eat more nutrient-dense foods and consider consulting a nutritionist.)\n"); + } else { + outputTextArea.append("You have a healthy weight. (Good job!)\n"); + } + + outputTextArea.append("\n***CHOLESTEROL LEVEL***\n"); + if (c > 200) { + outputTextArea.append("You have high Cholesterol Level. \n(TIP: Reduce intake of saturated and trans fats.)\n"); + } else if (c < 180) { + outputTextArea.append("You have low Cholesterol Level. \n(TIP: Consider adding more healthy fats to your diet, such as avocados and nuts.)\n"); + } else { + outputTextArea.append("You have normal Cholesterol Level. (Good job!)\n"); + } + + // Append increase/decrease in values + outputTextArea.append("\n***INCREASE/DECREASE IN VALUES***\n"); + outputTextArea.append("Increase in BP High: " + bpH + "\n"); + outputTextArea.append("Increase in BP Low: " + bpL + "\n"); + outputTextArea.append("Increase in Haemoglobin: " + haemo + "\n"); + outputTextArea.append("Increase in Blood Sugar Level: " + sugar + "\n"); + outputTextArea.append("Increase in Weight: " + weight + "\n"); + outputTextArea.append("Increase in Cholesterol Level: " + choles + "\n"); + + } + public static void main(String[] args) { + // Create new HealthTrendsGUI object + checkHealthtrendsGUI gui = new checkHealthtrendsGUI(); + } +} +