ENGINE = InnoDBDEFAULT CHARACTER SET = utf8mb4COLLATE = utf8mb4_0900_ai_ci; `last_name` VARCHAR255 NOT NULL, `dob` DATE NOT NULL, `gender` VARCHAR255 NOT NULL, `phone_number` VARCHAR255
GIỚI THIỆU VỀ ỨNG DỤNG
Hệ thống Quản lý Bệnh viện (HMS) được thiết kế để tối ưu hóa quản lý thông tin y tế và hành chính trong bệnh viện, bao gồm việc lưu trữ và theo dõi thông tin của nhân viên, bệnh nhân, khoa, thuốc và dịch vụ y tế Ứng dụng này giúp tăng cường hiệu quả hoạt động bằng cách quản lý thông tin bác sĩ, y tá, chuyên khoa và lịch sử làm việc Thông tin bệnh nhân được lưu trữ chi tiết với mã định danh duy nhất, bao gồm hồ sơ y tế và chi tiết điều trị Hệ thống còn tích hợp quản lý lịch sử khám chữa bệnh, tự động cập nhật tình trạng bệnh nhân và theo dõi quá trình sử dụng thuốc, đồng thời đánh dấu thuốc hết hạn để tránh sử dụng Cuối cùng, HMS cung cấp báo cáo chi tiết về bệnh nhân, tài nguyên y tế và trạng thái hoạt động của bệnh viện, hỗ trợ ban quản lý đưa ra quyết định nhanh chóng và chính xác.
Ứng dụng được thiết kế với giao diện thân thiện, phục vụ cho nhân viên y tế, quản lý bệnh viện, nhà cung cấp và bệnh nhân Với công nghệ hiện đại và khả năng triển khai trên nền tảng web hoặc di động, ứng dụng dễ dàng tích hợp và mở rộng, tối ưu hóa hoạt động của bệnh viện và nâng cao chất lượng chăm sóc bệnh nhân.
PHÂN TÍCH VÀ THIẾT KẾ HỆ THỐNG
Mô hình nghiệp vụ
Một bệnh viện X cần xây dựng hệ thống thông tin quản lý để quản lý thông tin bệnh nhân, bác sĩ và y tá.
Cơ sở dữ liệu của bệnh viện X cần quản lý thông tin nhân viên, bao gồm bác sĩ và điều dưỡng với các thông tin như mã duy nhất, họ tên đầy đủ, ngày sinh, giới tính, địa chỉ, ngày bắt đầu làm việc, số điện thoại, chuyên khoa và năm cấp bằng Bệnh viện có nhiều khoa, mỗi khoa được xác định bằng mã duy nhất, có chức danh và một khoa trưởng là bác sĩ.
Mỗi nhân viên phải thuộc về một khoa cụ thể, và mỗi khoa cần có ít nhất một nhân viên trở lên Trưởng khoa cần có chuyên môn đặc thù và tối thiểu 5 năm kinh nghiệm kể từ khi nhận bằng chuyên môn.
Bệnh nhân cần cung cấp thông tin cá nhân cho bệnh viện, bao gồm họ và tên đầy đủ, ngày sinh, giới tính, địa chỉ và số điện thoại Sau khi tiếp nhận thông tin, hệ thống sẽ lưu trữ vào cơ sở dữ liệu và tạo mã duy nhất để xác định từng bệnh nhân.
Bệnh nhân được phân loại thành hai nhóm: bệnh nhân ngoại trú và bệnh nhân nội trú Để xác định loại bệnh nhân, bệnh viện sẽ sử dụng mã duy nhất gồm hai ký tự đầu tiên Cụ thể, mã của bệnh nhân ngoại trú sẽ bắt đầu bằng "OP", tiếp theo là 9 chữ số.
“OP000000001.” Nếu là bệnh nhân nội trú, mã duy nhất của bệnh nhân đó bắt đầu bằng “IP,” sau đó là 9 chữ số như “IP000000001.”
1 Đối với bệnh nhân ngoại trú, cần lưu trữ thông tin của bác sĩ khám. Bệnh nhân ngoại trú có thể khám nhiều lần với bác sĩ khám Bệnh viện cần lưu trữ thông tin chi tiết của từng lần khám như: ngày khám, chẩn đoán, ngày khám tiếp theo nếu có, thuốc và lệ phí.
2 Đối với bệnh nhân nội trú, một số thông tin được thêm vào như: ngày nhập viện, bác sĩ điều trị, điều dưỡng chăm sóc, chẩn đoán, phòng bệnh, ngày xuất viện và phí Sau khi nhập viện, bệnh nhân có thể được điều trị từ ít nhất một bác sĩ Một bác sĩ có thể điều trị cho nhiều bệnh nhân cùng một lúc, hoặc đôi khi, không có bệnh nhân nào để điều trị Bệnh viện cần thông tin chi tiết về từng lần điều trị như: thời gian điều trị (ngày bắt đầu và ngày kết thúc), kết quả và thuốc Mỗi bệnh nhân nội trú được một y tá chăm sóc;một y tá có thể chăm sóc nhiều bệnh nhân nội trú cùng một lúc Hơn nữa,khi một bệnh nhân hồi phục và lần điều trị cuối cùng của bệnh nhân đó được bác sĩ xác nhận là “hồi phục”, bệnh nhân đó sẽ được xuất viện Do đó,ngày xuất viện phải được hệ thống ghi lại Thông tin về thuốc cũng được lưu trữ trong cơ sở dữ liệu Thông tin này bao gồm một mã duy nhất, tên thuốc,tác dụng, giá và ngày hết hạn Một loại thuốc được cung cấp bởi một hoặc nhiều nhà cung cấp và một nhà cung cấp có thể cung cấp nhiều loại thuốc.
Nhà cung cấp được xác định qua số hiệu, tên, địa chỉ và số điện thoại duy nhất Bệnh viện cần lưu trữ thông tin về thuốc nhập khẩu, bao gồm ngày nhập khẩu, giá cả và số lượng Khi một loại thuốc hết hạn, hệ thống sẽ tự động đánh dấu loại thuốc đó trong cơ sở dữ liệu.
Thiết kế cơ sở dữ liệu
2.2.1 Mô hình liên kết thực thể (ER)
Hình 1 Mô hình liên kết thực thể E-R
Quan hệ giữa bảng USER và ROLES
Quan hệ giữa bảng EMPLOYEE và USER
Quan hệ giữa bảng EMPLOYEE và DEPARTMENT
Quan hệ giữa bảng EMPLOYEE và DISTRICT
Quan hệ giữa bảng EMPLOYEE và WARD
Quan hệ giữa bảng EMPLOYEE và CITY
Quan hệ giữa bảng DOCTOR và DEPARTMENT
Quan hệ giữa bảng DOCTOR và EXAMINATION
Quan hệ giữa bảng DOCTOR và ADMISSION
Quan hệ giữa bảng NURSE và ADMISSION
Quan hệ giữa bảng PROVIDER và DISTRICT
Quan hệ giữa bảng PROVIDER và CITY
Quan hệ giữa bảng PROVIDER và WARD
Quan hệ giữa bảng PROVIDER và MEDICATION
Quan hệ giữa bảng PATIENT và CITY
Quan hệ giữa bảng PATIENT và WARD
Quan hệ giữa bảng PATIENT và DISTRICT
Quan hệ giữa bảng WARD và DISTRICT
Quan hệ giữa bảng DISTRICT và CITY
Quan hệ giữa bảng DEPARTMENT và ROOM
Quan hệ giũa bảng OUTPATIENT và EXAMINATION
Quan hệ giữa bảng INPATIENT và ADMISSION
Quan hệ giữa bảng EXAMINATION và MEDICATION
Quan hệ giữa bảng MEDICATION và TREATMENT
Quan hệ giữa bảng TREATMENT và TREATMENT_STATUS
Quan hệ giữa bảng TREATMENT và ADMISSION
2.3.3 Các bảng dữ liệu vật lý
CREATE TABLE IF NOT EXISTS `springbootweb`.`cities` ( `city_id` INT NOT NULL AUTO_INCREMENT,
The database schema includes a `city_code` field of type VARCHAR(10) that cannot be null, ensuring each city has a unique identifier The `city_name` field, which is a VARCHAR(100), also cannot be null and stores the name of the city An optional `index_id` field of type INT is included, allowing for indexing purposes Additionally, there are two BIT(1) fields: `is_active`, which indicates whether the city is currently active, and `is_delete`, which shows if the city has been marked for deletion The primary key for this table is defined as `city_id`, ensuring unique identification for each city record.
ENGINE = InnoDB DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`districts` (
Hình 2 Mô hình quan hệ
`district_id` INT NOT NULL AUTO_INCREMENT, `district_code` VARCHAR(10) NOT NULL,
`district_name` VARCHAR(100) NOT NULL, `city_id` INT NULL DEFAULT NULL,
`order_id` INT NULL DEFAULT NULL, `dan_so` INT NULL DEFAULT NULL, `is_active` BIT(1) NULL DEFAULT NULL, `is_delete` BIT(1) NULL DEFAULT NULL, PRIMARY KEY (`district_id`),
INDEX `FK3g7x8w4lc7qxth7ibrr5j73mn` (`city_id` ASC) , CONSTRAINT `FK3g7x8w4lc7qxth7ibrr5j73mn`
FOREIGN KEY (`city_id`) REFERENCES `springbootweb`.`cities` (`city_id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`wards` ( `ward_id` INT NOT NULL AUTO_INCREMENT,
The database schema includes a `ward_code` and `ward_name`, both defined as VARCHAR(255) and marked as NOT NULL Additionally, it features a `district_id` as an INT that can be NULL, along with two BIT(1) fields, `is_active` and `is_delete`, both of which can also be NULL An `order_id` INT field is included, which can be NULL as well The primary key for this table is designated as `ward_id`.
INDEX `FKfjqt744bo800mb5uax74lav8k` (`district_id` ASC) , CONSTRAINT `FKfjqt744bo800mb5uax74lav8k`
FOREIGN KEY (`district_id`)REFERENCES `springbootweb`.`districts` (`district_id`))
ENGINE = InnoDB DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`employee` (
`id` INT NOT NULL AUTO_INCREMENT, `first_name` VARCHAR(255) NOT NULL, `code` VARCHAR(255) NOT NULL,
`last_name` VARCHAR(255) NOT NULL, `dob` DATE NOT NULL,
`gender` VARCHAR(255) NOT NULL, `phone_number` VARCHAR(255) NOT NULL, `department_id` INT NOT NULL,
`street` VARCHAR(255) NOT NULL, `city_id` INT NULL DEFAULT NULL, `district_id` INT NULL DEFAULT NULL, `ward_id` INT NULL DEFAULT NULL, `degree_year` INT NOT NULL,
The article outlines a database schema featuring a `start_date` that is mandatory, a `specialty` field with a maximum length of 255 characters, and an optional `user_id` that defaults to NULL It includes an `is_active` status, defaulting to '1', indicating active records, alongside timestamps for `created_at` that can also be NULL The `created_by` field captures the creator's identity, while the `is_deleted` flag, defaulting to '0', signifies that the record is not marked as deleted.
`updated_at` DATETIME(6) NULL DEFAULT NULL, `updated_by` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`id`),
UNIQUE INDEX `UKnbyivu8qgmx0r7wtbplf01gf8` (`code` ASC) VISIBLE,
UNIQUE INDEX `phone_number_UNIQUE` (`phone_number` ASC) VISIBLE,
UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC) VISIBLE,
INDEX `FKigbpniownw9b9to1b3ovhd70f` (`city_id` ASC) VISIBLE,
INDEX `FKbejtwvg9bxus2mffsm3swj3u9` (`department_id` ASC) VISIBLE,
INDEX `FK7gt4p8et7e09w4odi5ajoyw0r` (`district_id` ASC) VISIBLE,
INDEX `FKhoyb92v8jphc9pf5bv9ns4jh7` (`ward_id` ASC) VISIBLE,
CONSTRAINT `FK7gt4p8et7e09w4odi5ajoyw0r`
FOREIGN KEY (`district_id`) REFERENCES `springbootweb`.`districts` (`district_id`), CONSTRAINT `FKbejtwvg9bxus2mffsm3swj3u9`
FOREIGN KEY (`department_id`) REFERENCES `springbootweb`.`department` (`id`), CONSTRAINT `FKhal2duyxxjtadykhxos7wd3wg`
FOREIGN KEY (`user_id`) REFERENCES `springbootweb`.`users` (`id`), CONSTRAINT `FKhoyb92v8jphc9pf5bv9ns4jh7`
FOREIGN KEY (`ward_id`) REFERENCES `springbootweb`.`wards` (`ward_id`), CONSTRAINT `FKigbpniownw9b9to1b3ovhd70f`
FOREIGN KEY (`city_id`) REFERENCES `springbootweb`.`cities` (`city_id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`doctor` ( `id` INT NOT NULL,
PRIMARY KEY (`id`), CONSTRAINT `FKrelirtfpv90ue5n7jismnxf6`
FOREIGN KEY (`id`) REFERENCES `springbootweb`.`employee` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`nurse` ( `id` INT NOT NULL,
PRIMARY KEY (`id`), CONSTRAINT `FK4tfs9a53fmepirsr30a931dqd`
FOREIGN KEY (`id`) REFERENCES `springbootweb`.`employee` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS
`id` INT NOT NULL AUTO_INCREMENT, `code` VARCHAR(255) NOT NULL,
`doctor_id` INT NOT NULL, `title` VARCHAR(255) NOT NULL, `created_at` DATETIME(6) NULL DEFAULT NULL, `created_by` VARCHAR(255) NULL DEFAULT NULL, `is_deleted` TINYINT(1) NULL DEFAULT '0',
`is_active` TINYINT(1) NULL DEFAULT '1', `updated_at` DATETIME(6) NULL DEFAULT NULL, `updated_by` VARCHAR(255) NULL DEFAULT NULL,PRIMARY KEY (`id`),
UNIQUE INDEX `UKq8ymhgj6pt1msox0o3bg51uvo` (`code` ASC) VISIBLE,
UNIQUE INDEX `doctor_id_UNIQUE` (`doctor_id` ASC) VISIBLE,
INDEX `FKg72fcdoas3uuljy08ugxafh6b_idx` (`doctor_id` ASC) VISIBLE,
CONSTRAINT `FKg72fcdoas3uuljy08ugxafh6b`
FOREIGN KEY (`doctor_id`) REFERENCES `springbootweb`.`doctor` (`id`)
ON UPDATE NO ACTION) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci
CREATE TABLE IF NOT EXISTS `springbootweb`.`room` ( `room_no` INT NOT NULL AUTO_INCREMENT,
`capacity` INT NOT NULL, `room_name` VARCHAR(255) NOT NULL, `depart_id` INT NOT NULL,
INDEX `FKaq2gdhj8qswr3b1l40qu9wlt` (`depart_id` ASC) VISIBLE,
CONSTRAINT `FKaq2gdhj8qswr3b1l40qu9wlt`
FOREIGN KEY (`depart_id`) REFERENCES `springbootweb`.`department` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci
CREATE TABLE IF NOT EXISTS `springbootweb`.`users` ( `id` INT NOT NULL AUTO_INCREMENT,
`created_at` DATETIME(6) NULL DEFAULT NULL, `created_by` VARCHAR(255) NULL DEFAULT NULL, `updated_at` DATETIME(6) NULL DEFAULT NULL, `updated_by` VARCHAR(255) NULL DEFAULT NULL, `password` VARCHAR(255) NOT NULL,
`username` VARCHAR(255) NOT NULL, `role_id` BIGINT NOT NULL,
`is_active` TINYINT(1) NULL DEFAULT '1', `is_deleted` TINYINT(1) NULL DEFAULT '0', PRIMARY KEY (`id`),
UNIQUE INDEX `UKr43af9ap4edm43mmtq01oddj6`
INDEX `FKp56c1712k691lhsyewcssf40f` (`role_id` ASC) VISIBLE,
FOREIGN KEY (`role_id`) REFERENCES `springbootweb`.`roles` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS
`user_id` INT NOT NULL,
`role_id` BIGINT NOT NULL,
INDEX `FKh8ciramu9cc9q3qcqiv4ue8a6` (`role_id` ASC) VISIBLE,
INDEX `FKhfh9dx7w3ubf1co1vdev94g3f` (`user_id` ASC) VISIBLE,
CONSTRAINT `FKh8ciramu9cc9q3qcqiv4ue8a6`
FOREIGN KEY (`role_id`)REFERENCES `springbootweb`.`roles` (`id`),
CONSTRAINT `FKhfh9dx7w3ubf1co1vdev94g3f`
FOREIGN KEY (`user_id`) REFERENCES `springbootweb`.`users` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`roles` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`code` VARCHAR(255) NULL DEFAULT NULL,
`name` VARCHAR(20) NULL DEFAULT NULL, PRIMARY KEY (`id`))
ENGINE = InnoDB DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`provider` (
`id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(100) NOT NULL, `phone_number` VARCHAR(15) NOT NULL, `street` VARCHAR(255) NULL DEFAULT NULL, `city_id` INT NULL DEFAULT NULL,
`district_id` INT NULL DEFAULT NULL, `ward_id` INT NULL DEFAULT NULL, PRIMARY KEY (`id`),
UNIQUE INDEX `phone_number_UNIQUE` (`phone_number` ASC) VISIBLE,
INDEX `FKm2vw1d8gnc9wjjms3kgb27tth` (`city_id` ASC) VISIBLE,
INDEX `FKfljklwi6pe8psf3fmy78sdkm4` (`district_id` ASC) VISIBLE,
INDEX `FKk6g5t4ug48vmhajwsu6qgb1oc` (`ward_id` ASC) VISIBLE,
CONSTRAINT `FKfljklwi6pe8psf3fmy78sdkm4`
FOREIGN KEY (`district_id`) REFERENCES `springbootweb`.`districts` (`district_id`), CONSTRAINT `FKk6g5t4ug48vmhajwsu6qgb1oc`
FOREIGN KEY (`ward_id`) REFERENCES `springbootweb`.`wards` (`ward_id`), CONSTRAINT `FKm2vw1d8gnc9wjjms3kgb27tth`
FOREIGN KEY (`city_id`) REFERENCES `springbootweb`.`cities` (`city_id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS
`id` INT NOT NULL AUTO_INCREMENT, `code` VARCHAR(255) NOT NULL,
`effect` VARCHAR(255) NULL DEFAULT NULL, `name` VARCHAR(255) NOT NULL,
The database schema includes a `price` field defined as DECIMAL(10,0) that can be null, and an `expiration_date` field set to DATETIME(6) which is mandatory Additionally, there is an `is_active` field represented as TINYINT(1) with a default value of '1', indicating active status The `created_at` field, also of type DATETIME(6), can be null, while the `created_by` field is a VARCHAR(255) that may also be null Lastly, the `is_deleted` field, a TINYINT(1), has a default value of '0', signifying that the record is not marked as deleted.
`updated_at` DATETIME(6) NULL DEFAULT NULL, `updated_by` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`id`))
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS
`id` INT NOT NULL AUTO_INCREMENT, `medication_id` INT NULL DEFAULT NULL, `provider_id` INT NULL DEFAULT NULL, `import_date` DATE NOT NULL,
`price` DECIMAL(10,0) NULL DEFAULT NULL, `quantity` INT NOT NULL,
INDEX `FK48lhp4h2kyslsajh4xvxaqo09` (`medication_id` ASC) VISIBLE,
INDEX `FKtmv7q257u0veqcoivjhymp9do` (`provider_id` ASC) VISIBLE,
CONSTRAINT `FK48lhp4h2kyslsajh4xvxaqo09`
FOREIGN KEY (`medication_id`) REFERENCES `springbootweb`.`medication` (`id`), CONSTRAINT `FKtmv7q257u0veqcoivjhymp9do`
FOREIGN KEY (`provider_id`) REFERENCES `springbootweb`.`provider` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`patient` ( `id` INT NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(100) NOT NULL, `last_name` VARCHAR(100) NOT NULL, `dob` DATETIME(6) NOT NULL,
`phone_number` VARCHAR(15) NOT NULL, `street` VARCHAR(255) NULL DEFAULT NULL, `city_id` INT NULL DEFAULT NULL,
The database schema includes several fields: `district_id` and `ward_id`, both of which are integers that can be null; `is_active`, a tiny integer defaulting to '1', indicating the active status; `created_at`, a datetime field that can also be null; `created_by`, a variable character field for the creator's information; and `is_deleted`, another tiny integer defaulting to '0', signifying whether the record is marked as deleted.
`updated_at` DATETIME(6) NULL DEFAULT NULL, `updated_by` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`id`),
UNIQUE INDEX `phone_number_UNIQUE` (`phone_number` ASC) VISIBLE,
INDEX `FK3p23hjvxtxe57ugwvsy6ivh92` (`city_id` ASC) VISIBLE,
INDEX `FKecmsmj368p8xa6kww88avfydb` (`district_id` ASC) VISIBLE,
INDEX `FKhu4y2d0sp61b15h157oac75gu` (`ward_id` ASC) VISIBLE,
CONSTRAINT `FK3p23hjvxtxe57ugwvsy6ivh92`
FOREIGN KEY (`city_id`) REFERENCES `springbootweb`.`cities` (`city_id`), CONSTRAINT `FKecmsmj368p8xa6kww88avfydb`
FOREIGN KEY (`district_id`) REFERENCES `springbootweb`.`districts` (`district_id`), CONSTRAINT `FKhu4y2d0sp61b15h157oac75gu`
FOREIGN KEY (`ward_id`) REFERENCES `springbootweb`.`wards` (`ward_id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `springbootweb`.`outpatient` (
`outpatient_id` INT NOT NULL, `code` VARCHAR(255) NOT NULL, PRIMARY KEY (`outpatient_id`),
UNIQUE INDEX `UK3p4vdug63i3lc1ec8vpbjo3ad` (`outpatient_id` ASC) VISIBLE,
UNIQUE INDEX `UK2d0xyfidcu83w1id5urjc1lvc` (`code` ASC) VISIBLE,
CONSTRAINT `FKbd9if9wnp1oo90bxb7p7jqw0v`
FOREIGN KEY (`outpatient_id`) REFERENCES `springbootweb`.`patient` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci
CREATE TABLE IF NOT EXISTS `springbootweb`.`inpatient` ( `inpatient_id` INT NOT NULL,
UNIQUE INDEX `UKabm58ulfh4gmba7vx67olptso` (`code` ASC) VISIBLE,
UNIQUE INDEX `UKgho72eorxryfvwu73mhn829ul` (`inpatient_id` ASC) VISIBLE,
PRIMARY KEY (`inpatient_id`), CONSTRAINT `FKpoxe9v7py2yu4tg7wkete1ds0`
FOREIGN KEY (`inpatient_id`) REFERENCES `springbootweb`.`patient` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4COLLATE = utf8mb4_0900_ai_ci
CREATE TABLE IF NOT EXISTS
`id` INT NOT NULL AUTO_INCREMENT, `inpatient_id` INT NOT NULL,
`doctor_id` INT NOT NULL, `nurse_id` INT NOT NULL, `date_admission` DATE NOT NULL, `date_of_discharge` DATE NULL DEFAULT NULL, `sickroom` INT NOT NULL,
`diagnosis` VARCHAR(255) NULL DEFAULT NULL, `fee` DECIMAL(10,0) NULL DEFAULT NULL,
`is_active` TINYINT(1) NULL DEFAULT '1', `created_at` DATETIME(6) NULL DEFAULT NULL, `created_by` VARCHAR(255) NULL DEFAULT NULL, `is_deleted` TINYINT(1) NULL DEFAULT '0',
`updated_at` DATETIME(6) NULL DEFAULT NULL, `updated_by` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`id`),
INDEX `FKqi7hetb5f8mblyma0kd4b6j4b` (`doctor_id` ASC) VISIBLE,
INDEX `FKgo4a2vbdyxreucinq0icht5a7` (`nurse_id` ASC) VISIBLE,
INDEX `FKbnsahcpmnxnyt38dyeiq78d7w` (`sickroom` ASC) VISIBLE,
INDEX `FKqok0a3c272u0ysu3g3yacu2g5` (`inpatient_id` ASC) VISIBLE,
FOREIGN KEY (`sickroom`) REFERENCES `springbootweb`.`room` (`room_no`), CONSTRAINT `FKgo4a2vbdyxreucinq0icht5a7`
REFERENCES `springbootweb`.`nurse` (`id`), CONSTRAINT `FKqi7hetb5f8mblyma0kd4b6j4b`
FOREIGN KEY (`doctor_id`) REFERENCES `springbootweb`.`doctor` (`id`), CONSTRAINT `FKqok0a3c272u0ysu3g3yacu2g5`
FOREIGN KEY (`inpatient_id`) REFERENCES `springbootweb`.`inpatient` (`inpatient_id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci
CREATE TABLE IF NOT EXISTS
`id` INT NOT NULL AUTO_INCREMENT, `admission_id` INT NOT NULL,
`start_date` DATETIME(6) NOT NULL, `end_date` DATETIME(6) NULL DEFAULT NULL, `medications` VARCHAR(255) NULL DEFAULT NULL, `description` VARCHAR(255) NULL DEFAULT NULL, `status_id` INT NOT NULL,
`is_active` TINYINT(1) NULL DEFAULT '1', `created_at` DATETIME(6) NULL DEFAULT NULL, `created_by` VARCHAR(255) NULL DEFAULT NULL, `is_deleted` TINYINT(1) NULL DEFAULT '0',
`updated_at` DATETIME(6) NULL DEFAULT NULL, `updated_by` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`id`),
INDEX `FKih4ajhu5b823exgtrcg4l93yh` (`admission_id` ASC) VISIBLE,
INDEX `FKnx26bvprcw7r1btbee80c2hhg` (`status_id` ASC) VISIBLE,
CONSTRAINT `FKih4ajhu5b823exgtrcg4l93yh`
FOREIGN KEY (`admission_id`) REFERENCES `springbootweb`.`admission` (`id`), CONSTRAINT `FKnx26bvprcw7r1btbee80c2hhg`
FOREIGN KEY (`status_id`) REFERENCES `springbootweb`.`treatment_status` (`id`)) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci
(constain kiểm tra ngày) ALTER TABLE treatment ADD CONSTRAINT chk_treatment_dates CHECK (start_date