From 9e28ac99e24309aed1263f0aab977c5c53580fbb Mon Sep 17 00:00:00 2001 From: Kamida <2379674377@qq.com> Date: Mon, 23 Dec 2024 11:02:20 +0800 Subject: [PATCH] v1.1 --- .../项目所需数据库文件/hms.sql | 673 ++++++++++++++++++ 1 file changed, 673 insertions(+) create mode 100644 医院管理系统/项目所需数据库文件/hms.sql diff --git a/医院管理系统/项目所需数据库文件/hms.sql b/医院管理系统/项目所需数据库文件/hms.sql new file mode 100644 index 0000000..3287468 --- /dev/null +++ b/医院管理系统/项目所需数据库文件/hms.sql @@ -0,0 +1,673 @@ +/* + Navicat Premium Data Transfer + + Source Server : openGauss + Source Server Type : PostgreSQL + Source Server Version : 90204 (90204) + Source Host : 192.168.161.128:5432 + Source Catalog : hms + Source Schema : public + + Target Server Type : PostgreSQL + Target Server Version : 90204 (90204) + File Encoding : 65001 + + Date: 23/12/2024 10:56:16 +*/ + + +-- ---------------------------- +-- Sequence structure for admin_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."admin_id_seq"; +CREATE SEQUENCE "public"."admin_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for department_department_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."department_department_id_seq"; +CREATE SEQUENCE "public"."department_department_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for doctor_doctor_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."doctor_doctor_id_seq"; +CREATE SEQUENCE "public"."doctor_doctor_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for doctor_login_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."doctor_login_id_seq"; +CREATE SEQUENCE "public"."doctor_login_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for medical_record_record_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."medical_record_record_id_seq"; +CREATE SEQUENCE "public"."medical_record_record_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for medication_medication_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."medication_medication_id_seq"; +CREATE SEQUENCE "public"."medication_medication_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for order_order_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."order_order_id_seq"; +CREATE SEQUENCE "public"."order_order_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for patient_login_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."patient_login_id_seq"; +CREATE SEQUENCE "public"."patient_login_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for patient_patient_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."patient_patient_id_seq"; +CREATE SEQUENCE "public"."patient_patient_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for prescription_prescription_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."prescription_prescription_id_seq"; +CREATE SEQUENCE "public"."prescription_prescription_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for ward_ward_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."ward_ward_id_seq"; +CREATE SEQUENCE "public"."ward_ward_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Table structure for admin +-- ---------------------------- +DROP TABLE IF EXISTS "public"."admin"; +CREATE TABLE "public"."admin" ( + "id" int4 NOT NULL DEFAULT nextval('admin_id_seq'::regclass), + "username" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, + "password" varchar(255) COLLATE "pg_catalog"."default" NOT NULL +) +; + +-- ---------------------------- +-- Records of admin +-- ---------------------------- +INSERT INTO "public"."admin" VALUES (1, 'admin', '123456'); + +-- ---------------------------- +-- Table structure for department +-- ---------------------------- +DROP TABLE IF EXISTS "public"."department"; +CREATE TABLE "public"."department" ( + "department_id" int4 NOT NULL DEFAULT nextval('department_department_id_seq'::regclass), + "department_name" varchar(100) COLLATE "pg_catalog"."default" NOT NULL, + "location" varchar(100) COLLATE "pg_catalog"."default" +) +; + +-- ---------------------------- +-- Records of department +-- ---------------------------- +INSERT INTO "public"."department" VALUES (1, '内科', '1楼'); +INSERT INTO "public"."department" VALUES (2, '外科', '2楼'); +INSERT INTO "public"."department" VALUES (3, '儿科', '3楼'); +INSERT INTO "public"."department" VALUES (4, '妇产科', '4楼'); +INSERT INTO "public"."department" VALUES (5, '眼科', '5楼'); +INSERT INTO "public"."department" VALUES (6, '牙科', '6楼'); +INSERT INTO "public"."department" VALUES (7, '精神科', '7楼'); +INSERT INTO "public"."department" VALUES (8, '皮肤科', '8楼'); +INSERT INTO "public"."department" VALUES (9, '耳鼻喉科', '9楼'); +INSERT INTO "public"."department" VALUES (10, '肿瘤科', '10楼'); + +-- ---------------------------- +-- Table structure for doctor +-- ---------------------------- +DROP TABLE IF EXISTS "public"."doctor"; +CREATE TABLE "public"."doctor" ( + "doctor_id" int4 NOT NULL DEFAULT nextval('doctor_doctor_id_seq'::regclass), + "name" varchar(100) COLLATE "pg_catalog"."default" NOT NULL, + "phone_number" varchar(15) COLLATE "pg_catalog"."default", + "email" varchar(100) COLLATE "pg_catalog"."default", + "years_of_experience" int4, + "department_id" int4 +) +; + +-- ---------------------------- +-- Records of doctor +-- ---------------------------- +INSERT INTO "public"."doctor" VALUES (2, '张世鹏', '202211070128', 'wangwu@hospital.com', 8, 2); +INSERT INTO "public"."doctor" VALUES (3, '赵六', '13900000003', 'zhaoliu@hospital.com', 12, 3); +INSERT INTO "public"."doctor" VALUES (5, '周八', '13900000005', 'zhouba@hospital.com', 7, 5); +INSERT INTO "public"."doctor" VALUES (7, '吴十', '13900000007', 'wushi@hospital.com', 4, 7); +INSERT INTO "public"."doctor" VALUES (8, '郑十一', '13900000008', 'zheng11@hospital.com', 11, 8); +INSERT INTO "public"."doctor" VALUES (9, '冯十二', '13900000009', 'feng12@hospital.com', 5, 9); +INSERT INTO "public"."doctor" VALUES (10, '杨十三', '13900000010', 'yang13@hospital.com', 15, 10); +INSERT INTO "public"."doctor" VALUES (6, '钱九', '13900000006', 'qianjiu@hospital.com', 9, 6); +INSERT INTO "public"."doctor" VALUES (1, '徐圣源', '202211070123', 'lisi@hospital.com', 10, 1); +INSERT INTO "public"."doctor" VALUES (4, '孙七', '13900000004', 'sunqi@hospital.com', 6, 4); +INSERT INTO "public"."doctor" VALUES (11, '小红', '13900000011', 'yang@hospital.com', 7, 2); +INSERT INTO "public"."doctor" VALUES (12, '小明', '13900000012', 'yang@hosl.com', 7, 4); +INSERT INTO "public"."doctor" VALUES (13, '小白', '13900000013', 'yang@.com', 11, 4); + +-- ---------------------------- +-- Table structure for doctor_user +-- ---------------------------- +DROP TABLE IF EXISTS "public"."doctor_user"; +CREATE TABLE "public"."doctor_user" ( + "id" int4 NOT NULL DEFAULT nextval('doctor_login_id_seq'::regclass), + "username" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, + "password" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, + "doctor_id" int4 +) +; + +-- ---------------------------- +-- Records of doctor_user +-- ---------------------------- +INSERT INTO "public"."doctor_user" VALUES (1, '徐圣源', '123456', 1); + +-- ---------------------------- +-- Table structure for medical_record +-- ---------------------------- +DROP TABLE IF EXISTS "public"."medical_record"; +CREATE TABLE "public"."medical_record" ( + "record_id" int4 NOT NULL DEFAULT nextval('medical_record_record_id_seq'::regclass), + "patient_id" int4, + "doctor_id" int4, + "visit_date" timestamp(0) NOT NULL, + "diagnosis" text COLLATE "pg_catalog"."default", + "treatment_plan" text COLLATE "pg_catalog"."default" +) +; + +-- ---------------------------- +-- Records of medical_record +-- ---------------------------- +INSERT INTO "public"."medical_record" VALUES (1, 1, 1, '2024-12-21 00:00:00', '感冒', '服用抗生素治疗,注意休息和多喝水'); +INSERT INTO "public"."medical_record" VALUES (2, 2, 2, '2024-12-21 00:00:00', '体检', '抽血检查、胸透检查,结果良好'); +INSERT INTO "public"."medical_record" VALUES (3, 3, 3, '2024-12-20 00:00:00', '流感', '服用抗病毒药物,继续休息,多喝水'); +INSERT INTO "public"."medical_record" VALUES (4, 4, 4, '2024-12-19 00:00:00', '手术前准备', '手术前身体检查,确认适合手术'); +INSERT INTO "public"."medical_record" VALUES (5, 5, 5, '2024-12-18 00:00:00', '腰部疼痛', '开具止痛药,建议理疗治疗'); +INSERT INTO "public"."medical_record" VALUES (6, 6, 6, '2024-12-17 00:00:00', '肺部疾病', '胸部CT检查显示轻度肺炎,开始治疗'); +INSERT INTO "public"."medical_record" VALUES (7, 7, 7, '2024-12-16 00:00:00', '发热', '开具退烧药,建议卧床休息'); +INSERT INTO "public"."medical_record" VALUES (8, 8, 8, '2024-12-15 00:00:00', '胃部不适', '做胃镜检查,排除胃病,服用胃药'); +INSERT INTO "public"."medical_record" VALUES (9, 9, 9, '2024-12-14 00:00:00', '急性咽炎', '抗生素治疗,注意嗓子保护'); +INSERT INTO "public"."medical_record" VALUES (10, 10, 10, '2024-12-21 00:00:00', '过敏反应严重', '开具抗过敏药物,避免接触过敏源'); +INSERT INTO "public"."medical_record" VALUES (13, 10, 10, '2024-12-22 00:00:00', '好', '好'); +INSERT INTO "public"."medical_record" VALUES (15, 10, 8, '2024-12-22 00:00:00', '好', '非常好'); + +-- ---------------------------- +-- Table structure for medication +-- ---------------------------- +DROP TABLE IF EXISTS "public"."medication"; +CREATE TABLE "public"."medication" ( + "medication_id" int4 NOT NULL DEFAULT nextval('medication_medication_id_seq'::regclass), + "name" varchar(100) COLLATE "pg_catalog"."default" NOT NULL, + "dosage" varchar(50) COLLATE "pg_catalog"."default", + "unit_price" numeric(10,2), + "stock_quantity" int4, + "expiration_date" timestamp(0) +) +; + +-- ---------------------------- +-- Records of medication +-- ---------------------------- +INSERT INTO "public"."medication" VALUES (1, '阿莫西林', '250mg', 30.50, 200, '2024-12-31 00:00:00'); +INSERT INTO "public"."medication" VALUES (2, '布洛芬', '200mg', 25.00, 150, '2024-09-30 00:00:00'); +INSERT INTO "public"."medication" VALUES (3, '洛伐他汀', '20mg', 80.00, 100, '2025-05-20 00:00:00'); +INSERT INTO "public"."medication" VALUES (4, '氯氮平', '50mg', 55.75, 50, '2024-06-15 00:00:00'); +INSERT INTO "public"."medication" VALUES (5, '阿司匹林', '100mg', 15.00, 300, '2025-03-10 00:00:00'); +INSERT INTO "public"."medication" VALUES (6, '钙片', '500mg', 10.00, 400, '2025-08-15 00:00:00'); +INSERT INTO "public"."medication" VALUES (7, '甘草片', '100mg', 20.00, 180, '2024-11-01 00:00:00'); +INSERT INTO "public"."medication" VALUES (8, '维生素C', '500mg', 12.00, 500, '2025-07-25 00:00:00'); +INSERT INTO "public"."medication" VALUES (9, '卡托普利', '25mg', 40.00, 250, '2024-12-10 00:00:00'); +INSERT INTO "public"."medication" VALUES (10, '盐酸二氢吡啶', '20mg', 18.50, 120, '2025-02-05 00:00:00'); + +-- ---------------------------- +-- Table structure for order +-- ---------------------------- +DROP TABLE IF EXISTS "public"."order"; +CREATE TABLE "public"."order" ( + "order_id" int4 NOT NULL DEFAULT nextval('order_order_id_seq'::regclass), + "prescription_id" int4, + "doctor_id" int4, + "patient_id" int4, + "order_date" timestamp(0) NOT NULL, + "order_type" varchar(50) COLLATE "pg_catalog"."default", + "order_details" text COLLATE "pg_catalog"."default", + "status" varchar(20) COLLATE "pg_catalog"."default" +) +; + +-- ---------------------------- +-- Records of order +-- ---------------------------- +INSERT INTO "public"."order" VALUES (1, 1, 1, 1, '2024-12-21 00:00:00', 'Medication', '服用抗生素治疗感冒,持续5天', 'Active'); +INSERT INTO "public"."order" VALUES (2, 2, 2, 2, '2024-12-21 00:00:00', 'Treatment', '进行体检,抽血化验', 'Active'); +INSERT INTO "public"."order" VALUES (3, 3, 3, 3, '2024-12-20 00:00:00', 'Medication', '服用抗病毒药物治疗流感,持续7天', 'Active'); +INSERT INTO "public"."order" VALUES (4, 4, 4, 4, '2024-12-19 00:00:00', 'Procedure', '准备手术,清洁手术部位', 'Active'); +INSERT INTO "public"."order" VALUES (5, 5, 5, 5, '2024-12-18 00:00:00', 'Medication', '服用止痛药缓解疼痛,持续3天', 'Active'); +INSERT INTO "public"."order" VALUES (6, 6, 6, 6, '2024-12-17 00:00:00', 'Treatment', '做胸部CT检查,检查肺部健康', 'Completed'); +INSERT INTO "public"."order" VALUES (7, 7, 7, 7, '2024-12-16 00:00:00', 'Medication', '服用退烧药物,持续3天', 'Completed'); +INSERT INTO "public"."order" VALUES (8, 8, 8, 8, '2024-12-15 00:00:00', 'Procedure', '做胃镜检查,排除胃部疾病', 'Cancelled'); +INSERT INTO "public"."order" VALUES (9, 9, 9, 9, '2024-12-14 00:00:00', 'Treatment', '进行抗生素治疗,缓解感染症状', 'Active'); +INSERT INTO "public"."order" VALUES (10, 10, 10, 10, '2024-12-13 00:00:00', 'Medication', '服用抗过敏药物,缓解过敏反应', 'Active'); + +-- ---------------------------- +-- Table structure for patient +-- ---------------------------- +DROP TABLE IF EXISTS "public"."patient"; +CREATE TABLE "public"."patient" ( + "patient_id" int4 NOT NULL DEFAULT nextval('patient_patient_id_seq'::regclass), + "name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL, + "gender" char(1) COLLATE "pg_catalog"."default", + "birthdate" timestamp(0) NOT NULL, + "contact_number" varchar(15) COLLATE "pg_catalog"."default", + "address" varchar(100) COLLATE "pg_catalog"."default", + "insurance_id" varchar(50) COLLATE "pg_catalog"."default" NOT NULL, + "attending_doctor_id" int4, + "visit_type" varchar(20) COLLATE "pg_catalog"."default" +) +; + +-- ---------------------------- +-- Records of patient +-- ---------------------------- +INSERT INTO "public"."patient" VALUES (2, '张世鹏', 'M', '2004-07-15 00:00:00', '202211070123', '山东科技大学', 'INS1234567891', 2, 'Outpatient'); +INSERT INTO "public"."patient" VALUES (3, '王五', 'M', '1982-10-22 00:00:00', '13900000003', '北京市昌平区', 'INS1234567892', 1, 'Inpatient'); +INSERT INTO "public"."patient" VALUES (4, '赵六', 'F', '1979-12-30 00:00:00', '13900000004', '北京市东城区', 'INS1234567893', 3, 'Outpatient'); +INSERT INTO "public"."patient" VALUES (5, '孙七', 'M', '1995-02-18 00:00:00', '13900000005', '北京市丰台区', 'INS1234567894', 4, 'Inpatient'); +INSERT INTO "public"."patient" VALUES (6, '周八', 'F', '1988-05-10 00:00:00', '13900000006', '北京市西城区', 'INS1234567895', 1, 'Outpatient'); +INSERT INTO "public"."patient" VALUES (7, '钱九', 'M', '1975-08-25 00:00:00', '13900000007', '北京市石景山区', 'INS1234567896', 2, 'Inpatient'); +INSERT INTO "public"."patient" VALUES (8, '吴十', 'F', '1998-01-01 00:00:00', '13900000008', '北京市通州区', 'INS1234567897', 3, 'Outpatient'); +INSERT INTO "public"."patient" VALUES (9, '郑十一', 'M', '1984-06-15 00:00:00', '13900000009', '北京市朝阳区', 'INS1234567898', 1, 'Inpatient'); +INSERT INTO "public"."patient" VALUES (10, '冯十二', 'F', '1993-11-20 00:00:00', '13900000010', '北京市怀柔区', 'INS1234567899', 4, 'Outpatient'); +INSERT INTO "public"."patient" VALUES (1, '徐圣源', 'M', '2004-03-25 00:00:00', '202211070123', '山东科技大学', 'INS1234567890', 1, 'Outpatient'); + +-- ---------------------------- +-- Table structure for patient_user +-- ---------------------------- +DROP TABLE IF EXISTS "public"."patient_user"; +CREATE TABLE "public"."patient_user" ( + "id" int4 NOT NULL DEFAULT nextval('patient_login_id_seq'::regclass), + "username" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, + "password" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, + "patient_id" int4 +) +; + +-- ---------------------------- +-- Records of patient_user +-- ---------------------------- +INSERT INTO "public"."patient_user" VALUES (1, '张世鹏', '123456', 2); + +-- ---------------------------- +-- Table structure for prescription +-- ---------------------------- +DROP TABLE IF EXISTS "public"."prescription"; +CREATE TABLE "public"."prescription" ( + "prescription_id" int4 NOT NULL DEFAULT nextval('prescription_prescription_id_seq'::regclass), + "doctor_id" int4, + "patient_id" int4, + "prescription_date" timestamp(0) NOT NULL, + "total_amount" numeric(10,2), + "medication_id" int4 +) +; + +-- ---------------------------- +-- Records of prescription +-- ---------------------------- +INSERT INTO "public"."prescription" VALUES (1, 1, 1, '2024-12-21 00:00:00', 150.00, 2); +INSERT INTO "public"."prescription" VALUES (2, 2, 2, '2024-12-21 00:00:00', 200.00, 3); +INSERT INTO "public"."prescription" VALUES (3, 3, 3, '2024-12-20 00:00:00', 180.00, 4); +INSERT INTO "public"."prescription" VALUES (4, 4, 4, '2024-12-19 00:00:00', 120.00, 1); +INSERT INTO "public"."prescription" VALUES (5, 5, 5, '2024-12-18 00:00:00', 250.00, 5); +INSERT INTO "public"."prescription" VALUES (6, 6, 6, '2024-12-17 00:00:00', 160.00, 2); +INSERT INTO "public"."prescription" VALUES (7, 7, 7, '2024-12-16 00:00:00', 210.00, 3); +INSERT INTO "public"."prescription" VALUES (8, 8, 8, '2024-12-15 00:00:00', 190.00, 4); +INSERT INTO "public"."prescription" VALUES (9, 9, 9, '2024-12-14 00:00:00', 130.00, 1); +INSERT INTO "public"."prescription" VALUES (10, 10, 10, '2024-12-13 00:00:00', 220.00, 5); + +-- ---------------------------- +-- Table structure for ward +-- ---------------------------- +DROP TABLE IF EXISTS "public"."ward"; +CREATE TABLE "public"."ward" ( + "ward_id" int4 NOT NULL DEFAULT nextval('ward_ward_id_seq'::regclass), + "total_beds" int4, + "available_beds" int4, + "department_id" int4 +) +; + +-- ---------------------------- +-- Records of ward +-- ---------------------------- +INSERT INTO "public"."ward" VALUES (1, 20, 5, 1); +INSERT INTO "public"."ward" VALUES (2, 100, 50, 2); +INSERT INTO "public"."ward" VALUES (3, 15, 3, 3); +INSERT INTO "public"."ward" VALUES (4, 50, 25, 4); +INSERT INTO "public"."ward" VALUES (5, 30, 10, 5); +INSERT INTO "public"."ward" VALUES (6, 10, 5, 6); +INSERT INTO "public"."ward" VALUES (7, 20, 12, 7); +INSERT INTO "public"."ward" VALUES (8, 40, 20, 8); +INSERT INTO "public"."ward" VALUES (9, 35, 15, 9); +INSERT INTO "public"."ward" VALUES (10, 60, 30, 10); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."admin_id_seq" +OWNED BY "public"."admin"."id"; +SELECT setval('"public"."admin_id_seq"', 1, false); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."department_department_id_seq" +OWNED BY "public"."department"."department_id"; +SELECT setval('"public"."department_department_id_seq"', 10, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."doctor_doctor_id_seq" +OWNED BY "public"."doctor"."doctor_id"; +SELECT setval('"public"."doctor_doctor_id_seq"', 10, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."doctor_login_id_seq" +OWNED BY "public"."doctor_user"."id"; +SELECT setval('"public"."doctor_login_id_seq"', 1, false); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."medical_record_record_id_seq" +OWNED BY "public"."medical_record"."record_id"; +SELECT setval('"public"."medical_record_record_id_seq"', 15, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."medication_medication_id_seq" +OWNED BY "public"."medication"."medication_id"; +SELECT setval('"public"."medication_medication_id_seq"', 10, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."order_order_id_seq" +OWNED BY "public"."order"."order_id"; +SELECT setval('"public"."order_order_id_seq"', 10, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."patient_login_id_seq" +OWNED BY "public"."patient_user"."id"; +SELECT setval('"public"."patient_login_id_seq"', 1, false); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."patient_patient_id_seq" +OWNED BY "public"."patient"."patient_id"; +SELECT setval('"public"."patient_patient_id_seq"', 23, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."prescription_prescription_id_seq" +OWNED BY "public"."prescription"."prescription_id"; +SELECT setval('"public"."prescription_prescription_id_seq"', 10, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."ward_ward_id_seq" +OWNED BY "public"."ward"."ward_id"; +SELECT setval('"public"."ward_ward_id_seq"', 10, true); + +-- ---------------------------- +-- Primary Key structure for table admin +-- ---------------------------- +ALTER TABLE "public"."admin" ADD CONSTRAINT "admin_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table department +-- ---------------------------- +ALTER TABLE "public"."department" ADD CONSTRAINT "department_pkey" PRIMARY KEY ("department_id"); + +-- ---------------------------- +-- Indexes structure for table doctor +-- ---------------------------- +CREATE INDEX "idx_doctor_department_id" ON "public"."doctor" USING btree ( + "department_id" "pg_catalog"."int4_ops" ASC NULLS LAST +); +CREATE UNIQUE INDEX "idx_doctor_email" ON "public"."doctor" USING btree ( + "email" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Primary Key structure for table doctor +-- ---------------------------- +ALTER TABLE "public"."doctor" ADD CONSTRAINT "doctor_pkey" PRIMARY KEY ("doctor_id"); + +-- ---------------------------- +-- Uniques structure for table doctor_user +-- ---------------------------- +ALTER TABLE "public"."doctor_user" ADD CONSTRAINT "doctor_login_username_key" UNIQUE ("username"); + +-- ---------------------------- +-- Primary Key structure for table doctor_user +-- ---------------------------- +ALTER TABLE "public"."doctor_user" ADD CONSTRAINT "doctor_login_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table medical_record +-- ---------------------------- +CREATE INDEX "idx_medical_record_patient_id" ON "public"."medical_record" USING btree ( + "patient_id" "pg_catalog"."int4_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Primary Key structure for table medical_record +-- ---------------------------- +ALTER TABLE "public"."medical_record" ADD CONSTRAINT "medical_record_pkey" PRIMARY KEY ("record_id"); + +-- ---------------------------- +-- Indexes structure for table medication +-- ---------------------------- +CREATE INDEX "idx_medication_name" ON "public"."medication" USING btree ( + "name" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Primary Key structure for table medication +-- ---------------------------- +ALTER TABLE "public"."medication" ADD CONSTRAINT "medication_pkey" PRIMARY KEY ("medication_id"); + +-- ---------------------------- +-- Indexes structure for table order +-- ---------------------------- +CREATE INDEX "idx_order_patient_id" ON "public"."order" USING btree ( + "patient_id" "pg_catalog"."int4_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Checks structure for table order +-- ---------------------------- +ALTER TABLE "public"."order" ADD CONSTRAINT "order_order_type_check" CHECK (((order_type)::text = ANY ((ARRAY['Medication'::character varying, 'Treatment'::character varying, 'Procedure'::character varying])::text[]))); +ALTER TABLE "public"."order" ADD CONSTRAINT "order_status_check" CHECK (((status)::text = ANY ((ARRAY['Active'::character varying, 'Completed'::character varying, 'Cancelled'::character varying])::text[]))); + +-- ---------------------------- +-- Primary Key structure for table order +-- ---------------------------- +ALTER TABLE "public"."order" ADD CONSTRAINT "order_pkey" PRIMARY KEY ("order_id"); + +-- ---------------------------- +-- Indexes structure for table patient +-- ---------------------------- +CREATE UNIQUE INDEX "idx_patient_insurance_id" ON "public"."patient" USING btree ( + "insurance_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Uniques structure for table patient +-- ---------------------------- +ALTER TABLE "public"."patient" ADD CONSTRAINT "patient_insurance_id_key" UNIQUE ("insurance_id"); + +-- ---------------------------- +-- Checks structure for table patient +-- ---------------------------- +ALTER TABLE "public"."patient" ADD CONSTRAINT "patient_gender_check" CHECK ((gender = ANY (ARRAY['M'::bpchar, 'F'::bpchar]))); +ALTER TABLE "public"."patient" ADD CONSTRAINT "patient_visit_type_check" CHECK (((visit_type)::text = ANY ((ARRAY['Inpatient'::character varying, 'Outpatient'::character varying])::text[]))); + +-- ---------------------------- +-- Primary Key structure for table patient +-- ---------------------------- +ALTER TABLE "public"."patient" ADD CONSTRAINT "patient_pkey" PRIMARY KEY ("patient_id"); + +-- ---------------------------- +-- Uniques structure for table patient_user +-- ---------------------------- +ALTER TABLE "public"."patient_user" ADD CONSTRAINT "patient_login_username_key" UNIQUE ("username"); + +-- ---------------------------- +-- Primary Key structure for table patient_user +-- ---------------------------- +ALTER TABLE "public"."patient_user" ADD CONSTRAINT "patient_login_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table prescription +-- ---------------------------- +CREATE INDEX "idx_prescription_patient_id" ON "public"."prescription" USING btree ( + "patient_id" "pg_catalog"."int4_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Primary Key structure for table prescription +-- ---------------------------- +ALTER TABLE "public"."prescription" ADD CONSTRAINT "prescription_pkey" PRIMARY KEY ("prescription_id"); + +-- ---------------------------- +-- Indexes structure for table ward +-- ---------------------------- +CREATE INDEX "idx_ward_department_id" ON "public"."ward" USING btree ( + "department_id" "pg_catalog"."int4_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Primary Key structure for table ward +-- ---------------------------- +ALTER TABLE "public"."ward" ADD CONSTRAINT "ward_pkey" PRIMARY KEY ("ward_id"); + +-- ---------------------------- +-- Foreign Keys structure for table doctor +-- ---------------------------- +ALTER TABLE "public"."doctor" ADD CONSTRAINT "doctor_department_id_fkey" FOREIGN KEY ("department_id") REFERENCES "public"."department" ("department_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table doctor_user +-- ---------------------------- +ALTER TABLE "public"."doctor_user" ADD CONSTRAINT "doctor_login_doctor_id_fkey" FOREIGN KEY ("doctor_id") REFERENCES "public"."doctor" ("doctor_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table medical_record +-- ---------------------------- +ALTER TABLE "public"."medical_record" ADD CONSTRAINT "medical_record_attending_doctor_id_fkey" FOREIGN KEY ("doctor_id") REFERENCES "public"."doctor" ("doctor_id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."medical_record" ADD CONSTRAINT "medical_record_patient_id_fkey" FOREIGN KEY ("patient_id") REFERENCES "public"."patient" ("patient_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table order +-- ---------------------------- +ALTER TABLE "public"."order" ADD CONSTRAINT "order_doctor_id_fkey" FOREIGN KEY ("doctor_id") REFERENCES "public"."doctor" ("doctor_id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order" ADD CONSTRAINT "order_patient_id_fkey" FOREIGN KEY ("patient_id") REFERENCES "public"."patient" ("patient_id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order" ADD CONSTRAINT "order_prescription_id_fkey" FOREIGN KEY ("prescription_id") REFERENCES "public"."prescription" ("prescription_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table patient +-- ---------------------------- +ALTER TABLE "public"."patient" ADD CONSTRAINT "patient_attending_doctor_id_fkey" FOREIGN KEY ("attending_doctor_id") REFERENCES "public"."doctor" ("doctor_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table patient_user +-- ---------------------------- +ALTER TABLE "public"."patient_user" ADD CONSTRAINT "patient_login_patient_id_fkey" FOREIGN KEY ("patient_id") REFERENCES "public"."patient" ("patient_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table prescription +-- ---------------------------- +ALTER TABLE "public"."prescription" ADD CONSTRAINT "fk_medication" FOREIGN KEY ("medication_id") REFERENCES "public"."medication" ("medication_id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."prescription" ADD CONSTRAINT "prescription_doctor_id_fkey" FOREIGN KEY ("doctor_id") REFERENCES "public"."doctor" ("doctor_id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."prescription" ADD CONSTRAINT "prescription_patient_id_fkey" FOREIGN KEY ("patient_id") REFERENCES "public"."patient" ("patient_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table ward +-- ---------------------------- +ALTER TABLE "public"."ward" ADD CONSTRAINT "ward_department_id_fkey" FOREIGN KEY ("department_id") REFERENCES "public"."department" ("department_id") ON DELETE NO ACTION ON UPDATE NO ACTION;