Skip to content
Snippets Groups Projects
Commit 113c1d30 authored by wyl's avatar wyl
Browse files

Merge remote-tracking branch 'origin/main' into...

Merge remote-tracking branch 'origin/main' into 34-as-a-superadmin-i-want-to-be-able-to-see-my-username-and-permissions-on-the-page-so-that-i-can

# Conflicts:
#	src/main/resources/application-dev.yml
parents efdacdb6 e1d63fa7
No related branches found
No related tags found
1 merge request!77update system
Showing
with 1045 additions and 240 deletions
/*
Navicat Premium Data Transfer
Source Server : wyl
Source Server Type : MySQL
Source Server Version : 80031
Source Host : localhost:3306
Source Schema : health_care
Target Server Type : MySQL
Target Server Version : 80031
File Encoding : 65001
Date: 09/12/2024 10:09:27
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for common_admin
-- ----------------------------
DROP TABLE IF EXISTS `common_admin`;
CREATE TABLE `common_admin` (
`id` int NOT NULL AUTO_INCREMENT,
`email` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`roleId` int NULL DEFAULT NULL,
`phone` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`status` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of common_admin
-- ----------------------------
INSERT INTO `common_admin` VALUES (1, '26497@qq.com', '$2a$10$5UzuKUxgR8H0RzLYrP.BUu8.76yKwMD4XkvJIu/xxB7AAHWfphFQm', 'commonAdmin', 1, '111', 'justnoww', 1);
INSERT INTO `common_admin` VALUES (2, '1234@qq.com', '$2a$10$iW/zeL9TLq55SHFaOfyfr.xFMvB4aD3CL2layeAlGC7CqZ9kcscA.', 'commonAdmin', 1, '123', 'BAa', 1);
INSERT INTO `common_admin` VALUES (3, '123cmy@qq.com', '$2a$10$u2KxNBaHuTVwX7KudUgyNelp8j2lymarXKkkUXfWBMRAgbPNryTuW', 'commonAdmin', 1, '123', 'cmy', 1);
-- ----------------------------
-- Table structure for device
-- ----------------------------
DROP TABLE IF EXISTS `device`;
CREATE TABLE `device` (
`id` int NOT NULL AUTO_INCREMENT,
`hospitalId` int NULL DEFAULT NULL,
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`freeTime` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of device
-- ----------------------------
INSERT INTO `device` VALUES (1, 0, 'bed1', 'bed', '2024-12-02 09:51:12');
INSERT INTO `device` VALUES (2, 2, 'bed2', 'bed', '2024-12-03 09:30:00');
INSERT INTO `device` VALUES (3, 2, 'bed3', 'bed', '2025-12-05 10:30:35');
INSERT INTO `device` VALUES (4, 2, 'instrument1', 'instrument', '2024-12-05 07:15:59');
INSERT INTO `device` VALUES (5, 2, 'instrument5', 'instrument', '2024-12-05 10:30:00');
-- ----------------------------
-- Table structure for hospital
-- ----------------------------
DROP TABLE IF EXISTS `hospital`;
CREATE TABLE `hospital` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`amountPatient` int NULL DEFAULT NULL,
`maxAmount` int NULL DEFAULT NULL,
`type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`address` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`phone` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`status` int NULL DEFAULT NULL,
`roleId` int NULL DEFAULT NULL,
`email` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`patientId` int NULL DEFAULT NULL,
`deviceId` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of hospital
-- ----------------------------
INSERT INTO `hospital` VALUES (1, 'hospital0', 3, 100, 'hospital', 'road', '145267', 1, 3, 'agag', '$2a$10$wvAZoj4V51MH/MLhVIrnG.NrY07/.Gn9Ar6JsyzRAubWtqbWzgKie', 0, 0);
INSERT INTO `hospital` VALUES (2, 'hospital1', 5, 200, 'hospital', 'beijing', '6371', 1, 3, 'soga', '$2a$10$wvAZoj4V51MH/MLhVIrnG.NrY07/.Gn9Ar6JsyzRAubWtqbWzgKie', 0, 0);
INSERT INTO `hospital` VALUES (3, 'hospital2', 10, 50, 'hospital', 'cardiff', '123', 1, 3, 'hospital2@qq.com', '$2a$10$wvAZoj4V51MH/MLhVIrnG.NrY07/.Gn9Ar6JsyzRAubWtqbWzgKie', 0, 0);
-- ----------------------------
-- Table structure for hospital_device
-- ----------------------------
DROP TABLE IF EXISTS `hospital_device`;
CREATE TABLE `hospital_device` (
`hospitalId` int NULL DEFAULT NULL,
`deviceId` int NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of hospital_device
-- ----------------------------
-- ----------------------------
-- Table structure for nurse
-- ----------------------------
DROP TABLE IF EXISTS `nurse`;
CREATE TABLE `nurse` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`status` int NULL DEFAULT NULL,
`hospitalId` int NULL DEFAULT NULL,
`type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`age` int NULL DEFAULT NULL,
`phone` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`email` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`address` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of nurse
-- ----------------------------
INSERT INTO `nurse` VALUES (1, 'nn', 0, 2, 'nurse', 23, '111', '23453', 'Cardiff');
INSERT INTO `nurse` VALUES (2, 'Li Xiaoming', 1, 2, 'nurse', 25, '222', '4399', 'Cardiff');
INSERT INTO `nurse` VALUES (3, 'Sun Hao', 1, 0, 'nurse', 24, '123', '23576', 'Bute');
INSERT INTO `nurse` VALUES (4, 'Wang Xiaoming', 0, 2, 'nurse', 26, '333', '34578', 'Cardiff');
INSERT INTO `nurse` VALUES (5, 'Tian Hao', 0, 2, 'nurse', 30, '321', '24353', 'Cardiff');
-- ----------------------------
-- Table structure for patient
-- ----------------------------
DROP TABLE IF EXISTS `patient`;
CREATE TABLE `patient` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`roleId` int NULL DEFAULT NULL,
`status` int NULL DEFAULT NULL,
`hospitalId` int NULL DEFAULT NULL,
`type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`age` int NULL DEFAULT NULL,
`phone` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
`email` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of patient
-- ----------------------------
INSERT INTO `patient` VALUES (1, 'Li Ming', '$2a$10$obgmyiqAuhIkBjuw3bROr.LkCh.Nb70e4dL8lwKjSsPxS8gSpQxSC', 2, 1, 0, 'patient', 20, '135', 'wwgwg@outlook.com');
INSERT INTO `patient` VALUES (2, 'Li Hua', '$2a$10$obgmyiqAuhIkBjuw3bROr.LkCh.Nb70e4dL8lwKjSsPxS8gSpQxSC', 2, 0, 0, 'patient', 21, '166', 'ss@qq.com');
INSERT INTO `patient` VALUES (3, 'Huang Li', '$2a$10$obgmyiqAuhIkBjuw3bROr.LkCh.Nb70e4dL8lwKjSsPxS8gSpQxSC', 2, 0, 0, 'patient', 13, '111', '22@qq.com');
INSERT INTO `patient` VALUES (4, 'Xia Ming', '$2a$10$obgmyiqAuhIkBjuw3bROr.LkCh.Nb70e4dL8lwKjSsPxS8gSpQxSC', 2, 1, 2, 'patient', 61, '15', '131@qq.com');
INSERT INTO `patient` VALUES (5, 'Xia Yu', '$2a$10$obgmyiqAuhIkBjuw3bROr.LkCh.Nb70e4dL8lwKjSsPxS8gSpQxSC', 2, 1, 2, 'patient', 33, '14315', 'xx@qq.com');
-- ----------------------------
-- Table structure for patient_hospital
-- ----------------------------
DROP TABLE IF EXISTS `patient_hospital`;
CREATE TABLE `patient_hospital` (
`hosptialId` int NULL DEFAULT NULL,
`patientId` int NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of patient_hospital
-- ----------------------------
-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`roleId` int NULL DEFAULT NULL,
`type` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO `role` VALUES (0, 'SUPER');
INSERT INTO `role` VALUES (1, 'ADMIN');
INSERT INTO `role` VALUES (2, 'PATIENT');
INSERT INTO `role` VALUES (3, 'HOSPITAL');
-- ----------------------------
-- Table structure for super_admin
-- ----------------------------
DROP TABLE IF EXISTS `super_admin`;
CREATE TABLE `super_admin` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`password` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`roleId` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of super_admin
-- ----------------------------
INSERT INTO `super_admin` VALUES (1, '2649783657@qq.com', '$2a$10$5UzuKUxgR8H0RzLYrP.BUu8.76yKwMD4XkvJIu/xxB7AAHWfphFQm', 0);
-- ----------------------------
-- Procedure structure for reset_primary_keys
-- ----------------------------
DROP PROCEDURE IF EXISTS `reset_primary_keys`;
delimiter ;;
CREATE PROCEDURE `reset_primary_keys`()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE current_id INT DEFAULT 0;
DECLARE cur CURSOR FOR
SELECT id FROM common_admin ORDER BY id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur;
-- 重新更新每一条记录的 ID
read_loop: LOOP
FETCH cur INTO current_id;
IF done THEN
LEAVE read_loop;
END IF;
-- 根据新的排序修改 ID
UPDATE common_admin SET id = current_id - 1 WHERE id = current_id;
END LOOP;
CLOSE cur;
END
;;
delimiter ;
SET FOREIGN_KEY_CHECKS = 1;
package com.cardiff.client_project.controller.nursinghome;
import com.cardiff.client_project.pojo.dto.HospitalDTO;
import com.cardiff.client_project.service.NursingHomeService;
import com.cardiff.client_project.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/hospitals")
@CrossOrigin(origins = "*")
public class NursingHomeController {
@Autowired
private NursingHomeService nursingHomeService;
// READ - Get available beds
@GetMapping("/available")
public Result<List<HospitalDTO>> getAvailableBeds() {
try {
return nursingHomeService.getAvailableBeds();
} catch (Exception e) {
return Result.error("Error fetching available beds: " + e.getMessage());
}
}
// CREATE - Add new hospital/bed data
@PostMapping
public Result<HospitalDTO> addHospital(@RequestBody HospitalDTO hospitalDTO) {
try {
return nursingHomeService.insertPatientInfo(hospitalDTO);
} catch (Exception e) {
return Result.error("Error adding hospital: " + e.getMessage());
}
}
// UPDATE - Update bed count
@PutMapping("/{hospitalId}/beds")
public Result<String> updateBedCount(
@PathVariable int hospitalId,
@RequestParam int currentPatients) {
try {
return nursingHomeService.updateBedCount(hospitalId, currentPatients);
} catch (Exception e) {
return Result.error("Error updating bed count: " + e.getMessage());
}
}
// DELETE - Delete hospital record
@DeleteMapping("/{id}")
public Result<String> deleteHospital(@PathVariable int id) {
try {
List<Integer> ids = List.of(id);
return nursingHomeService.deletePatientById(ids);
} catch (Exception e) {
return Result.error("Error deleting hospital: " + e.getMessage());
}
}
}
package com.cardiff.client_project.mapper;
import com.cardiff.client_project.pojo.dto.HospitalDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class NursingHomeMapper {
@Autowired
private JdbcTemplate jdbcTemplate;
public List<HospitalDTO> findAllNursingHomes() {
String sql = """
SELECT
id,
name,
address,
phone,
maxAmount,
amountPatient,
status
FROM hospital
WHERE status = 1
""";
return jdbcTemplate.query(sql, (rs, rowNum) -> {
HospitalDTO dto = new HospitalDTO();
dto.setId(rs.getInt("id"));
dto.setName(rs.getString("name"));
dto.setLocation(rs.getString("address"));
dto.setPhone(rs.getString("phone"));
dto.setTotalBeds(rs.getInt("maxAmount"));
int maxAmount = rs.getInt("maxAmount");
int amountPatient = rs.getInt("amountPatient");
dto.setAvailableBeds(maxAmount - amountPatient);
dto.setOccupancyRate(calculateOccupancy(maxAmount, amountPatient));
return dto;
});
}
private double calculateOccupancy(int maxAmount, int amountPatient) {
return maxAmount > 0 ? ((double) amountPatient / maxAmount) * 100 : 0;
}
public int insertHospital(HospitalDTO dto) {
String sql = """
INSERT INTO hospital (
name,
address,
phone,
maxAmount,
amountPatient,
status,
type,
roleId
) VALUES (?, ?, ?, ?, ?, 1, 'hospital', 3)
""";
return jdbcTemplate.update(sql,
dto.getName(),
dto.getLocation(),
dto.getPhone(),
dto.getTotalBeds(),
dto.getTotalBeds() - dto.getAvailableBeds()
);
}
public int updateHospital(HospitalDTO dto) {
String sql = """
UPDATE hospital
SET
name = ?,
address = ?,
phone = ?,
maxAmount = ?,
amountPatient = ?
WHERE id = ? AND status = 1
""";
return jdbcTemplate.update(sql,
dto.getName(),
dto.getLocation(),
dto.getPhone(),
dto.getTotalBeds(),
dto.getTotalBeds() - dto.getAvailableBeds(),
dto.getId()
);
}
public int[] deleteHospitalByIds(List<Integer> ids) {
String sql = "UPDATE hospital SET status = 0 WHERE id = ?";
List<Object[]> params = ids.stream()
.map(id -> new Object[]{id})
.toList();
return jdbcTemplate.batchUpdate(sql, params);
}
public int updateBedCount(int hospitalId, int currentPatients) {
String sql = """
UPDATE hospital
SET amountPatient = ?
WHERE id = ? AND maxAmount >= ? AND status = 1
""";
return jdbcTemplate.update(sql, currentPatients, hospitalId, currentPatients);
}
}
\ No newline at end of file
...@@ -6,8 +6,8 @@ import lombok.Data; ...@@ -6,8 +6,8 @@ import lombok.Data;
public class HospitalDTO { public class HospitalDTO {
private int id; private int id;
private String name; private String name;
private String address;
private String location; private String location;
private String address;
private String phone; private String phone;
private int totalBeds; private int totalBeds;
private int availableBeds; private int availableBeds;
......
package com.cardiff.client_project.pojo.entity;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class NursingHome {
private int id;
private String name;
private String password;
private int maxAmount;
private int amountPatient;
private int patientId;
private int deviceId;
private String type;
private String address;
private String phone;
private String email;
private int roleId;
private int status;
}
package com.cardiff.client_project.service;
import com.cardiff.client_project.pojo.dto.HospitalDTO;
import com.cardiff.client_project.utils.Result;
import java.util.List;
public interface NursingHomeService {
Result<List<HospitalDTO>> getAvailableBeds();
Result<HospitalDTO> insertPatientInfo(HospitalDTO hospitalDTO);
Result<String> updatePatient(HospitalDTO hospitalDTO);
Result<String> deletePatientById(List<Integer> ids);
Result<List<HospitalDTO>> getAllPatients();
Result<String> updateBedCount(int hospitalId, int currentPatients);
}
\ No newline at end of file
package com.cardiff.client_project.service.imp;
import com.cardiff.client_project.mapper.NursingHomeMapper;
import com.cardiff.client_project.pojo.dto.HospitalDTO;
import com.cardiff.client_project.service.NursingHomeService;
import com.cardiff.client_project.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.dao.DataAccessException;
import java.util.List;
@Service
public class NursingHomeServiceImp implements NursingHomeService {
@Autowired
private NursingHomeMapper nursingHomeMapper;
@Override
public Result<List<HospitalDTO>> getAvailableBeds() {
try {
List<HospitalDTO> hospitals = nursingHomeMapper.findAllNursingHomes();
if (hospitals == null || hospitals.isEmpty()) {
return Result.error("No hospitals available");
}
return Result.success(hospitals);
} catch (DataAccessException e) {
return Result.error("Database error: " + e.getMessage());
} catch (Exception e) {
return Result.error("Internal server error");
}
}
@Override
public Result<HospitalDTO> insertPatientInfo(HospitalDTO hospitalDTO) {
try {
if (!validateHospitalData(hospitalDTO)) {
return Result.error("Invalid hospital data");
}
int result = nursingHomeMapper.insertHospital(hospitalDTO);
if (result > 0) {
return Result.success(hospitalDTO);
}
return Result.error("Failed to insert hospital");
} catch (DataAccessException e) {
return Result.error("Database error: " + e.getMessage());
} catch (Exception e) {
return Result.error("Internal server error");
}
}
@Override
public Result<String> updatePatient(HospitalDTO hospitalDTO) {
try {
if (!validateHospitalData(hospitalDTO)) {
return Result.error("Invalid hospital data");
}
int result = nursingHomeMapper.updateHospital(hospitalDTO);
return result > 0 ?
Result.success("Hospital updated successfully") :
Result.error("Failed to update hospital");
} catch (Exception e) {
return Result.error("Error updating hospital: " + e.getMessage());
}
}
@Override
public Result<String> deletePatientById(List<Integer> ids) {
try {
int[] results = nursingHomeMapper.deleteHospitalByIds(ids);
return results.length > 0 ?
Result.success("Hospital deleted successfully") :
Result.error("No hospitals were deleted");
} catch (Exception e) {
return Result.error("Error deleting hospital: " + e.getMessage());
}
}
@Override
public Result<List<HospitalDTO>> getAllPatients() {
return getAvailableBeds();
}
@Override
public Result<String> updateBedCount(int hospitalId, int currentPatients) {
try {
if (currentPatients < 0) {
return Result.error("Patient count cannot be negative");
}
int result = nursingHomeMapper.updateBedCount(hospitalId, currentPatients);
return result > 0 ?
Result.success("Bed count updated successfully") :
Result.error("Failed to update bed count");
} catch (Exception e) {
return Result.error("Error updating bed count: " + e.getMessage());
}
}
private boolean validateHospitalData(HospitalDTO hospitalDTO) {
if (hospitalDTO == null) return false;
return hospitalDTO.getName() != null &&
!hospitalDTO.getName().trim().isEmpty() &&
hospitalDTO.getLocation() != null &&
!hospitalDTO.getLocation().trim().isEmpty() &&
hospitalDTO.getPhone() != null &&
!hospitalDTO.getPhone().trim().isEmpty() &&
hospitalDTO.getTotalBeds() > 0 &&
hospitalDTO.getAvailableBeds() >= 0 &&
hospitalDTO.getAvailableBeds() <= hospitalDTO.getTotalBeds();
}
}
\ No newline at end of file
/* Base Styles */ /* Base Styles */
:root {
--primary-color: #1f2937;
--secondary-color: #3b82f6;
--background-color: #f3f4f6;
--text-color: #1f2937;
--border-color: #e5e7eb;
--success-color: #10b981;
--warning-color: #f59e0b;
--danger-color: #ef4444;
}
body { body {
font-family: 'Poppins', sans-serif; font-family: 'Poppins', sans-serif;
margin: 0; margin: 0;
padding: 0; padding: 0;
background: linear-gradient(135deg, #f6f8fd 0%, #f1f4f9 100%); background-color: var(--background-color);
color: #2c3e50; color: var(--text-color);
line-height: 1.5;
} }
/* Header Styling */ /* Header Styling */
header { header {
background: linear-gradient(135deg, #1f2937 0%, #374151 100%); background: var(--primary-color);
color: white; color: white;
text-align: center; padding: 2rem;
padding: 2rem 0; border-radius: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
margin-bottom: 2rem; margin-bottom: 2rem;
text-align: center;
} }
header h1 { header h1 {
font-size: 2.5rem;
margin: 0; margin: 0;
font-size: 2rem;
font-weight: 600; font-weight: 600;
letter-spacing: 0.5px;
} }
header p { header p {
font-size: 1.1rem;
margin-top: 0.5rem; margin-top: 0.5rem;
opacity: 0.9; opacity: 0.9;
} }
/* Main Container */ /* Main Container */
.main-container { .main-container {
max-width: 1400px; max-width: 1200px;
margin: 0 auto; margin: 0 auto;
padding: 0 2rem; padding: 2rem;
} }
/* Toolbar Section */ /* Toolbar Section */
...@@ -50,6 +60,15 @@ header p { ...@@ -50,6 +60,15 @@ header p {
flex-wrap: wrap; flex-wrap: wrap;
} }
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
gap: 1rem;
flex-wrap: wrap;
}
.searchBox { .searchBox {
padding: 0.75rem 1rem; padding: 0.75rem 1rem;
border: 2px solid #e5e7eb; border: 2px solid #e5e7eb;
...@@ -65,19 +84,34 @@ header p { ...@@ -65,19 +84,34 @@ header p {
outline: none; outline: none;
} }
.search-group {
display: flex;
gap: 1rem;
flex: 1;
}
.search-input {
flex: 1;
padding: 0.75rem;
border: 1px solid var(--border-color);
border-radius: 8px;
font-size: 1rem;
}
/* Table Styling */ /* Table Styling */
.table-container { .table-container {
background: white; background: white;
border-radius: 12px; border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); padding: 1rem;
margin-top: 1rem;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
overflow: hidden; overflow: hidden;
margin-bottom: 2rem; margin-bottom: 2rem;
} }
table { table {
width: 100%; width: 100%;
border-collapse: separate; border-collapse: collapse;
border-spacing: 0;
} }
th { th {
...@@ -99,19 +133,33 @@ tr:hover td { ...@@ -99,19 +133,33 @@ tr:hover td {
background-color: #f8fafc; background-color: #f8fafc;
} }
th, td {
padding: 0.75rem;
text-align: left;
border-bottom: 1px solid var(--border-color);
}
th {
background: #f8fafc;
font-weight: 600;
}
/* Button Styling */ /* Button Styling */
.btn { .btn {
padding: 0.75rem 1.5rem; padding: 0.5rem 1rem;
border-radius: 8px; border-radius: 4px;
font-weight: 500; font-weight: 500;
cursor: pointer; cursor: pointer;
transition: all 0.3s ease; transition: all 0.3s ease;
border: none; border: none;
font-size: 0.95rem; font-size: 0.95rem;
display: inline-flex;
align-items: center;
gap: 0.5rem;
} }
.primary-btn { .primary-btn {
background: #3b82f6; background: var(--secondary-color);
color: white; color: white;
} }
...@@ -121,23 +169,34 @@ tr:hover td { ...@@ -121,23 +169,34 @@ tr:hover td {
} }
.secondary-btn { .secondary-btn {
background: #e5e7eb; background: var(--border-color);
color: #4b5563; color: var(--text-color);
} }
.secondary-btn:hover { .secondary-btn:hover {
background: #d1d5db; background: #d1d5db;
} }
.edit-btn {
background: #3b82f6;
color: white;
margin-right: 0.5rem;
}
.delete-btn {
background: #ef4444;
color: white;
}
/* Modal Styling */ /* Modal Styling */
.modal-overlay { .modal-overlay {
display: none;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 1000; z-index: 1000;
...@@ -146,7 +205,7 @@ tr:hover td { ...@@ -146,7 +205,7 @@ tr:hover td {
.modal { .modal {
background: white; background: white;
border-radius: 12px; border-radius: 10px;
padding: 2rem; padding: 2rem;
width: 90%; width: 90%;
max-width: 600px; max-width: 600px;
...@@ -154,6 +213,9 @@ tr:hover td { ...@@ -154,6 +213,9 @@ tr:hover td {
} }
.modal-header { .modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }
...@@ -164,7 +226,7 @@ tr:hover td { ...@@ -164,7 +226,7 @@ tr:hover td {
} }
.form-group { .form-group {
margin-bottom: 1.5rem; margin-bottom: 1rem;
} }
.form-group label { .form-group label {
...@@ -177,9 +239,10 @@ tr:hover td { ...@@ -177,9 +239,10 @@ tr:hover td {
.form-group input { .form-group input {
width: 100%; width: 100%;
padding: 0.75rem; padding: 0.75rem;
border: 2px solid #e5e7eb; border: 1px solid var(--border-color);
border-radius: 8px; border-radius: 8px;
transition: all 0.3s ease; transition: all 0.3s ease;
font-size: 1rem;
} }
.form-group input:focus { .form-group input:focus {
...@@ -188,6 +251,21 @@ tr:hover td { ...@@ -188,6 +251,21 @@ tr:hover td {
outline: none; outline: none;
} }
.button-group {
display: flex;
justify-content: flex-end;
gap: 1rem;
margin-top: 2rem;
}
.close-btn {
background: none;
border: none;
cursor: pointer;
font-size: 1.25rem;
color: var(--text-color);
}
/* Status Indicators */ /* Status Indicators */
.status-badge { .status-badge {
padding: 0.5rem 1rem; padding: 0.5rem 1rem;
...@@ -231,10 +309,18 @@ footer { ...@@ -231,10 +309,18 @@ footer {
align-items: stretch; align-items: stretch;
} }
.toolbar {
flex-direction: column;
}
.searchBox { .searchBox {
width: 100%; width: 100%;
} }
.search-group {
width: 100%;
}
th, td { th, td {
padding: 1rem 0.75rem; padding: 1rem 0.75rem;
} }
...@@ -243,5 +329,16 @@ footer { ...@@ -243,5 +329,16 @@ footer {
width: 100%; width: 100%;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
.table-container {
overflow-x: auto;
}
}
/* beds.css */
.error {
color: #ef4444;
text-align: center;
padding: 1rem;
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Available Beds Dashboard</title> <title>Hospital Bed Management</title>
<link rel="stylesheet" href="../css/beds.css"> <link rel="stylesheet" href="../css/beds.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
...@@ -11,164 +11,81 @@ ...@@ -11,164 +11,81 @@
</head> </head>
<body> <body>
<div class="main-container"> <div class="main-container">
<!-- Header Section -->
<header> <header>
<h1>Hospital Bed Management</h1>
<h1>Hospital Management Dashboard</h1>
<p>Track and manage hospital bed availability with ease</p> <p>Track and manage hospital bed availability with ease</p>
</header> </header>
<div class="toolbar">
<div class="search-group">
<!-- Toolbar Section --> <input type="text" id="searchName" class="search-input" placeholder="Search by hospital name...">
<button id="searchButton" class="btn primary-btn">
<div id="toolbar"> <i class="fas fa-search"></i> Search
</button>
<label for="searchName">Search by Name:</label> </div>
<button id="addHospitalBtn" class="btn primary-btn">
<input type="text" id="searchName" class="searchBox" placeholder="Enter hospital name..."> <i class="fas fa-plus"></i> Add Hospital
</button>
<label for="searchLocation">Location:</label>
<input type="text" id="searchLocation" class="searchBox" placeholder="Enter location...">
<label for="searchStatus">Status:</label>
<select id="searchStatus" class="searchBox">
<option value="">All</option>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
</select>
<button id="searchButton" class="btn search-btn">Search</button>
<button id="addButton" class="btn add-btn">Add Hospital</button>
</div> </div>
<!-- Table Section -->
<div class="table-container"> <div class="table-container">
<table id="hospitalTable">
<h2>Hospitals with Available Beds</h2>
<table>
<thead> <thead>
<tr> <tr>
<th>ID</th>
<th>Hospital ID</th>
<th>Hospital Name</th> <th>Hospital Name</th>
<th>Location</th> <th>Location</th>
<th>Phone</th> <th>Phone</th>
<th>Total Beds</th> <th>Total Beds</th>
<th>Available Beds</th> <th>Available Beds</th>
<th>Occupancy</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- Data populated by JavaScript -->
<!-- Table Rows Populated Dynamically -->
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
<!-- Modal for Add/Edit -->
<div id="hospitalModal" class="modal-overlay">
<!-- Add/Edit Modal --> <div class="modal">
<div class="modal-header">
<div id="overlay"> <h2 id="modalTitle">Add Hospital</h2>
<button class="close-btn"><i class="fas fa-times"></i></button>
<div id="formContainer"> </div>
<h2 id="modalTitle">Add New Hospital</h2>
<form id="hospitalForm"> <form id="hospitalForm">
<input type="hidden" id="hospitalId"> <input type="hidden" id="hospitalId">
<div class="form-group">
<label for="hospitalName">Hospital Name:</label> <label for="hospitalName">Hospital Name</label>
<input type="text" id="hospitalName" required>
<input type="text" id="hospitalName" placeholder="Enter hospital name..." required> </div>
<div class="form-group">
<label for="hospitalLocation">Location</label>
<input type="text" id="hospitalLocation" required>
<label for="hospitalLocation">Location:</label> </div>
<div class="form-group">
<input type="text" id="hospitalLocation" placeholder="Enter location..." required> <label for="hospitalPhone">Phone</label>
<input type="tel" id="hospitalPhone" required>
</div>
<div class="form-group">
<label for="hospitalPhone">Phone:</label> <label for="totalBeds">Total Beds</label>
<input type="number" id="totalBeds" min="0" required>
<input type="text" id="hospitalPhone" placeholder="Enter phone number..." required> </div>
<div class="form-group">
<label for="availableBeds">Available Beds</label>
<input type="number" id="availableBeds" min="0" required>
<label for="hospitalTotalBeds">Total Beds:</label> </div>
<div class="button-group">
<input type="number" id="hospitalTotalBeds" placeholder="Enter total beds..." required> <button type="submit" class="btn primary-btn">Save</button>
<button type="button" class="btn secondary-btn" id="cancelBtn">Cancel</button>
</div>
<label for="hospitalAvailableBeds">Available Beds:</label>
<input type="number" id="hospitalAvailableBeds" placeholder="Enter available beds..." required>
<button type="submit" class="btn save-btn">Save</button>
<button type="button" id="cancelButton" class="btn cancel-btn">Cancel</button>
</form> </form>
</div> </div>
</div> </div>
<footer>
<p>&copy; 2024 Hospital Management System</p>
</footer>
<script src="../js/beds.js"></script> <script src="../js/beds.js"></script>
</body> </body>
</html> </html>
...@@ -17,19 +17,48 @@ ...@@ -17,19 +17,48 @@
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3); /* Dark shadow effect */ box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3); /* Dark shadow effect */
padding: 10px; padding: 10px;
} }
#top {
border-radius: 15px;
margin-bottom: 5px;
background-color: #2c3e50;
height: 10vh;
width: 100%;
position: relative;
display: flex;
align-items: center;
justify-content: space-between; /* Adjust spacing between elements */
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
padding: 0 20px; /* Add padding for consistent spacing */
}
#showSpan {
color: #ecf0f1;
display: flex;
flex-direction: column;
align-items: flex-end;
}
#loginIdText {
color: white;
text-align: left;
margin: 0;
}
</style> </style>
</head> </head>
<body> <body>
<div id="container" style="display: flex; flex-direction: column; height: 100vh;"> <div id="container" style="display: flex; flex-direction: column; height: 100vh;">
<!-- top area --> <!-- top area -->
<div id="top" style="border-radius: 15px; margin-bottom: 5px; background-color: #2c3e50; height: 10vh; width: 100%; position: relative; display: flex; align-items: center; box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);"> <div id="top">
<!-- Centered title -->
<span style="color: #ecf0f1; font-size: 1.5rem; font-weight: bold; font-family: 'Arial', sans-serif; position: absolute; left: 50%; transform: translateX(-50%);"> <span style="color: #ecf0f1; font-size: 1.5rem; font-weight: bold; font-family: 'Arial', sans-serif; position: absolute; left: 50%; transform: translateX(-50%);">
Digital Insight for Health Digital Insight for Health
</span> </span>
<span id="showSpan" style="color: #ecf0f1; position: absolute; right: 20px; display: flex; flex-direction: column; align-items: flex-end;"></span>
</div>
<!-- Left aligned elements -->
<div style="display: flex; flex-direction: column; align-items: flex-end;">
<span id="showSpan"></span>
<p id="loginIdText">current loginId: </p>
</div>
</div>
<!-- main block,left and right --> <!-- main block,left and right -->
<div style="display: flex; height: 80vh;"> <div style="display: flex; height: 80vh;">
...@@ -53,6 +82,9 @@ ...@@ -53,6 +82,9 @@
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const hospitalId = localStorage.getItem('hospitalId'); const hospitalId = localStorage.getItem('hospitalId');
var loginIdText = document.getElementById('loginIdText');
loginIdText.textContent = 'current loginId: hospital ' + hospitalId;
const type = urlParams.get('type'); const type = urlParams.get('type');
if(type==null){ if(type==null){
$('#mainview').load("/hospitalLoadMain2"); $('#mainview').load("/hospitalLoadMain2");
...@@ -73,6 +105,7 @@ ...@@ -73,6 +105,7 @@
if(type=="nurse"){ if(type=="nurse"){
$('#mainview').load(`/nurseLoadMain/${hospitalId}`); $('#mainview').load(`/nurseLoadMain/${hospitalId}`);
} }
}) })
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -155,6 +155,8 @@ ...@@ -155,6 +155,8 @@
var itemsArray=data.msg.split(","); var itemsArray=data.msg.split(",");
var type=itemsArray[0]; var type=itemsArray[0];
var item=itemsArray[1]; var item=itemsArray[1];
localStorage.setItem("type",type);
localStorage.setItem("name",item);
if (type == "[" + "SUPER" + "]") { if (type == "[" + "SUPER" + "]") {
window.location.href = "superAdminView.html"; window.location.href = "superAdminView.html";
} }
......
$(document).ready(function () { $(document).ready(function () {
// Constants
const API_BASE_URL = '/api/hospitals';
const DEFAULT_ERROR = 'Operation failed. Please try again.';
// Initialize page
setupNavBar();
loadHospitals(); loadHospitals();
initializeEventHandlers();
function setupNavBar() {
const nav = `
<nav class="top-nav">
<div class="nav-brand">Digital Insight for Health</div>
<div class="nav-items">
<a href="/dashboard" class="nav-link">
<i class="fas fa-home"></i> Home
</a>
<a href="/beds" class="nav-link active">
<i class="fas fa-bed"></i> Beds
</a>
<button class="nav-link sign-out" onclick="handleSignOut()">
<i class="fas fa-sign-out-alt"></i> Sign Out
</button>
</div>
<div class="user-info">
<span class="user-name">${localStorage.getItem('name') || 'User'}</span>
<span class="user-role">${localStorage.getItem('type') || 'Guest'}</span>
</div>
</nav>
`;
$('.main-container').prepend(nav);
}
function loadHospitals() { function loadHospitals() {
showLoading();
$.ajax({ $.ajax({
url: '/api/hospitals/available', url: `${API_BASE_URL}/available`,
method: 'GET', method: 'GET',
contentType: 'application/json',
success: function(response) { success: function(response) {
if(response.code === 200) { if(response && response.code === 1) {
populateTable(response.data); updateTable(response.data || []);
} else { } else {
alert(response.msg); showError(response.msg || DEFAULT_ERROR);
} }
}, },
error: function(xhr) { error: handleAjaxError
alert('Error loading hospitals: ' + xhr.responseText); });
} }
function updateTable(hospitals) {
const tbody = $('#hospitalTable tbody');
tbody.empty();
hospitals.forEach(function(hospital) {
const tr = `
<tr>
<td>${hospital.id}</td>
<td>${hospital.name || ''}</td>
<td>${hospital.location || ''}</td>
<td>${hospital.phone || ''}</td>
<td>${hospital.totalBeds || 0}</td>
<td>${hospital.availableBeds || 0}</td>
<td>${Math.round(hospital.occupancyRate)}%</td>
<td>
<button class="btn edit-btn" data-id="${hospital.id}">
<i class="fas fa-edit"></i>
</button>
<button class="btn delete-btn" data-id="${hospital.id}">
<i class="fas fa-trash"></i>
</button>
</td>
</tr>
`;
tbody.append(tr);
}); });
} }
$("#hospitalForm").submit(function(e) { function initializeEventHandlers() {
e.preventDefault(); // Search Handler
const hospitalData = { $("#searchButton").click(handleSearch);
name: $("#hospitalName").val(),
location: $("#hospitalLocation").val(), // Add Hospital Handler
phone: $("#hospitalPhone").val(), $("#addHospitalBtn").click(function() {
totalBeds: parseInt($("#hospitalTotalBeds").val()), $("#hospitalModal").fadeIn();
availableBeds: parseInt($("#hospitalAvailableBeds").val()) $("#modalTitle").text("Add New Hospital");
}; $("#hospitalForm")[0].reset();
$("#hospitalId").val('');
});
// Close Modal Handler
$(".close-btn, #cancelBtn").click(function() {
$("#hospitalModal").fadeOut();
});
// Form Submit Handler
$("#hospitalForm").submit(handleFormSubmit);
// Delete Handler
$(document).on('click', '.delete-btn', function() {
const id = $(this).data('id');
if(confirm('Are you sure you want to delete this hospital?')) {
$.ajax({ $.ajax({
url: '/api/hospitals', url: `${API_BASE_URL}/${id}`,
method: 'POST', method: 'DELETE',
contentType: 'application/json',
data: JSON.stringify(hospitalData),
success: function(response) { success: function(response) {
if(response.code === 200) { if(response.code === 200) {
alert('Hospital added successfully');
$("#overlay").fadeOut();
loadHospitals(); loadHospitals();
} else { } else {
alert(response.msg); alert(response.msg || 'Delete failed');
} }
}, },
error: function(xhr) { error: function(xhr) {
alert('Error adding hospital: ' + xhr.responseText); alert('Delete failed');
console.error('Delete Error:', xhr);
} }
}); });
}
}); });
}
function handleSearch(event) {
event.preventDefault();
const searchTerm = $("#searchName").val().trim();
// Add delete functionality
$(document).on('click', '.delete-btn', function() {
const hospitalId = $(this).data('id');
if(confirm('Are you sure you want to delete this hospital?')) {
$.ajax({ $.ajax({
url: '/api/hospitals', url: `${API_BASE_URL}/search`,
method: 'DELETE', method: 'POST',
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify([hospitalId]), data: JSON.stringify({ name: searchTerm }),
success: function(response) { success: function(response) {
if(response.code === 200) { if(response && response.code === 1) {
loadHospitals(); updateTable(response.data || []);
} else { } else {
alert(response.msg); showError('No hospitals found');
} }
}, },
error: function(xhr) { error: handleAjaxError
alert('Error deleting hospital: ' + xhr.responseText);
}
}); });
} }
function handleFormSubmit(event) {
event.preventDefault();
const formData = {
name: $("#hospitalName").val(),
address: $("#hospitalLocation").val(),
phone: $("#hospitalPhone").val(),
maxAmount: parseInt($("#totalBeds").val()),
amountPatient: parseInt($("#totalBeds").val() - $("#availableBeds").val()),
type: 'hospital',
status: 1
};
const id = $("#hospitalId").val();
const method = id ? 'PUT' : 'POST';
const url = id ? `${API_BASE_URL}/${id}` : API_BASE_URL;
$.ajax({
url: url,
method: method,
contentType: 'application/json',
data: JSON.stringify(formData),
success: function(response) {
if(response && response.code === 1) {
$("#hospitalModal").fadeOut();
showSuccess('Operation successful');
loadHospitals();
} else {
showError(response.msg || DEFAULT_ERROR);
}
},
error: handleAjaxError
}); });
}
function handleAjaxError(xhr, status, error) {
console.error('API Error:', {xhr, status, error});
showError(DEFAULT_ERROR);
}
function showLoading() {
$('#hospitalTable tbody').html('<tr><td colspan="8" class="text-center">Loading...</td></tr>');
}
function showNoDataMessage() {
$('#hospitalTable tbody').html('<tr><td colspan="8" class="text-center">No hospitals available</td></tr>');
}
function showError(message) {
$('#hospitalTable tbody').html(`<tr><td colspan="8" class="text-center text-danger">${message}</td></tr>`);
}
// Add CSS for new components
const styles = `
.top-nav {
background: var(--primary-color);
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.nav-brand {
color: white;
font-size: 1.5rem;
font-weight: 600;
}
.nav-items {
display: flex;
gap: 1rem;
align-items: center;
}
.nav-link {
color: white;
text-decoration: none;
padding: 0.5rem 1rem;
border-radius: 6px;
transition: all 0.3s ease;
}
.nav-link:hover, .nav-link.active {
background: rgba(255,255,255,0.1);
}
.sign-out {
background: var(--danger-color);
border: none;
cursor: pointer;
}
.user-info {
display: flex;
flex-direction: column;
align-items: flex-end;
color: white;
}
.user-name {
font-weight: 500;
}
.user-role {
font-size: 0.875rem;
opacity: 0.8;
}
.success-message {
background: var(--success-color);
color: white;
padding: 1rem;
border-radius: 6px;
margin-bottom: 1rem;
display: flex;
align-items: center;
justify-content: space-between;
}
`;
$('<style>').text(styles).appendTo('head');
// Initialize tooltips and other UI enhancements
$('[data-toggle="tooltip"]').tooltip();
// Add fade effects for smoother transitions
$('.table-container').hide().fadeIn();
}); });
function handleSignOut() {
localStorage.clear();
window.location.href = '/login';
}
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<!-- Vertical navigation bar --> <!-- Vertical navigation bar -->
<!--<div class="nav-item" onclick="chooseAdmin()">CommonAdmin</div>--> <!--<div class="nav-item" onclick="chooseAdmin()">CommonAdmin</div>-->
<div class="nav-item" onclick="chooseHospital()">Hospital</div> <div class="nav-item" onclick="chooseHospital()">Hospital</div>
<div class="nav-item" onclick="choosePatient()">Patient</div>
<div class="nav-item" onclick="chooseDevice()">Device</div> <div class="nav-item" onclick="chooseDevice()">Device</div>
<div class="nav-item" onclick="chooseNurse()">Nurse</div> <div class="nav-item" onclick="chooseNurse()">Nurse</div>
<div class="nav-item" onclick="chooseOut()" style="margin-top: 335px">Sign Out</div> <div class="nav-item" onclick="chooseOut()" style="margin-top: 335px">Sign Out</div>
...@@ -21,10 +20,6 @@ ...@@ -21,10 +20,6 @@
window.location.href="/HospitalView.html?type=hospital" window.location.href="/HospitalView.html?type=hospital"
} }
function choosePatient(){
window.location.href="/HospitalView.html?type=patient"
}
function chooseDevice(){ function chooseDevice(){
window.location.href="/HospitalView.html?type=device" window.location.href="/HospitalView.html?type=device"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment