Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team Hotbytes_SY_18 #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions AddRecord.java
Original file line number Diff line number Diff line change
@@ -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<Patient> medicalRecords;
private JTextField nameField, idField, diagnosisField, passwordField, dateField;
private JButton submitButton;

public AddRecord(ArrayList<Patient> 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();
}
}
143 changes: 143 additions & 0 deletions AddReport.java
Original file line number Diff line number Diff line change
@@ -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<Patient> medicalRecords;

public AddReport(ArrayList<Patient> 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.");
}
}

88 changes: 88 additions & 0 deletions Adddate.java
Original file line number Diff line number Diff line change
@@ -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();

}

}
Loading