fire emergency

This commit is contained in:
lds217 committed 2025-01-25 20:29:35 -05:00
1 parent 8d9b3ed69a
commit a6292aefb3
4 files changed
+70 -11

No files matched your search

@@ -42,6 +42,7 @@ public class AddDialog extends JDialog {
void getRecentPatientHandler(GetRecentPatientResponse response) {
log.info("Received GetRecentPatientResponse");
patientData = response.getPatientData();
patientTableModel.setDataVector(patientData, patientColumns);
}
@@ -49,7 +50,7 @@ public class AddDialog extends JDialog {
super(parent, "Add Patient", true);
// Set size of the dialog
setSize(1000, 600);
setSize(1000, 400);
setResizable(true);
// Send request to get the latest 20 patients in the database
@@ -3,6 +3,7 @@ package BsK.client.ui.component.CheckUpPage;
import BsK.client.LocalStorage;
import BsK.client.network.handler.ClientHandler;
import BsK.client.network.handler.ResponseListener;
import BsK.client.ui.component.CheckUpPage.AddDialog.AddDialog;
import BsK.client.ui.component.CheckUpPage.MedicineDialog.MedicineDialog;
import BsK.client.ui.component.CheckUpPage.PrintDialog.MedicineInvoice;
import BsK.client.ui.component.CheckUpPage.ServiceDialog.ServiceDialog;
@@ -54,8 +55,11 @@ public class CheckUpPage extends JPanel {
private String[] doctorOptions;
private MedicineDialog medDialog = null;
private ServiceDialog serDialog = null;
private AddDialog addDialog = null;
private int previousSelectedRow = -1;
private boolean saved = false;
boolean returnCell = false;
public void updateQueue() {
ClientHandler.addResponseListener(GetCheckUpQueueResponse.class, checkUpQueueListener);
@@ -207,6 +211,7 @@ public class CheckUpPage extends JPanel {
RoundedPanel rightTopPanel = new RoundedPanel(20, Color.WHITE, false);
RoundedPanel rightBottomPanel = new RoundedPanel(20, Color.WHITE, false);
JPanel topPanel = new JPanel(new BorderLayout());
JLabel titleText1 = new JLabel();
titleText1.setText("Check Up Queue 1");
@@ -215,10 +220,28 @@ public class CheckUpPage extends JPanel {
titleText1.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Padding
JButton rightButton = new JButton(" ADD ");
rightButton.setBackground(new Color(63, 81, 181));
rightButton.setForeground(Color.WHITE);
rightButton.setFocusPainted(false);
rightButton.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); // Padding
rightButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
rightButton.addActionListener(e -> {
if(addDialog == null) {
addDialog = new AddDialog(mainFrame);
}
addDialog.setVisible(true);
});
topPanel.add(titleText1, BorderLayout.WEST);
topPanel.add(rightButton, BorderLayout.EAST);
leftPanel.setLayout(new BorderLayout());
leftPanel.add(titleText1, BorderLayout.NORTH);
leftPanel.add(topPanel, BorderLayout.NORTH);
leftPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 10));
rightBottomPanel.setLayout(new BorderLayout());
rightBottomPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 10));
@@ -460,7 +483,7 @@ public class CheckUpPage extends JPanel {
iconPanel.setLayout(new GridLayout(1, 5));
iconPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Padding
iconPanel.setBackground(Color.WHITE);
String[] iconName = {"add", "save", "service", "medicine", "printer"};
String[] iconName = {"save", "service", "medicine", "printer"};
for (String name : iconName) {
ImageIcon originalIcon = new ImageIcon("src/main/java/BsK/client/ui/assets/icon/" + name + ".png");
Image scaledImage = originalIcon.getImage().getScaledInstance(32, 32, Image.SCALE_SMOOTH); // Resize to 32x32
@@ -472,10 +495,6 @@ public class CheckUpPage extends JPanel {
@Override
public void mouseClicked(MouseEvent e) {
switch (name) {
case "add":
// Add action
JOptionPane.showMessageDialog(null, "Add action triggered");
break;
case "service":
// If there is no user selected, show a warning message
if (checkupIdField.getText().isEmpty()) {
@@ -680,8 +699,6 @@ public class CheckUpPage extends JPanel {
customerWeightSpinner.setValue(Double.parseDouble(customerWeight));
customerHeightSpinner.setValue(Double.parseDouble(customerHeight));
NetworkUtil.sendPacket(ClientHandler.ctx.channel(), new GetCustomerHistoryRequest(Integer.parseInt(queue[selectedRow][9])));
}
@@ -0,0 +1,39 @@
package BsK.common.util.date;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
public class DateUtils {
/**
* Extracts the year from a given timestamp string in milliseconds.
*
* @param timestampStr the timestamp as a string (e.g., "1085875200000")
* @return the year as an integer, or -1 if the input is invalid
*/
public static int extractYearFromTimestamp(String timestampStr) {
try {
// Parse the string to a long value
long timestamp = Long.parseLong(timestampStr);
// Convert the timestamp to a LocalDateTime
LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
return dateTime.getYear(); // Return the year
} catch (NumberFormatException e) {
// Handle invalid input
System.err.println("Invalid timestamp: " + timestampStr);
return -1; // Return -1 to indicate an error
}
}
public static void main(String[] args) {
// Test the method with valid and invalid input
String validTimestamp = "1085875200000";
String invalidTimestamp = "invalid";
int validYear = DateUtils.extractYearFromTimestamp(validTimestamp);
System.out.println("Year: " + validYear); // Output: Year: 2004
int invalidYear = DateUtils.extractYearFromTimestamp(invalidTimestamp);
System.out.println("Year: " + invalidYear); // Output: Year: -1
}
}
@@ -5,6 +5,7 @@ import BsK.common.packet.PacketSerializer;
import BsK.common.packet.req.*;
import BsK.common.packet.res.*;
import BsK.common.packet.res.ErrorResponse.Error;
import BsK.common.util.date.DateUtils;
import BsK.server.network.manager.SessionManager;
import BsK.server.network.util.UserUtil;
import io.netty.channel.ChannelHandlerContext;
@@ -321,12 +322,13 @@ public class ServerHandler extends SimpleChannelInboundHandler<TextWebSocketFram
String customerLastName = rs.getString("customer_last_name");
String customerFirstName = rs.getString("customer_first_name");
String customerDob = rs.getString("customer_dob");
String year = Integer.toString(DateUtils.extractYearFromTimestamp(customerDob));
String customerNumber = rs.getString("customer_number");
String customerAddress = rs.getString("customer_address");
String customerGender = rs.getString("customer_gender");
String result = String.join("|", customerId, customerLastName + customerFirstName,
customerDob, customerNumber, customerAddress, customerGender);
String result = String.join("|", customerId, customerLastName + " " + customerFirstName,
year, customerNumber, customerAddress, customerGender);
resultList.add(result);
}